Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

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