You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

13 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
9 jaren geleden
9 jaren geleden
8 jaren geleden
11 jaren geleden
9 jaren geleden
8 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
6 jaren geleden
6 jaren geleden
9 jaren geleden
8 jaren geleden
6 jaren geleden
9 jaren geleden
6 jaren geleden
9 jaren geleden
8 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
11 jaren geleden
9 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
9 jaren geleden
9 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
9 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
9 jaren geleden
9 jaren geleden
12 jaren geleden
9 jaren geleden
9 jaren geleden
7 jaren geleden
9 jaren geleden
7 jaren geleden
9 jaren geleden
13 jaren geleden
13 jaren geleden
11 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
12 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
11 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
11 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
12 jaren geleden
12 jaren geleden
12 jaren geleden
8 jaren geleden
6 jaren geleden
13 jaren geleden
8 jaren geleden
9 jaren geleden
8 jaren geleden
13 jaren geleden
13 jaren geleden
11 jaren geleden
11 jaren geleden
13 jaren geleden
6 jaren geleden
6 jaren geleden
12 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
6 jaren geleden
6 jaren geleden
13 jaren geleden
9 jaren geleden
12 jaren geleden
12 jaren geleden
6 jaren geleden
12 jaren geleden
12 jaren geleden
6 jaren geleden
12 jaren geleden
12 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
11 jaren geleden
9 jaren geleden
11 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
12 jaren geleden
9 jaren geleden
6 jaren geleden
13 jaren geleden
13 jaren geleden
8 jaren geleden
13 jaren geleden
10 jaren geleden
13 jaren geleden
13 jaren geleden
9 jaren geleden
9 jaren geleden
9 jaren geleden
13 jaren geleden
9 jaren geleden
13 jaren geleden
10 jaren geleden
13 jaren geleden
11 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
8 jaren geleden
10 jaren geleden
13 jaren geleden
6 jaren geleden
13 jaren geleden
9 jaren geleden
12 jaren geleden
12 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
13 jaren geleden
9 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
12 jaren geleden
13 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
12 jaren geleden
6 jaren geleden
12 jaren geleden
12 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
12 jaren geleden
12 jaren geleden
9 jaren geleden
12 jaren geleden
9 jaren geleden
11 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
11 jaren geleden
6 jaren geleden
9 jaren geleden
9 jaren geleden
11 jaren geleden
6 jaren geleden
6 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
11 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
6 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638
  1. ;;; emacs.el --- 10sr emacs initialization
  2. ;;; Code:
  3. ;; SETUP_LOAD: (let ((file "DOTFILES_DIR/emacs.el"))
  4. ;; SETUP_LOAD: (and (file-readable-p file)
  5. ;; SETUP_LOAD: (load-file file)))
  6. (setq debug-on-error t)
  7. ;; make directories
  8. (unless (file-directory-p (expand-file-name user-emacs-directory))
  9. (make-directory (expand-file-name user-emacs-directory)))
  10. (require 'cl-lib)
  11. (require 'simple)
  12. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  13. ;; Some macros for internals
  14. (defun call-after-init (func)
  15. "If `after-init-hook' has been run, call FUNC immediately.
  16. Otherwize hook it."
  17. (if after-init-time
  18. (funcall func)
  19. (add-hook 'after-init-hook
  20. func)))
  21. (defmacro safe-require-or-eval (feature)
  22. "Require FEATURE if available.
  23. At compile time the feature will be loaded immediately."
  24. `(eval-and-compile
  25. (message "safe-require-or-eval: Trying to require %s" ,feature)
  26. (require ,feature nil t)))
  27. (defmacro autoload-eval-lazily (feature &optional functions &rest body)
  28. "Define autoloading FEATURE that defines FUNCTIONS.
  29. FEATURE is a symbol. FUNCTIONS is a list of symbols. If FUNCTIONS is nil,
  30. the function same as FEATURE is defined as autoloaded function. BODY is passed
  31. to `eval-after-load'.
  32. After this macro is expanded, this returns the path to library if FEATURE
  33. found, otherwise returns nil."
  34. (declare (indent 2) (debug t))
  35. (let* ((libname (symbol-name (eval feature)))
  36. (libpath (locate-library libname)))
  37. `(progn
  38. (when (locate-library ,libname)
  39. ,@(mapcar (lambda (f)
  40. `(unless (fboundp ',f)
  41. (progn
  42. (message "Autoloaded function `%S' defined (%s)"
  43. (quote ,f)
  44. ,libpath)
  45. (autoload (quote ,f)
  46. ,libname
  47. ,(concat "Autoloaded function defined in \""
  48. libpath
  49. "\".")
  50. t))))
  51. (or (eval functions)
  52. `(,(eval feature)))))
  53. (eval-after-load ,feature
  54. (quote (progn
  55. ,@body)))
  56. (locate-library ,libname))))
  57. (when (autoload-eval-lazily 'tetris nil
  58. (message "Tetris loaded!"))
  59. (message "Tetris found!"))
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. ;; package
  62. (set (defvar 10sr-package-list)
  63. '(
  64. vimrc-mode
  65. markdown-mode
  66. yaml-mode
  67. gnuplot-mode
  68. php-mode
  69. erlang
  70. js2-mode
  71. js-doc
  72. git-commit
  73. gitignore-mode
  74. adoc-mode
  75. go-mode
  76. ;; It seems malabar has been merged into jdee and this package
  77. ;; already removed
  78. ;; malabar-mode
  79. ;; ack
  80. color-moccur
  81. ggtags
  82. flycheck
  83. auto-highlight-symbol
  84. hl-todo
  85. ;; Currently not available
  86. ;; pp-c-l
  87. ;; is flymake installs are required?
  88. ;;flymake-jshint
  89. ;;flymake-python-pyflakes
  90. xclip
  91. foreign-regexp
  92. multi-term
  93. term-run
  94. editorconfig
  95. git-ps1-mode
  96. restart-emacs
  97. fill-column-indicator
  98. pkgbuild-mode
  99. minibuffer-line
  100. which-key
  101. ;; I think this works in place of my autosave lib
  102. super-save
  103. pipenv
  104. imenu-list
  105. scala-mode
  106. ;;ensime
  107. editorconfig
  108. editorconfig-custom-majormode
  109. git-command
  110. prompt-text
  111. ;; 10sr repository
  112. ;; 10sr-extras
  113. terminal-title
  114. recentf-show
  115. dired-list-all-mode
  116. pack
  117. set-modeline-color
  118. read-only-only-mode
  119. smart-revert
  120. autosave
  121. ;;window-organizer
  122. remember-major-modes-mode
  123. ilookup
  124. pasteboard
  125. end-mark
  126. sl
  127. gosh-mode
  128. ))
  129. (when (safe-require-or-eval 'package)
  130. (setq package-archives
  131. `(,@package-archives
  132. ("melpa" . "https://melpa.org/packages/")
  133. ;; Somehow fails to download via https
  134. ("10sr-el" . "http://10sr.github.io/emacs-lisp/elpa/")))
  135. (package-initialize)
  136. (defun my-auto-install-package ()
  137. "Install packages semi-automatically."
  138. (interactive)
  139. (package-refresh-contents)
  140. (mapc (lambda (pkg)
  141. (or (package-installed-p pkg)
  142. (package-install pkg)))
  143. 10sr-package-list))
  144. )
  145. ;; (lazy-load-eval 'sudoku)
  146. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  147. ;; my-idle-hook
  148. (defvar my-idle-hook nil
  149. "Hook run when idle for several secs.")
  150. (defvar my-idle-hook-sec 5
  151. "Second to run `my-idle-hook'.")
  152. (run-with-idle-timer my-idle-hook-sec
  153. t
  154. (lambda ()
  155. (run-hooks 'my-idle-hook)))
  156. ;; (add-hook 'my-idle-hook
  157. ;; (lambda ()
  158. ;; (message "idle hook message")))
  159. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  160. ;; start and quit
  161. (setq inhibit-startup-message t)
  162. (setq confirm-kill-emacs 'y-or-n-p)
  163. (setq gc-cons-threshold (* 1024 1024 4))
  164. (when window-system
  165. (add-to-list 'default-frame-alist '(cursor-type . box))
  166. (add-to-list 'default-frame-alist '(background-color . "white"))
  167. (add-to-list 'default-frame-alist '(foreground-color . "gray10"))
  168. ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100)))
  169. ;; does not work?
  170. )
  171. ;; (add-to-list 'default-frame-alist '(cursor-type . box))
  172. (if window-system (menu-bar-mode 1) (menu-bar-mode 0))
  173. (and (fboundp 'tool-bar-mode)
  174. (tool-bar-mode 0))
  175. (and (fboundp 'set-scroll-bar-mode)
  176. (set-scroll-bar-mode nil))
  177. (call-after-init
  178. (lambda ()
  179. (message "%s %s" invocation-name emacs-version)
  180. (message "Invocation directory: %s" default-directory)
  181. (message "%s was taken to initialize emacs." (emacs-init-time))
  182. (switch-to-buffer "*Messages*")))
  183. (cd ".") ; when using windows use / instead of \ in `default-directory'
  184. ;; locale
  185. (set-language-environment "Japanese")
  186. (set-default-coding-systems 'utf-8-unix)
  187. (prefer-coding-system 'utf-8-unix)
  188. (setq system-time-locale "C")
  189. ;; my prefix map
  190. (defvar my-prefix-map nil
  191. "My prefix map.")
  192. (define-prefix-command 'my-prefix-map)
  193. (define-key ctl-x-map (kbd "C-x") 'my-prefix-map)
  194. (define-key my-prefix-map (kbd "C-q") 'quoted-insert)
  195. (define-key my-prefix-map (kbd "C-z") 'suspend-frame)
  196. ;; (comint-show-maximum-output)
  197. ;; kill scratch
  198. (call-after-init (lambda ()
  199. (let ((buf (get-buffer "*scratch*")))
  200. (when buf
  201. (kill-buffer buf)))))
  202. ;; modifier keys
  203. ;; (setq mac-option-modifier 'control)
  204. ;; display
  205. (setq visible-bell t)
  206. (setq ring-bell-function 'ignore)
  207. (mouse-avoidance-mode 'banish)
  208. (setq echo-keystrokes 0.1)
  209. (defun reload-init-file ()
  210. "Reload Emacs init file."
  211. (interactive)
  212. (when (and user-init-file
  213. (file-readable-p user-init-file))
  214. (load-file user-init-file)))
  215. (safe-require-or-eval 'session)
  216. ;; server
  217. (set-variable 'server-name (concat "server"
  218. (number-to-string (emacs-pid))))
  219. ;; In Cygwin Environment `server-runnning-p' stops when server-use-tcp is nil
  220. ;; In Darwin environment, init fails with message like 'Service name too long'
  221. ;; when server-use-tcp is nil
  222. (when (or (eq system-type
  223. 'cygwin)
  224. (eq system-type
  225. 'darwin))
  226. (set-variable 'server-use-tcp t))
  227. ;; MSYS2 fix
  228. (when (eq system-type
  229. 'windows-nt)
  230. (setq shell-file-name
  231. (executable-find "bash"))
  232. '(setq function-key-map
  233. `(,@function-key-map ([pause] . [?\C-c])
  234. ))
  235. (define-key key-translation-map
  236. (kbd "<pause>")
  237. (kbd "C-c"))
  238. '(keyboard-translate [pause]
  239. (kbd "C-c")p)
  240. ;; TODO: move to other place later
  241. (when (not window-system)
  242. (setq interprogram-paste-function nil)
  243. (setq interprogram-cut-function nil)))
  244. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  245. ;; global keys
  246. (global-set-key (kbd "<up>") 'scroll-down-line)
  247. (global-set-key (kbd "<down>") 'scroll-up-line)
  248. (global-set-key (kbd "<left>") 'scroll-down)
  249. (global-set-key (kbd "<right>") 'scroll-up)
  250. ;; (define-key my-prefix-map (kbd "C-h") help-map)
  251. (global-set-key (kbd "C-\\") help-map)
  252. (define-key ctl-x-map (kbd "DEL") help-map)
  253. (define-key ctl-x-map (kbd "C-h") help-map)
  254. (define-key help-map "a" 'apropos)
  255. ;; disable annoying keys
  256. (global-set-key [prior] 'ignore)
  257. (global-set-key (kbd "<next>") 'ignore)
  258. (global-set-key [menu] 'ignore)
  259. (global-set-key [down-mouse-1] 'ignore)
  260. (global-set-key [down-mouse-2] 'ignore)
  261. (global-set-key [down-mouse-3] 'ignore)
  262. (global-set-key [mouse-1] 'ignore)
  263. (global-set-key [mouse-2] 'ignore)
  264. (global-set-key [mouse-3] 'ignore)
  265. (global-set-key (kbd "<eisu-toggle>") 'ignore)
  266. (global-set-key (kbd "C-<eisu-toggle>") 'ignore)
  267. (when (safe-require-or-eval 'which-key)
  268. (which-key-mode))
  269. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  270. ;; editting
  271. (setq kill-whole-line t)
  272. (setq scroll-conservatively 35
  273. scroll-margin 2
  274. scroll-step 0)
  275. (setq-default major-mode 'text-mode)
  276. (setq next-line-add-newlines nil)
  277. (setq kill-read-only-ok t)
  278. (setq truncate-partial-width-windows nil) ; when splitted horizontally
  279. ;; (setq-default line-spacing 0.2)
  280. (setq-default indicate-empty-lines t) ; when using x indicate empty line
  281. ;; (setq-default tab-width 4)
  282. (setq-default indent-tabs-mode nil)
  283. (setq-default indent-line-function 'indent-to-left-margin)
  284. ;; (setq-default indent-line-function nil)
  285. (setq-default truncate-lines nil)
  286. ;; (pc-selection-mode 1) ; make some already defined keybind back to default
  287. (delete-selection-mode 1)
  288. (cua-mode 0)
  289. (setq line-move-visual nil)
  290. ;; key bindings
  291. ;; moving around
  292. ;;(keyboard-translate ?\M-j ?\C-j)
  293. ;; (global-set-key (kbd "M-p") 'backward-paragraph)
  294. (define-key esc-map "p" 'backward-paragraph)
  295. ;; (global-set-key (kbd "M-n") 'forward-paragraph)
  296. (define-key esc-map "n" 'forward-paragraph)
  297. (global-set-key (kbd "C-<up>") 'scroll-down-line)
  298. (global-set-key (kbd "C-<down>") 'scroll-up-line)
  299. (global-set-key (kbd "C-<left>") 'scroll-down)
  300. (global-set-key (kbd "C-<right>") 'scroll-up)
  301. (global-set-key (kbd "<select>") 'ignore) ; 'previous-line-mark)
  302. (define-key ctl-x-map (kbd "ESC x") 'execute-extended-command)
  303. (define-key ctl-x-map (kbd "ESC :") 'eval-expression)
  304. ;; C-h and DEL
  305. (global-set-key (kbd "C-h") (kbd "DEL"))
  306. ;;(global-set-key (kbd "C-m") 'reindent-then-newline-and-indent)
  307. (global-set-key (kbd "C-m") 'newline-and-indent)
  308. ;; (global-set-key (kbd "C-o") (kbd "C-e C-m"))
  309. ;; (global-set-key "\C-z" 'undo) ; undo is M-u
  310. (define-key esc-map "u" 'undo)
  311. (define-key esc-map "i" (kbd "ESC TAB"))
  312. ;; (global-set-key (kbd "C-r") 'query-replace-regexp)
  313. (global-set-key (kbd "C-s") 'isearch-forward-regexp)
  314. (global-set-key (kbd "C-r") 'isearch-backward-regexp)
  315. (define-key my-prefix-map (kbd "C-o") 'occur)
  316. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  317. ;; title and mode-line
  318. (when (safe-require-or-eval 'terminal-title)
  319. ;; if TERM is not screen use default value
  320. (if (getenv "TMUX")
  321. ;; if use tmux locally just basename of current dir
  322. (set-variable 'terminal-title-format
  323. '((file-name-nondirectory (directory-file-name
  324. default-directory))))
  325. (if (and (let ((tty-type (frame-parameter nil
  326. 'tty-type)))
  327. (and tty-type
  328. (equal (car (split-string tty-type
  329. "-"))
  330. "screen")))
  331. (not (getenv "SSH_CONNECTION")))
  332. (set-variable 'terminal-title-format
  333. '((file-name-nondirectory (directory-file-name
  334. default-directory))))
  335. ;; seems that TMUX is used locally and ssh to remote host
  336. (set-variable 'terminal-title-format
  337. `("em:"
  338. ,user-login-name
  339. "@"
  340. ,(car (split-string (system-name)
  341. "\\."))
  342. ":"
  343. default-directory))
  344. )
  345. )
  346. (terminal-title-mode))
  347. (setq eol-mnemonic-dos "\\r\\n")
  348. (setq eol-mnemonic-mac "\\r")
  349. (setq eol-mnemonic-unix "")
  350. (which-function-mode 0)
  351. (line-number-mode 0)
  352. (column-number-mode 0)
  353. (size-indication-mode 0)
  354. (setq mode-line-position
  355. '(:eval (format "L%%l/%d:C%%c"
  356. (count-lines (point-max)
  357. (point-min)))))
  358. ;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title
  359. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  360. ;; minibuffer
  361. (setq insert-default-directory t)
  362. (setq completion-ignore-case t
  363. read-file-name-completion-ignore-case t
  364. read-buffer-completion-ignore-case t)
  365. (setq resize-mini-windows t)
  366. (temp-buffer-resize-mode 1)
  367. (savehist-mode 1)
  368. (defvar display-time-format "%Y/%m/%d %a %H:%M")
  369. (fset 'yes-or-no-p 'y-or-n-p)
  370. ;; complete symbol when `eval'
  371. (define-key read-expression-map (kbd "TAB") 'completion-at-point)
  372. (define-key minibuffer-local-map (kbd "C-u")
  373. (lambda () (interactive) (delete-region (point-at-bol) (point))))
  374. ;; I dont know these bindings are good
  375. (define-key minibuffer-local-map (kbd "C-p") (kbd "ESC p"))
  376. (define-key minibuffer-local-map (kbd "C-n") (kbd "ESC n"))
  377. (when (safe-require-or-eval 'minibuffer-line)
  378. (set-face-underline 'minibuffer-line nil)
  379. (set-variable 'minibuffer-line-refresh-interval
  380. 25)
  381. ;; Set idle timer
  382. (defvar my-minibuffer-line--idle-timer nil)
  383. (defvar minibuffer-line-mode)
  384. (add-hook 'minibuffer-line-mode-hook
  385. (lambda ()
  386. (when my-minibuffer-line--idle-timer
  387. (cancel-timer my-minibuffer-line--idle-timer)
  388. (setq my-minibuffer-line--idle-timer nil))
  389. (when minibuffer-line-mode
  390. (setq my-minibuffer-line--idle-timer
  391. (run-with-idle-timer 0.5
  392. t
  393. 'minibuffer-line--update)))))
  394. (set-variable 'minibuffer-line-format
  395. `(,(concat user-login-name
  396. "@"
  397. (car (split-string (system-name)
  398. "\\."))
  399. ":")
  400. (:eval (abbreviate-file-name (or buffer-file-name
  401. default-directory)))
  402. (:eval (and (fboundp 'git-ps1-mode-get-current)
  403. (git-ps1-mode-get-current " [GIT:%s]")))
  404. " "
  405. (:eval (format-time-string display-time-format))))
  406. (minibuffer-line-mode 1)
  407. )
  408. (when (safe-require-or-eval 'prompt-text)
  409. (set-variable 'prompt-text-format
  410. `(,(concat ""
  411. user-login-name
  412. "@"
  413. (car (split-string (system-name)
  414. "\\."))
  415. ":")
  416. (:eval (abbreviate-file-name (or buffer-file-name
  417. default-directory)))
  418. (:eval (and (fboundp 'git-ps1-mode-get-current)
  419. (git-ps1-mode-get-current " [GIT:%s]")))
  420. " "
  421. (:eval (format-time-string display-time-format))
  422. "\n"
  423. (:eval (symbol-name this-command))
  424. ": "))
  425. (prompt-text-mode 1))
  426. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  427. ;; letters, font-lock mode and fonts
  428. ;; (set-face-background 'vertical-border (face-foreground 'mode-line))
  429. ;; (set-window-margins (selected-window) 1 1)
  430. (and (or (eq system-type 'Darwin)
  431. (eq system-type 'darwin))
  432. (fboundp 'mac-set-input-method-parameter)
  433. (mac-set-input-method-parameter 'japanese 'cursor-color "red")
  434. (mac-set-input-method-parameter 'roman 'cursor-color "black"))
  435. (when (and (boundp 'input-method-activate-hook) ; i dont know this is correct
  436. (boundp 'input-method-inactivate-hook))
  437. (add-hook 'input-method-activate-hook
  438. (lambda () (set-cursor-color "red")))
  439. (add-hook 'input-method-inactivate-hook
  440. (lambda () (set-cursor-color "black"))))
  441. (when (safe-require-or-eval 'paren)
  442. (show-paren-mode 1)
  443. (setq show-paren-delay 0.5
  444. show-paren-style 'parenthesis) ; mixed is hard to read
  445. ;; (set-face-background 'show-paren-match
  446. ;; "black")
  447. ;; ;; (face-foreground 'default))
  448. ;; (set-face-foreground 'show-paren-match
  449. ;; "white")
  450. ;; (set-face-inverse-video-p 'show-paren-match
  451. ;; t)
  452. )
  453. (transient-mark-mode 1)
  454. (global-font-lock-mode 1)
  455. (setq font-lock-global-modes
  456. '(not
  457. help-mode
  458. eshell-mode
  459. ;;term-mode
  460. Man-mode))
  461. ;; (standard-display-ascii ?\n "$\n")
  462. ;; (defvar my-eol-face
  463. ;; '(("\n" . (0 font-lock-comment-face t nil)))
  464. ;; )
  465. ;; (defvar my-tab-face
  466. ;; '(("\t" . '(0 highlight t nil))))
  467. (defvar my-jspace-face
  468. '(("\u3000" . '(0 highlight t nil))))
  469. (add-hook 'font-lock-mode-hook
  470. (lambda ()
  471. ;; (font-lock-add-keywords nil my-eol-face)
  472. (font-lock-add-keywords nil my-jspace-face)
  473. ))
  474. (when (safe-require-or-eval 'whitespace)
  475. (add-to-list 'whitespace-display-mappings
  476. ;; We need t since last one takes precedence
  477. `(tab-mark ?\t ,(vconcat "^I\t")) t)
  478. ;; (add-to-list 'whitespace-display-mappings
  479. ;; `(newline-mark ?\n ,(vconcat "$\n")))
  480. (setq whitespace-style '(face
  481. trailing ; trailing blanks
  482. newline ; newlines
  483. newline-mark ; use display table for newline
  484. tab-mark
  485. empty ; empty lines at beg or end of buffer
  486. lines-tail ; lines over 80
  487. ))
  488. ;; (setq whitespace-newline 'font-lock-comment-face)
  489. (set-variable 'whitespace-line-column nil)
  490. (global-whitespace-mode t)
  491. (add-hook 'dired-mode-hook
  492. (lambda ()
  493. (set (make-local-variable 'whitespace-style) nil)))
  494. (if (eq (display-color-cells)
  495. 256)
  496. (set-face-foreground 'whitespace-newline "color-109")
  497. ;; (progn
  498. ;; (set-face-bold-p 'whitespace-newline
  499. ;; t))
  500. ))
  501. (and nil
  502. '(safe-require-or-eval 'fill-column-indicator)
  503. (setq fill-column-indicator))
  504. ;; highlight current line
  505. ;; http://wiki.riywo.com/index.php?Meadow
  506. (face-spec-set 'hl-line
  507. '((((min-colors 256)
  508. (background dark))
  509. (:background "color-234"))
  510. (((min-colors 256)
  511. (background light))
  512. (:background "color-234"))
  513. (t
  514. (:underline "black"))))
  515. (set-variable 'hl-line-global-modes
  516. '(not
  517. term-mode))
  518. (global-hl-line-mode 1) ;; (hl-line-mode 1)
  519. (set-face-foreground 'font-lock-regexp-grouping-backslash "#666")
  520. (set-face-foreground 'font-lock-regexp-grouping-construct "#f60")
  521. ;;(safe-require-or-eval 'set-modeline-color)
  522. ;; (let ((fg (face-foreground 'default))
  523. ;; (bg (face-background 'default)))
  524. ;; (set-face-background 'mode-line-inactive
  525. ;; (if (face-inverse-video-p 'mode-line) fg bg))
  526. ;; (set-face-foreground 'mode-line-inactive
  527. ;; (if (face-inverse-video-p 'mode-line) bg fg)))
  528. ;; (set-face-underline 'mode-line-inactive
  529. ;; t)
  530. ;; (set-face-underline 'vertical-border
  531. ;; nil)
  532. (when (safe-require-or-eval 'end-mark)
  533. (global-end-mark-mode))
  534. (when (safe-require-or-eval 'auto-highlight-symbol)
  535. (set-variable 'ahs-idle-interval 0.6)
  536. (global-auto-highlight-symbol-mode 1))
  537. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  538. ;; file handling
  539. (when (safe-require-or-eval 'editorconfig)
  540. ;; (set-variable 'editorconfig-get-properties-function
  541. ;; 'editorconfig-core-get-properties-hash)
  542. (editorconfig-mode 1)
  543. (set-variable 'editorconfig-mode-lighter " EC")
  544. (with-eval-after-load 'org-src
  545. ;; [*.org\[\*Org Src*\[ c \]*\]]
  546. (add-hook 'org-src-mode-hook
  547. 'editorconfig-mode-apply t)))
  548. (when (fboundp 'editorconfig-custom-majormode)
  549. (add-hook 'editorconfig-custom-hooks
  550. 'editorconfig-custom-majormode))
  551. ;; Add readonly=true to set read-only-mode
  552. (add-hook 'editorconfig-custom-hooks
  553. (lambda (props)
  554. (let ((r (gethash 'readonly props)))
  555. (when (and (string= r "true")
  556. (not buffer-read-only))
  557. (read-only-mode 1)))))
  558. ;; (when (fboundp 'editorconfig-charset-extras)
  559. ;; (add-hook 'editorconfig-custom-hooks
  560. ;; 'editorconfig-charset-extras))
  561. (setq revert-without-query '(".+"))
  562. ;; save cursor position
  563. (when (safe-require-or-eval 'saveplace)
  564. (setq-default save-place t)
  565. (setq save-place-file (concat user-emacs-directory
  566. "places")))
  567. ;; http://www.bookshelf.jp/soft/meadow_24.html#SEC260
  568. (setq make-backup-files t)
  569. ;; (make-directory (expand-file-name "~/.emacsbackup"))
  570. (setq backup-directory-alist
  571. (cons (cons "\\.*$" (expand-file-name (concat user-emacs-directory
  572. "backup")))
  573. backup-directory-alist))
  574. (setq version-control 'never)
  575. (setq delete-old-versions t)
  576. (setq auto-save-list-file-prefix (expand-file-name (concat user-emacs-directory
  577. "auto-save/")))
  578. (setq delete-auto-save-files t)
  579. (add-to-list 'completion-ignored-extensions ".bak")
  580. (set-variable 'completion-cycle-threshold nil) ;; NEVER use
  581. (setq delete-by-moving-to-trash t)
  582. ;; trash-directory "~/.emacs.d/trash")
  583. (add-hook 'after-save-hook
  584. 'executable-make-buffer-file-executable-if-script-p)
  585. (set (defvar bookmark-default-file)
  586. (expand-file-name (concat user-emacs-directory
  587. "bmk")))
  588. (with-eval-after-load 'recentf
  589. (defvar recentf-exclude nil)
  590. (add-to-list 'recentf-exclude
  591. (regexp-quote bookmark-default-file)))
  592. (when (safe-require-or-eval 'smart-revert)
  593. (smart-revert-on))
  594. ;; autosave
  595. (when (safe-require-or-eval 'autosave)
  596. (autosave-set 8))
  597. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  598. ;; buffer killing
  599. ;; (defun my-delete-window-killing-buffer () nil)
  600. (defun my-query-kill-current-buffer ()
  601. "Interactively kill current buffer."
  602. (interactive)
  603. (if (y-or-n-p (concat "kill current buffer? :"))
  604. (kill-buffer (current-buffer))))
  605. ;;(global-set-key "\C-xk" 'my-query-kill-current-buffer)
  606. (substitute-key-definition 'kill-buffer
  607. 'my-query-kill-current-buffer
  608. global-map)
  609. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  610. ;; share clipboard with x
  611. ;; this page describes this in details, but only these sexps seem to be needed
  612. ;; http://garin.jp/doc/Linux/xwindow_clipboard
  613. (and nil
  614. (not window-system)
  615. (not (eq window-system 'mac))
  616. (getenv "DISPLAY")
  617. (not (equal (getenv "DISPLAY") ""))
  618. (executable-find "xclip")
  619. ;; (< emacs-major-version 24)
  620. '(safe-require-or-eval 'xclip)
  621. nil
  622. (turn-on-xclip))
  623. (and (eq system-type 'darwin)
  624. (safe-require-or-eval 'pasteboard)
  625. (turn-on-pasteboard))
  626. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  627. ;; some modes and hooks
  628. ;; Include some extra modes
  629. (require 'generic-x)
  630. (when (autoload-eval-lazily 'ggtags)
  631. (add-hook 'c-mode-common-hook
  632. (lambda ()
  633. (when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
  634. (ggtags-mode 1))))
  635. (add-hook 'python-mode-hook
  636. (lambda ()
  637. (ggtags-mode 1))))
  638. (when (autoload-eval-lazily 'imenu-list)
  639. (set-variable 'imenu-list-auto-resize t)
  640. (set-variable 'imenu-list-focus-after-activation t)
  641. (define-key ctl-x-map "l" 'imenu-list-smart-toggle))
  642. (with-eval-after-load 'compile
  643. (defvar compilation-filter-start)
  644. (defvar compilation-error-regexp-alist)
  645. (require 'ansi-color)
  646. (add-hook 'compilation-filter-hook
  647. (lambda ()
  648. (let ((inhibit-read-only t))
  649. (ansi-color-apply-on-region compilation-filter-start
  650. (point)))))
  651. (add-to-list 'compilation-error-regexp-alist
  652. ;; ansible-lint
  653. '("^\\([^ \n]+\\):\\([0-9]+\\)$" 1 2)))
  654. ;; Workaround to avoid ensime error
  655. (defvar ensime-mode-key-prefix nil)
  656. ;; http://qiita.com/sune2/items/b73037f9e85962f5afb7
  657. (when (safe-require-or-eval 'company)
  658. (global-company-mode)
  659. (set-variable 'company-idle-delay 0.5)
  660. (set-variable 'company-minimum-prefix-length 2)
  661. (set-variable 'company-selection-wrap-around t))
  662. ;; https://github.com/lunaryorn/flycheck
  663. (when (safe-require-or-eval 'flycheck)
  664. (call-after-init 'global-flycheck-mode))
  665. (when (autoload-eval-lazily 'ilookup)
  666. (define-key ctl-x-map "d" 'ilookup-open-word))
  667. (set-variable 'ac-ignore-case nil)
  668. (when (autoload-eval-lazily 'term-run '(term-run-shell-command term-run))
  669. (define-key ctl-x-map "t" 'term-run-shell-command))
  670. (add-to-list 'safe-local-variable-values
  671. '(encoding utf-8))
  672. (setq enable-local-variables :safe)
  673. ;; (when (safe-require-or-eval 'remember-major-modes-mode)
  674. ;; (remember-major-modes-mode 1))
  675. ;; Detect file type from shebang and set major-mode.
  676. (add-to-list 'interpreter-mode-alist
  677. '("python3" . python-mode))
  678. (add-to-list 'interpreter-mode-alist
  679. '("python2" . python-mode))
  680. (with-eval-after-load 'python
  681. (defvar python-mode-map (make-sparse-keymap))
  682. (define-key python-mode-map (kbd "C-m") 'newline-and-indent))
  683. ;; http://fukuyama.co/foreign-regexp
  684. '(and (safe-require-or-eval 'foreign-regexp)
  685. (progn
  686. (setq foreign-regexp/regexp-type 'perl)
  687. '(setq reb-re-syntax 'foreign-regexp)
  688. ))
  689. (autoload-eval-lazily 'sql '(sql-mode)
  690. (require 'sql-indent nil t))
  691. (when (autoload-eval-lazily 'git-command)
  692. (define-key ctl-x-map "g" 'git-command))
  693. (when (safe-require-or-eval 'git-commit)
  694. (global-git-commit-mode 1))
  695. (with-eval-after-load 'git-commit
  696. (add-hook 'git-commit-setup-hook
  697. 'turn-off-auto-fill t))
  698. (autoload-eval-lazily 'sl)
  699. (with-eval-after-load 'rst
  700. (defvar rst-mode-map)
  701. (define-key rst-mode-map (kbd "C-m") 'newline-and-indent))
  702. (with-eval-after-load 'jdee
  703. (add-hook 'jdee-mode-hook
  704. (lambda ()
  705. (make-local-variable 'global-mode-string)
  706. (add-to-list 'global-mode-string
  707. mode-line-position))))
  708. ;; Cannot enable error thrown. Why???
  709. ;; https://github.com/m0smith/malabar-mode#Installation
  710. ;; (when (autoload-eval-lazily 'malabar-mode)
  711. ;; (add-to-list 'load-path
  712. ;; (expand-file-name (concat user-emacs-directory "/cedet")))
  713. ;; (safe-require-or-eval 'cedet-devel-load)
  714. ;; (call-after-init 'activate-malabar-mode))
  715. (with-eval-after-load 'make-mode
  716. (defvar makefile-mode-map (make-sparse-keymap))
  717. (define-key makefile-mode-map (kbd "C-m") 'newline-and-indent)
  718. ;; this functions is set in write-file-functions, i cannot find any
  719. ;; good way to remove this.
  720. (fset 'makefile-warn-suspicious-lines 'ignore))
  721. (with-eval-after-load 'verilog-mode
  722. (defvar verilog-mode-map (make-sparse-keymap))
  723. (define-key verilog-mode-map ";" 'self-insert-command))
  724. (setq diff-switches "-u")
  725. (with-eval-after-load 'diff-mode
  726. ;; (when (and (eq major-mode
  727. ;; 'diff-mode)
  728. ;; (not buffer-file-name))
  729. ;; ;; do not pass when major-mode is derived mode of diff-mode
  730. ;; (view-mode 1))
  731. (set-face-attribute 'diff-header nil
  732. :foreground nil
  733. :background nil
  734. :weight 'bold)
  735. (set-face-attribute 'diff-file-header nil
  736. :foreground nil
  737. :background nil
  738. :weight 'bold)
  739. (set-face-foreground 'diff-index "blue")
  740. (set-face-attribute 'diff-hunk-header nil
  741. :foreground "cyan"
  742. :weight 'normal)
  743. (set-face-attribute 'diff-context nil
  744. ;; :foreground "white"
  745. :foreground nil
  746. :weight 'normal)
  747. (set-face-foreground 'diff-removed "red")
  748. (set-face-foreground 'diff-added "green")
  749. (set-face-background 'diff-removed nil)
  750. (set-face-background 'diff-added nil)
  751. (set-face-attribute 'diff-changed nil
  752. :foreground "magenta"
  753. :weight 'normal)
  754. (set-face-attribute 'diff-refine-changed nil
  755. :foreground nil
  756. :background nil
  757. :weight 'bold
  758. :inverse-video t)
  759. ;; Annoying !
  760. ;;(diff-auto-refine-mode)
  761. )
  762. ;; (ffap-bindings)
  763. (set-variable 'browse-url-browser-function
  764. 'eww-browse-url)
  765. (set-variable 'sh-here-document-word "__EOC__")
  766. (when (autoload-eval-lazily 'adoc-mode
  767. nil
  768. (defvar adoc-mode-map (make-sparse-keymap))
  769. (define-key adoc-mode-map (kbd "C-m") 'newline))
  770. (setq auto-mode-alist
  771. `(("\\.adoc\\'" . adoc-mode)
  772. ("\\.asciidoc\\'" . adoc-mode)
  773. ,@auto-mode-alist)))
  774. (with-eval-after-load 'markup-faces
  775. ;; Is this too match ?
  776. (set-face-foreground 'markup-meta-face
  777. "color-245")
  778. (set-face-foreground 'markup-meta-hide-face
  779. "color-245")
  780. )
  781. ;; TODO: check if this is required
  782. (when (autoload-eval-lazily 'groovy-mode nil
  783. (defvar groovy-mode-map (make-sparse-keymap))
  784. (define-key groovy-mode-map "(" 'self-insert-command)
  785. (define-key groovy-mode-map ")" 'self-insert-command)
  786. (define-key groovy-mode-map (kbd "C-m") 'newline-and-indent)
  787. )
  788. (add-to-list 'auto-mode-alist
  789. '("build\\.gradle\\'" . groovy-mode)))
  790. (with-eval-after-load 'yaml-mode
  791. (defvar yaml-mode-map (make-sparse-keymap))
  792. (define-key yaml-mode-map (kbd "C-m") 'newline))
  793. (with-eval-after-load 'html-mode
  794. (defvar html-mode-map (make-sparse-keymap))
  795. (define-key html-mode-map (kbd "C-m") 'reindent-then-newline-and-indent))
  796. (with-eval-after-load 'text-mode
  797. (define-key text-mode-map (kbd "C-m") 'newline))
  798. (with-eval-after-load 'info
  799. (defvar Info-directory-list nil)
  800. (add-to-list 'Info-directory-list
  801. (expand-file-name "~/.brew/share/info")))
  802. (with-eval-after-load 'apropos
  803. (defvar apropos-mode-map (make-sparse-keymap))
  804. (define-key apropos-mode-map "n" 'next-line)
  805. (define-key apropos-mode-map "p" 'previous-line))
  806. ;; `isearch' library does not call `provide' so cannot use with-eval-after-load
  807. ;; (define-key isearch-mode-map
  808. ;; (kbd "C-j") 'isearch-other-control-char)
  809. ;; (define-key isearch-mode-map
  810. ;; (kbd "C-k") 'isearch-other-control-char)
  811. ;; (define-key isearch-mode-map
  812. ;; (kbd "C-h") 'isearch-other-control-char)
  813. (define-key isearch-mode-map (kbd "C-h") 'isearch-delete-char)
  814. (define-key isearch-mode-map (kbd "M-r")
  815. 'isearch-query-replace-regexp)
  816. ;; do not cleanup isearch highlight: use `lazy-highlight-cleanup' to remove
  817. (setq lazy-highlight-cleanup nil)
  818. ;; face for isearch highlighing
  819. (set-face-attribute 'lazy-highlight
  820. nil
  821. :foreground `unspecified
  822. :background `unspecified
  823. :underline t
  824. ;; :weight `bold
  825. )
  826. (add-hook 'outline-mode-hook
  827. (lambda ()
  828. (when (string-match "\\.md\\'" buffer-file-name)
  829. (set (make-local-variable 'outline-regexp) "#+ "))))
  830. (add-to-list 'auto-mode-alist (cons "\\.ol\\'" 'outline-mode))
  831. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'outline-mode))
  832. (when (autoload-eval-lazily 'markdown-mode
  833. '(markdown-mode gfm-mode)
  834. (defvar gfm-mode-map (make-sparse-keymap))
  835. (define-key gfm-mode-map (kbd "C-m") 'electric-indent-just-newline))
  836. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'gfm-mode))
  837. (set-variable 'markdown-command (or (executable-find "markdown")
  838. (executable-find "markdown.pl")
  839. ""))
  840. (add-hook 'markdown-mode-hook
  841. (lambda ()
  842. (outline-minor-mode 1)
  843. (flyspell-mode)
  844. (set (make-local-variable 'comment-start) ";")))
  845. )
  846. ;; c-mode
  847. ;; http://www.emacswiki.org/emacs/IndentingC
  848. ;; http://en.wikipedia.org/wiki/Indent_style
  849. ;; http://d.hatena.ne.jp/emergent/20070203/1170512717
  850. ;; http://seesaawiki.jp/whiteflare503/d/Emacs%20%a5%a4%a5%f3%a5%c7%a5%f3%a5%c8
  851. (with-eval-after-load 'cc-vars
  852. (defvar c-default-style nil)
  853. (add-to-list 'c-default-style
  854. '(c-mode . "k&r"))
  855. (add-to-list 'c-default-style
  856. '(c++-mode . "k&r")))
  857. (autoload-eval-lazily 'js2-mode nil
  858. ;; currently do not use js2-mode
  859. ;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  860. ;; (add-to-list 'auto-mode-alist '("\\.jsm\\'" . js2-mode))
  861. ;; (defvar js2-mode-map (make-sparse-keymap))
  862. ;; (define-key js2-mode-map (kbd "C-m") (lambda ()
  863. ;; (interactive)
  864. ;; (js2-enter-key)
  865. ;; (indent-for-tab-command)))
  866. ;; (add-hook (kill-local-variable 'before-save-hook)
  867. ;; 'js2-before-save)
  868. ;; (add-hook 'before-save-hook
  869. ;; 'my-indent-buffer
  870. ;; nil
  871. ;; t)
  872. )
  873. (add-to-list 'interpreter-mode-alist
  874. '("node" . js-mode))
  875. (when (autoload-eval-lazily 'flymake-jslint
  876. '(flymake-jslint-load))
  877. (autoload-eval-lazily 'js nil
  878. (add-hook 'js-mode-hook
  879. 'flymake-jslint-load)))
  880. (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
  881. (with-eval-after-load 'uniquify
  882. (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
  883. (setq uniquify-ignore-buffers-re "*[^*]+*")
  884. (setq uniquify-min-dir-content 1))
  885. (with-eval-after-load 'view
  886. (defvar view-mode-map (make-sparse-keymap))
  887. (define-key view-mode-map "j" 'scroll-up-line)
  888. (define-key view-mode-map "k" 'scroll-down-line)
  889. (define-key view-mode-map "v" 'toggle-read-only)
  890. (define-key view-mode-map "q" 'bury-buffer)
  891. ;; (define-key view-mode-map "/" 'nonincremental-re-search-forward)
  892. ;; (define-key view-mode-map "?" 'nonincremental-re-search-backward)
  893. ;; (define-key view-mode-map
  894. ;; "n" 'nonincremental-repeat-search-forward)
  895. ;; (define-key view-mode-map
  896. ;; "N" 'nonincremental-repeat-search-backward)
  897. (define-key view-mode-map "/" 'isearch-forward-regexp)
  898. (define-key view-mode-map "?" 'isearch-backward-regexp)
  899. (define-key view-mode-map "n" 'isearch-repeat-forward)
  900. (define-key view-mode-map "N" 'isearch-repeat-backward)
  901. (define-key view-mode-map (kbd "C-m") 'my-rgrep-symbol-at-point))
  902. (global-set-key "\M-r" 'view-mode)
  903. ;; (setq view-read-only t)
  904. (with-eval-after-load 'term
  905. (defvar term-raw-map (make-sparse-keymap))
  906. (define-key term-raw-map (kbd "C-x")
  907. (lookup-key (current-global-map)
  908. (kbd "C-x"))))
  909. (add-hook 'term-mode-hook
  910. (lambda ()
  911. ;; Stop current line highlighting
  912. (set (make-local-variable (defvar hl-line-range-function))
  913. (lambda () '(0 . 0)))
  914. (set (make-local-variable 'scroll-margin)
  915. 0)))
  916. (add-hook 'Man-mode-hook
  917. (lambda ()
  918. (view-mode 1)
  919. (setq truncate-lines nil)))
  920. (set-variable 'Man-notify-method (if window-system
  921. 'newframe
  922. 'aggressive))
  923. (set-variable 'woman-cache-filename (expand-file-name (concat user-emacs-directory
  924. "woman_cache.el")))
  925. ;; not work because man.el will be loaded when man called
  926. (defalias 'man 'woman)
  927. (add-to-list 'auto-mode-alist
  928. '("tox\\.ini\\'" . conf-unix-mode))
  929. (when (autoload-eval-lazily 'toml-mode)
  930. (add-to-list 'auto-mode-alist
  931. '("/Pipfile\\'" . toml-mode)))
  932. (when (autoload-eval-lazily 'json-mode)
  933. (add-to-list 'auto-mode-alist
  934. '("/Pipfile\\.lock\\'" . json-mode)))
  935. (add-hook 'go-mode-hook
  936. (lambda()
  937. (defvar go-mode-map)
  938. (add-hook 'before-save-hook' 'gofmt-before-save)
  939. (define-key go-mode-map (kbd "M-.") 'godef-jump)))
  940. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  941. ;; buffer switching
  942. (defvar bs-configurations)
  943. (when (autoload-eval-lazily 'bs '(bs-show)
  944. (add-to-list 'bs-configurations
  945. '("specials" "^\\*" nil ".*" nil nil))
  946. (add-to-list 'bs-configurations
  947. '("files-and-specials" "^\\*" buffer-file-name ".*" nil nil))
  948. (defvar bs-mode-map)
  949. (defvar bs-current-configuration)
  950. (define-key bs-mode-map (kbd "t")
  951. ;; TODO: fix toggle feature
  952. (lambda ()
  953. (interactive)
  954. (if (string= "specials"
  955. bs-current-configuration)
  956. (bs-set-configuration "files")
  957. (bs-set-configuration "specials"))
  958. (bs-refresh)
  959. (bs-message-without-log "%s"
  960. (bs--current-config-message))))
  961. ;; (setq bs-configurations (list
  962. ;; '("processes" nil get-buffer-process ".*" nil nil)
  963. ;; '("files-and-scratch" "^\\*scratch\\*$" nil nil
  964. ;; bs-visits-non-file bs-sort-buffer-interns-are-last)))
  965. )
  966. (defalias 'list-buffers 'bs-show)
  967. (set-variable 'bs-default-configuration "files-and-specials")
  968. (set-variable 'bs-default-sort-name "by nothing")
  969. (add-hook 'bs-mode-hook
  970. (lambda ()
  971. (set (make-local-variable 'scroll-margin) 0))))
  972. ;;(iswitchb-mode 1)
  973. (icomplete-mode)
  974. (defun iswitchb-buffer-display-other-window ()
  975. "Do iswitchb in other window."
  976. (interactive)
  977. (let ((iswitchb-default-method 'display))
  978. (call-interactively 'iswitchb-buffer)))
  979. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  980. ;; vc
  981. (set-variable 'vc-handled-backends '())
  982. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  983. ;; recentf-mode
  984. (set-variable 'recentf-save-file (expand-file-name (concat user-emacs-directory
  985. "recentf")))
  986. (set-variable 'recentf-max-menu-items 20)
  987. (set-variable 'recentf-max-saved-items 30)
  988. (set-variable 'recentf-show-file-shortcuts-flag nil)
  989. (when (safe-require-or-eval 'recentf)
  990. (add-to-list 'recentf-exclude
  991. (regexp-quote recentf-save-file))
  992. (add-to-list 'recentf-exclude
  993. (regexp-quote (expand-file-name user-emacs-directory)))
  994. (define-key ctl-x-map (kbd "C-r") 'recentf-open-files)
  995. (remove-hook 'find-file-hook
  996. 'recentf-track-opened-file)
  997. (defun my-recentf-load-track-save-list ()
  998. "Load current recentf list from file, track current visiting file, then save
  999. the list."
  1000. (recentf-load-list)
  1001. (recentf-track-opened-file)
  1002. (recentf-save-list))
  1003. (add-hook 'find-file-hook
  1004. 'my-recentf-load-track-save-list)
  1005. (add-hook 'kill-emacs-hook
  1006. 'recentf-load-list)
  1007. ;;(run-with-idle-timer 5 t 'recentf-save-list)
  1008. ;; (add-hook 'find-file-hook
  1009. ;; (lambda ()
  1010. ;; (recentf-add-file default-directory)))
  1011. (and (autoload-eval-lazily 'recentf-show)
  1012. (define-key ctl-x-map (kbd "C-r") 'recentf-show)
  1013. (add-hook 'recentf-show-before-listing-hook
  1014. 'recentf-load-list))
  1015. (recentf-mode 1)
  1016. (define-key recentf-dialog-mode-map (kbd "<up>") 'previous-line)
  1017. (define-key recentf-dialog-mode-map (kbd "<down>") 'next-line)
  1018. (define-key recentf-dialog-mode-map "p" 'previous-line)
  1019. (define-key recentf-dialog-mode-map "n" 'next-line)
  1020. (add-hook 'recentf-dialog-mode-hook
  1021. (lambda ()
  1022. ;; (recentf-save-list)
  1023. ;; (define-key recentf-dialog-mode-map (kbd "C-x C-f")
  1024. ;; 'my-recentf-cd-and-find-file)
  1025. (cd "~/"))))
  1026. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1027. ;; dired
  1028. (defun my-dired-echo-file-head (arg)
  1029. "Echo head of current file.
  1030. ARG is num to show, or defaults to 7."
  1031. (interactive "P")
  1032. (let ((f (dired-get-filename)))
  1033. (message "%s"
  1034. (with-temp-buffer
  1035. (insert-file-contents f)
  1036. (buffer-substring-no-properties
  1037. (point-min)
  1038. (progn (goto-char (point-min))
  1039. (forward-line (1- (if arg
  1040. (prefix-numeric-value arg)
  1041. 7)))
  1042. (point-at-eol)))))))
  1043. (defun my-dired-diff ()
  1044. "Show diff of marked file and file of current line."
  1045. (interactive)
  1046. (let ((files (dired-get-marked-files nil nil nil t)))
  1047. (if (eq (car files)
  1048. t)
  1049. (diff (cadr files) (dired-get-filename))
  1050. (message "One file must be marked!"))))
  1051. (defun dired-get-file-info ()
  1052. "Print information of current line file."
  1053. (interactive)
  1054. (let ((f (shell-quote-argument (dired-get-filename t))))
  1055. (if (file-directory-p f)
  1056. (progn
  1057. (message "Calculating disk usage...")
  1058. (shell-command (concat "du -hsD "
  1059. f)))
  1060. (shell-command (concat "file "
  1061. f)))))
  1062. (defun my-dired-scroll-up ()
  1063. "Scroll up."
  1064. (interactive)
  1065. (my-dired-previous-line (- (window-height) 1)))
  1066. (defun my-dired-scroll-down ()
  1067. "Scroll down."
  1068. (interactive)
  1069. (my-dired-next-line (- (window-height) 1)))
  1070. ;; (defun my-dired-forward-line (arg)
  1071. ;; ""
  1072. ;; (interactive "p"))
  1073. (defun my-dired-previous-line (arg)
  1074. "Move ARG lines up."
  1075. (interactive "p")
  1076. (if (> arg 0)
  1077. (progn
  1078. (if (eq (line-number-at-pos)
  1079. 1)
  1080. (goto-char (point-max))
  1081. (forward-line -1))
  1082. (my-dired-previous-line (if (or (dired-get-filename nil t)
  1083. (dired-get-subdir))
  1084. (- arg 1)
  1085. arg)))
  1086. (dired-move-to-filename)))
  1087. (defun my-dired-next-line (arg)
  1088. "Move ARG lines down."
  1089. (interactive "p")
  1090. (if (> arg 0)
  1091. (progn
  1092. (if (eq (point)
  1093. (point-max))
  1094. (goto-char (point-min))
  1095. (forward-line 1))
  1096. (my-dired-next-line (if (or (dired-get-filename nil t)
  1097. (dired-get-subdir))
  1098. (- arg 1)
  1099. arg)))
  1100. (dired-move-to-filename)))
  1101. (defun my-dired-tramp-open (host)
  1102. "Open HOST home directory."
  1103. (interactive "sHostname: ")
  1104. (find-file (format "/scp:%s:" host)))
  1105. ;;http://bach.istc.kobe-u.ac.jp/lect/tamlab/ubuntu/emacs.html
  1106. (if (eq window-system 'mac)
  1107. (setq dired-listing-switches "-lhF")
  1108. (setq dired-listing-switches "-lhF --time-style=long-iso")
  1109. )
  1110. (setq dired-listing-switches "-lhF")
  1111. (put 'dired-find-alternate-file 'disabled nil)
  1112. ;; when using dired-find-alternate-file
  1113. ;; reuse current dired buffer for the file to open
  1114. (set-variable 'dired-ls-F-marks-symlinks t)
  1115. (set-variable 'ls-lisp-use-insert-directory-program nil) ; always use ls-lisp
  1116. (set-variable 'ls-lisp-dirs-first t)
  1117. (set-variable 'ls-lisp-use-localized-time-format t)
  1118. (set-variable 'ls-lisp-format-time-list
  1119. '("%Y-%m-%d %H:%M"
  1120. "%Y-%m-%d "))
  1121. (set-variable 'dired-dwim-target t)
  1122. (set-variable 'dired-isearch-filenames t)
  1123. (set-variable 'dired-hide-details-hide-symlink-targets nil)
  1124. (set-variable 'dired-hide-details-hide-information-lines nil)
  1125. (set-variable 'dired-deletion-confirmer 'y-or-n-p)
  1126. (set-variable 'dired-recursive-deletes 'always)
  1127. ;; (add-hook 'dired-after-readin-hook
  1128. ;; 'my-replace-nasi-none)
  1129. (with-eval-after-load 'dired
  1130. (safe-require-or-eval 'ls-lisp)
  1131. (defvar dired-mode-map (make-sparse-keymap))
  1132. (define-key dired-mode-map "i" 'dired-get-file-info)
  1133. (define-key dired-mode-map "f" 'find-file)
  1134. (define-key dired-mode-map "!" 'shell-command)
  1135. (define-key dired-mode-map "&" 'async-shell-command)
  1136. (define-key dired-mode-map "X" 'dired-do-async-shell-command)
  1137. (define-key dired-mode-map "=" 'my-dired-diff)
  1138. (define-key dired-mode-map "B" 'gtkbm-add-current-dir)
  1139. (define-key dired-mode-map "b" 'gtkbm)
  1140. (define-key dired-mode-map "h" 'my-dired-echo-file-head)
  1141. (define-key dired-mode-map (kbd "TAB") 'other-window)
  1142. ;; (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack)
  1143. (define-key dired-mode-map "/" 'dired-isearch-filenames)
  1144. (define-key dired-mode-map (kbd "DEL") 'dired-up-directory)
  1145. (define-key dired-mode-map (kbd "C-h") 'dired-up-directory)
  1146. (substitute-key-definition 'dired-next-line
  1147. 'my-dired-next-line
  1148. dired-mode-map)
  1149. (substitute-key-definition 'dired-previous-line
  1150. 'my-dired-previous-line
  1151. dired-mode-map)
  1152. ;; (define-key dired-mode-map (kbd "C-p") 'my-dired-previous-line)
  1153. ;; (define-key dired-mode-map (kbd "p") 'my-dired-previous-line)
  1154. ;; (define-key dired-mode-map (kbd "C-n") 'my-dired-next-line)
  1155. ;; (define-key dired-mode-map (kbd "n") 'my-dired-next-line)
  1156. (define-key dired-mode-map (kbd "<left>") 'my-dired-scroll-up)
  1157. (define-key dired-mode-map (kbd "<right>") 'my-dired-scroll-down)
  1158. (define-key dired-mode-map (kbd "ESC p") 'my-dired-scroll-up)
  1159. (define-key dired-mode-map (kbd "ESC n") 'my-dired-scroll-down)
  1160. (add-hook 'dired-mode-hook
  1161. (lambda ()
  1162. (when (fboundp 'dired-hide-details-mode)
  1163. (dired-hide-details-mode t)
  1164. (local-set-key "l" 'dired-hide-details-mode))
  1165. (let ((file "._Icon\015"))
  1166. (when nil
  1167. '(file-readable-p file)
  1168. (delete-file file)))))
  1169. (when (autoload-eval-lazily 'pack '(dired-do-pack-or-unpack pack-pack))
  1170. (with-eval-after-load 'dired
  1171. (define-key dired-mode-map "P" 'pack-dired-dwim)))
  1172. (when (autoload-eval-lazily 'dired-list-all-mode)
  1173. (setq dired-listing-switches "-lhF")
  1174. (with-eval-after-load 'dired
  1175. (define-key dired-mode-map "a" 'dired-list-all-mode))))
  1176. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1177. ;; misc funcs
  1178. (defalias 'qcalc 'quick-calc)
  1179. (defun memo (&optional dir)
  1180. "Open memo.txt in DIR."
  1181. (interactive)
  1182. (pop-to-buffer (find-file-noselect (concat (if dir
  1183. (file-name-as-directory dir)
  1184. "")
  1185. "memo.txt"))))
  1186. (set (defvar my-rgrep-alist nil
  1187. "Alist of rgrep command.
  1188. Each element is in the form like (NAME SEXP COMMAND), where SEXP returns the
  1189. condition to choose COMMAND when evaluated.")
  1190. `(
  1191. ;; git grep
  1192. ("gitgrep"
  1193. (eq 0
  1194. (shell-command "git rev-parse --git-dir"))
  1195. "git --no-pager -c color.grep=always grep -nH -e ")
  1196. ;; ripgrep
  1197. ("rg"
  1198. (executable-find "rg")
  1199. "rg --no-heading --smart-case ")
  1200. ;; sift
  1201. ("sift"
  1202. (executable-find "sift")
  1203. ("sift --binary-skip --filename --line-number --git --smart-case "))
  1204. ;; the silver searcher
  1205. ("ag"
  1206. (executable-find "ag")
  1207. "ag --nogroup --nopager --filename ")
  1208. ;; ack
  1209. ("ack"
  1210. (executable-find "ack")
  1211. "ack --nogroup --nopager --with-filename ")
  1212. ;; gnu global
  1213. ("global"
  1214. (and (require 'ggtags nil t)
  1215. (executable-find "global")
  1216. (ggtags-current-project-root))
  1217. "global --result grep ")
  1218. ;; grep
  1219. ("grep"
  1220. t
  1221. ,(concat "find . "
  1222. "-path '*/.git' -prune -o "
  1223. "-path '*/.svn' -prune -o "
  1224. "-type f -print0 | "
  1225. "xargs -0 grep -nH -e "))
  1226. )
  1227. )
  1228. (defvar my-rgrep-default nil
  1229. "Default command name for my-rgrep.")
  1230. (defun my-rgrep-grep-command (&optional name alist)
  1231. "Return recursive grep command for current directory or nil.
  1232. If NAME is given, use that without testing.
  1233. Commands are searched from ALIST."
  1234. (if alist
  1235. (if name
  1236. ;; if name is given search that from alist and return the command
  1237. (nth 2 (assoc name
  1238. alist))
  1239. ;; if name is not given try test in 1th elem
  1240. (let ((car (car alist))
  1241. (cdr (cdr alist)))
  1242. (if (eval (nth 1 car))
  1243. ;; if the condition is true return the command
  1244. (nth 2 car)
  1245. ;; try next one
  1246. (and cdr
  1247. (my-rgrep-grep-command name cdr)))))
  1248. ;; if alist is not given set default value
  1249. (my-rgrep-grep-command name my-rgrep-alist)))
  1250. (defun my-rgrep (command-args)
  1251. "My recursive grep. Run COMMAND-ARGS.
  1252. If prefix argument is given, use current symbol as default search target
  1253. and search from projectile root (if projectile is available)."
  1254. (interactive (let ((cmd (my-rgrep-grep-command my-rgrep-default
  1255. nil)))
  1256. (if cmd
  1257. (list (read-shell-command "grep command: "
  1258. (concat cmd
  1259. (if current-prefix-arg
  1260. (thing-at-point 'symbol t)
  1261. ""))
  1262. 'grep-find-history))
  1263. (error "My-Rgrep: Command for rgrep not found")
  1264. )))
  1265. (if (and current-prefix-arg
  1266. (safe-require-or-eval 'projectile))
  1267. (projectile-with-default-dir (projectile-project-root)
  1268. (compilation-start command-args
  1269. 'grep-mode))
  1270. (compilation-start command-args
  1271. 'grep-mode)))
  1272. (defun my-rgrep-thing-at-point-projectile-root ()
  1273. "My recursive grep to find thing at point from project root."
  1274. (interactive)
  1275. (let* ((cmd (my-rgrep-grep-command my-rgrep-default
  1276. nil))
  1277. (command-args
  1278. (if cmd
  1279. (concat cmd
  1280. (thing-at-point 'symbol t))
  1281. (error "My-Rgrep: Command for rgrep not found"))))
  1282. (if (safe-require-or-eval 'projectile)
  1283. (projectile-with-default-dir (projectile-project-root)
  1284. (compilation-start command-args
  1285. 'grep-mode))
  1286. (compilation-start command-args
  1287. 'grep-mode))))
  1288. (defmacro define-my-rgrep (name)
  1289. "Define rgrep for NAME."
  1290. `(defun ,(intern (concat "my-rgrep-"
  1291. name)) ()
  1292. ,(format "My recursive grep by %s."
  1293. name)
  1294. (interactive)
  1295. (let ((my-rgrep-default ,name))
  1296. (if (called-interactively-p 'any)
  1297. (call-interactively 'my-rgrep)
  1298. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1299. )
  1300. (define-my-rgrep "ack")
  1301. (define-my-rgrep "ag")
  1302. (define-my-rgrep "rg")
  1303. (define-my-rgrep "sift")
  1304. (define-my-rgrep "gitgrep")
  1305. (define-my-rgrep "grep")
  1306. (define-my-rgrep "global")
  1307. (define-key ctl-x-map "s" 'my-rgrep)
  1308. (define-key ctl-x-map "." 'my-rgrep-thing-at-point-projectile-root)
  1309. (defalias 'make 'compile)
  1310. (define-key ctl-x-map "c" 'compile)
  1311. ;;;;;;;;;;;;;;;;;;;;;;;
  1312. ;; adoc-simple-mode
  1313. (when (safe-require-or-eval 'adoc-mode)
  1314. (defvar adoc-simple-font-lock-keywords
  1315. nil)
  1316. (define-derived-mode adoc-simple-mode adoc-mode
  1317. "Adoc-Simple"
  1318. "Major mode for editing AsciiDoc text files.
  1319. This mode is a simplified version of `adoc-mode'."
  1320. '(set (make-local-variable 'font-lock-defaults)
  1321. '(adoc-simple-font-lock-keywords
  1322. nil nil nil nil
  1323. (font-lock-multiline . t)
  1324. (font-lock-mark-block-function . adoc-font-lock-mark-block-function))))
  1325. (add-to-list 'auto-mode-alist
  1326. '("\\.adoc\\'" . adoc-simple-mode)))
  1327. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1328. ;; awk-preview
  1329. (defgroup awk-preview nil
  1330. "Awk previewer."
  1331. :tag "Awk Preview"
  1332. :prefix "awk-preview-"
  1333. :group 'tools)
  1334. (defcustom awk-preview-program
  1335. (or (executable-find "gawk")
  1336. (executable-find "awk")
  1337. "awk")
  1338. "Awk program to execute."
  1339. :type 'string
  1340. :group 'awk-preview)
  1341. (defcustom awk-preview-switches
  1342. '("--sandbox" "--" "{print}")
  1343. "String of awk options appended when running awk preview."
  1344. :type '(repeat string)
  1345. :group 'awk-preview)
  1346. (defun awk-preview--invoke (start end output)
  1347. "Execute awk process and get result."
  1348. (let ((proc (apply 'start-process
  1349. "awk-preview"
  1350. output
  1351. awk-preview-program
  1352. awk-preview-switches)))
  1353. (message "%S" proc)
  1354. (process-send-region proc start end)
  1355. (process-send-eof proc)
  1356. (accept-process-output proc)
  1357. )
  1358. output)
  1359. (defun awk-preview (start end)
  1360. "Run awk and preview result."
  1361. (interactive "r")
  1362. (let ((output (with-current-buffer (get-buffer-create "*awk-preview output*")
  1363. (erase-buffer)
  1364. (current-buffer))))
  1365. (awk-preview--invoke start end output)
  1366. (message "awk-preview: %s" (with-current-buffer output
  1367. (buffer-substring-no-properties (point-min) (point-max))))
  1368. ))
  1369. (defun my-file-head (filename &optional n)
  1370. "Return list of first N lines of file FILENAME."
  1371. (let ((num (or n 10))
  1372. (size 100)
  1373. (beg 0)
  1374. (end 0)
  1375. (result '()))
  1376. (with-temp-buffer
  1377. (while (<= (count-lines (point-min)
  1378. (point-max))
  1379. num)
  1380. (setq end (+ beg size))
  1381. (insert-file-contents filename
  1382. nil
  1383. beg
  1384. end)
  1385. (setq beg end))
  1386. (goto-char (point-min))
  1387. (while (< (length result) num)
  1388. (let ((start (point)))
  1389. (forward-line 1)
  1390. (setq result
  1391. `(,@result ,(buffer-substring-no-properties start
  1392. (point))))))
  1393. result)))
  1394. ;; (apply 'concat (car (my-file-head "./emacs.el"))
  1395. (set-variable 'dumb-jump-prefer-searcher 'rg)
  1396. ;; Local Variables:
  1397. ;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
  1398. ;; flycheck-checker: emacs-lisp
  1399. ;; End:
  1400. ;;; emancs.el ends here