Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

emacs.el 102 KiB

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