25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

1825 lines
61 KiB

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