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