Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

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