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.
 
 
 
 
 
 

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