Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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