You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4 jaren geleden
6 jaren geleden
13 jaren geleden
5 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
6 jaren geleden
4 jaren geleden
9 jaren geleden
9 jaren geleden
5 jaren geleden
9 jaren geleden
8 jaren geleden
5 jaren geleden
11 jaren geleden
9 jaren geleden
8 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
9 jaren geleden
8 jaren geleden
6 jaren geleden
9 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
11 jaren geleden
9 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
13 jaren geleden
5 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
12 jaren geleden
6 jaren geleden
4 jaren geleden
5 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
4 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
9 jaren geleden
9 jaren geleden
12 jaren geleden
9 jaren geleden
6 jaren geleden
9 jaren geleden
Remove my-company-lighter-current-length Debugger entered--Lisp error: (error "`global' non-zero exit: global: GTAGS not found.") signal(error ("`global' non-zero exit: global: GTAGS not found.")) error("`%s' non-zero exit: %s" "global" "global: GTAGS not found.") ggtags-process-string("global" "--ignore-case" "-c" "sys") apply(ggtags-process-string "global" ("--ignore-case" "-c" "sys")) #f(compiled-function (prefix) #<bytecode 0x40751ea1>)("sys") #f(compiled-function (string pred action) #<bytecode 0x40751ec9>)("sys" nil t) all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-pcm--all-completions("" ("sys" point) #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-basic-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) #f(compiled-function (style) #<bytecode 0x4088a97f>)(basic) completion--some(#f(compiled-function (style) #<bytecode 0x4088a97f>) (basic partial-completion emacs22)) completion--nth-completion(2 "sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3 nil) completion-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) company-capf(candidates "sys") apply(company-capf (candidates "sys")) company-call-backend-raw(candidates "sys") apply(company-call-backend-raw (candidates "sys")) company--force-sync(company-call-backend-raw (candidates "sys") company-capf) company-call-backend(candidates "sys") company--fetch-candidates("sys") company-calculate-candidates("sys" nil) company--begin-new() company--perform() company-auto-begin() company-manual-begin() my-company-lighter-current-length() eval((my-company-lighter-current-length)) redisplay_internal\ \(C\ function\)()
5 jaren geleden
Remove my-company-lighter-current-length Debugger entered--Lisp error: (error "`global' non-zero exit: global: GTAGS not found.") signal(error ("`global' non-zero exit: global: GTAGS not found.")) error("`%s' non-zero exit: %s" "global" "global: GTAGS not found.") ggtags-process-string("global" "--ignore-case" "-c" "sys") apply(ggtags-process-string "global" ("--ignore-case" "-c" "sys")) #f(compiled-function (prefix) #<bytecode 0x40751ea1>)("sys") #f(compiled-function (string pred action) #<bytecode 0x40751ec9>)("sys" nil t) all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-pcm--all-completions("" ("sys" point) #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-basic-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) #f(compiled-function (style) #<bytecode 0x4088a97f>)(basic) completion--some(#f(compiled-function (style) #<bytecode 0x4088a97f>) (basic partial-completion emacs22)) completion--nth-completion(2 "sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3 nil) completion-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) company-capf(candidates "sys") apply(company-capf (candidates "sys")) company-call-backend-raw(candidates "sys") apply(company-call-backend-raw (candidates "sys")) company--force-sync(company-call-backend-raw (candidates "sys") company-capf) company-call-backend(candidates "sys") company--fetch-candidates("sys") company-calculate-candidates("sys" nil) company--begin-new() company--perform() company-auto-begin() company-manual-begin() my-company-lighter-current-length() eval((my-company-lighter-current-length)) redisplay_internal\ \(C\ function\)()
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
7 jaren geleden
9 jaren geleden
9 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
9 jaren geleden
5 jaren geleden
9 jaren geleden
7 jaren geleden
9 jaren geleden
4 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
13 jaren geleden
13 jaren geleden
11 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
12 jaren geleden
11 jaren geleden
13 jaren geleden
13 jaren geleden
5 jaren geleden
13 jaren geleden
13 jaren geleden
5 jaren geleden
5 jaren geleden
4 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
13 jaren geleden
11 jaren geleden
5 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
6 jaren geleden
13 jaren geleden
13 jaren geleden
5 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
11 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
12 jaren geleden
12 jaren geleden
12 jaren geleden
12 jaren geleden
8 jaren geleden
6 jaren geleden
13 jaren geleden
8 jaren geleden
8 jaren geleden
5 jaren geleden
8 jaren geleden
5 jaren geleden
8 jaren geleden
9 jaren geleden
8 jaren geleden
13 jaren geleden
13 jaren geleden
6 jaren geleden
11 jaren geleden
11 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
13 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
12 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
6 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
13 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
12 jaren geleden
6 jaren geleden
12 jaren geleden
6 jaren geleden
12 jaren geleden
12 jaren geleden
6 jaren geleden
12 jaren geleden
12 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
Remove my-company-lighter-current-length Debugger entered--Lisp error: (error "`global' non-zero exit: global: GTAGS not found.") signal(error ("`global' non-zero exit: global: GTAGS not found.")) error("`%s' non-zero exit: %s" "global" "global: GTAGS not found.") ggtags-process-string("global" "--ignore-case" "-c" "sys") apply(ggtags-process-string "global" ("--ignore-case" "-c" "sys")) #f(compiled-function (prefix) #<bytecode 0x40751ea1>)("sys") #f(compiled-function (string pred action) #<bytecode 0x40751ec9>)("sys" nil t) all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-pcm--all-completions("" ("sys" point) #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-basic-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) #f(compiled-function (style) #<bytecode 0x4088a97f>)(basic) completion--some(#f(compiled-function (style) #<bytecode 0x4088a97f>) (basic partial-completion emacs22)) completion--nth-completion(2 "sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3 nil) completion-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) company-capf(candidates "sys") apply(company-capf (candidates "sys")) company-call-backend-raw(candidates "sys") apply(company-call-backend-raw (candidates "sys")) company--force-sync(company-call-backend-raw (candidates "sys") company-capf) company-call-backend(candidates "sys") company--fetch-candidates("sys") company-calculate-candidates("sys" nil) company--begin-new() company--perform() company-auto-begin() company-manual-begin() my-company-lighter-current-length() eval((my-company-lighter-current-length)) redisplay_internal\ \(C\ function\)()
5 jaren geleden
5 jaren geleden
5 jaren geleden
Remove my-company-lighter-current-length Debugger entered--Lisp error: (error "`global' non-zero exit: global: GTAGS not found.") signal(error ("`global' non-zero exit: global: GTAGS not found.")) error("`%s' non-zero exit: %s" "global" "global: GTAGS not found.") ggtags-process-string("global" "--ignore-case" "-c" "sys") apply(ggtags-process-string "global" ("--ignore-case" "-c" "sys")) #f(compiled-function (prefix) #<bytecode 0x40751ea1>)("sys") #f(compiled-function (string pred action) #<bytecode 0x40751ec9>)("sys" nil t) all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-pcm--all-completions("" ("sys" point) #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil) completion-basic-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) #f(compiled-function (style) #<bytecode 0x4088a97f>)(basic) completion--some(#f(compiled-function (style) #<bytecode 0x4088a97f>) (basic partial-completion emacs22)) completion--nth-completion(2 "sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3 nil) completion-all-completions("sys" #f(compiled-function (string pred action) #<bytecode 0x40751ec9>) nil 3) company-capf(candidates "sys") apply(company-capf (candidates "sys")) company-call-backend-raw(candidates "sys") apply(company-call-backend-raw (candidates "sys")) company--force-sync(company-call-backend-raw (candidates "sys") company-capf) company-call-backend(candidates "sys") company--fetch-candidates("sys") company-calculate-candidates("sys" nil) company--begin-new() company--perform() company-auto-begin() company-manual-begin() my-company-lighter-current-length() eval((my-company-lighter-current-length)) redisplay_internal\ \(C\ function\)()
5 jaren geleden
5 jaren geleden
5 jaren geleden
11 jaren geleden
5 jaren geleden
4 jaren geleden
5 jaren geleden
11 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
4 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
12 jaren geleden
9 jaren geleden
6 jaren geleden
4 jaren geleden
13 jaren geleden
13 jaren geleden
8 jaren geleden
5 jaren geleden
6 jaren geleden
13 jaren geleden
6 jaren geleden
10 jaren geleden
13 jaren geleden
13 jaren geleden
9 jaren geleden
9 jaren geleden
13 jaren geleden
9 jaren geleden
13 jaren geleden
10 jaren geleden
13 jaren geleden
11 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
8 jaren geleden
10 jaren geleden
13 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
5 jaren geleden
13 jaren geleden
6 jaren geleden
13 jaren geleden
9 jaren geleden
12 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
13 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
12 jaren geleden
6 jaren geleden
12 jaren geleden
12 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
5 jaren geleden
12 jaren geleden
12 jaren geleden
9 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
12 jaren geleden
5 jaren geleden
6 jaren geleden
9 jaren geleden
11 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
5 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
11 jaren geleden
6 jaren geleden
9 jaren geleden
6 jaren geleden
6 jaren geleden
9 jaren geleden
11 jaren geleden
6 jaren geleden
6 jaren geleden
11 jaren geleden
11 jaren geleden
6 jaren geleden
6 jaren geleden
11 jaren geleden
11 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
5 jaren geleden
4 jaren geleden
4 jaren geleden
4 jaren geleden
6 jaren geleden
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650
  1. ;;; emacs.el --- 10sr emacs initialization
  2. ;;; Code:
  3. ;; SETUP_LOAD: (load "bytecomp") ;; Required for WSL environment
  4. ;; SETUP_LOAD: (let ((file "DOTFILES_DIR/emacs.el"))
  5. ;; SETUP_LOAD: (and (file-readable-p file)
  6. ;; SETUP_LOAD: (byte-recompile-file file nil 0 t)))
  7. ;; TODO: Use custom-set-variables in place of set-variable
  8. (setq debug-on-error t)
  9. ;; make directories
  10. (unless (file-directory-p (expand-file-name user-emacs-directory))
  11. (make-directory (expand-file-name user-emacs-directory)))
  12. (require 'cl-lib)
  13. (require 'simple)
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15. ;; Some macros for internals
  16. (defmacro eval-after-init (&rest body)
  17. "If `after-init-hook' has been run, run BODY immediately.
  18. Otherwize hook it."
  19. (declare (indent 0) (debug t))
  20. `(if after-init-time
  21. ;; Currently after-init-hook is run just after setting after-init-hook
  22. (progn
  23. ,@body)
  24. (add-hook 'after-init-hook
  25. (lambda ()
  26. ,@body))))
  27. ;; TODO: Remove: Just checking fboundp should be enough for most cases
  28. (defmacro safe-require-or-eval (feature)
  29. "Require FEATURE if available.
  30. At compile time the feature will be loaded immediately."
  31. `(eval-and-compile
  32. (message "safe-require-or-eval: Trying to require %s" ,feature)
  33. (require ,feature nil t)))
  34. ;; TODO: Remove: Defining autoload is no more needed for most cases
  35. (defmacro autoload-eval-lazily (feature &optional functions &rest body)
  36. "Define autoloading FEATURE that defines FUNCTIONS.
  37. FEATURE is a symbol. FUNCTIONS is a list of symbols. If FUNCTIONS is nil,
  38. the function same as FEATURE is defined as autoloaded function. BODY is passed
  39. to `eval-after-load'.
  40. After this macro is expanded, this returns the path to library if FEATURE
  41. found, otherwise returns nil."
  42. (declare (indent 2) (debug t))
  43. (let* ((libname (symbol-name (eval feature)))
  44. (libpath (locate-library libname)))
  45. `(progn
  46. (when (locate-library ,libname)
  47. ,@(mapcar (lambda (f)
  48. `(unless (fboundp ',f)
  49. (progn
  50. (message "Autoloaded function `%S' defined (%s)"
  51. (quote ,f)
  52. ,libpath)
  53. (autoload (quote ,f)
  54. ,libname
  55. ,(concat "Autoloaded function defined in \""
  56. libpath
  57. "\".")
  58. t))))
  59. (or (eval functions)
  60. `(,(eval feature)))))
  61. (eval-after-load ,feature
  62. (quote (progn
  63. ,@body)))
  64. (locate-library ,libname))))
  65. (when (autoload-eval-lazily 'tetris nil
  66. (message "Tetris loaded!"))
  67. (message "Tetris found!"))
  68. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  69. ;; package
  70. (set (defvar 10sr-package-list)
  71. '(
  72. vimrc-mode
  73. markdown-mode
  74. yaml-mode
  75. gnuplot-mode
  76. php-mode
  77. erlang
  78. js2-mode
  79. js-doc
  80. git-commit
  81. gitignore-mode
  82. adoc-mode
  83. go-mode
  84. ;; It seems malabar has been merged into jdee and this package
  85. ;; already removed
  86. ;; malabar-mode
  87. gosh-mode
  88. scala-mode
  89. web-mode
  90. color-moccur
  91. ggtags
  92. flycheck
  93. auto-highlight-symbol
  94. hl-todo
  95. ;; Currently not available
  96. ;; pp-c-l
  97. xclip
  98. foreign-regexp
  99. multi-term
  100. term-run
  101. editorconfig
  102. git-ps1-mode
  103. restart-emacs
  104. fill-column-indicator
  105. pkgbuild-mode
  106. minibuffer-line
  107. which-key
  108. ;; I think this works in place of my autosave lib
  109. super-save
  110. pipenv
  111. imenu-list
  112. page-break-lines
  113. aggressive-indent
  114. dired-filter
  115. wgrep
  116. magit
  117. git-gutter
  118. end-mark
  119. sl
  120. ;; TODO: Configure pony-tpl-mode
  121. pony-mode
  122. gited
  123. highlight-indentation
  124. diminish
  125. fzf
  126. fic-mode
  127. term-cursor
  128. pydoc
  129. swoop
  130. color-identifiers-mode
  131. dired-k
  132. editorconfig
  133. editorconfig-custom-majormode
  134. git-command
  135. prompt-text
  136. ;; 10sr repository
  137. ;; 10sr-extras
  138. terminal-title
  139. dired-list-all-mode
  140. pack
  141. set-modeline-color
  142. read-only-only-mode
  143. smart-revert
  144. autosave
  145. ;;window-organizer
  146. ilookup
  147. pasteboard
  148. awk-preview
  149. recently
  150. ))
  151. (when (safe-require-or-eval 'package)
  152. (setq package-archives
  153. `(,@package-archives
  154. ("melpa" . "https://melpa.org/packages/")
  155. ;; Somehow fails to download via https
  156. ("10sr-el" . "http://10sr.github.io/emacs-lisp/elpa/")))
  157. (package-initialize)
  158. (defun my-auto-install-package ()
  159. "Install packages semi-automatically."
  160. (interactive)
  161. (package-refresh-contents)
  162. (mapc (lambda (pkg)
  163. (or (package-installed-p pkg)
  164. (package-install pkg)))
  165. 10sr-package-list))
  166. )
  167. ;; (lazy-load-eval 'sudoku)
  168. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  169. ;; my-idle-hook
  170. (defvar my-idle-hook nil
  171. "Hook run when idle for several secs.")
  172. (defvar my-idle-hook-sec 5
  173. "Second to run `my-idle-hook'.")
  174. (run-with-idle-timer my-idle-hook-sec
  175. t
  176. (lambda ()
  177. (run-hooks 'my-idle-hook)))
  178. ;; (add-hook 'my-idle-hook
  179. ;; (lambda ()
  180. ;; (message "idle hook message")))
  181. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  182. ;; start and quit
  183. (setq inhibit-startup-message t)
  184. (setq initial-buffer-choice 'messages-buffer)
  185. (setq confirm-kill-emacs 'y-or-n-p)
  186. (setq gc-cons-threshold (* 1024 1024 16))
  187. (setq garbage-collection-messages nil)
  188. (when window-system
  189. (add-to-list 'default-frame-alist '(cursor-type . box))
  190. (add-to-list 'default-frame-alist '(background-color . "white"))
  191. (add-to-list 'default-frame-alist '(foreground-color . "gray10"))
  192. ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100)))
  193. ;; does not work?
  194. )
  195. ;; (add-to-list 'default-frame-alist '(cursor-type . box))
  196. (menu-bar-mode 1)
  197. (define-key ctl-x-map "m" 'menu-bar-open)
  198. (and (fboundp 'tool-bar-mode)
  199. (tool-bar-mode 0))
  200. (and (fboundp 'set-scroll-bar-mode)
  201. (set-scroll-bar-mode nil))
  202. (eval-after-init
  203. (message "%s %s" invocation-name emacs-version)
  204. (message "Invocation directory: %s" default-directory)
  205. (message "%s was taken to initialize emacs." (emacs-init-time))
  206. ;; (view-echo-area-messages)
  207. ;; (view-emacs-news)
  208. )
  209. (with-current-buffer "*Messages*"
  210. (emacs-lock-mode 'kill))
  211. (cd ".") ; when using windows use / instead of \ in `default-directory'
  212. ;; locale
  213. (set-language-environment "Japanese")
  214. (set-default-coding-systems 'utf-8-unix)
  215. (prefer-coding-system 'utf-8-unix)
  216. (setq system-time-locale "C")
  217. ;; my prefix map
  218. (defvar my-prefix-map nil
  219. "My prefix map.")
  220. (define-prefix-command 'my-prefix-map)
  221. (global-set-key (kbd "C-^") 'my-prefix-map)
  222. ;; (define-key my-prefix-map (kbd "C-q") 'quoted-insert)
  223. ;; (define-key my-prefix-map (kbd "C-z") 'suspend-frame)
  224. ;; (comint-show-maximum-output)
  225. ;; kill scratch
  226. (eval-after-init
  227. (let ((buf (get-buffer "*scratch*")))
  228. (when buf
  229. (kill-buffer buf))))
  230. ;; modifier keys
  231. ;; (setq mac-option-modifier 'control)
  232. ;; display
  233. (setq visible-bell t)
  234. (setq ring-bell-function 'ignore)
  235. (mouse-avoidance-mode 'banish)
  236. (setq echo-keystrokes 0.1)
  237. (defun reload-init-file ()
  238. "Reload Emacs init file."
  239. (interactive)
  240. (when (and user-init-file
  241. (file-readable-p user-init-file))
  242. (load-file user-init-file)))
  243. (safe-require-or-eval 'session)
  244. ;; server
  245. (set-variable 'server-name (concat "server"
  246. (number-to-string (emacs-pid))))
  247. ;; In Cygwin Environment `server-runnning-p' stops when server-use-tcp is nil
  248. ;; In Darwin environment, init fails with message like 'Service name too long'
  249. ;; when server-use-tcp is nil
  250. (when (or (eq system-type
  251. 'cygwin)
  252. (eq system-type
  253. 'darwin))
  254. (set-variable 'server-use-tcp t))
  255. ;; MSYS2 fix
  256. (when (eq system-type
  257. 'windows-nt)
  258. (setq shell-file-name
  259. (executable-find "bash"))
  260. '(setq function-key-map
  261. `(,@function-key-map ([pause] . [?\C-c])
  262. ))
  263. (define-key key-translation-map
  264. (kbd "<pause>")
  265. (kbd "C-c"))
  266. '(keyboard-translate [pause]
  267. (kbd "C-c")p)
  268. ;; TODO: move to other place later
  269. (when (not window-system)
  270. (setq interprogram-paste-function nil)
  271. (setq interprogram-cut-function nil)))
  272. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  273. ;; global keys
  274. (global-set-key (kbd "<up>") 'scroll-down-line)
  275. (global-set-key (kbd "<down>") 'scroll-up-line)
  276. (global-set-key (kbd "<left>") 'scroll-down)
  277. (global-set-key (kbd "<right>") 'scroll-up)
  278. ;; (define-key my-prefix-map (kbd "C-h") help-map)
  279. (global-set-key (kbd "C-\\") help-map)
  280. (define-key ctl-x-map (kbd "DEL") help-map)
  281. (define-key ctl-x-map (kbd "C-h") help-map)
  282. (define-key help-map "a" 'apropos)
  283. ;; disable annoying keys
  284. (global-set-key [prior] 'ignore)
  285. (global-set-key (kbd "<next>") 'ignore)
  286. (global-set-key [menu] 'ignore)
  287. (global-set-key [down-mouse-1] 'ignore)
  288. (global-set-key [down-mouse-2] 'ignore)
  289. (global-set-key [down-mouse-3] 'ignore)
  290. (global-set-key [mouse-1] 'ignore)
  291. (global-set-key [mouse-2] 'ignore)
  292. (global-set-key [mouse-3] 'ignore)
  293. (global-set-key (kbd "<eisu-toggle>") 'ignore)
  294. (global-set-key (kbd "C-<eisu-toggle>") 'ignore)
  295. ;; Interactively evaluate Emacs Lisp expressions
  296. (define-key ctl-x-map "i" 'ielm)
  297. (when (safe-require-or-eval 'which-key)
  298. (which-key-mode))
  299. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  300. ;; editor
  301. ;; Basically it should not set globally (instead use something like file local
  302. ;; variables or editorconfig), but for most cases I just need this...
  303. (defun my-set-require-final-newline ()
  304. "Set `require-final-newline'."
  305. (set (make-local-variable 'require-final-newline)
  306. mode-require-final-newline))
  307. (add-hook 'prog-mode-hook
  308. 'my-set-require-final-newline)
  309. (add-hook 'text-mode-hook
  310. 'my-set-require-final-newline)
  311. (add-hook 'conf-mode-hook
  312. 'my-set-require-final-newline)
  313. ;; Used from term-cursor
  314. ;; hbar is too hard to find...
  315. (defun my-cursor-type-change (&rest args)
  316. "ARGS are discarded."
  317. ;; TODO: Support wdired and wgrep
  318. (if buffer-read-only
  319. (setq cursor-type 'hbar)
  320. (setq cursor-type 'box)))
  321. ;; (add-hook 'switch-buffer-functions
  322. ;; 'my-cursor-type-change)
  323. ;; (add-hook 'read-only-mode-hook
  324. ;; 'my-cursor-type-change)
  325. ;; (when (fboundp 'global-term-cursor-mode)
  326. ;; (global-term-cursor-mode 1))
  327. ;; ;; (term-cursor--eval)
  328. (setq kill-whole-line t)
  329. (setq scroll-conservatively 35
  330. scroll-margin 2)
  331. (setq-default major-mode 'text-mode)
  332. (setq next-line-add-newlines nil)
  333. (setq kill-read-only-ok t)
  334. (setq truncate-partial-width-windows nil) ; when splitted horizontally
  335. ;; (setq-default line-spacing 0.2)
  336. (setq-default indicate-empty-lines t) ; when using x indicate empty line
  337. ;; (setq-default tab-width 4)
  338. (setq-default indent-tabs-mode nil)
  339. (setq-default indent-line-function 'indent-to-left-margin)
  340. ;; (setq-default indent-line-function nil)
  341. (setq-default truncate-lines nil)
  342. ;; (pc-selection-mode 1) ; make some already defined keybind back to default
  343. (delete-selection-mode 1)
  344. (cua-mode 0)
  345. (setq line-move-visual nil)
  346. (setq create-lockfiles nil)
  347. (add-hook 'before-save-hook
  348. 'time-stamp)
  349. ;; Add Time-stamp: <> to insert timestamp there
  350. (set-variable 'time-stamp-format
  351. "%:y-%02m-%02d %02H:%02M:%02S %Z 10sr")
  352. ;; key bindings
  353. ;; moving around
  354. ;;(keyboard-translate ?\M-j ?\C-j)
  355. ;; (global-set-key (kbd "M-p") 'backward-paragraph)
  356. (define-key esc-map "p" 'backward-paragraph)
  357. ;; (global-set-key (kbd "M-n") 'forward-paragraph)
  358. (define-key esc-map "n" 'forward-paragraph)
  359. (global-set-key (kbd "C-<up>") 'scroll-down-line)
  360. (global-set-key (kbd "C-<down>") 'scroll-up-line)
  361. (global-set-key (kbd "C-<left>") 'scroll-down)
  362. (global-set-key (kbd "C-<right>") 'scroll-up)
  363. (global-set-key (kbd "<select>") 'ignore) ; 'previous-line-mark)
  364. (define-key ctl-x-map (kbd "ESC x") 'execute-extended-command)
  365. (define-key ctl-x-map (kbd "ESC :") 'eval-expression)
  366. ;; C-h and DEL
  367. (global-set-key (kbd "C-h") (kbd "DEL"))
  368. ;; (normal-erase-is-backspace-mode 1)
  369. ;;(global-set-key (kbd "C-m") 'reindent-then-newline-and-indent)
  370. (global-set-key (kbd "C-m") 'newline-and-indent)
  371. ;; (global-set-key (kbd "C-o") (kbd "C-e C-m"))
  372. ;; (global-set-key "\C-z" 'undo) ; undo is M-u
  373. (define-key esc-map "u" 'undo)
  374. (define-key esc-map "i" (kbd "ESC TAB"))
  375. ;; (global-set-key (kbd "C-r") 'query-replace-regexp)
  376. (global-set-key (kbd "C-s") 'isearch-forward-regexp)
  377. (global-set-key (kbd "C-r") 'isearch-backward-regexp)
  378. (when (fboundp 'undo-fu-only-undo)
  379. (global-set-key (kbd "C-_") 'undo-fu-only-undo))
  380. (when (fboundp 'undo-fu-only-redo)
  381. (global-set-key (kbd "C-M-_") 'undo-fu-only-redo))
  382. (require 'page-ext nil t)
  383. (when (safe-require-or-eval 'page-break-lines)
  384. (global-page-break-lines-mode 1))
  385. (when (safe-require-or-eval 'git-gutter)
  386. (declare-function global-git-gutter-mode "git-gutter")
  387. (custom-set-variables
  388. '(git-gutter:lighter " Gttr"))
  389. (custom-set-variables
  390. '(git-gutter:update-interval 2))
  391. (custom-set-variables
  392. '(git-gutter:unchanged-sign " "))
  393. (when (>= (display-color-cells)
  394. 256)
  395. (let ((c "color-233"))
  396. (set-face-background 'git-gutter:modified c)
  397. (set-face-background 'git-gutter:added c)
  398. (set-face-background 'git-gutter:deleted c)
  399. (set-face-background 'git-gutter:unchanged c)))
  400. (global-git-gutter-mode 1)
  401. )
  402. ;; (when (safe-require-or-eval 'fancy-narrow)
  403. ;; (fancy-narrow-mode 1))
  404. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  405. ;; title and mode-line
  406. (when (safe-require-or-eval 'terminal-title)
  407. ;; if TERM is not screen use default value
  408. (if (getenv "TMUX")
  409. ;; if use tmux locally just basename of current dir
  410. (set-variable 'terminal-title-format
  411. '((file-name-nondirectory (directory-file-name
  412. default-directory))))
  413. (if (and (let ((tty-type (frame-parameter nil
  414. 'tty-type)))
  415. (and tty-type
  416. (equal (car (split-string tty-type
  417. "-"))
  418. "screen")))
  419. (not (getenv "SSH_CONNECTION")))
  420. (set-variable 'terminal-title-format
  421. '((file-name-nondirectory (directory-file-name
  422. default-directory))))
  423. ;; seems that TMUX is used locally and ssh to remote host
  424. (set-variable 'terminal-title-format
  425. `("em:"
  426. ,user-login-name
  427. "@"
  428. ,(car (split-string (system-name)
  429. "\\."))
  430. ":"
  431. default-directory))
  432. )
  433. )
  434. (terminal-title-mode))
  435. (setq eol-mnemonic-dos "\\r\\n")
  436. (setq eol-mnemonic-mac "\\r")
  437. (setq eol-mnemonic-unix "")
  438. (which-function-mode 1)
  439. (line-number-mode 0)
  440. (column-number-mode 0)
  441. (size-indication-mode 0)
  442. (setq mode-line-position
  443. '(:eval (format ":%%l:%%c /%d%s"
  444. (count-lines (point-max)
  445. (point-min))
  446. (if (buffer-narrowed-p)
  447. "[N]"
  448. "")
  449. )))
  450. (when (safe-require-or-eval 'diminish)
  451. ;; FIXME: Eval after enabling mode
  452. (eval-after-init
  453. (diminish 'recently-mode)
  454. (diminish 'editorconfig-mode)
  455. (diminish 'auto-highlight-symbol-mode)
  456. (diminish 'global-whitespace-mode)
  457. (diminish 'which-key-mode)
  458. (diminish 'page-break-lines-mode)
  459. (diminish 'highlight-indentation-mode)
  460. (diminish 'color-identifiers-mode)
  461. ))
  462. (setq mode-line-front-space "")
  463. ;; (setq mode-line-end-spaces "")
  464. ;; Set current frame name to empty string
  465. (setq-default mode-line-format
  466. (let* ((l mode-line-format)
  467. (l (cl-substitute " " " "
  468. l
  469. :test 'equal))
  470. (l (cl-substitute " " " "
  471. l
  472. :test 'equal))
  473. )
  474. l))
  475. (set-frame-parameter nil 'name "")
  476. ;; See color-name-rgb-alist for available color names
  477. ;; http://www.raebear.net/computers/emacs-colors/
  478. ;; https://www.emacswiki.org/emacs/ListColors
  479. ;; (list-colors-display is not a complete list)
  480. (defconst my-mode-line-background-default
  481. (face-background 'mode-line)
  482. "Default color of mode-line at init.")
  483. (defun my-mode-line-color-update (&rest args)
  484. "ARGS are discarded"
  485. (let ((ro "skyblue")
  486. (rw my-mode-line-background-default))
  487. (if (or (not buffer-read-only)
  488. (and (eq major-mode 'wdired-mode)))
  489. (set-face-background 'mode-line
  490. rw)
  491. (set-face-background 'mode-line
  492. ro))))
  493. (add-hook 'switch-buffer-functions
  494. 'my-mode-line-color-update)
  495. (add-hook 'read-only-mode-hook
  496. 'my-mode-line-color-update)
  497. (add-hook 'wdired-mode-hook
  498. 'my-mode-line-color-update)
  499. (advice-add 'wdired-change-to-dired-mode
  500. :after
  501. 'my-mode-line-color-update)
  502. (advice-add 'wgrep-change-to-wgrep-mode
  503. :after
  504. 'my-mode-line-color-update)
  505. (advice-add 'wgrep-to-original-mode
  506. :after
  507. 'my-mode-line-color-update)
  508. (set-face-background 'header-line
  509. my-mode-line-background-default)
  510. ;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title
  511. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  512. ;; minibuffer
  513. (setq insert-default-directory t)
  514. (setq completion-ignore-case t
  515. read-file-name-completion-ignore-case t
  516. read-buffer-completion-ignore-case t)
  517. (setq resize-mini-windows t)
  518. (temp-buffer-resize-mode 1)
  519. (savehist-mode 1)
  520. (defvar display-time-format "%Y/%m/%d %a %H:%M")
  521. (set-variable 'help-at-pt-display-when-idle t)
  522. (fset 'yes-or-no-p 'y-or-n-p)
  523. ;; complete symbol when `eval'
  524. (define-key read-expression-map (kbd "TAB") 'completion-at-point)
  525. (define-key minibuffer-local-map (kbd "C-u")
  526. (lambda () (interactive) (delete-region (point-at-bol) (point))))
  527. ;; I dont know these bindings are good
  528. (define-key minibuffer-local-map (kbd "C-p") (kbd "ESC p"))
  529. (define-key minibuffer-local-map (kbd "C-n") (kbd "ESC n"))
  530. (when (safe-require-or-eval 'minibuffer-line)
  531. (set-face-underline 'minibuffer-line nil)
  532. (set-variable 'minibuffer-line-refresh-interval
  533. 25)
  534. ;; Set idle timer
  535. (defvar my-minibuffer-line--idle-timer nil)
  536. (defvar minibuffer-line-mode)
  537. (add-hook 'minibuffer-line-mode-hook
  538. (lambda ()
  539. (when my-minibuffer-line--idle-timer
  540. (cancel-timer my-minibuffer-line--idle-timer)
  541. (setq my-minibuffer-line--idle-timer nil))
  542. (when minibuffer-line-mode
  543. (setq my-minibuffer-line--idle-timer
  544. (run-with-idle-timer 0.5
  545. t
  546. 'minibuffer-line--update)))))
  547. (set-variable 'minibuffer-line-format
  548. `(,(concat user-login-name
  549. "@"
  550. (car (split-string (system-name)
  551. "\\."))
  552. ":")
  553. (:eval (abbreviate-file-name (or buffer-file-name
  554. default-directory)))
  555. (:eval (and (fboundp 'git-ps1-mode-get-current)
  556. (git-ps1-mode-get-current " [GIT:%s]")))
  557. " "
  558. (:eval (format-time-string display-time-format))))
  559. (minibuffer-line-mode 1)
  560. )
  561. (when (safe-require-or-eval 'prompt-text)
  562. (set-variable 'prompt-text-format
  563. `(,(concat ""
  564. user-login-name
  565. "@"
  566. (car (split-string (system-name)
  567. "\\."))
  568. ":")
  569. (:eval (abbreviate-file-name (or buffer-file-name
  570. default-directory)))
  571. (:eval (and (fboundp 'git-ps1-mode-get-current)
  572. (git-ps1-mode-get-current " [GIT:%s]")))
  573. " "
  574. (:eval (format-time-string display-time-format))
  575. "\n"
  576. (:eval (symbol-name this-command))
  577. ": "))
  578. (prompt-text-mode 1))
  579. (autoload-eval-lazily 'helm nil
  580. (defvar helm-map)
  581. (define-key helm-map (kbd "C-h") (kbd "DEL")))
  582. (setq-default header-line-format
  583. '(:eval (let ((f (or (buffer-file-name)
  584. default-directory)))
  585. (when f
  586. (abbreviate-file-name f)))))
  587. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  588. ;; letters, font-lock mode and fonts
  589. (when (fboundp 'color-identifiers-mode)
  590. (add-hook 'prog-mode-hook
  591. 'color-identifiers-mode))
  592. (setq text-quoting-style 'grave)
  593. ;; (set-face-background 'vertical-border (face-foreground 'mode-line))
  594. ;; (set-window-margins (selected-window) 1 1)
  595. (unless window-system
  596. (setq frame-background-mode 'dark))
  597. (and (or (eq system-type 'Darwin)
  598. (eq system-type 'darwin))
  599. (fboundp 'mac-set-input-method-parameter)
  600. (mac-set-input-method-parameter 'japanese 'cursor-color "red")
  601. (mac-set-input-method-parameter 'roman 'cursor-color "black"))
  602. (when (and (boundp 'input-method-activate-hook) ; i dont know this is correct
  603. (boundp 'input-method-inactivate-hook))
  604. (add-hook 'input-method-activate-hook
  605. (lambda () (set-cursor-color "red")))
  606. (add-hook 'input-method-inactivate-hook
  607. (lambda () (set-cursor-color "black"))))
  608. (when (safe-require-or-eval 'paren)
  609. (show-paren-mode 1)
  610. (setq show-paren-delay 0.5
  611. show-paren-style 'parenthesis) ; mixed is hard to read
  612. ;; (set-face-background 'show-paren-match
  613. ;; "black")
  614. ;; ;; (face-foreground 'default))
  615. ;; (set-face-foreground 'show-paren-match
  616. ;; "white")
  617. ;; (set-face-inverse-video-p 'show-paren-match
  618. ;; t)
  619. )
  620. (transient-mark-mode 1)
  621. (global-font-lock-mode 1)
  622. (setq font-lock-global-modes
  623. '(not
  624. help-mode
  625. eshell-mode
  626. ;;term-mode
  627. Man-mode
  628. ))
  629. ;; (standard-display-ascii ?\n "$\n")
  630. ;; (defvar my-eol-face
  631. ;; '(("\n" . (0 font-lock-comment-face t nil)))
  632. ;; )
  633. ;; (defvar my-tab-face
  634. ;; '(("\t" . '(0 highlight t nil))))
  635. (defvar my-jspace-face
  636. '(("\u3000" . '(0 highlight t nil))))
  637. (add-hook 'font-lock-mode-hook
  638. (lambda ()
  639. ;; (font-lock-add-keywords nil my-eol-face)
  640. (font-lock-add-keywords nil my-jspace-face)
  641. ))
  642. (when (safe-require-or-eval 'whitespace)
  643. (add-to-list 'whitespace-display-mappings
  644. ;; We need t since last one takes precedence
  645. `(tab-mark ?\t ,(vconcat "|>\t")) t)
  646. ;; (add-to-list 'whitespace-display-mappings
  647. ;; `(newline-mark ?\n ,(vconcat "$\n")))
  648. (setq whitespace-style '(face
  649. trailing ; trailing blanks
  650. ;; tabs
  651. ;; spaces
  652. ;; lines
  653. lines-tail ; lines over 80
  654. newline ; newlines
  655. ;; empty ; empty lines at beg or end of buffer
  656. ;; big-indent
  657. ;; space-mark
  658. tab-mark
  659. newline-mark ; use display table for newline
  660. ))
  661. ;; (setq whitespace-newline 'font-lock-comment-face)
  662. ;; (setq whitespace-style (delq 'newline-mark whitespace-style))
  663. (defun my-whitesspace-mode-reload ()
  664. "Reload whitespace-mode config."
  665. (interactive)
  666. (when whitespace-mode
  667. (whitespace-mode 0)
  668. (whitespace-mode 1)))
  669. (set-variable 'whitespace-line-column nil)
  670. (global-whitespace-mode t)
  671. (add-hook 'dired-mode-hook
  672. (lambda ()
  673. (set (make-local-variable 'whitespace-style) nil)))
  674. (if (>= (display-color-cells)
  675. 256)
  676. (set-face-foreground 'whitespace-newline "color-109")
  677. ;; (progn
  678. ;; (set-face-bold-p 'whitespace-newline
  679. ;; t))
  680. ))
  681. (and nil
  682. '(safe-require-or-eval 'fill-column-indicator)
  683. (setq fill-column-indicator))
  684. (defun my-gen-hl-line-color-dark ()
  685. "Generate color for current line in black background."
  686. (let* ((candidates (mapcar 'number-to-string (number-sequence 1 6)))
  687. (limit (length candidates))
  688. (r 0) (g 0) (b 0))
  689. (while (and (<= (abs (- r g)) 1)
  690. (<= (abs (- g b)) 1)
  691. (<= (abs (- b r)) 1))
  692. (setq r (random limit))
  693. (setq g (random limit))
  694. (setq b (random limit)))
  695. (format "#%s%s%s"
  696. (nth r candidates)
  697. (nth g candidates)
  698. (nth b candidates)
  699. )))
  700. ;; (my-gen-hl-line-color-dark)
  701. ;; highlight current line
  702. ;; http://wiki.riywo.com/index.php?Meadow
  703. (face-spec-set 'hl-line
  704. `((((min-colors 256)
  705. (background dark))
  706. ;; Rotate midnightblue
  707. (:background ,(my-gen-hl-line-color-dark)))
  708. (((min-colors 256)
  709. (background light))
  710. ;; TODO: What is should be?
  711. (:background "color-234"))
  712. (t
  713. (:underline "black"))))
  714. (set-variable 'hl-line-global-modes
  715. '(not
  716. term-mode))
  717. (global-hl-line-mode 1) ;; (hl-line-mode 1)
  718. (set-face-foreground 'font-lock-regexp-grouping-backslash "#666")
  719. (set-face-foreground 'font-lock-regexp-grouping-construct "#f60")
  720. ;;(safe-require-or-eval 'set-modeline-color)
  721. ;; (let ((fg (face-foreground 'default))
  722. ;; (bg (face-background 'default)))
  723. ;; (set-face-background 'mode-line-inactive
  724. ;; (if (face-inverse-video-p 'mode-line) fg bg))
  725. ;; (set-face-foreground 'mode-line-inactive
  726. ;; (if (face-inverse-video-p 'mode-line) bg fg)))
  727. ;; (set-face-underline 'mode-line-inactive
  728. ;; t)
  729. ;; (set-face-underline 'vertical-border
  730. ;; nil)
  731. ;; (when (safe-require-or-eval 'end-mark)
  732. ;; (global-end-mark-mode))
  733. ;; M-x highlight-* to highlight things
  734. (global-hi-lock-mode 1)
  735. (unless (fboundp 'highlight-region-text)
  736. (defun highlight-region-text (beg end)
  737. "Highlight text between BEG and END."
  738. (interactive "r")
  739. (highlight-regexp (regexp-quote (buffer-substring-no-properties beg
  740. end)))
  741. (setq deactivate-mark t)))
  742. (when (safe-require-or-eval 'auto-highlight-symbol)
  743. (set-variable 'ahs-idle-interval 0.6)
  744. (global-auto-highlight-symbol-mode 1))
  745. (when (safe-require-or-eval 'highlight-indentation)
  746. (set-face-background 'highlight-indentation-face "color-236")
  747. (dolist (hook
  748. '(
  749. prog-mode-hook
  750. text-mode-hook
  751. ))
  752. (add-hook hook
  753. 'highlight-indentation-mode)))
  754. ;; (set-face-background 'highlight-indentation-current-column-face "#c3b3b3")
  755. (when (fboundp 'fic-mode)
  756. (add-hook 'prog-mode-hook
  757. 'fic-mode))
  758. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  759. ;; file handling
  760. (auto-insert-mode 1)
  761. ;; fzf
  762. ;; Too slow in term buffer!
  763. ;; (set-variable 'fzf/executable "sk")
  764. ;; (set-variable 'fzf/args "--color bw --print-query")
  765. ;; Modified from hardcoded default to include:
  766. ;; - directories
  767. ;; - hidden files
  768. ;; - root directory (.)
  769. ;; - parent directory (..)
  770. ;; ripgrep cannot list directories...
  771. ;; (setenv "FZF_DEFAULT_COMMAND" "rg --files --hidden --follow --glob '!.git/*' --no-ignore")
  772. (let* ((find (if (executable-find "bfs")
  773. ;; Breadth-first find https://github.com/tavianator/bfs
  774. "bfs"
  775. ;; Use gfind if available?
  776. "find"))
  777. (findcmd (concat "set -eu; set -o pipefail; "
  778. "echo .; "
  779. "echo ..; "
  780. "command " find " -L . "
  781. "-mindepth 1 "
  782. "\\( -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune "
  783. "-o -print "
  784. "2> /dev/null "
  785. "| "
  786. "cut -b3-"))
  787. (fdcmd (concat "set -eu; set -o pipefail; "
  788. "echo .; "
  789. "echo ..; "
  790. "command fd "
  791. "--follow --hidden --no-ignore "
  792. "--color always "
  793. "2>/dev/null")))
  794. (if (executable-find "fd")
  795. (setenv "FZF_DEFAULT_COMMAND" fdcmd)
  796. (setenv "FZF_DEFAULT_COMMAND" findcmd)))
  797. (set-variable 'fzf/window-height 45)
  798. (set-variable 'fzf/args "--print-query --ansi --color='bg+:-1' --inline-info --cycle")
  799. ;; (set-variable 'fzf/args "--print-query --ansi --inline-info --cycle")
  800. ;; (set-variable 'fzf/args "--print-query --ansi --color=bw --inline-info --cycle")
  801. (defun my-fzf-or-find-file ()
  802. "Call fzf if usable or call find-file."
  803. (declare (interactive-only t))
  804. (interactive)
  805. (if (and (executable-find "fzf")
  806. (fboundp 'fzf)
  807. (not (file-remote-p default-directory)))
  808. (fzf)
  809. (call-interactively 'find-file)))
  810. (define-key ctl-x-map "f" 'my-fzf-or-find-file)
  811. (defun my-fzf-all-lines ()
  812. "Fzf all lines."
  813. (interactive)
  814. (let ((process-environment (cl-copy-list process-environment)))
  815. (setenv "FZF_DEFAULT_COMMAND" "rg -nH --no-heading --hidden --follow --glob '!.git/*' --color=always ^")
  816. (fzf)))
  817. (define-key ctl-x-map "S" 'my-fzf-all-lines)
  818. ;; recently
  819. (when (safe-require-or-eval 'recently)
  820. (define-key ctl-x-map (kbd "C-r") 'recently-show)
  821. (set-variable 'recently-max 1000)
  822. (recently-mode 1))
  823. (when (safe-require-or-eval 'editorconfig)
  824. (set-variable 'editorconfig-get-properties-function
  825. 'editorconfig-core-get-properties-hash)
  826. (editorconfig-mode 1)
  827. (set-variable 'editorconfig-mode-lighter "")
  828. (when (fboundp 'ws-butler-mode)
  829. (set-variable 'editorconfig-trim-whitespaces-mode
  830. 'ws-butler-mode))
  831. (with-eval-after-load 'org-src
  832. ;; [*.org\[\*Org Src*\[ c \]*\]]
  833. (add-hook 'org-src-mode-hook
  834. 'editorconfig-mode-apply t)))
  835. (when (fboundp 'editorconfig-custom-majormode)
  836. (add-hook 'editorconfig-after-apply-functions
  837. 'editorconfig-custom-majormode))
  838. ;; Add readonly=true to set read-only-mode
  839. (add-hook 'editorconfig-after-apply-functions
  840. (lambda (props)
  841. (let ((r (gethash 'readonly props)))
  842. (when (and (string= r "true")
  843. (not buffer-read-only))
  844. (read-only-mode 1)))))
  845. (add-hook 'editorconfig-hack-properties-functions
  846. '(lambda (props)
  847. (when (derived-mode-p 'makefile-mode)
  848. (puthash 'indent_style "tab" props))
  849. (when (derived-mode-p 'diff-mode)
  850. (puthash 'trim_trailing_whitespace "false" props)
  851. (puthash 'insert_final_newline "false" props)
  852. )
  853. ))
  854. (when (fboundp 'editorconfig-auto-apply-enable)
  855. (add-hook 'editorconfig-conf-mode-hook
  856. 'editorconfig-auto-apply-enable))
  857. ;; (when (fboundp 'editorconfig-charset-extras)
  858. ;; (add-hook 'editorconfig-custom-hooks
  859. ;; 'editorconfig-charset-extras))
  860. (setq revert-without-query '(".+"))
  861. ;; save cursor position
  862. (when (safe-require-or-eval 'saveplace)
  863. (setq-default save-place t)
  864. (setq save-place-file (concat user-emacs-directory
  865. "places")))
  866. ;; http://www.bookshelf.jp/soft/meadow_24.html#SEC260
  867. (setq make-backup-files t)
  868. (setq vc-make-backup-files t)
  869. ;; (make-directory (expand-file-name "~/.emacsbackup"))
  870. (setq backup-directory-alist
  871. (cons (cons "." (expand-file-name (concat user-emacs-directory
  872. "backup")))
  873. backup-directory-alist))
  874. (setq version-control 't)
  875. (setq delete-old-versions t)
  876. (setq kept-new-versions 20)
  877. (setq auto-save-list-file-prefix (expand-file-name (concat user-emacs-directory
  878. "auto-save/")))
  879. ;; (setq delete-auto-save-files t)
  880. (setq auto-save-visited-interval 8)
  881. (auto-save-visited-mode 1)
  882. ;; (add-to-list 'auto-save-file-name-transforms
  883. ;; `(".*" ,(concat user-emacs-directory "auto-save-dir") t))
  884. ;; (setq auto-save-interval 3)
  885. ;; (auto-save-mode 1)
  886. (add-to-list 'completion-ignored-extensions ".bak")
  887. (set-variable 'completion-cycle-threshold nil) ;; NEVER use
  888. (setq delete-by-moving-to-trash t)
  889. ;; trash-directory "~/.emacs.d/trash")
  890. (add-hook 'after-save-hook
  891. 'executable-make-buffer-file-executable-if-script-p)
  892. (set-variable 'bookmark-default-file
  893. (expand-file-name (concat user-emacs-directory
  894. "bmk")))
  895. (set-variable 'bookmark-save-flag
  896. 1)
  897. (with-eval-after-load 'recentf
  898. (defvar recentf-exclude)
  899. (defvar bookmark-default-file)
  900. (add-to-list 'recentf-exclude
  901. (regexp-quote bookmark-default-file)))
  902. (when (safe-require-or-eval 'smart-revert)
  903. (smart-revert-on))
  904. ;; autosave
  905. ;; auto-save-visited-mode can be used instead?
  906. ;; (when (safe-require-or-eval 'autosave)
  907. ;; (autosave-set 8))
  908. ;; bookmarks
  909. ;; (define-key ctl-x-map "m" 'list-bookmarks)
  910. ;; vc
  911. (set-variable 'vc-handled-backends '(RCS))
  912. (set-variable 'vc-rcs-register-switches "-l")
  913. (set-variable 'vc-rcs-checkin-switches "-l")
  914. (set-variable 'vc-command-messages t)
  915. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  916. ;; share clipboard with x
  917. ;; this page describes this in details, but only these sexps seem to be needed
  918. ;; http://garin.jp/doc/Linux/xwindow_clipboard
  919. (and nil
  920. (not window-system)
  921. (not (eq window-system 'mac))
  922. (getenv "DISPLAY")
  923. (not (equal (getenv "DISPLAY") ""))
  924. (executable-find "xclip")
  925. ;; (< emacs-major-version 24)
  926. '(safe-require-or-eval 'xclip)
  927. nil
  928. (turn-on-xclip))
  929. (and (eq system-type 'darwin)
  930. (safe-require-or-eval 'pasteboard)
  931. (turn-on-pasteboard))
  932. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  933. ;; some modes and hooks
  934. ;; Include some extra modes
  935. (require 'generic-x)
  936. ;; Derived from https://github.com/ensime/ensime-emacs/issues/591#issuecomment-291916753
  937. (defun my-scalafmt ()
  938. (interactive)
  939. (cl-assert buffer-file-name)
  940. (cl-assert (not (buffer-modified-p)))
  941. (let* ((configdir (locate-dominating-file default-directory ".scalafmt.conf"))
  942. (configoption (if configdir
  943. (concat " --config "
  944. (shell-quote-argument (expand-file-name configdir))
  945. ".scalafmt.conf"
  946. )
  947. ""))
  948. (str (concat "scalafmt -f "
  949. (shell-quote-argument buffer-file-name)
  950. configoption
  951. " -i --exclude ensime")))
  952. (message str)
  953. (shell-command-to-string str))
  954. (message "scalafmt done")
  955. (revert-buffer nil t))
  956. (when (fboundp 'web-mode)
  957. (add-to-list 'auto-mode-alist
  958. '("\\.html\\.j2\\'" . web-mode))
  959. (add-to-list 'auto-mode-alist
  960. ;; Django Template Language
  961. '("\\.dtl\\'" . web-mode))
  962. )
  963. (when (autoload-eval-lazily 'wgrep)
  964. (set-variable 'wgrep-auto-save-buffer t)
  965. (with-eval-after-load 'grep
  966. (defvar grep-mode-map)
  967. (define-key grep-mode-map
  968. "e"
  969. 'wgrep-change-to-wgrep-mode)))
  970. (when (fboundp 'grep-context-mode)
  971. (add-hook 'compilation-mode-hook #'grep-context-mode))
  972. (with-eval-after-load 'remember
  973. (defvar remember-mode-map)
  974. (define-key remember-mode-map (kbd "C-x C-s") 'ignore))
  975. (set-variable 'remember-notes-initial-major-mode
  976. 'change-log-mode)
  977. (with-eval-after-load 'magit-files
  978. ;; `global-magit-file-mode' is enabled by default and this mode overwrites
  979. ;; existing keybindings.
  980. ;; Apparently it is a HARMFUL behavior and it is really awful that I have
  981. ;; to disable thie mode here, but do anyway.
  982. ;; See also https://github.com/magit/magit/issues/3517
  983. (global-magit-file-mode -1))
  984. (with-eval-after-load 'magit-section
  985. (set-face-background 'magit-section-highlight
  986. nil))
  987. ;; Sane colors
  988. (with-eval-after-load 'magit-diff
  989. (set-face-background 'magit-diff-context nil)
  990. (set-face-background 'magit-diff-context-highlight nil)
  991. (set-face-foreground 'magit-diff-hunk-heading nil)
  992. (set-face-background 'magit-diff-hunk-heading nil)
  993. (set-face-foreground 'magit-diff-hunk-heading-highlight nil)
  994. (set-face-background 'magit-diff-hunk-heading-highlight nil)
  995. ;; https://blog.shibayu36.org/entry/2016/03/27/220552
  996. (set-face-foreground 'magit-diff-added "green")
  997. (set-face-background 'magit-diff-added nil)
  998. (set-face-foreground 'magit-diff-added-highlight "green")
  999. (set-face-background 'magit-diff-added-highlight nil)
  1000. (set-face-foreground 'magit-diff-removed "red")
  1001. (set-face-background 'magit-diff-removed nil)
  1002. (set-face-foreground 'magit-diff-removed-highlight "red")
  1003. (set-face-background 'magit-diff-removed-highlight nil)
  1004. (set-face-background 'magit-diff-lines-boundary "blue")
  1005. )
  1006. (defun my-magit-messenger (file line)
  1007. "Magit messenger."
  1008. (interactive (list buffer-file-name
  1009. (line-number-at-pos)))
  1010. (cl-assert file)
  1011. (cl-assert line)
  1012. (let* ((blame-args '("-w"))
  1013. (id (with-temp-buffer
  1014. (let ((exit (apply 'call-process
  1015. "git" ;; PROGRAM
  1016. nil ;; INFILE
  1017. t ;; DESTINATION
  1018. nil ;; DISPLAY
  1019. "--no-pager" ;; ARGS
  1020. "blame"
  1021. "-L"
  1022. (format "%d,+1" line)
  1023. "--porcelain"
  1024. file
  1025. blame-args
  1026. )))
  1027. (goto-char (point-min))
  1028. (cl-assert (eq exit 0)
  1029. "Failed: %s" (buffer-substring (point)
  1030. (point-at-eol)))
  1031. (save-match-data
  1032. (re-search-forward (rx buffer-start
  1033. (one-or-more hex-digit)))
  1034. (match-string 0))))))
  1035. (magit-show-commit id)))
  1036. (when (boundp 'git-rebase-filename-regexp)
  1037. (add-to-list 'auto-mode-alist
  1038. `(,git-rebase-filename-regexp . text-mode)))
  1039. (when (safe-require-or-eval 'aggressive-indent)
  1040. (defvar aggressive-indent-excluded-modes)
  1041. (setq aggressive-indent-excluded-modes
  1042. `(web-mode
  1043. diff-mode
  1044. toml-mode
  1045. conf-mode
  1046. dockerfile-mode
  1047. groovy-mode
  1048. scala-mode
  1049. ,@aggressive-indent-excluded-modes))
  1050. (global-aggressive-indent-mode 1))
  1051. (when (fboundp 'ggtags-mode)
  1052. (add-hook 'c-mode-common-hook
  1053. 'ggtags-mode)
  1054. (add-hook 'python-mode-hook
  1055. 'ggtags-mode)
  1056. (add-hook 'js-mode-hook
  1057. 'ggtags-mode)
  1058. (add-hook 'scheme-mode-hook
  1059. 'ggtags-mode)
  1060. )
  1061. (when (fboundp 'imenu-list-minor-mode)
  1062. (defvar imenu-list-buffer-name)
  1063. (defun my-imenu-list-toggle ()
  1064. "My 'imenu-list` toggle."
  1065. (interactive)
  1066. (require 'imenu-list)
  1067. (if (eq (window-buffer)
  1068. (get-buffer imenu-list-buffer-name))
  1069. (imenu-list-minor-mode -1)
  1070. (imenu-list-minor-mode 1)))
  1071. ;; (set-variable 'imenu-list-auto-resize t)
  1072. (set-variable 'imenu-list-focus-after-activation t)
  1073. (define-key ctl-x-map (kbd "C-l") 'my-imenu-list-toggle))
  1074. (add-hook 'emacs-lisp-mode-hook
  1075. (lambda ()
  1076. (setq imenu-generic-expression
  1077. `(("Sections" ";;;\+\n;; \\(.*\\)\n" 1)
  1078. ,@imenu-generic-expression))))
  1079. ;; TODO: Try paraedit http://daregada.blogspot.com/2012/03/paredit.html
  1080. (with-eval-after-load 'compile
  1081. (defvar compilation-filter-start)
  1082. (defvar compilation-error-regexp-alist)
  1083. (require 'ansi-color)
  1084. (add-hook 'compilation-filter-hook
  1085. (lambda ()
  1086. (let ((inhibit-read-only t))
  1087. (ansi-color-apply-on-region compilation-filter-start
  1088. (point)))))
  1089. (add-to-list 'compilation-error-regexp-alist
  1090. ;; ansible-lint
  1091. '("^\\([^ \n]+\\):\\([0-9]+\\)$" 1 2))
  1092. (add-to-list 'compilation-error-regexp-alist
  1093. ;; pydocstyle
  1094. '("^\\([^ \n]+\\):\\([0-9]+\\) " 1 2))
  1095. )
  1096. (when (safe-require-or-eval 'company)
  1097. ;; http://qiita.com/sune2/items/b73037f9e85962f5afb7
  1098. ;; https://qiita.com/yuze/items/a145b1e3edb6d0c24cbf
  1099. (global-company-mode)
  1100. (set-variable 'company-idle-delay nil)
  1101. (set-variable 'company-minimum-prefix-length 2)
  1102. (set-variable 'company-selection-wrap-around t)
  1103. (defvar company-mode-map)
  1104. (define-key company-mode-map (kbd "C-i") 'company-indent-or-complete-common)
  1105. ;; (with-eval-after-load 'python
  1106. ;; (defvar python-indent-trigger-commands)
  1107. ;; ;; TODO: This disables completion in puthon?
  1108. ;; (add-to-list 'python-indent-trigger-commands
  1109. ;; 'company-indent-or-complete-common))
  1110. (define-key ctl-x-map (kbd "C-i") 'company-complete) ; Originally `indent-rigidly'
  1111. (defvar company-active-map)
  1112. (define-key company-active-map (kbd "C-n") 'company-select-next)
  1113. (define-key company-active-map (kbd "C-p") 'company-select-previous)
  1114. (define-key company-active-map (kbd "C-s") 'company-filter-candidates)
  1115. (define-key company-active-map (kbd "C-i") 'company-complete-selection)
  1116. (define-key company-active-map (kbd "C-f") 'company-complete-selection)
  1117. (defvar company-mode)
  1118. (defvar company-candidates)
  1119. (defvar company-candidates-length)
  1120. ;; (popup-tip "Hello, World!")
  1121. (defun my-company-lighter-current-length ()
  1122. "Get current candidate length."
  1123. (interactive)
  1124. (let ((l nil)
  1125. (inhibit-message t))
  1126. (when (and company-mode
  1127. (not (minibufferp))
  1128. ;; Do nothing when already in company completion
  1129. (not company-candidates))
  1130. ;; FIXME: Somehow it cannto catch errors from ggtags
  1131. (ignore-errors
  1132. ;; (company-auto-begin)
  1133. (company-manual-begin)
  1134. (setq l company-candidates-length)
  1135. (company-cancel)))
  1136. (if l
  1137. (format "[%d]" l)
  1138. "")))
  1139. (defvar company-lighter)
  1140. (set-variable 'company-lighter-base "Cmp")
  1141. ;; (add-to-list 'company-lighter
  1142. ;; '(:eval (my-company-lighter-current-length))
  1143. ;; t)
  1144. ;; This breaks japanese text input
  1145. ;; (set-variable 'my-company-length-popup-tip-timer
  1146. ;; (run-with-idle-timer 0.2 t
  1147. ;; 'my-company-length-popup-tip))
  1148. ;; (current-active-maps)
  1149. ;; (lookup-key)
  1150. '(mapcar (lambda (map)
  1151. (lookup-key map (kbd "C-i")))
  1152. (current-active-maps))
  1153. ;; https://qiita.com/syohex/items/8d21d7422f14e9b53b17
  1154. (set-face-attribute 'company-tooltip nil
  1155. :foreground "black" :background "lightgrey")
  1156. (set-face-attribute 'company-tooltip-common nil
  1157. :foreground "black" :background "lightgrey")
  1158. (set-face-attribute 'company-tooltip-common-selection nil
  1159. :foreground "white" :background "steelblue")
  1160. (set-face-attribute 'company-tooltip-selection nil
  1161. :foreground "black" :background "steelblue")
  1162. (set-face-attribute 'company-preview-common nil
  1163. :background nil :foreground "lightgrey" :underline t)
  1164. (set-face-attribute 'company-scrollbar-fg nil
  1165. :background "orange")
  1166. (set-face-attribute 'company-scrollbar-bg nil
  1167. :background "gray40")
  1168. )
  1169. ;; https://github.com/lunaryorn/flycheck
  1170. ;; TODO: Any way to disable auto check?
  1171. ;; Update flycheck-hooks-alist?
  1172. (when (safe-require-or-eval 'flycheck)
  1173. (eval-after-init (global-flycheck-mode)))
  1174. ;; (set-variable 'flycheck-display-errors-delay 2.0)
  1175. ;; (fset 'flycheck-display-error-at-point-soon 'ignore)
  1176. ;; (with-eval-after-load 'flycheck
  1177. ;; (when (fboundp 'flycheck-black-check-setup)
  1178. ;; (flycheck-black-check-setup)))
  1179. (when (autoload-eval-lazily 'ilookup)
  1180. (define-key ctl-x-map "d" 'ilookup-open-word))
  1181. (set-variable 'ac-ignore-case nil)
  1182. (when (autoload-eval-lazily 'term-run '(term-run-shell-command term-run))
  1183. (define-key ctl-x-map "t" 'term-run-shell-command))
  1184. (add-to-list 'safe-local-variable-values
  1185. '(encoding utf-8))
  1186. (setq enable-local-variables :safe)
  1187. ;; Detect file type from shebang and set major-mode.
  1188. (add-to-list 'interpreter-mode-alist
  1189. '("python3" . python-mode))
  1190. (add-to-list 'interpreter-mode-alist
  1191. '("python2" . python-mode))
  1192. (with-eval-after-load 'python
  1193. (defvar python-mode-map (make-sparse-keymap))
  1194. (define-key python-mode-map (kbd "C-m") 'newline-and-indent))
  1195. ;; I want to use this, but this breaks normal self-insert-command
  1196. ;; (set-variable 'py-indent-list-style
  1197. ;; 'one-level-to-beginning-of-statement)
  1198. (set-variable 'pydoc-command
  1199. "python3 -m pydoc")
  1200. (with-eval-after-load 'pydoc
  1201. (when (require 'with-venv nil t)
  1202. (with-venv-advice-add 'pydoc)))
  1203. (when (autoload-eval-lazily 'pipenv)
  1204. ;; (declare-function pipenv-projectile-after-switch-default "pipenv")
  1205. ;; (add-hook 'python-mode-hook
  1206. ;; (lambda ()
  1207. ;; (pipenv-mode 1)
  1208. ;; (pipenv-projectile-after-switch-default)))
  1209. )
  1210. (set-variable 'flycheck-python-mypy-ini ".mypy.ini")
  1211. (set-variable 'flycheck-flake8rc "setup.cfg")
  1212. (set-variable 'flycheck-python-pylint-executable "python3")
  1213. (set-variable 'flycheck-python-pycompile-executable "python3")
  1214. (set-variable 'python-indent-guess-indent-offset nil)
  1215. (with-eval-after-load 'blacken
  1216. (when (require 'with-venv nil t)
  1217. (with-venv-advice-add 'blacken-buffer)))
  1218. ;; isortify-buffer breaks buffer when it contains japanese text
  1219. (defun my-isortify ()
  1220. (interactive)
  1221. (cl-assert buffer-file-name)
  1222. (cl-assert (not (buffer-modified-p)))
  1223. (with-venv
  1224. (call-process "python" ;; PROGRAM
  1225. nil ;; INFILE
  1226. nil ;; DESTINATION
  1227. nil ;; DISPLAY
  1228. "-m" "isort" buffer-file-name))
  1229. (message "isortify done")
  1230. (revert-buffer nil t))
  1231. ;; https://github.com/lunaryorn/old-emacs-configuration/blob/master/lisp/flycheck-virtualenv.el
  1232. (defun my-set-venv-flycheck-executable-find ()
  1233. "Set flycheck executabie find."
  1234. (interactive)
  1235. (when (and (require 'with-venv nil t)
  1236. ;; Hack not to set when venv dir not found
  1237. (with-venv-find-venv-dir))
  1238. (set-variable 'flycheck-executable-find
  1239. '(lambda (e)
  1240. (with-venv
  1241. (executable-find e)))
  1242. t)))
  1243. (defun my-update-flycheck-flake8-error-level-alist ()
  1244. "Update `flycheck-flake8-error-level-alist'."
  1245. (defvar flycheck-flake8-error-level-alist)
  1246. ;; (add-to-list 'flycheck-flake8-error-level-alist
  1247. ;; '("^D.*$" . warning))
  1248. (set-variable 'flycheck-flake8-error-level-alist
  1249. nil)
  1250. )
  1251. (add-hook 'python-mode-hook
  1252. 'my-set-venv-flycheck-executable-find)
  1253. (add-hook 'python-mode-hook
  1254. 'my-update-flycheck-flake8-error-level-alist)
  1255. ;; Run multiple chekcers
  1256. ;; https://github.com/flycheck/flycheck/issues/186
  1257. ;; http://fukuyama.co/foreign-regexp
  1258. '(and (safe-require-or-eval 'foreign-regexp)
  1259. (progn
  1260. (setq foreign-regexp/regexp-type 'perl)
  1261. '(setq reb-re-syntax 'foreign-regexp)
  1262. ))
  1263. (autoload-eval-lazily 'sql '(sql-mode)
  1264. (require 'sql-indent nil t))
  1265. (add-to-list 'auto-mode-alist
  1266. '("\\.hql\\'" . sql-mode))
  1267. (when (autoload-eval-lazily 'git-command)
  1268. (define-key ctl-x-map "g" 'git-command))
  1269. ;; This keybind cause unexpected call really many many times
  1270. ;; (when (autoload-eval-lazily 'gited)
  1271. ;; (define-key ctl-x-map (kbd "C-g") 'gited-list))
  1272. (defalias 'gited 'gited-list)
  1273. (when (safe-require-or-eval 'git-commit)
  1274. (global-git-commit-mode 1))
  1275. (with-eval-after-load 'git-commit
  1276. (add-hook 'git-commit-setup-hook
  1277. 'turn-off-auto-fill t))
  1278. (autoload-eval-lazily 'sl)
  1279. (with-eval-after-load 'rst
  1280. (defvar rst-mode-map)
  1281. (define-key rst-mode-map (kbd "C-m") 'newline-and-indent))
  1282. (with-eval-after-load 'jdee
  1283. (add-hook 'jdee-mode-hook
  1284. (lambda ()
  1285. (make-local-variable 'global-mode-string)
  1286. (add-to-list 'global-mode-string
  1287. mode-line-position))))
  1288. ;; Cannot enable error thrown. Why???
  1289. ;; https://github.com/m0smith/malabar-mode#Installation
  1290. ;; (when (autoload-eval-lazily 'malabar-mode)
  1291. ;; (add-to-list 'load-path
  1292. ;; (expand-file-name (concat user-emacs-directory "/cedet")))
  1293. ;; (safe-require-or-eval 'cedet-devel-load)
  1294. ;; (eval-after-init (activate-malabar-mode)))
  1295. (with-eval-after-load 'make-mode
  1296. (defvar makefile-mode-map (make-sparse-keymap))
  1297. (define-key makefile-mode-map (kbd "C-m") 'newline-and-indent)
  1298. ;; this functions is set in write-file-functions, i cannot find any
  1299. ;; good way to remove this.
  1300. (fset 'makefile-warn-suspicious-lines 'ignore))
  1301. (with-eval-after-load 'verilog-mode
  1302. (defvar verilog-mode-map (make-sparse-keymap))
  1303. (define-key verilog-mode-map ";" 'self-insert-command))
  1304. (setq diff-switches "-u")
  1305. (autoload 'diff-goto-source "diff-mode")
  1306. (with-eval-after-load 'diff-mode
  1307. ;; (when (and (eq major-mode
  1308. ;; 'diff-mode)
  1309. ;; (not buffer-file-name))
  1310. ;; ;; do not pass when major-mode is derived mode of diff-mode
  1311. ;; (view-mode 1))
  1312. (set-face-attribute 'diff-header nil
  1313. :foreground nil
  1314. :background nil
  1315. :weight 'bold)
  1316. (set-face-attribute 'diff-file-header nil
  1317. :foreground nil
  1318. :background nil
  1319. :weight 'bold)
  1320. (set-face-foreground 'diff-index "blue")
  1321. (set-face-attribute 'diff-hunk-header nil
  1322. :foreground "cyan"
  1323. :weight 'normal)
  1324. (set-face-attribute 'diff-context nil
  1325. ;; :foreground "white"
  1326. :foreground nil
  1327. :weight 'normal)
  1328. (set-face-foreground 'diff-removed "red")
  1329. (set-face-foreground 'diff-added "green")
  1330. (set-face-background 'diff-removed nil)
  1331. (set-face-background 'diff-added nil)
  1332. (set-face-attribute 'diff-changed nil
  1333. :foreground "magenta"
  1334. :weight 'normal)
  1335. (set-face-attribute 'diff-refine-changed nil
  1336. :foreground nil
  1337. :background nil
  1338. :weight 'bold
  1339. :inverse-video t)
  1340. ;; Annoying !
  1341. ;;(diff-auto-refine-mode)
  1342. )
  1343. ;; (ffap-bindings)
  1344. (set-variable 'browse-url-browser-function
  1345. 'eww-browse-url)
  1346. (set-variable 'sh-here-document-word "__EOC__")
  1347. (when (autoload-eval-lazily 'adoc-mode
  1348. nil
  1349. (defvar adoc-mode-map (make-sparse-keymap))
  1350. (define-key adoc-mode-map (kbd "C-m") 'newline))
  1351. (setq auto-mode-alist
  1352. `(("\\.adoc\\'" . adoc-mode)
  1353. ("\\.asciidoc\\'" . adoc-mode)
  1354. ,@auto-mode-alist)))
  1355. (with-eval-after-load 'markup-faces
  1356. ;; Is this too match ?
  1357. (set-face-foreground 'markup-meta-face
  1358. "color-245")
  1359. (set-face-foreground 'markup-meta-hide-face
  1360. "color-245")
  1361. )
  1362. ;; TODO: check if this is required
  1363. (when (autoload-eval-lazily 'groovy-mode nil
  1364. (defvar groovy-mode-map (make-sparse-keymap))
  1365. (define-key groovy-mode-map "(" 'self-insert-command)
  1366. (define-key groovy-mode-map ")" 'self-insert-command)
  1367. (define-key groovy-mode-map (kbd "C-m") 'newline-and-indent)
  1368. )
  1369. (add-to-list 'auto-mode-alist
  1370. '("build\\.gradle\\'" . groovy-mode)))
  1371. (add-to-list 'auto-mode-alist
  1372. '("\\.gawk\\'" . awk-mode))
  1373. (with-eval-after-load 'yaml-mode
  1374. (defvar yaml-mode-map (make-sparse-keymap))
  1375. (define-key yaml-mode-map (kbd "C-m") 'newline))
  1376. (with-eval-after-load 'html-mode
  1377. (defvar html-mode-map (make-sparse-keymap))
  1378. (define-key html-mode-map (kbd "C-m") 'reindent-then-newline-and-indent))
  1379. (with-eval-after-load 'text-mode
  1380. (define-key text-mode-map (kbd "C-m") 'newline))
  1381. (autoload-eval-lazily 'info nil
  1382. (defvar Info-additional-directory-list)
  1383. (dolist (dir (directory-files (concat user-emacs-directory
  1384. "info")
  1385. t
  1386. "^[^.].*"))
  1387. (when (file-directory-p dir)
  1388. (add-to-list 'Info-additional-directory-list
  1389. dir)))
  1390. (let ((dir (expand-file-name "~/.brew/share/info")))
  1391. (when (file-directory-p dir)
  1392. (add-to-list 'Info-additional-directory-list
  1393. dir))))
  1394. (with-eval-after-load 'apropos
  1395. (defvar apropos-mode-map (make-sparse-keymap))
  1396. (define-key apropos-mode-map "n" 'next-line)
  1397. (define-key apropos-mode-map "p" 'previous-line))
  1398. ;; `isearch' library does not call `provide' so cannot use with-eval-after-load
  1399. ;; (define-key isearch-mode-map
  1400. ;; (kbd "C-j") 'isearch-other-control-char)
  1401. ;; (define-key isearch-mode-map
  1402. ;; (kbd "C-k") 'isearch-other-control-char)
  1403. ;; (define-key isearch-mode-map
  1404. ;; (kbd "C-h") 'isearch-other-control-char)
  1405. (define-key isearch-mode-map (kbd "C-h") 'isearch-del-char)
  1406. (define-key isearch-mode-map (kbd "M-r")
  1407. 'isearch-query-replace-regexp)
  1408. ;; do not cleanup isearch highlight: use `lazy-highlight-cleanup' to remove
  1409. (setq lazy-highlight-cleanup nil)
  1410. ;; face for isearch highlighing
  1411. (set-face-attribute 'lazy-highlight
  1412. nil
  1413. :foreground `unspecified
  1414. :background `unspecified
  1415. :underline t
  1416. ;; :weight `bold
  1417. )
  1418. (add-hook 'outline-mode-hook
  1419. (lambda ()
  1420. (when (string-match "\\.md\\'" buffer-file-name)
  1421. (set (make-local-variable 'outline-regexp) "#+ "))))
  1422. (add-hook 'outline-mode-hook
  1423. 'outline-show-all)
  1424. (add-to-list 'auto-mode-alist (cons "\\.ol\\'" 'outline-mode))
  1425. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'outline-mode))
  1426. (when (autoload-eval-lazily 'markdown-mode
  1427. '(markdown-mode gfm-mode)
  1428. (defvar gfm-mode-map (make-sparse-keymap))
  1429. (define-key gfm-mode-map (kbd "C-m") 'electric-indent-just-newline)
  1430. (define-key gfm-mode-map "`" nil) ;; markdown-electric-backquote
  1431. )
  1432. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'gfm-mode))
  1433. (set-variable 'markdown-command (or (executable-find "markdown")
  1434. (executable-find "markdown.pl")
  1435. ""))
  1436. (add-hook 'markdown-mode-hook
  1437. (lambda ()
  1438. (outline-minor-mode 1)
  1439. (flyspell-mode)
  1440. (set (make-local-variable 'comment-start) ";")))
  1441. )
  1442. ;; c-mode
  1443. ;; http://www.emacswiki.org/emacs/IndentingC
  1444. ;; http://en.wikipedia.org/wiki/Indent_style
  1445. ;; http://d.hatena.ne.jp/emergent/20070203/1170512717
  1446. ;; http://seesaawiki.jp/whiteflare503/d/Emacs%20%a5%a4%a5%f3%a5%c7%a5%f3%a5%c8
  1447. (with-eval-after-load 'cc-vars
  1448. (defvar c-default-style nil)
  1449. (add-to-list 'c-default-style
  1450. '(c-mode . "k&r"))
  1451. (add-to-list 'c-default-style
  1452. '(c++-mode . "k&r")))
  1453. (autoload-eval-lazily 'js2-mode nil
  1454. ;; currently do not use js2-mode
  1455. ;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  1456. ;; (add-to-list 'auto-mode-alist '("\\.jsm\\'" . js2-mode))
  1457. ;; (defvar js2-mode-map (make-sparse-keymap))
  1458. ;; (define-key js2-mode-map (kbd "C-m") (lambda ()
  1459. ;; (interactive)
  1460. ;; (js2-enter-key)
  1461. ;; (indent-for-tab-command)))
  1462. ;; (add-hook (kill-local-variable 'before-save-hook)
  1463. ;; 'js2-before-save)
  1464. ;; (add-hook 'before-save-hook
  1465. ;; 'my-indent-buffer
  1466. ;; nil
  1467. ;; t)
  1468. )
  1469. (add-to-list 'interpreter-mode-alist
  1470. '("node" . js-mode))
  1471. (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
  1472. (with-eval-after-load 'uniquify
  1473. (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
  1474. (setq uniquify-ignore-buffers-re "*[^*]+*")
  1475. (setq uniquify-min-dir-content 1))
  1476. (with-eval-after-load 'view
  1477. (defvar view-mode-map (make-sparse-keymap))
  1478. (define-key view-mode-map "j" 'scroll-up-line)
  1479. (define-key view-mode-map "k" 'scroll-down-line)
  1480. (define-key view-mode-map "v" 'toggle-read-only)
  1481. (define-key view-mode-map "q" 'bury-buffer)
  1482. ;; (define-key view-mode-map "/" 'nonincremental-re-search-forward)
  1483. ;; (define-key view-mode-map "?" 'nonincremental-re-search-backward)
  1484. ;; (define-key view-mode-map
  1485. ;; "n" 'nonincremental-repeat-search-forward)
  1486. ;; (define-key view-mode-map
  1487. ;; "N" 'nonincremental-repeat-search-backward)
  1488. ;; N conflicts with git-walktree
  1489. ;; (define-key view-mode-map "/" 'isearch-forward-regexp)
  1490. ;; (define-key view-mode-map "?" 'isearch-backward-regexp)
  1491. ;; (define-key view-mode-map "n" 'isearch-repeat-forward)
  1492. ;; (define-key view-mode-map "N" 'isearch-repeat-backward)
  1493. (define-key view-mode-map (kbd "C-m") 'my-rgrep-symbol-at-point))
  1494. (global-set-key "\M-r" 'view-mode)
  1495. ;; (setq view-read-only t)
  1496. (with-eval-after-load 'term
  1497. (defvar term-raw-map (make-sparse-keymap))
  1498. (define-key term-raw-map (kbd "C-x")
  1499. (lookup-key (current-global-map)
  1500. (kbd "C-x"))))
  1501. (add-hook 'term-mode-hook
  1502. (lambda ()
  1503. ;; Stop current line highlighting
  1504. (set-variable 'hl-line-range-function (lambda () '(0 . 0)) t)
  1505. (set-variable 'scroll-margin 0 t)
  1506. ))
  1507. (set-variable 'term-buffer-maximum-size 20480)
  1508. (set-variable 'term-suppress-hard-newline t)
  1509. (add-hook 'Man-mode-hook
  1510. (lambda ()
  1511. (view-mode 1)
  1512. (setq truncate-lines nil)))
  1513. (set-variable 'Man-notify-method (if window-system
  1514. 'newframe
  1515. 'aggressive))
  1516. (set-variable 'woman-cache-filename (expand-file-name (concat user-emacs-directory
  1517. "woman_cache.el")))
  1518. ;; not work because man.el will be loaded when man called
  1519. (defalias 'man 'woman)
  1520. (add-to-list 'auto-mode-alist
  1521. '("tox\\.ini\\'" . conf-unix-mode))
  1522. (when (autoload-eval-lazily 'toml-mode)
  1523. (add-to-list 'auto-mode-alist
  1524. '("/tox\\.ini\\'" . toml-mode))
  1525. (add-to-list 'auto-mode-alist
  1526. '("/Pipfile\\'" . toml-mode))
  1527. (add-to-list 'auto-mode-alist
  1528. '("/poetry\\.lock\\'" . toml-mode))
  1529. )
  1530. (when (autoload-eval-lazily 'json-mode)
  1531. (add-to-list 'auto-mode-alist
  1532. '("/Pipfile\\.lock\\'" . json-mode)))
  1533. (add-hook 'go-mode-hook
  1534. (lambda()
  1535. (defvar go-mode-map)
  1536. (add-hook 'before-save-hook' 'gofmt-before-save nil t)
  1537. (define-key go-mode-map (kbd "M-.") 'godef-jump)))
  1538. (when (autoload-eval-lazily 'k8s-mode)
  1539. (add-to-list 'auto-mode-alist
  1540. '("\\.k8s\\'" . k8s-mode)))
  1541. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1542. ;; buffers
  1543. (defvar bs-configurations)
  1544. (declare-function bs-set-configuration "bs")
  1545. (declare-function bs-refresh "bs")
  1546. (declare-function bs-message-without-log "bs")
  1547. (declare-function bs--current-config-message "bs")
  1548. (when (autoload-eval-lazily 'bs '(bs-show)
  1549. (add-to-list 'bs-configurations
  1550. '("specials" "^\\*" nil ".*" nil nil))
  1551. (add-to-list 'bs-configurations
  1552. '("files-and-specials" "^\\*" buffer-file-name ".*" nil nil))
  1553. (defvar bs-mode-map)
  1554. (defvar bs-current-configuration)
  1555. (define-key bs-mode-map (kbd "t")
  1556. ;; TODO: fix toggle feature
  1557. (lambda ()
  1558. (interactive)
  1559. (if (string= "specials"
  1560. bs-current-configuration)
  1561. (bs-set-configuration "files")
  1562. (bs-set-configuration "specials"))
  1563. (bs-refresh)
  1564. (bs-message-without-log "%s"
  1565. (bs--current-config-message))))
  1566. ;; (setq bs-configurations (list
  1567. ;; '("processes" nil get-buffer-process ".*" nil nil)
  1568. ;; '("files-and-scratch" "^\\*scratch\\*$" nil nil
  1569. ;; bs-visits-non-file bs-sort-buffer-interns-are-last)))
  1570. )
  1571. (defalias 'list-buffers 'bs-show)
  1572. (set-variable 'bs-default-configuration "files-and-specials")
  1573. (set-variable 'bs-default-sort-name "by nothing")
  1574. (add-hook 'bs-mode-hook
  1575. (lambda ()
  1576. (set (make-local-variable 'scroll-margin) 0))))
  1577. ;;(iswitchb-mode 1)
  1578. (icomplete-mode)
  1579. (defun iswitchb-buffer-display-other-window ()
  1580. "Do iswitchb in other window."
  1581. (interactive)
  1582. (let ((iswitchb-default-method 'display))
  1583. (call-interactively 'iswitchb-buffer)))
  1584. ;; buffer killing
  1585. ;; (defun my-delete-window-killing-buffer () nil)
  1586. (defun my-query-kill-current-buffer ()
  1587. "Interactively kill current buffer."
  1588. (interactive)
  1589. (if (y-or-n-p (concat "kill current buffer? :"))
  1590. (kill-buffer (current-buffer))))
  1591. (defun my-force-query-kill-current-buffer ()
  1592. "Interactively kill current buffer."
  1593. (interactive)
  1594. (when (y-or-n-p (concat "kill current buffer? :"))
  1595. (let ((kill-buffer-hook nil)
  1596. (kill-buffer-query-functions nil))
  1597. (kill-buffer (current-buffer)))))
  1598. ;;(global-set-key "\C-xk" 'my-query-kill-current-buffer)
  1599. ;; Originally C-x C-k -> kmacro-keymap
  1600. ;; (global-set-key "\C-x\C-k" 'kmacro-keymap)
  1601. (global-set-key (kbd "C-x C-k") 'my-query-kill-current-buffer)
  1602. (substitute-key-definition 'kill-buffer
  1603. 'my-query-kill-current-buffer
  1604. global-map)
  1605. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1606. ;; dired
  1607. (defun my-file-head (filename &optional n)
  1608. "Return list of first N lines of file FILENAME."
  1609. ;; TODO: Fix for janapese text
  1610. ;; TODO: Fix for short text
  1611. (let ((num (or n 10))
  1612. (size 100)
  1613. (beg 0)
  1614. (end 0)
  1615. (result '())
  1616. (read -1))
  1617. (with-temp-buffer
  1618. (erase-buffer)
  1619. (while (or (<= (count-lines (point-min)
  1620. (point-max))
  1621. num)
  1622. (eq read 0))
  1623. (setq end (+ beg size))
  1624. (setq read (nth 1 (insert-file-contents-literally filename
  1625. nil
  1626. beg
  1627. end)))
  1628. (goto-char (point-max))
  1629. (setq beg (+ beg size)))
  1630. (goto-char (point-min))
  1631. (while (< (length result) num)
  1632. (let ((start (point)))
  1633. (forward-line 1)
  1634. (setq result
  1635. `(,@result ,(buffer-substring-no-properties start
  1636. (point))))))
  1637. result
  1638. ;; (buffer-substring-no-properties (point-min)
  1639. ;; (progn
  1640. ;; (forward-line num)
  1641. ;; (point)))
  1642. )))
  1643. ;; (apply 'concat (my-file-head "./shrc" 10)
  1644. (defun my-dired-echo-file-head (arg)
  1645. "Echo head of current file.
  1646. ARG is num to show, or defaults to 7."
  1647. (interactive "P")
  1648. (let ((f (dired-get-filename)))
  1649. (message "%s"
  1650. (apply 'concat
  1651. (my-file-head f
  1652. 7)))))
  1653. (defun my-dired-diff ()
  1654. "Show diff of marked file and file of current line."
  1655. (interactive)
  1656. (let ((files (dired-get-marked-files nil nil nil t)))
  1657. (if (eq (car files)
  1658. t)
  1659. (diff (cadr files) (dired-get-filename))
  1660. (message "One file must be marked!"))))
  1661. (defun dired-get-file-info ()
  1662. "Print information of current line file."
  1663. (interactive)
  1664. (let* ((file (dired-get-filename t))
  1665. (quoted (shell-quote-argument file)))
  1666. (if (file-directory-p file)
  1667. (progn
  1668. (message "Calculating disk usage...")
  1669. (let ((du (or (executable-find "gdu")
  1670. (executable-find "du")
  1671. (error "du not found"))))
  1672. (shell-command (concat du
  1673. " -hsD "
  1674. quoted))))
  1675. (shell-command (concat "file "
  1676. quoted)))))
  1677. (defun my-dired-scroll-up ()
  1678. "Scroll up."
  1679. (interactive)
  1680. (my-dired-previous-line (- (window-height) 1)))
  1681. (defun my-dired-scroll-down ()
  1682. "Scroll down."
  1683. (interactive)
  1684. (my-dired-next-line (- (window-height) 1)))
  1685. ;; (defun my-dired-forward-line (arg)
  1686. ;; ""
  1687. ;; (interactive "p"))
  1688. (defun my-dired-previous-line (arg)
  1689. "Move ARG lines up."
  1690. (interactive "p")
  1691. (if (> arg 0)
  1692. (progn
  1693. (if (eq (line-number-at-pos)
  1694. 1)
  1695. (goto-char (point-max))
  1696. (forward-line -1))
  1697. (my-dired-previous-line (if (or (dired-get-filename nil t)
  1698. (dired-get-subdir))
  1699. (- arg 1)
  1700. arg)))
  1701. (dired-move-to-filename)))
  1702. (defun my-dired-next-line (arg)
  1703. "Move ARG lines down."
  1704. (interactive "p")
  1705. (if (> arg 0)
  1706. (progn
  1707. (if (eq (point)
  1708. (point-max))
  1709. (goto-char (point-min))
  1710. (forward-line 1))
  1711. (my-dired-next-line (if (or (dired-get-filename nil t)
  1712. (dired-get-subdir))
  1713. (- arg 1)
  1714. arg)))
  1715. (dired-move-to-filename)))
  1716. (defun my-tramp-remote-find-file (f)
  1717. "Open F."
  1718. (interactive (list (read-file-name "My Find File Tramp: "
  1719. "/scp:"
  1720. nil ;; "/scp:"
  1721. (confirm-nonexistent-file-or-buffer))))
  1722. (find-file f))
  1723. ;;http://bach.istc.kobe-u.ac.jp/lect/tamlab/ubuntu/emacs.html
  1724. (if (eq window-system 'mac)
  1725. (setq dired-listing-switches "-lhF")
  1726. (setq dired-listing-switches "-lhF --time-style=long-iso")
  1727. )
  1728. (setq dired-listing-switches "-lhF")
  1729. ;; when using dired-find-alternate-file
  1730. ;; reuse current dired buffer for the file to open
  1731. ;; (put 'dired-find-alternate-file 'disabled nil)
  1732. (set-variable 'dired-ls-F-marks-symlinks t)
  1733. (set-variable 'ls-lisp-use-insert-directory-program nil) ; always use ls-lisp
  1734. (set-variable 'ls-lisp-dirs-first t)
  1735. (set-variable 'ls-lisp-use-localized-time-format t)
  1736. (set-variable 'ls-lisp-format-time-list
  1737. '("%Y-%m-%d %H:%M"
  1738. "%Y-%m-%d "))
  1739. (set-variable 'dired-dwim-target t)
  1740. (set-variable 'dired-isearch-filenames t)
  1741. (set-variable 'dired-hide-details-hide-symlink-targets nil)
  1742. (set-variable 'dired-hide-details-hide-information-lines nil)
  1743. (set-variable 'dired-deletion-confirmer 'y-or-n-p)
  1744. (set-variable 'dired-recursive-deletes 'always)
  1745. ;; (add-hook 'dired-after-readin-hook
  1746. ;; 'my-replace-nasi-none)
  1747. (with-eval-after-load 'dired
  1748. (safe-require-or-eval 'ls-lisp)
  1749. (defvar dired-mode-map (make-sparse-keymap))
  1750. ;; dired-do-chgrp sometimes cause system hung
  1751. (define-key dired-mode-map "G" 'ignore)
  1752. (define-key dired-mode-map "e" 'wdired-change-to-wdired-mode)
  1753. (define-key dired-mode-map "i" 'dired-get-file-info)
  1754. ;; (define-key dired-mode-map "f" 'find-file)
  1755. (define-key dired-mode-map "f" 'my-fzf-or-find-file)
  1756. (define-key dired-mode-map "z" 'fzf)
  1757. (define-key dired-mode-map "!" 'shell-command)
  1758. (define-key dired-mode-map "&" 'async-shell-command)
  1759. (define-key dired-mode-map "X" 'dired-do-async-shell-command)
  1760. (define-key dired-mode-map "=" 'my-dired-diff)
  1761. (define-key dired-mode-map "B" 'gtkbm-add-current-dir)
  1762. (define-key dired-mode-map "b" 'gtkbm)
  1763. (define-key dired-mode-map "h" 'my-dired-echo-file-head)
  1764. (define-key dired-mode-map (kbd "TAB") 'other-window)
  1765. ;; (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack)
  1766. (define-key dired-mode-map "/" 'dired-isearch-filenames)
  1767. (define-key dired-mode-map (kbd "DEL") 'dired-up-directory)
  1768. (define-key dired-mode-map (kbd "C-h") 'dired-up-directory)
  1769. (substitute-key-definition 'dired-next-line
  1770. 'my-dired-next-line
  1771. dired-mode-map)
  1772. (substitute-key-definition 'dired-previous-line
  1773. 'my-dired-previous-line
  1774. dired-mode-map)
  1775. ;; (define-key dired-mode-map (kbd "C-p") 'my-dired-previous-line)
  1776. ;; (define-key dired-mode-map (kbd "p") 'my-dired-previous-line)
  1777. ;; (define-key dired-mode-map (kbd "C-n") 'my-dired-next-line)
  1778. ;; (define-key dired-mode-map (kbd "n") 'my-dired-next-line)
  1779. (define-key dired-mode-map (kbd "<left>") 'my-dired-scroll-up)
  1780. (define-key dired-mode-map (kbd "<right>") 'my-dired-scroll-down)
  1781. (define-key dired-mode-map (kbd "ESC p") 'my-dired-scroll-up)
  1782. (define-key dired-mode-map (kbd "ESC n") 'my-dired-scroll-down)
  1783. (add-hook 'dired-mode-hook
  1784. (lambda ()
  1785. (when (fboundp 'dired-hide-details-mode)
  1786. (dired-hide-details-mode t)
  1787. (local-set-key "l" 'dired-hide-details-mode))
  1788. (let ((file "._Icon\015"))
  1789. (when nil
  1790. '(file-readable-p file)
  1791. (delete-file file)))))
  1792. (when (fboundp 'pack-dired-dwim)
  1793. (with-eval-after-load 'dired
  1794. (define-key dired-mode-map "P" 'pack-dired-dwim)))
  1795. (when (autoload-eval-lazily 'dired-list-all-mode)
  1796. (setq dired-listing-switches "-lhF")
  1797. (with-eval-after-load 'dired
  1798. (define-key dired-mode-map "a" 'dired-list-all-mode))))
  1799. (when (autoload-eval-lazily 'dired-filter)
  1800. (add-hook 'dired-mode-hook
  1801. 'dired-filter-mode))
  1802. (set-variable 'dired-filter-stack nil)
  1803. ;; Currently disabled in favor of dired-from-git-ls-files
  1804. ;; (define-key ctl-x-map "f" 'find-dired)
  1805. (defvar my-dired-git-ls-files-history
  1806. "History for `my-dired-git-ls-files'." nil)
  1807. (defun my-dired-git-ls-files (arg)
  1808. "Dired from git ls-files."
  1809. (interactive (list
  1810. (read-shell-command "git ls-files: "
  1811. "git ls-files -z ")))
  1812. (pop-to-buffer-same-window
  1813. (dired-noselect `(,default-directory
  1814. ,@(split-string (shell-command-to-string arg)
  1815. "\0" t))
  1816. ""))
  1817. )
  1818. (define-key ctl-x-map (kbd "G") 'my-dired-git-ls-files)
  1819. (with-eval-after-load 'dired
  1820. (defvar dired-mode-map (make-sparse-keymap))
  1821. (define-key dired-mode-map "G" 'my-dired-git-ls-files))
  1822. (with-eval-after-load 'pack
  1823. (set-variable 'pack-silence
  1824. t)
  1825. (defvar pack-program-alist)
  1826. (add-to-list 'pack-program-alist
  1827. '("\\.txz\\'" :pack "tar -cJf" :unpack "tar -xf"))
  1828. (when (executable-find "aunpack")
  1829. (add-to-list 'pack-program-alist
  1830. ' ("\\.zip\\'"
  1831. :pack ("zip" "-r" archive sources)
  1832. :pack-append ("zip" "-r" archive sources)
  1833. :unpack ("aunpack" archive))))
  1834. )
  1835. ;; (define-minor-mode my-dired-glob-filter)
  1836. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1837. ;; misc funcs
  1838. (define-key ctl-x-map "T" 'git-worktree)
  1839. (define-key ctl-x-map "W" 'git-walktree)
  1840. (when (fboundp 'browse-url-default-macosx-browser)
  1841. (defalias 'browse-osx 'browse-url-default-macosx-browser))
  1842. (defalias 'qcalc 'quick-calc)
  1843. (defun memo (&optional dir)
  1844. "Open memo.txt in DIR."
  1845. (interactive)
  1846. (pop-to-buffer (find-file-noselect (concat (if dir
  1847. (file-name-as-directory dir)
  1848. "")
  1849. "memo.txt"))))
  1850. ;; TODO: remember-projectile
  1851. (set (defvar my-privnotes-path nil
  1852. "My privnotes repository path.")
  1853. (expand-file-name "~/my/privnotes"))
  1854. (defun my-privnotes-readme (dir)
  1855. "Open my privnotes DIR."
  1856. (interactive (list
  1857. (read-file-name "Privnotes: "
  1858. (expand-file-name (format-time-string "%Y%m%d_")
  1859. my-privnotes-path))))
  1860. (let ((path (expand-file-name "README.md" dir)))
  1861. (with-current-buffer (find-file path)
  1862. (unless (file-exists-p path)
  1863. (insert (file-name-base dir)
  1864. "\n"
  1865. "=======\n"
  1866. "\n\n")))))
  1867. (define-key ctl-x-map "p" 'my-privnotes-readme)
  1868. (set (defvar my-rgrep-alist nil
  1869. "Alist of rgrep command.
  1870. Each element is in the form like (NAME SEXP COMMAND), where SEXP returns the
  1871. condition to choose COMMAND when evaluated.")
  1872. `(
  1873. ;; ripgrep
  1874. ("rg"
  1875. (executable-find "rg")
  1876. "rg -nH --no-heading --hidden --glob '!.git/' --smart-case -M 1280 ")
  1877. ;; git grep
  1878. ("gitgrep"
  1879. (eq 0
  1880. (shell-command "git rev-parse --git-dir"))
  1881. "git --no-pager grep -nH -e ")
  1882. ;; sift
  1883. ("sift"
  1884. (executable-find "sift")
  1885. ("sift --binary-skip --filename --line-number --git --smart-case "))
  1886. ;; the silver searcher
  1887. ("ag"
  1888. (executable-find "ag")
  1889. "ag --nogroup --nopager --filename ")
  1890. ;; ack
  1891. ("ack"
  1892. (executable-find "ack")
  1893. "ack --nogroup --nopager --with-filename ")
  1894. ;; gnu global
  1895. ("global"
  1896. (and (require 'ggtags nil t)
  1897. (executable-find "global")
  1898. (ggtags-current-project-root))
  1899. "global --result grep ")
  1900. ;; grep
  1901. ("grep"
  1902. t
  1903. ,(concat "find . "
  1904. "-path '*/.git' -prune -o "
  1905. "-path '*/.svn' -prune -o "
  1906. "-type f -print0 | "
  1907. "xargs -0 grep -nH -e "))
  1908. )
  1909. )
  1910. (defvar my-rgrep-default nil
  1911. "Default command name for my-rgrep.")
  1912. (defun my-rgrep-grep-command (&optional name alist)
  1913. "Return recursive grep command for current directory or nil.
  1914. If NAME is given, use that without testing.
  1915. Commands are searched from ALIST."
  1916. (if alist
  1917. (if name
  1918. ;; if name is given search that from alist and return the command
  1919. (nth 2 (assoc name
  1920. alist))
  1921. ;; if name is not given try test in 1th elem
  1922. (let ((car (car alist))
  1923. (cdr (cdr alist)))
  1924. (if (eval (nth 1 car))
  1925. ;; if the condition is true return the command
  1926. (nth 2 car)
  1927. ;; try next one
  1928. (and cdr
  1929. (my-rgrep-grep-command name cdr)))))
  1930. ;; if alist is not given set default value
  1931. (my-rgrep-grep-command name my-rgrep-alist)))
  1932. (defun my-rgrep (command-args)
  1933. "My recursive grep. Run COMMAND-ARGS.
  1934. If prefix argument is given, use current symbol as default search target
  1935. and search from projectile root (if projectile is available)."
  1936. (interactive (let ((cmd (my-rgrep-grep-command my-rgrep-default
  1937. nil)))
  1938. (if cmd
  1939. (list (read-shell-command "grep command: "
  1940. (concat cmd
  1941. (if current-prefix-arg
  1942. (thing-at-point 'symbol t)
  1943. ""))
  1944. 'grep-find-history))
  1945. (error "My-Rgrep: Command for rgrep not found")
  1946. )))
  1947. (if (and current-prefix-arg
  1948. (safe-require-or-eval 'projectile)
  1949. (projectile-project-p))
  1950. (projectile-with-default-dir (projectile-project-root)
  1951. (compilation-start command-args
  1952. 'grep-mode))
  1953. (compilation-start command-args
  1954. 'grep-mode)))
  1955. (defun my-rgrep-thing-at-point-projectile-root ()
  1956. "My recursive grep to find thing at point from project root."
  1957. (interactive)
  1958. (let* ((cmd (my-rgrep-grep-command my-rgrep-default
  1959. nil))
  1960. (command-args
  1961. (if cmd
  1962. (concat cmd
  1963. (or (thing-at-point 'symbol t)
  1964. (error "No symbol at point")))
  1965. (error "My-Rgrep: Command for rgrep not found"))))
  1966. (if (safe-require-or-eval 'projectile)
  1967. (projectile-with-default-dir (or (projectile-project-root)
  1968. default-directory)
  1969. (compilation-start command-args
  1970. 'grep-mode))
  1971. (compilation-start command-args
  1972. 'grep-mode))))
  1973. (defmacro define-my-rgrep (name)
  1974. "Define rgrep for NAME."
  1975. `(defun ,(intern (concat "my-rgrep-"
  1976. name)) ()
  1977. ,(format "My recursive grep by %s."
  1978. name)
  1979. (interactive)
  1980. (let ((my-rgrep-default ,name))
  1981. (if (called-interactively-p 'any)
  1982. (call-interactively 'my-rgrep)
  1983. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1984. )
  1985. (define-my-rgrep "ack")
  1986. (define-my-rgrep "ag")
  1987. (define-my-rgrep "rg")
  1988. (define-my-rgrep "sift")
  1989. (define-my-rgrep "gitgrep")
  1990. (define-my-rgrep "grep")
  1991. (define-my-rgrep "global")
  1992. (define-key ctl-x-map "s" 'my-rgrep)
  1993. (define-key ctl-x-map "." 'my-rgrep-thing-at-point-projectile-root)
  1994. (defun my-occur (regexp &optional region)
  1995. "My occur command to search REGEXP."
  1996. (interactive (list (read-string "List lines matching regexp: "
  1997. (thing-at-point 'symbol t))))
  1998. (occur regexp nil region))
  1999. (define-key ctl-x-map (kbd "C-o") 'my-occur)
  2000. (set-variable 'dumb-jump-prefer-searcher 'rg)
  2001. (defalias 'make 'compile)
  2002. (define-key ctl-x-map "c" 'compile)
  2003. (defun my-pushbullet-note (text &optional title)
  2004. "Push TEXT."
  2005. (interactive "sText to Push: ")
  2006. (pb/push-item '("") text "note" (or title "")))
  2007. ;;;;;;;;;;;;;;;;;;;;;
  2008. ;; git-bug
  2009. (defconst git-bug-ls-regexp
  2010. (eval-when-compile
  2011. (rx bol
  2012. (submatch (one-or-more alphanumeric)) ; id
  2013. ;; (one-or-more any)
  2014. (one-or-more space)
  2015. (submatch (or "open" "close")) ; status
  2016. (one-or-more space)
  2017. (submatch (maximal-match (zero-or-more print))) ; title
  2018. "\t"
  2019. (submatch (one-or-more alphanumeric)) ; user
  2020. (one-or-more space)
  2021. "C:"
  2022. (submatch (one-or-more digit)) ; Comment num
  2023. (one-or-more space)
  2024. "L:"
  2025. (submatch (one-or-more digit)) ; Label num
  2026. eol
  2027. ))
  2028. "Regexp to parse line of output of git-bug ls.
  2029. Used by `git-bug-ls'.")
  2030. (defun git-bug-bugs ()
  2031. "Get list of git-bug bugs."
  2032. (with-temp-buffer
  2033. (git-bug--call-process "bug" "ls")
  2034. (goto-char (point-min))
  2035. (let ((bugs nil))
  2036. (while (not (eq (point) (point-max)))
  2037. (save-match-data
  2038. (when (re-search-forward git-bug-ls-regexp (point-at-eol) t)
  2039. (setq bugs `(,@bugs
  2040. ,(list
  2041. :id (match-string 1)
  2042. :status (match-string 2)
  2043. :title (string-trim (match-string 3))
  2044. :user (match-string 4)
  2045. :comment-num (match-string 5)
  2046. :label-num (match-string 6)
  2047. )))))
  2048. (forward-line 1)
  2049. (goto-char (point-at-bol)))
  2050. bugs)))
  2051. (defun git-bug-ls ()
  2052. "Open and select git bug list buffer."
  2053. (interactive)
  2054. (pop-to-buffer (git-bug-ls-noselect)))
  2055. (defun git-bug-ls-noselect (&optional directory)
  2056. "Open git bug list buffer.
  2057. If optional arg DIRECTORY is given change current directory to there before
  2058. initializing."
  2059. (setq directory (expand-file-name (or directory
  2060. default-directory)))
  2061. (cl-assert (file-directory-p directory))
  2062. (let* ((root (git-bug--get-repository-root directory))
  2063. (name (file-name-nondirectory root))
  2064. (bname (format "*GitBug<%s>*" name)))
  2065. (with-current-buffer (get-buffer-create bname)
  2066. (cd root)
  2067. (git-bug-ls--set-tabulated-list-mode-variables)
  2068. (git-bug-ls-mode)
  2069. (current-buffer))))
  2070. (defun git-bug--get-repository-root (dir)
  2071. "Resolve repository root of DIR.
  2072. If DIR is not inside of any git repository, signal an error."
  2073. (cl-assert (file-directory-p dir))
  2074. (with-temp-buffer
  2075. (cd dir)
  2076. (git-bug--call-process "rev-parse" "--show-toplevel")
  2077. (goto-char (point-min))
  2078. (buffer-substring-no-properties (point-at-bol) (point-at-eol))))
  2079. (defun git-bug--call-process (&rest args)
  2080. "Start git process synchronously with ARGS.
  2081. Raise error when git process ends with non-zero status.
  2082. Any output will be written to current buffer."
  2083. (let ((status (apply 'call-process
  2084. "git"
  2085. nil
  2086. t
  2087. nil
  2088. args)))
  2089. (cl-assert (eq status 0)
  2090. nil
  2091. (buffer-substring-no-properties (point-min) (point-max)))))
  2092. ;;;;;;;;;;;;;;;;;;;
  2093. ;; peek-file-mode
  2094. (defvar peek-file-buffers
  2095. ()
  2096. "Peek buffers.")
  2097. (defun peek-file (file)
  2098. "Peek FILE."
  2099. (interactive "fFile to peek: ")
  2100. (with-current-buffer (find-file file)
  2101. (peek-file-mode)))
  2102. (define-minor-mode peek-file-mode
  2103. "Peek file mode."
  2104. :lighter "PK"
  2105. (view-mode peek-file-mode)
  2106. (add-to-list 'peek-file-buffers
  2107. (current-buffer))
  2108. (add-hook 'switch-buffer-functions
  2109. 'peek-file-remove-buffers))
  2110. (defun peek-file-remove-buffers (&args _)
  2111. "Remove peek file buffers."
  2112. (cl-dolist (buf (cl-copy-list peek-file-buffers))
  2113. (unless (get-buffer-window buf t)
  2114. (setq peek-file-buffers
  2115. (delq buf
  2116. peek-file-buffers))
  2117. (with-current-buffer buf
  2118. (when peek-file-mode
  2119. (kill-buffer))))))
  2120. ;;;;;;;;;;;;;;;;;;;;
  2121. ;; remember-projectile
  2122. ;; TODO: Add global-minor-mode
  2123. (defvar remember-data-file)
  2124. (defun my-set-remember-data-file-buffer-local ()
  2125. "Set `remember-data-file'."
  2126. (when (require 'projectile nil t)
  2127. (setq-local remember-data-file
  2128. (expand-file-name ".remember.notes"
  2129. (projectile-project-root)))))
  2130. (add-hook 'after-change-major-mode-hook
  2131. 'my-set-remember-data-file-buffer-local)
  2132. (define-key ctl-x-map "R" 'remember)
  2133. ;; ivy
  2134. (defvar ivy-re-builders-alist)
  2135. (set-variable 'ivy-re-builders-alist
  2136. '((t . (lambda (s)
  2137. ;; Ignore whitespace
  2138. (ivy--regex-fuzzy (replace-regexp-in-string (rx space)
  2139. ""
  2140. s))))))
  2141. (with-eval-after-load 'ivy
  2142. (defvar ivy-minibuffer-map)
  2143. (define-key ivy-minibuffer-map (kbd "C-u")
  2144. (lambda () (interactive) (delete-region (point-at-bol) (point)))))
  2145. (when (fboundp 'counsel-M-x)
  2146. (define-key esc-map "x" 'counsel-M-x)
  2147. ;; (counsel-mode 1)
  2148. ;; counsel-fzf executes fzf -f QUERY for each input
  2149. ;; (define-key ctl-x-map "f"
  2150. ;; (lambda ()
  2151. ;; (interactive
  2152. ;; (let ((process-environment (cl-copy-list process-environment)))
  2153. ;; (setenv "FZF_DEFAULT_COMMAND" nil)
  2154. ;; (counsel-fzf)))))
  2155. )
  2156. (when (eval-and-compile (require 'counsel nil t))
  2157. (defvar counsel-describe-map)
  2158. (defun my-counsel-describe-symbol ()
  2159. "Forwaord to `describe-symbol'."
  2160. (interactive)
  2161. (ivy-read "Describe symbol: " obarray
  2162. :predicate (lambda (sym)
  2163. (or (fboundp sym)
  2164. (boundp sym)
  2165. (facep sym)
  2166. (symbol-plist sym)))
  2167. :require-match t
  2168. :history 'counsel-describe-symbol-history
  2169. :keymap counsel-describe-map
  2170. :preselect (ivy-thing-at-point)
  2171. :action (lambda (x)
  2172. (describe-symbol (intern x)))
  2173. :caller 'my-counsel-describe-symbol))
  2174. (ivy-configure 'my-counsel-describe-symbol
  2175. :sort-fn #'ivy-string<)
  2176. (define-key help-map "o" 'my-counsel-describe-symbol)
  2177. )
  2178. (when (fboundp 'counsel-imenu)
  2179. (define-key ctl-x-map "l" 'counsel-imenu))
  2180. (when (fboundp 'swoop)
  2181. ;; (global-set-key (kbd "C-s") 'swoop)
  2182. ;; (global-set-key (kbd "C-r") 'swoop)
  2183. ;; (define-key esc-map (kbd "C-s") 'swoop-multi)
  2184. (define-key esc-map (kbd "C-s") 'swoop)
  2185. (with-eval-after-load 'swoop-lib
  2186. (defvar swoop-map)
  2187. (define-key swoop-map (kbd "C-s") 'swoop-action-goto-line-next)
  2188. (define-key swoop-map (kbd "C-r") 'swoop-action-goto-line-prev)
  2189. )
  2190. ;; TODO: case sensitive swoop
  2191. ;; Wrap swoop-async-get-match-lines-list?
  2192. ;; (with-eval-after-load 'swoop-lib
  2193. ;; (defun my-swoop-advice-smart-case (orig-func &rest args)
  2194. ;; "Function to wrap swoop function."
  2195. ;; (message "args: %S" args)
  2196. ;; (let* (
  2197. ;; (query (car args))
  2198. ;; ;; (query (plist-get args
  2199. ;; ;; :$query))
  2200. ;; (case-fold-search
  2201. ;; (let ((case-fold-search nil))
  2202. ;; (not (string-match-p (rx upper) query))))
  2203. ;; )
  2204. ;; ;; (message "case-fold-search: %S" case-fold-search)
  2205. ;; ;; (message "query: %S" query)
  2206. ;; (apply orig-func args)))
  2207. ;; (advice-add 'swoop-async-get-match-lines-list
  2208. ;; :around
  2209. ;; 'my-swoop-advice-smart-case)
  2210. ;; (set-variable 'swoop-async-get-match-lines-list
  2211. ;; (byte-compile 'swoop-async-get-match-lines-list))
  2212. ;; )
  2213. )
  2214. ;; なんかよくわからないけど頻繁に index.lock を残してしまう
  2215. (when (fboundp 'dired-k)
  2216. (set-variable 'dired-k-style 'git)
  2217. ;; What is the best way of doing this?
  2218. (with-eval-after-load 'dired-k
  2219. (fset 'dired-k--highlight-by-file-attribyte 'ignore))
  2220. ;; (set-variable 'dired-k-size-colors
  2221. ;; `((,most-positive-fixnum)))
  2222. ;; (set-variable 'dired-k-date-colors
  2223. ;; `((,most-positive-fixnum)))
  2224. ;; always execute dired-k when dired buffer is opened and reverted
  2225. ;; (add-hook 'dired-after-readin-hook #'dired-k-no-revert)
  2226. ;; This causes:
  2227. ;; fatal: Unable to create '.git/index.lock': File exist.s
  2228. ;; (add-hook 'switch-buffer-functions
  2229. ;; (lambda (prev cur)
  2230. ;; (when (derived-mode-p 'dired-mode)
  2231. ;; (dired-k-no-revert))))
  2232. )
  2233. (add-hook 'python-mode-hook
  2234. (lambda ()
  2235. ;; Currently on python-mode eldoc-mode sometimes print
  2236. ;; wired message on "from" keyword:
  2237. ;;var from = require("./from")
  2238. (eldoc-mode -1)))
  2239. ;; ?
  2240. (define-key input-decode-map "\e[1;5C" [C-right])
  2241. (define-key input-decode-map "\e[1;5D" [C-left])
  2242. ;; mozc
  2243. (when (locate-library "mozc")
  2244. ;; https://tottoto.net/mac-emacs-karabiner-elements-japanese-input-method-config/
  2245. (with-eval-after-load 'mozc
  2246. ;; (define-key mozc-mode-map (kbd "C-h") 'backward-delete-char)
  2247. ;; (define-key mozc-mode-map (kbd "C-p") (kbd "<up>"))
  2248. ;; (define-key mozc-mode-map (kbd "C-n") (kbd "SPC"))
  2249. )
  2250. ;; (setq default-input-method "japanese-mozc")
  2251. (custom-set-variables '(mozc-leim-title "あ"))
  2252. (defun turn-on-input-method ()
  2253. (interactive)
  2254. (activate-input-method default-input-method))
  2255. (defun turn-off-input-method ()
  2256. (interactive)
  2257. (deactivate-input-method))
  2258. ;; (setq mozc-candidate-style 'echo-area)
  2259. (require 'mozc-popup)
  2260. (set-variable 'mozc-candidate-style 'popup)
  2261. (require 'mozc-im)
  2262. (setq default-input-method "japanese-mozc-im")
  2263. (global-set-key (kbd "C-j") 'toggle-input-method)
  2264. (global-set-key (kbd "C-c m e") 'turn-on-input-method)
  2265. (global-set-key (kbd "C-c m d") 'turn-off-input-method)
  2266. ) ;; 日本語入力ぐぐる
  2267. ;; (global-set-key
  2268. ;; (kbd "C-<f11>" . turn-on-input-method)
  2269. ;; ("C-<f12>" . turn-off-input-method))
  2270. ;; (setq mozc-candidate-style 'overlay)
  2271. ;; (setq mozc-candidate-style 'echo-area)
  2272. ;; Local Variables:
  2273. ;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
  2274. ;; flycheck-checker: emacs-lisp
  2275. ;; End:
  2276. ;;; emancs.el ends here