Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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