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

1829 строки
62 KiB

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