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.
 
 
 
 
 
 

1824 line
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. hl-todo
  91. ;; is flymake installs are required?
  92. ;;flymake-jshint
  93. ;;flymake-python-pyflakes
  94. xclip
  95. foreign-regexp
  96. multi-term
  97. term-run
  98. editorconfig
  99. git-ps1-mode
  100. restart-emacs
  101. fill-column-indicator
  102. pkgbuild-mode
  103. minibuffer-line
  104. which-key
  105. scala-mode
  106. ensime
  107. editorconfig
  108. editorconfig-custom-majormode
  109. cyberpunk-theme
  110. grandshell-theme
  111. afternoon-theme
  112. git-command
  113. prompt-text
  114. ;; 10sr repository
  115. ;; 10sr-extras
  116. terminal-title
  117. recentf-show
  118. dired-list-all-mode
  119. pack
  120. set-modeline-color
  121. read-only-only-mode
  122. smart-revert
  123. autosave
  124. ;;window-organizer
  125. remember-major-modes-mode
  126. ilookup
  127. pasteboard
  128. end-mark
  129. sl
  130. gosh-mode
  131. ))
  132. (when (safe-require-or-eval 'package)
  133. (setq package-archives
  134. `(,@package-archives
  135. ("melpa" . "https://melpa.org/packages/")
  136. ("10sr-el" . "https://10sr.github.io/emacs-lisp/p/")))
  137. (package-initialize)
  138. (defun my-auto-install-package ()
  139. "Install packages semi-automatically."
  140. (interactive)
  141. (package-refresh-contents)
  142. (mapc (lambda (pkg)
  143. (or (package-installed-p pkg)
  144. (package-install pkg)))
  145. 10sr-package-list))
  146. )
  147. ;; (lazy-load-eval 'sudoku)
  148. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  149. ;; my-idle-hook
  150. (defvar my-idle-hook nil
  151. "Hook run when idle for several secs.")
  152. (defvar my-idle-hook-sec 5
  153. "Second to run `my-idle-hook'.")
  154. (run-with-idle-timer my-idle-hook-sec
  155. t
  156. (lambda ()
  157. (run-hooks 'my-idle-hook)))
  158. ;; (add-hook 'my-idle-hook
  159. ;; (lambda ()
  160. ;; (message "idle hook message")))
  161. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  162. ;; start and quit
  163. (setq inhibit-startup-message t)
  164. (setq confirm-kill-emacs 'y-or-n-p)
  165. (setq gc-cons-threshold (* 1024 1024 4))
  166. (when window-system
  167. (add-to-list 'default-frame-alist '(cursor-type . box))
  168. (add-to-list 'default-frame-alist '(background-color . "white"))
  169. (add-to-list 'default-frame-alist '(foreground-color . "gray10"))
  170. ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100)))
  171. ;; does not work?
  172. )
  173. ;; (add-to-list 'default-frame-alist '(cursor-type . box))
  174. (if window-system (menu-bar-mode 1) (menu-bar-mode 0))
  175. (and (fboundp 'tool-bar-mode)
  176. (tool-bar-mode 0))
  177. (and (fboundp 'set-scroll-bar-mode)
  178. (set-scroll-bar-mode nil))
  179. (add-hook 'kill-emacs-hook
  180. ;; load init file when terminating emacs to ensure file is not broken
  181. 'reload-init-file)
  182. (defun my-force-kill-emacs ()
  183. "My force kill Emacs."
  184. (interactive)
  185. (let ((kill-emacs-hook nil))
  186. (kill-emacs)))
  187. (call-after-init
  188. (lambda ()
  189. (message "%s %s" invocation-name emacs-version)
  190. (message "Invocation directory: %s" default-directory)
  191. (message "%s was taken to initialize emacs." (emacs-init-time))
  192. (switch-to-buffer "*Messages*")))
  193. (cd ".") ; when using windows use / instead of \ in `default-directory'
  194. ;; locale
  195. (set-language-environment "Japanese")
  196. (set-default-coding-systems 'utf-8-unix)
  197. (prefer-coding-system 'utf-8-unix)
  198. (setq system-time-locale "C")
  199. ;; my prefix map
  200. (defvar my-prefix-map nil
  201. "My prefix map.")
  202. (define-prefix-command 'my-prefix-map)
  203. (define-key ctl-x-map (kbd "C-x") 'my-prefix-map)
  204. (define-key my-prefix-map (kbd "C-q") 'quoted-insert)
  205. (define-key my-prefix-map (kbd "C-z") 'suspend-frame)
  206. ;; (comint-show-maximum-output)
  207. ;; kill scratch
  208. (call-after-init (lambda ()
  209. (let ((buf (get-buffer "*scratch*")))
  210. (when buf
  211. (kill-buffer buf)))))
  212. ;; modifier keys
  213. ;; (setq mac-option-modifier 'control)
  214. ;; display
  215. (setq visible-bell t)
  216. (setq ring-bell-function 'ignore)
  217. (mouse-avoidance-mode 'banish)
  218. (setq echo-keystrokes 0.1)
  219. (defun reload-init-file ()
  220. "Reload Emacs init file."
  221. (interactive)
  222. (when (and user-init-file
  223. (file-readable-p user-init-file))
  224. (load-file user-init-file)))
  225. (safe-require-or-eval 'session)
  226. ;; server
  227. (set-variable 'server-name (concat "server"
  228. (number-to-string (emacs-pid))))
  229. ;; In Cygwin Environment `server-runnning-p' stops when server-use-tcp is nil
  230. ;; In Darwin environment, init fails with message like 'Service name too long'
  231. ;; when server-use-tcp is nil
  232. (when (or (eq system-type
  233. 'cygwin)
  234. (eq system-type
  235. 'darwin))
  236. (set-variable 'server-use-tcp t))
  237. ;; MSYS2 fix
  238. (when (eq system-type
  239. 'windows-nt)
  240. (setq shell-file-name
  241. (executable-find "bash"))
  242. '(setq function-key-map
  243. `(,@function-key-map ([pause] . [?\C-c])
  244. ))
  245. (define-key key-translation-map
  246. (kbd "<pause>")
  247. (kbd "C-c"))
  248. '(keyboard-translate [pause]
  249. (kbd "C-c")p)
  250. ;; TODO: move to other place later
  251. (when (not window-system)
  252. (setq interprogram-paste-function nil)
  253. (setq interprogram-cut-function nil)))
  254. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  255. ;; global keys
  256. (global-set-key (kbd "<up>") 'scroll-down-line)
  257. (global-set-key (kbd "<down>") 'scroll-up-line)
  258. (global-set-key (kbd "<left>") 'scroll-down)
  259. (global-set-key (kbd "<right>") 'scroll-up)
  260. ;; (define-key my-prefix-map (kbd "C-h") help-map)
  261. (global-set-key (kbd "C-\\") help-map)
  262. (define-key ctl-x-map (kbd "DEL") help-map)
  263. (define-key ctl-x-map (kbd "C-h") help-map)
  264. (define-key help-map "a" 'apropos)
  265. ;; disable annoying keys
  266. (global-set-key [prior] 'ignore)
  267. (global-set-key (kbd "<next>") 'ignore)
  268. (global-set-key [menu] 'ignore)
  269. (global-set-key [down-mouse-1] 'ignore)
  270. (global-set-key [down-mouse-2] 'ignore)
  271. (global-set-key [down-mouse-3] 'ignore)
  272. (global-set-key [mouse-1] 'ignore)
  273. (global-set-key [mouse-2] 'ignore)
  274. (global-set-key [mouse-3] 'ignore)
  275. (global-set-key (kbd "<eisu-toggle>") 'ignore)
  276. (global-set-key (kbd "C-<eisu-toggle>") 'ignore)
  277. (when (safe-require-or-eval 'which-key)
  278. (which-key-mode))
  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. (when (fboundp 'editorconfig-custom-majormode)
  599. (add-hook 'editorconfig-custom-hooks
  600. 'editorconfig-custom-majormode))
  601. (setq revert-without-query '(".+"))
  602. ;; save cursor position
  603. (when (safe-require-or-eval 'saveplace)
  604. (setq-default save-place t)
  605. (setq save-place-file (concat user-emacs-directory
  606. "places")))
  607. ;; http://www.bookshelf.jp/soft/meadow_24.html#SEC260
  608. (setq make-backup-files t)
  609. ;; (make-directory (expand-file-name "~/.emacsbackup"))
  610. (setq backup-directory-alist
  611. (cons (cons "\\.*$" (expand-file-name (concat user-emacs-directory
  612. "backup")))
  613. backup-directory-alist))
  614. (setq version-control 'never)
  615. (setq delete-old-versions t)
  616. (setq auto-save-list-file-prefix (expand-file-name (concat user-emacs-directory
  617. "auto-save/")))
  618. (setq delete-auto-save-files t)
  619. (add-to-list 'completion-ignored-extensions ".bak")
  620. ;; (setq delete-by-moving-to-trash t
  621. ;; trash-directory "~/.emacs.d/trash")
  622. (add-hook 'after-save-hook
  623. 'executable-make-buffer-file-executable-if-script-p)
  624. (set (defvar bookmark-default-file)
  625. (expand-file-name (concat user-emacs-directory
  626. "bmk")))
  627. (with-eval-after-load 'recentf
  628. (defvar recentf-exclude nil)
  629. (add-to-list 'recentf-exclude
  630. (regexp-quote bookmark-default-file)))
  631. (when (safe-require-or-eval 'smart-revert)
  632. (smart-revert-on))
  633. ;; autosave
  634. (when (safe-require-or-eval 'autosave)
  635. (autosave-set 2))
  636. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  637. ;; buffer killing
  638. ;; (defun my-delete-window-killing-buffer () nil)
  639. (defun my-query-kill-current-buffer ()
  640. "Interactively kill current buffer."
  641. (interactive)
  642. (if (y-or-n-p (concat "kill current buffer? :"))
  643. (kill-buffer (current-buffer))))
  644. ;;(global-set-key "\C-xk" 'my-query-kill-current-buffer)
  645. (substitute-key-definition 'kill-buffer
  646. 'my-query-kill-current-buffer
  647. global-map)
  648. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  649. ;; share clipboard with x
  650. ;; this page describes this in details, but only these sexps seem to be needed
  651. ;; http://garin.jp/doc/Linux/xwindow_clipboard
  652. (and (not window-system)
  653. (not (eq window-system 'mac))
  654. (getenv "DISPLAY")
  655. (not (equal (getenv "DISPLAY") ""))
  656. (executable-find "xclip")
  657. ;; (< emacs-major-version 24)
  658. (safe-require-or-eval 'xclip)
  659. nil
  660. (turn-on-xclip))
  661. (and (eq system-type 'darwin)
  662. (safe-require-or-eval 'pasteboard)
  663. (turn-on-pasteboard)
  664. (getenv "TMUX")
  665. (pasteboard-enable-rtun))
  666. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  667. ;; some modes and hooks
  668. ;; http://qiita.com/sune2/items/b73037f9e85962f5afb7
  669. (when (safe-require-or-eval 'company)
  670. (global-company-mode)
  671. (set-variable 'company-idle-delay 0.5)
  672. (set-variable 'company-minimum-prefix-length 2)
  673. (set-variable 'company-selection-wrap-around t))
  674. ;; https://github.com/lunaryorn/flycheck
  675. (when (safe-require-or-eval 'flycheck)
  676. (call-after-init 'global-flycheck-mode))
  677. (set-variable 'ac-ignore-case nil)
  678. (when (autoload-eval-lazily 'term-run '(term-run-shell-command term-run))
  679. (define-key ctl-x-map "t" 'term-run-shell-command))
  680. (add-to-list 'safe-local-variable-values
  681. '(encoding utf-8))
  682. (setq enable-local-variables :safe)
  683. (when (safe-require-or-eval 'remember-major-modes-mode)
  684. (remember-major-modes-mode 1))
  685. ;; Detect file type from shebang and set major-mode.
  686. (add-to-list 'interpreter-mode-alist
  687. '("python3" . python-mode))
  688. (add-to-list 'interpreter-mode-alist
  689. '("python2" . python-mode))
  690. ;; http://fukuyama.co/foreign-regexp
  691. '(and (safe-require-or-eval 'foreign-regexp)
  692. (progn
  693. (setq foreign-regexp/regexp-type 'perl)
  694. '(setq reb-re-syntax 'foreign-regexp)
  695. ))
  696. (autoload-eval-lazily 'sql '(sql-mode)
  697. (safe-require-or-eval 'sql-indent))
  698. (when (autoload-eval-lazily 'git-command)
  699. (define-key ctl-x-map "g" 'git-command))
  700. (when (safe-require-or-eval 'git-commit)
  701. (global-git-commit-mode 1))
  702. (autoload-eval-lazily 'sl)
  703. ;; jdee is too old! use malabar instead
  704. (with-eval-after-load 'jdee
  705. (add-hook 'jdee-mode-hook
  706. (lambda ()
  707. (make-local-variable 'global-mode-string)
  708. (add-to-list 'global-mode-string
  709. mode-line-position))))
  710. ;; Cannot enable error thrown. Why???
  711. ;; https://github.com/m0smith/malabar-mode#Installation
  712. ;; (when (autoload-eval-lazily 'malabar-mode)
  713. ;; (add-to-list 'load-path
  714. ;; (expand-file-name (concat user-emacs-directory "/cedet")))
  715. ;; (safe-require-or-eval 'cedet-devel-load)
  716. ;; (call-after-init 'activate-malabar-mode))
  717. (with-eval-after-load 'make-mode
  718. (defvar makefile-mode-map (make-sparse-keymap))
  719. (define-key makefile-mode-map (kbd "C-m") 'newline-and-indent)
  720. ;; this functions is set in write-file-functions, i cannot find any
  721. ;; good way to remove this.
  722. (fset 'makefile-warn-suspicious-lines 'ignore))
  723. (with-eval-after-load 'verilog-mode
  724. (defvar verilog-mode-map (make-sparse-keymap))
  725. (define-key verilog-mode-map ";" 'self-insert-command))
  726. (setq diff-switches "-u")
  727. (with-eval-after-load 'diff-mode
  728. ;; (when (and (eq major-mode
  729. ;; 'diff-mode)
  730. ;; (not buffer-file-name))
  731. ;; ;; do not pass when major-mode is derived mode of diff-mode
  732. ;; (view-mode 1))
  733. (set-face-attribute 'diff-header nil
  734. :foreground nil
  735. :background nil
  736. :weight 'bold)
  737. (set-face-attribute 'diff-file-header nil
  738. :foreground nil
  739. :background nil
  740. :weight 'bold)
  741. (set-face-foreground 'diff-index-face "blue")
  742. (set-face-attribute 'diff-hunk-header nil
  743. :foreground "cyan"
  744. :weight 'normal)
  745. (set-face-attribute 'diff-context nil
  746. ;; :foreground "white"
  747. :foreground nil
  748. :weight 'normal)
  749. (set-face-foreground 'diff-removed-face "red")
  750. (set-face-foreground 'diff-added-face "green")
  751. (set-face-background 'diff-removed-face nil)
  752. (set-face-background 'diff-added-face nil)
  753. (set-face-attribute 'diff-changed nil
  754. :foreground "magenta"
  755. :weight 'normal)
  756. (set-face-attribute 'diff-refine-change nil
  757. :foreground nil
  758. :background nil
  759. :weight 'bold
  760. :inverse-video t)
  761. ;; Annoying !
  762. ;;(diff-auto-refine-mode)
  763. )
  764. ;; (ffap-bindings)
  765. (set-variable 'browse-url-browser-function
  766. 'eww-browse-url)
  767. (set-variable 'sh-here-document-word "__EOC__")
  768. (when (autoload-eval-lazily 'adoc-mode
  769. nil
  770. (defvar adoc-mode-map (make-sparse-keymap))
  771. (define-key adoc-mode-map (kbd "C-m") 'newline))
  772. (setq auto-mode-alist
  773. `(("\\.adoc\\'" . adoc-mode)
  774. ("\\.asciidoc\\'" . adoc-mode)
  775. ,@auto-mode-alist)))
  776. (with-eval-after-load 'markup-faces
  777. ;; Is this too match ?
  778. (set-face-foreground 'markup-meta-face
  779. "color-245")
  780. (set-face-foreground 'markup-meta-hide-face
  781. "color-245")
  782. )
  783. (setq auto-mode-alist
  784. `(("autostart\\'" . sh-mode)
  785. ("xinitrc\\'" . sh-mode)
  786. ("xprograms\\'" . sh-mode)
  787. ("PKGBUILD\\'" . sh-mode)
  788. ,@auto-mode-alist))
  789. ;; TODO: check if this is required
  790. (and (autoload-eval-lazily 'groovy-mode)
  791. (add-to-list 'auto-mode-alist
  792. '("build\\.gradle\\'" . groovy-mode)))
  793. (with-eval-after-load 'yaml-mode
  794. (defvar yaml-mode-map (make-sparse-keymap))
  795. (define-key yaml-mode-map (kbd "C-m") 'newline))
  796. (with-eval-after-load 'html-mode
  797. (defvar html-mode-map (make-sparse-keymap))
  798. (define-key html-mode-map (kbd "C-m") 'reindent-then-newline-and-indent))
  799. (with-eval-after-load 'text-mode
  800. (define-key text-mode-map (kbd "C-m") 'newline))
  801. (add-to-list 'Info-default-directory-list
  802. (expand-file-name "~/.info/emacs-ja"))
  803. (with-eval-after-load 'apropos
  804. (defvar apropos-mode-map (make-sparse-keymap))
  805. (define-key apropos-mode-map "n" 'next-line)
  806. (define-key apropos-mode-map "p" 'previous-line))
  807. (with-eval-after-load 'isearch
  808. ;; (define-key isearch-mode-map
  809. ;; (kbd "C-j") 'isearch-other-control-char)
  810. ;; (define-key isearch-mode-map
  811. ;; (kbd "C-k") 'isearch-other-control-char)
  812. ;; (define-key isearch-mode-map
  813. ;; (kbd "C-h") 'isearch-other-control-char)
  814. (define-key isearch-mode-map (kbd "C-h") 'isearch-delete-char)
  815. (define-key isearch-mode-map (kbd "M-r")
  816. 'isearch-query-replace-regexp))
  817. ;; do not cleanup isearch highlight: use `lazy-highlight-cleanup' to remove
  818. (setq lazy-highlight-cleanup nil)
  819. ;; face for isearch highlighing
  820. (set-face-attribute 'lazy-highlight
  821. nil
  822. :foreground `unspecified
  823. :background `unspecified
  824. :underline t
  825. ;; :weight `bold
  826. )
  827. (add-hook 'outline-mode-hook
  828. (lambda ()
  829. (when (string-match "\\.md\\'" buffer-file-name)
  830. (set (make-local-variable 'outline-regexp) "#+ "))))
  831. (add-to-list 'auto-mode-alist (cons "\\.ol\\'" 'outline-mode))
  832. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'outline-mode))
  833. (when (autoload-eval-lazily 'markdown-mode
  834. '(markdown-mode gfm-mode)
  835. (defvar gfm-mode-map (make-sparse-keymap))
  836. (define-key gfm-mode-map (kbd "C-m") 'electric-indent-just-newline))
  837. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'gfm-mode))
  838. (set-variable 'markdown-command (or (executable-find "markdown")
  839. (executable-find "markdown.pl")
  840. ""))
  841. (add-hook 'markdown-mode-hook
  842. (lambda ()
  843. (outline-minor-mode 1)
  844. (flyspell-mode)
  845. (set (make-local-variable 'comment-start) ";")))
  846. )
  847. ;; c-mode
  848. ;; http://www.emacswiki.org/emacs/IndentingC
  849. ;; http://en.wikipedia.org/wiki/Indent_style
  850. ;; http://d.hatena.ne.jp/emergent/20070203/1170512717
  851. ;; http://seesaawiki.jp/whiteflare503/d/Emacs%20%a5%a4%a5%f3%a5%c7%a5%f3%a5%c8
  852. (with-eval-after-load 'cc-vars
  853. (defvar c-default-style nil)
  854. (add-to-list 'c-default-style
  855. '(c-mode . "k&r"))
  856. (add-to-list 'c-default-style
  857. '(c++-mode . "k&r"))
  858. (add-hook 'c-mode-common-hook
  859. (lambda ()
  860. ;; why c-basic-offset in k&r style defaults to 5 ???
  861. (set-variable 'c-basic-offset 4)
  862. (set-variable 'indent-tabs-mode nil)
  863. ;; (set-face-foreground 'font-lock-keyword-face "blue")
  864. (c-toggle-hungry-state -1)
  865. ;; (and (require 'gtags nil t)
  866. ;; (gtags-mode 1))
  867. )))
  868. (autoload-eval-lazily 'js2-mode nil
  869. ;; currently do not use js2-mode
  870. ;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  871. ;; (add-to-list 'auto-mode-alist '("\\.jsm\\'" . js2-mode))
  872. (defvar js2-mode-map (make-sparse-keymap))
  873. (define-key js2-mode-map (kbd "C-m") (lambda ()
  874. (interactive)
  875. (js2-enter-key)
  876. (indent-for-tab-command)))
  877. ;; (add-hook (kill-local-variable 'before-save-hook)
  878. ;; 'js2-before-save)
  879. ;; (add-hook 'before-save-hook
  880. ;; 'my-indent-buffer
  881. ;; nil
  882. ;; t)
  883. )
  884. (add-to-list 'interpreter-mode-alist
  885. '("node" . js-mode))
  886. (when (autoload-eval-lazily 'flymake-jslint
  887. '(flymake-jslint-load))
  888. (autoload-eval-lazily 'js nil
  889. (add-hook 'js-mode-hook
  890. 'flymake-jslint-load)))
  891. (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
  892. (with-eval-after-load 'uniquify
  893. (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
  894. (setq uniquify-ignore-buffers-re "*[^*]+*")
  895. (setq uniquify-min-dir-content 1))
  896. (with-eval-after-load 'view
  897. (defvar view-mode-map (make-sparse-keymap))
  898. (define-key view-mode-map "j" 'scroll-up-line)
  899. (define-key view-mode-map "k" 'scroll-down-line)
  900. (define-key view-mode-map "v" 'toggle-read-only)
  901. (define-key view-mode-map "q" 'bury-buffer)
  902. ;; (define-key view-mode-map "/" 'nonincremental-re-search-forward)
  903. ;; (define-key view-mode-map "?" 'nonincremental-re-search-backward)
  904. ;; (define-key view-mode-map
  905. ;; "n" 'nonincremental-repeat-search-forward)
  906. ;; (define-key view-mode-map
  907. ;; "N" 'nonincremental-repeat-search-backward)
  908. (define-key view-mode-map "/" 'isearch-forward-regexp)
  909. (define-key view-mode-map "?" 'isearch-backward-regexp)
  910. (define-key view-mode-map "n" 'isearch-repeat-forward)
  911. (define-key view-mode-map "N" 'isearch-repeat-backward)
  912. (define-key view-mode-map (kbd "C-m") 'my-rgrep-symbol-at-point))
  913. (global-set-key "\M-r" 'view-mode)
  914. ;; (setq view-read-only t)
  915. (add-hook 'Man-mode-hook
  916. (lambda ()
  917. (view-mode 1)
  918. (setq truncate-lines nil)))
  919. (set-variable 'Man-notify-method (if window-system
  920. 'newframe
  921. 'aggressive))
  922. (set-variable 'woman-cache-filename (expand-file-name (concat user-emacs-directory
  923. "woman_cache.el")))
  924. (defalias 'man 'woman)
  925. (add-to-list 'auto-mode-alist
  926. '("tox\\.ini\\'" . conf-unix-mode))
  927. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  928. ;; python
  929. (when (autoload-eval-lazily 'python '(python-mode)
  930. (defvar python-mode-map (make-sparse-keymap))
  931. (define-key python-mode-map (kbd "C-c C-e") 'my-python-run-as-command)
  932. (define-key python-mode-map (kbd "C-c C-b") 'my-python-display-python-buffer)
  933. (define-key python-mode-map (kbd "C-m") 'newline-and-indent)
  934. (defvar inferior-python-mode-map (make-sparse-keymap))
  935. (define-key inferior-python-mode-map (kbd "<up>") 'comint-previous-input)
  936. (define-key inferior-python-mode-map (kbd "<down>") 'comint-next-input)
  937. )
  938. (set-variable 'python-python-command (or (executable-find "python3")
  939. (executable-find "python")))
  940. ;; (defun my-python-run-as-command ()
  941. ;; ""
  942. ;; (interactive)
  943. ;; (shell-command (concat python-python-command " " buffer-file-name)))
  944. (defun my-python-display-python-buffer ()
  945. ""
  946. (interactive)
  947. (defvar python-buffer nil)
  948. (set-window-text-height (display-buffer python-buffer
  949. t)
  950. 7))
  951. (add-hook 'inferior-python-mode-hook
  952. (lambda ()
  953. (my-python-display-python-buffer))))
  954. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  955. ;; gauche-mode
  956. ;; http://d.hatena.ne.jp/kobapan/20090305/1236261804
  957. ;; http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el
  958. ;; NOTE: This gauche-mode returns 404.
  959. ;; There is another gosh-mode, so for now I submitted a recipe for that into
  960. ;; github.com/10sr/emacs-lisp/p. I'll add setup for that later.
  961. (when nil (and '(fetch-library
  962. "http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el"
  963. t)
  964. (autoload-eval-lazily 'gauche-mode '(gauche-mode run-scheme)
  965. (defvar gauche-mode-map (make-sparse-keymap))
  966. (defvar scheme-mode-map (make-sparse-keymap))
  967. (define-key gauche-mode-map
  968. (kbd "C-c C-z") 'run-gauche-other-window)
  969. (define-key scheme-mode-map
  970. (kbd "C-c C-c") 'scheme-send-buffer)
  971. (define-key scheme-mode-map
  972. (kbd "C-c C-b") 'my-scheme-display-scheme-buffer)))
  973. (let ((s (executable-find "gosh")))
  974. (set-variable 'scheme-program-name s)
  975. (set-variable 'gauche-program-name s))
  976. (defvar gauche-program-name nil)
  977. (defvar scheme-buffer nil)
  978. (defun run-gauche-other-window ()
  979. "Run gauche on other window"
  980. (interactive)
  981. (switch-to-buffer-other-window
  982. (get-buffer-create "*scheme*"))
  983. (run-gauche))
  984. (defun run-gauche ()
  985. "run gauche"
  986. (interactive)
  987. (run-scheme gauche-program-name)
  988. )
  989. (defun scheme-send-buffer ()
  990. ""
  991. (interactive)
  992. (scheme-send-region (point-min) (point-max))
  993. (my-scheme-display-scheme-buffer)
  994. )
  995. (defun my-scheme-display-scheme-buffer ()
  996. ""
  997. (interactive)
  998. (set-window-text-height (display-buffer scheme-buffer
  999. t)
  1000. 7))
  1001. (add-hook 'scheme-mode-hook
  1002. (lambda ()
  1003. nil))
  1004. (add-hook 'inferior-scheme-mode-hook
  1005. (lambda ()
  1006. ;; (my-scheme-display-scheme-buffer)
  1007. ))
  1008. (setq auto-mode-alist
  1009. (cons '("\.gosh\\'" . gauche-mode) auto-mode-alist))
  1010. (setq auto-mode-alist
  1011. (cons '("\.gaucherc\\'" . gauche-mode) auto-mode-alist))
  1012. )
  1013. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1014. ;; term mode
  1015. ;; (setq multi-term-program shell-file-name)
  1016. (when (autoload-eval-lazily 'multi-term)
  1017. (set-variable 'multi-term-switch-after-close nil)
  1018. (set-variable 'multi-term-dedicated-select-after-open-p t)
  1019. (set-variable 'multi-term-dedicated-window-height 20))
  1020. (when (autoload-eval-lazily 'term '(term ansi-term)
  1021. (defvar term-raw-map (make-sparse-keymap))
  1022. ;; (define-key term-raw-map "\C-xl" 'term-line-mode)
  1023. ;; (define-key term-mode-map "\C-xc" 'term-char-mode)
  1024. (define-key term-raw-map (kbd "<up>") 'scroll-down-line)
  1025. (define-key term-raw-map (kbd "<down>") 'scroll-up-line)
  1026. (define-key term-raw-map (kbd "<right>") 'scroll-up)
  1027. (define-key term-raw-map (kbd "<left>") 'scroll-down)
  1028. (define-key term-raw-map (kbd "C-p") 'term-send-raw)
  1029. (define-key term-raw-map (kbd "C-n") 'term-send-raw)
  1030. (define-key term-raw-map "q" 'my-term-quit-or-send-raw)
  1031. ;; (define-key term-raw-map (kbd "ESC") 'term-send-raw)
  1032. (define-key term-raw-map [delete] 'term-send-raw)
  1033. (define-key term-raw-map (kbd "DEL") 'term-send-backspace)
  1034. (define-key term-raw-map "\C-y" 'term-paste)
  1035. (define-key term-raw-map
  1036. "\C-c" 'term-send-raw) ;; 'term-interrupt-subjob)
  1037. '(define-key term-mode-map (kbd "C-x C-q") 'term-pager-toggle)
  1038. ;; (dolist (key '("<up>" "<down>" "<right>" "<left>"))
  1039. ;; (define-key term-raw-map (read-kbd-macro key) 'term-send-raw))
  1040. ;; (define-key term-raw-map "\C-d" 'delete-char)
  1041. ;; (define-key term-raw-map "\C-q" 'move-beginning-of-line)
  1042. ;; (define-key term-raw-map "\C-r" 'term-send-raw)
  1043. ;; (define-key term-raw-map "\C-s" 'term-send-raw)
  1044. ;; (define-key term-raw-map "\C-f" 'forward-char)
  1045. ;; (define-key term-raw-map "\C-b" 'backward-char)
  1046. ;; (define-key term-raw-map "\C-t" 'set-mark-command)
  1047. )
  1048. (defun my-term-quit-or-send-raw ()
  1049. ""
  1050. (interactive)
  1051. (if (get-buffer-process (current-buffer))
  1052. (call-interactively 'term-send-raw)
  1053. (kill-buffer)))
  1054. ;; http://d.hatena.ne.jp/goinger/20100416/1271399150
  1055. ;; (setq term-ansi-default-program shell-file-name)
  1056. (add-hook 'term-setup-hook
  1057. (lambda ()
  1058. (set-variable 'term-display-table (make-display-table))))
  1059. (add-hook 'term-mode-hook
  1060. (lambda ()
  1061. (defvar term-raw-map (make-sparse-keymap))
  1062. ;; (unless (memq (current-buffer)
  1063. ;; (and (featurep 'multi-term)
  1064. ;; (defvar multi-term-buffer-list)
  1065. ;; ;; current buffer is not multi-term buffer
  1066. ;; multi-term-buffer-list))
  1067. ;; )
  1068. (set (make-local-variable 'scroll-margin) 0)
  1069. ;; (set (make-local-variable 'cua-enable-cua-keys) nil)
  1070. ;; (cua-mode 0)
  1071. ;; (and cua-mode
  1072. ;; (local-unset-key (kbd "C-c")))
  1073. ;; (define-key cua--prefix-override-keymap
  1074. ;;"\C-c" 'term-interrupt-subjob)
  1075. (set (make-local-variable (defvar hl-line-range-function))
  1076. (lambda ()
  1077. '(0 . 0)))
  1078. (define-key term-raw-map
  1079. "\C-x" (lookup-key (current-global-map) "\C-x"))
  1080. (define-key term-raw-map
  1081. "\C-z" (lookup-key (current-global-map) "\C-z"))
  1082. ))
  1083. ;; (add-hook 'term-exec-hook 'forward-char)
  1084. )
  1085. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1086. ;; buffer switching
  1087. (defvar bs-configurations)
  1088. (when (autoload-eval-lazily 'bs '(bs-show)
  1089. (add-to-list 'bs-configurations
  1090. '("specials" "^\\*" nil ".*" nil nil))
  1091. (defvar bs-mode-map)
  1092. (defvar bs-current-configuration)
  1093. (define-key bs-mode-map (kbd "t")
  1094. (lambda ()
  1095. (interactive)
  1096. (if (string= "specials"
  1097. bs-current-configuration)
  1098. (bs-set-configuration "files")
  1099. (bs-set-configuration "specials"))
  1100. (bs-refresh)
  1101. (bs-message-without-log "%s"
  1102. (bs--current-config-message))))
  1103. ;; (setq bs-configurations (list
  1104. ;; '("processes" nil get-buffer-process ".*" nil nil)
  1105. ;; '("files-and-scratch" "^\\*scratch\\*$" nil nil
  1106. ;; bs-visits-non-file bs-sort-buffer-interns-are-last)))
  1107. )
  1108. (defalias 'list-buffers 'bs-show)
  1109. (set-variable 'bs-default-configuration "files")
  1110. (set-variable 'bs-default-sort-name "by nothing")
  1111. (add-hook 'bs-mode-hook
  1112. (lambda ()
  1113. (set (make-local-variable 'scroll-margin) 0))))
  1114. ;;(iswitchb-mode 1)
  1115. (icomplete-mode)
  1116. (defun iswitchb-buffer-display-other-window ()
  1117. "Do iswitchb in other window."
  1118. (interactive)
  1119. (let ((iswitchb-default-method 'display))
  1120. (call-interactively 'iswitchb-buffer)))
  1121. ;;;;;;;;;;;;;;;;;;;;;;;;
  1122. ;; ilookup
  1123. (with-eval-after-load 'ilookup
  1124. (set-variable 'ilookup-dict-alist
  1125. '(
  1126. ("sdcv" . (lambda (word)
  1127. (shell-command-to-string
  1128. (format "sdcv -n '%s'"
  1129. word))))
  1130. ("en" . (lambda (word)
  1131. (shell-command-to-string
  1132. (format "sdcv -n -u dictd_www.dict.org_gcide '%s'"
  1133. word))))
  1134. ("ja" . (lambda (word)
  1135. (shell-command-to-string
  1136. (format "sdcv -n -u EJ-GENE95 -u jmdict-en-ja '%s'"
  1137. word))))
  1138. ("jaj" . (lambda (word)
  1139. (shell-command-to-string
  1140. (format "sdcv -n -u jmdict-en-ja '%s'"
  1141. word))))
  1142. ("jag" .
  1143. (lambda (word)
  1144. (with-temp-buffer
  1145. (insert (shell-command-to-string
  1146. (format "sdcv -n -u 'Genius English-Japanese' '%s'"
  1147. word)))
  1148. (html2text)
  1149. (buffer-substring (point-min)
  1150. (point-max)))))
  1151. ("alc" . (lambda (word)
  1152. (shell-command-to-string
  1153. (format "alc '%s' | head -n 20"
  1154. word))))
  1155. ("app" . (lambda (word)
  1156. (shell-command-to-string
  1157. (format "dict_app '%s'"
  1158. word))))
  1159. ;; letters broken
  1160. ("ms" .
  1161. (lambda (word)
  1162. (let ((url (concat
  1163. "http://api.microsofttranslator.com/V2/Ajax.svc/"
  1164. "Translate?appId=%s&text=%s&to=%s"))
  1165. (apikey "3C9778666C5BA4B406FFCBEE64EF478963039C51")
  1166. (target "ja")
  1167. (eword (url-hexify-string word)))
  1168. (with-current-buffer (url-retrieve-synchronously
  1169. (format url
  1170. apikey
  1171. eword
  1172. target))
  1173. (message "")
  1174. (goto-char (point-min))
  1175. (search-forward-regexp "^$"
  1176. nil
  1177. t)
  1178. (url-unhex-string (buffer-substring-no-properties
  1179. (point)
  1180. (point-max)))))))
  1181. ))
  1182. ;; (funcall (cdr (assoc "ms"
  1183. ;; ilookup-alist))
  1184. ;; "dictionary")
  1185. ;; (switch-to-buffer (url-retrieve-synchronously "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=3C9778666C5BA4B406FFCBEE64EF478963039C51&text=dictionary&to=ja"))
  1186. ;; (switch-to-buffer (url-retrieve-synchronously "http://google.com"))
  1187. (set-variable 'ilookup-default "ja")
  1188. (when (locate-library "google-translate")
  1189. (defvar ilookup-dict-alist nil)
  1190. (add-to-list 'ilookup-dict-alist
  1191. '("gt" .
  1192. (lambda (word)
  1193. (save-excursion
  1194. (google-translate-translate "auto"
  1195. "ja"
  1196. word))
  1197. (with-current-buffer "*Google Translate*"
  1198. (buffer-substring-no-properties (point-min)
  1199. (point-max)))))))
  1200. )
  1201. (when (autoload-eval-lazily 'google-translate '(google-translate-translate
  1202. google-translate-at-point))
  1203. (set-variable 'google-translate-default-source-language "auto")
  1204. (set-variable 'google-translate-default-target-language "ja"))
  1205. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1206. ;; vc
  1207. (set-variable 'vc-handled-backends '())
  1208. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1209. ;; recentf-mode
  1210. (set-variable 'recentf-save-file (expand-file-name (concat user-emacs-directory
  1211. "recentf")))
  1212. (set-variable 'recentf-max-menu-items 20)
  1213. (set-variable 'recentf-max-saved-items 30)
  1214. (set-variable 'recentf-show-file-shortcuts-flag nil)
  1215. (when (safe-require-or-eval 'recentf)
  1216. (add-to-list 'recentf-exclude
  1217. (regexp-quote recentf-save-file))
  1218. (add-to-list 'recentf-exclude
  1219. (regexp-quote (expand-file-name user-emacs-directory)))
  1220. (define-key ctl-x-map (kbd "C-r") 'recentf-open-files)
  1221. (remove-hook 'find-file-hook
  1222. 'recentf-track-opened-file)
  1223. (defun my-recentf-load-track-save-list ()
  1224. "Load current recentf list from file, track current visiting file, then save
  1225. the list."
  1226. (recentf-load-list)
  1227. (recentf-track-opened-file)
  1228. (recentf-save-list))
  1229. (add-hook 'find-file-hook
  1230. 'my-recentf-load-track-save-list)
  1231. (add-hook 'kill-emacs-hook
  1232. 'recentf-load-list)
  1233. ;;(run-with-idle-timer 5 t 'recentf-save-list)
  1234. ;; (add-hook 'find-file-hook
  1235. ;; (lambda ()
  1236. ;; (recentf-add-file default-directory)))
  1237. (and (autoload-eval-lazily 'recentf-show)
  1238. (define-key ctl-x-map (kbd "C-r") 'recentf-show)
  1239. (add-hook 'recentf-show-before-listing-hook
  1240. 'recentf-load-list))
  1241. (recentf-mode 1)
  1242. (define-key recentf-dialog-mode-map (kbd "<up>") 'previous-line)
  1243. (define-key recentf-dialog-mode-map (kbd "<down>") 'next-line)
  1244. (define-key recentf-dialog-mode-map "p" 'previous-line)
  1245. (define-key recentf-dialog-mode-map "n" 'next-line)
  1246. (add-hook 'recentf-dialog-mode-hook
  1247. (lambda ()
  1248. ;; (recentf-save-list)
  1249. ;; (define-key recentf-dialog-mode-map (kbd "C-x C-f")
  1250. ;; 'my-recentf-cd-and-find-file)
  1251. (cd "~/"))))
  1252. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1253. ;; dired
  1254. (defun my-dired-echo-file-head (arg)
  1255. ""
  1256. (interactive "P")
  1257. (let ((f (dired-get-filename)))
  1258. (message "%s"
  1259. (with-temp-buffer
  1260. (insert-file-contents f)
  1261. (buffer-substring-no-properties
  1262. (point-min)
  1263. (progn (goto-char (point-min))
  1264. (forward-line (1- (if arg
  1265. (prefix-numeric-value arg)
  1266. 7)))
  1267. (point-at-eol)))))))
  1268. (defun my-dired-diff ()
  1269. ""
  1270. (interactive)
  1271. (let ((files (dired-get-marked-files nil nil nil t)))
  1272. (if (eq (car files)
  1273. t)
  1274. (diff (cadr files) (dired-get-filename))
  1275. (message "One file must be marked!"))))
  1276. (defun dired-get-file-info ()
  1277. "dired get file info"
  1278. (interactive)
  1279. (let ((f (shell-quote-argument (dired-get-filename t))))
  1280. (if (file-directory-p f)
  1281. (progn
  1282. (message "Calculating disk usage...")
  1283. (shell-command (concat "du -hsD "
  1284. f)))
  1285. (shell-command (concat "file "
  1286. f)))))
  1287. (defun my-dired-scroll-up ()
  1288. ""
  1289. (interactive)
  1290. (my-dired-previous-line (- (window-height) 1)))
  1291. (defun my-dired-scroll-down ()
  1292. ""
  1293. (interactive)
  1294. (my-dired-next-line (- (window-height) 1)))
  1295. ;; (defun my-dired-forward-line (arg)
  1296. ;; ""
  1297. ;; (interactive "p"))
  1298. (defun my-dired-previous-line (arg)
  1299. ""
  1300. (interactive "p")
  1301. (if (> arg 0)
  1302. (progn
  1303. (if (eq (line-number-at-pos)
  1304. 1)
  1305. (goto-char (point-max))
  1306. (forward-line -1))
  1307. (my-dired-previous-line (if (or (dired-get-filename nil t)
  1308. (dired-get-subdir))
  1309. (- arg 1)
  1310. arg)))
  1311. (dired-move-to-filename)))
  1312. (defun my-dired-next-line (arg)
  1313. ""
  1314. (interactive "p")
  1315. (if (> arg 0)
  1316. (progn
  1317. (if (eq (point)
  1318. (point-max))
  1319. (goto-char (point-min))
  1320. (forward-line 1))
  1321. (my-dired-next-line (if (or (dired-get-filename nil t)
  1322. (dired-get-subdir))
  1323. (- arg 1)
  1324. arg)))
  1325. (dired-move-to-filename)))
  1326. ;;http://bach.istc.kobe-u.ac.jp/lect/tamlab/ubuntu/emacs.html
  1327. (if (eq window-system 'mac)
  1328. (setq dired-listing-switches "-lhF")
  1329. (setq dired-listing-switches "-lhF --time-style=long-iso")
  1330. )
  1331. (setq dired-listing-switches "-lhF")
  1332. (put 'dired-find-alternate-file 'disabled nil)
  1333. ;; when using dired-find-alternate-file
  1334. ;; reuse current dired buffer for the file to open
  1335. (set-variable 'dired-ls-F-marks-symlinks t)
  1336. (with-eval-after-load 'ls-lisp
  1337. (setq ls-lisp-use-insert-directory-program nil) ; always use ls-lisp
  1338. (setq ls-lisp-dirs-first t)
  1339. (setq ls-lisp-use-localized-time-format t)
  1340. (setq ls-lisp-format-time-list
  1341. '("%Y-%m-%d %H:%M"
  1342. "%Y-%m-%d ")))
  1343. (set-variable 'dired-dwim-target t)
  1344. (set-variable 'dired-isearch-filenames t)
  1345. (set-variable 'dired-hide-details-hide-symlink-targets nil)
  1346. (set-variable 'dired-hide-details-hide-information-lines nil)
  1347. ;; (add-hook 'dired-after-readin-hook
  1348. ;; 'my-replace-nasi-none)
  1349. ;; (add-hook 'after-init-hook
  1350. ;; (lambda ()
  1351. ;; (dired ".")))
  1352. (with-eval-after-load 'dired
  1353. (safe-require-or-eval 'ls-lisp)
  1354. (defvar dired-mode-map (make-sparse-keymap))
  1355. (define-key dired-mode-map "o" 'my-dired-x-open)
  1356. (define-key dired-mode-map "i" 'dired-get-file-info)
  1357. (define-key dired-mode-map "f" 'find-file)
  1358. (define-key dired-mode-map "!" 'shell-command)
  1359. (define-key dired-mode-map "&" 'async-shell-command)
  1360. (define-key dired-mode-map "X" 'dired-do-async-shell-command)
  1361. (define-key dired-mode-map "=" 'my-dired-diff)
  1362. (define-key dired-mode-map "B" 'gtkbm-add-current-dir)
  1363. (define-key dired-mode-map "b" 'gtkbm)
  1364. (define-key dired-mode-map "h" 'my-dired-echo-file-head)
  1365. (define-key dired-mode-map "@" (lambda ()
  1366. (interactive) (my-x-open ".")))
  1367. (define-key dired-mode-map (kbd "TAB") 'other-window)
  1368. ;; (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack)
  1369. (define-key dired-mode-map "/" 'dired-isearch-filenames)
  1370. (define-key dired-mode-map (kbd "DEL") 'dired-up-directory)
  1371. (define-key dired-mode-map (kbd "C-h") 'dired-up-directory)
  1372. (substitute-key-definition 'dired-next-line
  1373. 'my-dired-next-line
  1374. dired-mode-map)
  1375. (substitute-key-definition 'dired-previous-line
  1376. 'my-dired-previous-line
  1377. dired-mode-map)
  1378. ;; (define-key dired-mode-map (kbd "C-p") 'my-dired-previous-line)
  1379. ;; (define-key dired-mode-map (kbd "p") 'my-dired-previous-line)
  1380. ;; (define-key dired-mode-map (kbd "C-n") 'my-dired-next-line)
  1381. ;; (define-key dired-mode-map (kbd "n") 'my-dired-next-line)
  1382. (define-key dired-mode-map (kbd "<left>") 'my-dired-scroll-up)
  1383. (define-key dired-mode-map (kbd "<right>") 'my-dired-scroll-down)
  1384. (define-key dired-mode-map (kbd "ESC p") 'my-dired-scroll-up)
  1385. (define-key dired-mode-map (kbd "ESC n") 'my-dired-scroll-down)
  1386. (add-hook 'dired-mode-hook
  1387. (lambda ()
  1388. (when (fboundp 'dired-hide-details-mode)
  1389. (dired-hide-details-mode t)
  1390. (local-set-key "l" 'dired-hide-details-mode))
  1391. (let ((file "._Icon\015"))
  1392. (when nil
  1393. '(file-readable-p file)
  1394. (delete-file file)))))
  1395. (when (autoload-eval-lazily 'pack '(dired-do-pack-or-unpack pack-pack))
  1396. (with-eval-after-load 'dired
  1397. (define-key dired-mode-map "P" 'dired-do-pack-or-unpack)))
  1398. (when (autoload-eval-lazily 'dired-list-all-mode)
  1399. (setq dired-listing-switches "-lhF")
  1400. (with-eval-after-load 'dired
  1401. (define-key dired-mode-map "a" 'dired-list-all-mode))))
  1402. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1403. ;; my-term
  1404. (defvar my-term nil
  1405. "My terminal buffer.")
  1406. (defvar my-term-function nil
  1407. "Function to create terminal buffer.
  1408. This function accept no argument and return newly created buffer of terminal.")
  1409. (defun my-term (&optional arg)
  1410. "Open terminal buffer and return that buffer.
  1411. If ARG is given or called with prefix argument, create new buffer."
  1412. (interactive "P")
  1413. (if (and (not arg)
  1414. my-term
  1415. (buffer-name my-term))
  1416. (pop-to-buffer my-term)
  1417. (setq my-term
  1418. (save-window-excursion
  1419. (funcall my-term-function)))
  1420. (and my-term
  1421. (my-term))))
  1422. ;; (setq my-term-function
  1423. ;; (lambda ()
  1424. ;; (if (eq system-type 'windows-nt)
  1425. ;; (eshell)
  1426. ;; (if (require 'multi-term nil t)
  1427. ;; (multi-term)
  1428. ;; (ansi-term shell-file-name)))))
  1429. (setq my-term-function (lambda () (eshell t)))
  1430. ;;(define-key my-prefix-map (kbd "C-s") 'my-term)
  1431. (define-key ctl-x-map "i" 'my-term)
  1432. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1433. ;; misc funcs
  1434. (defalias 'qcalc 'quick-calc)
  1435. (defun memo (&optional dir)
  1436. "Open memo.txt in DIR."
  1437. (interactive)
  1438. (pop-to-buffer (find-file-noselect (concat (if dir
  1439. (file-name-as-directory dir)
  1440. "")
  1441. "memo.txt"))))
  1442. (defvar my-rgrep-alist
  1443. `(
  1444. ;; the silver searcher
  1445. ("ag"
  1446. (executable-find "ag")
  1447. "ag --nocolor --nogroup --nopager --filename ")
  1448. ;; ack
  1449. ("ack"
  1450. (executable-find "ack")
  1451. "ack --nocolor --nogroup --nopager --with-filename ")
  1452. ;; gnu global
  1453. ("global"
  1454. (and (require 'gtags nil t)
  1455. (executable-find "global")
  1456. (gtags-get-rootpath))
  1457. "global --result grep ")
  1458. ;; git grep
  1459. ("gitgrep"
  1460. (eq 0
  1461. (shell-command "git rev-parse --git-dir"))
  1462. "git --no-pager -c color.grep=false grep -nH -e ")
  1463. ;; grep
  1464. ("grep"
  1465. t
  1466. ,(concat "find . "
  1467. "-path '*/.git' -prune -o "
  1468. "-path '*/.svn' -prune -o "
  1469. "-type f -print0 | "
  1470. "xargs -0 grep -nH -e "))
  1471. )
  1472. "Alist of rgrep command.
  1473. Each element is in the form like (NAME SEXP COMMAND), where SEXP returns the
  1474. condition to choose COMMAND when evaluated.")
  1475. (defvar my-rgrep-default nil
  1476. "Default command name for my-rgrep.")
  1477. (defun my-rgrep-grep-command (&optional name alist)
  1478. "Return recursive grep command for current directory or nil.
  1479. If NAME is given, use that without testing.
  1480. Commands are searched from ALIST."
  1481. (if alist
  1482. (if name
  1483. ;; if name is given search that from alist and return the command
  1484. (nth 2 (assoc name
  1485. alist))
  1486. ;; if name is not given try test in 1th elem
  1487. (let ((car (car alist))
  1488. (cdr (cdr alist)))
  1489. (if (eval (nth 1 car))
  1490. ;; if the condition is true return the command
  1491. (nth 2 car)
  1492. ;; try next one
  1493. (and cdr
  1494. (my-rgrep-grep-command name cdr)))))
  1495. ;; if alist is not given set default value
  1496. (my-rgrep-grep-command name my-rgrep-alist)))
  1497. (defun my-rgrep (command-args)
  1498. "My recursive grep. Run COMMAND-ARGS."
  1499. (interactive (let ((cmd (my-rgrep-grep-command my-rgrep-default
  1500. nil)))
  1501. (if cmd
  1502. (list (read-shell-command "grep command: "
  1503. cmd
  1504. 'grep-find-history))
  1505. (error "My-Rgrep: Command for rgrep not found")
  1506. )))
  1507. (compilation-start command-args
  1508. 'grep-mode))
  1509. ;; (defun my-rgrep-symbol-at-point (command-args)
  1510. ;; "My recursive grep. Run COMMAND-ARGS."
  1511. ;; (interactive (list (read-shell-command "grep command: "
  1512. ;; (concat (my-rgrep-grep-command)
  1513. ;; " "
  1514. ;; (thing-at-point 'symbol))
  1515. ;; 'grep-find-history)))
  1516. ;; (compilation-start command-args
  1517. ;; 'grep-mode))
  1518. (defmacro define-my-rgrep (name)
  1519. "Define rgrep for NAME."
  1520. `(defun ,(intern (concat "my-rgrep-"
  1521. name)) ()
  1522. ,(format "My recursive grep by %s."
  1523. name)
  1524. (interactive)
  1525. (let ((my-rgrep-default ,name))
  1526. (if (called-interactively-p 'any)
  1527. (call-interactively 'my-rgrep)
  1528. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1529. )
  1530. (define-my-rgrep "ack")
  1531. (define-my-rgrep "ag")
  1532. (define-my-rgrep "gitgrep")
  1533. (define-my-rgrep "grep")
  1534. (define-my-rgrep "global")
  1535. (define-key ctl-x-map "s" 'my-rgrep)
  1536. ;; (defun make ()
  1537. ;; "Run \"make -k\" in current directory."
  1538. ;; (interactive)
  1539. ;; (compile "make -k"))
  1540. (defalias 'make 'compile)
  1541. (define-key ctl-x-map "c" 'compile)
  1542. ;;;;;;;;;;;;;;;;;;;;;;;
  1543. ;; adoc-simple-mode
  1544. (when (safe-require-or-eval 'adoc-mode)
  1545. (defvar adoc-simple-font-lock-keywords
  1546. nil)
  1547. (define-derived-mode adoc-simple-mode adoc-mode
  1548. "Adoc-Simple"
  1549. "Major mode for editing AsciiDoc text files.
  1550. This mode is a simplified version of `adoc-mode'."
  1551. '(set (make-local-variable 'font-lock-defaults)
  1552. '(adoc-simple-font-lock-keywords
  1553. nil nil nil nil
  1554. (font-lock-multiline . t)
  1555. (font-lock-mark-block-function . adoc-font-lock-mark-block-function))))
  1556. (add-to-list 'auto-mode-alist
  1557. '("\\.adoc\\'" . adoc-simple-mode)))
  1558. (when (and (safe-require-or-eval 'google-translate)
  1559. (safe-require-or-eval 'google-translate-smooth-ui))
  1560. (add-to-list 'google-translate-translation-directions-alist
  1561. '("en" . "ja"))
  1562. (defun translate-echo-at-point ()
  1563. "Translate popup at point."
  1564. (interactive)
  1565. (let ((google-translate-output-destination 'echo-area))
  1566. (google-translate-translate "auto" "ja" (current-word t t))))
  1567. (define-minor-mode auto-translate-mode
  1568. "Translate word at point automatically."
  1569. :global nil
  1570. :lighter "ATranslate"))
  1571. ;;; emacs.el ends here