Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

1823 righe
61 KiB

  1. ;;; emacs.el --- 10sr emacs initialization
  2. ;;; Commentary:
  3. ;;; Code:
  4. ;; SETUP_LOAD: (let ((file "DOTFILES_DIR/emacs.el"))
  5. ;; SETUP_LOAD: (and (file-readable-p file)
  6. ;; SETUP_LOAD: (load-file file)))
  7. (setq debug-on-error t)
  8. ;; make directories
  9. (unless (file-directory-p (expand-file-name user-emacs-directory))
  10. (make-directory (expand-file-name user-emacs-directory)))
  11. (let ((d (expand-file-name (concat user-emacs-directory
  12. "lisp"))))
  13. (unless (file-directory-p d)
  14. (make-directory d))
  15. (add-to-list 'load-path d))
  16. (require 'cl-lib)
  17. (require 'simple)
  18. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  19. ;; Some macros for internals
  20. ;; `emacs --load emacs.el` with Emacs 24.3 requires with-eval-after-load to be
  21. ;; defined at the toplevel (means that it should not be defined inside of some
  22. ;; special forms like `when'. I do not now how to do with about this...)
  23. (unless (fboundp 'with-eval-after-load)
  24. ;; polyfill for Emacs < 24.4
  25. (defmacro with-eval-after-load (file &rest body)
  26. "After FILE is loaded execute BODY."
  27. (declare (indent 1) (debug t))
  28. `(eval-after-load ,file (quote (progn ,@body)))))
  29. (defun call-after-init (func)
  30. "If `after-init-hook' has been run, call FUNC immediately.
  31. Otherwize hook it."
  32. (if after-init-time
  33. (funcall func)
  34. (add-hook 'after-init-hook
  35. func)))
  36. (defmacro safe-require-or-eval (feature)
  37. "Require FEATURE if available.
  38. At compile time the feature will be loaded immediately."
  39. `(eval-and-compile
  40. (message "safe-require-or-eval: Trying to require %s" ,feature)
  41. (require ,feature nil t)))
  42. (defmacro autoload-eval-lazily (feature &optional functions &rest body)
  43. "Define autoloading FEATURE that defines FUNCTIONS.
  44. FEATURE is a symbol. FUNCTIONS is a list of symbols. If FUNCTIONS is nil,
  45. the function same as FEATURE is defined as autoloaded function. BODY is passed
  46. to `eval-after-load'.
  47. After this macro is expanded, this returns the path to library if FEATURE
  48. found, otherwise returns nil."
  49. (declare (indent 2) (debug t))
  50. (let* ((libname (symbol-name (eval feature)))
  51. (libpath (locate-library libname)))
  52. `(progn
  53. (when (locate-library ,libname)
  54. ,@(mapcar (lambda (f)
  55. `(unless (fboundp ',f)
  56. (progn
  57. (message "Autoloaded function `%S' defined (%s)"
  58. (quote ,f)
  59. ,libpath)
  60. (autoload (quote ,f)
  61. ,libname
  62. ,(concat "Autoloaded function defined in \""
  63. libpath
  64. "\".")
  65. t))))
  66. (or (eval functions)
  67. `(,(eval feature)))))
  68. (eval-after-load ,feature
  69. (quote (progn
  70. ,@body)))
  71. (locate-library ,libname))))
  72. (when (autoload-eval-lazily 'tetris nil
  73. (message "Tetris loaded!"))
  74. (message "Tetris found!"))
  75. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  76. ;; package
  77. (set (defvar 10sr-package-list)
  78. '(
  79. markdown-mode
  80. yaml-mode
  81. gnuplot-mode
  82. php-mode
  83. erlang
  84. js2-mode
  85. js-doc
  86. git-commit
  87. gitignore-mode
  88. adoc-mode
  89. malabar-mode
  90. ;; ack
  91. color-moccur
  92. ggtags
  93. flycheck
  94. auto-highlight-symbol
  95. ;; is flymake installs are required?
  96. ;;flymake-jshint
  97. ;;flymake-python-pyflakes
  98. xclip
  99. foreign-regexp
  100. multi-term
  101. term-run
  102. editorconfig
  103. git-ps1-mode
  104. restart-emacs
  105. fill-column-indicator
  106. pkgbuild-mode
  107. minibuffer-line
  108. which-key
  109. scala-mode
  110. ensime
  111. editorconfig
  112. cyberpunk-theme
  113. grandshell-theme
  114. afternoon-theme
  115. git-command
  116. prompt-text
  117. ;; 10sr repository
  118. ;; 10sr-extras
  119. terminal-title
  120. recentf-show
  121. dired-list-all-mode
  122. pack
  123. set-modeline-color
  124. read-only-only-mode
  125. smart-revert
  126. autosave
  127. ;;window-organizer
  128. remember-major-modes-mode
  129. ilookup
  130. pasteboard
  131. end-mark
  132. sl
  133. gosh-mode
  134. ))
  135. (when (safe-require-or-eval 'package)
  136. (setq package-archives
  137. `(,@package-archives
  138. ("melpa" . "https://melpa.org/packages/")
  139. ("10sr-el" . "https://10sr.github.io/emacs-lisp/p/")))
  140. (package-initialize)
  141. (defun my-auto-install-package ()
  142. "Install packages semi-automatically."
  143. (interactive)
  144. (package-refresh-contents)
  145. (mapc (lambda (pkg)
  146. (or (package-installed-p pkg)
  147. (package-install pkg)))
  148. 10sr-package-list))
  149. )
  150. ;; (lazy-load-eval 'sudoku)
  151. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  152. ;; my-idle-hook
  153. (defvar my-idle-hook nil
  154. "Hook run when idle for several secs.")
  155. (defvar my-idle-hook-sec 5
  156. "Second to run `my-idle-hook'.")
  157. (run-with-idle-timer my-idle-hook-sec
  158. t
  159. (lambda ()
  160. (run-hooks 'my-idle-hook)))
  161. ;; (add-hook 'my-idle-hook
  162. ;; (lambda ()
  163. ;; (message "idle hook message")))
  164. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  165. ;; start and quit
  166. (setq inhibit-startup-message t)
  167. (setq confirm-kill-emacs 'y-or-n-p)
  168. (setq gc-cons-threshold (* 1024 1024 4))
  169. (when window-system
  170. (add-to-list 'default-frame-alist '(cursor-type . box))
  171. (add-to-list 'default-frame-alist '(background-color . "white"))
  172. (add-to-list 'default-frame-alist '(foreground-color . "gray10"))
  173. ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100)))
  174. ;; does not work?
  175. )
  176. ;; (add-to-list 'default-frame-alist '(cursor-type . box))
  177. (if window-system (menu-bar-mode 1) (menu-bar-mode 0))
  178. (and (fboundp 'tool-bar-mode)
  179. (tool-bar-mode 0))
  180. (and (fboundp 'set-scroll-bar-mode)
  181. (set-scroll-bar-mode nil))
  182. (add-hook 'kill-emacs-hook
  183. ;; load init file when terminating emacs to ensure file is not broken
  184. 'reload-init-file)
  185. (defun my-force-kill-emacs ()
  186. "My force kill Emacs."
  187. (interactive)
  188. (let ((kill-emacs-hook nil))
  189. (kill-emacs)))
  190. (call-after-init
  191. (lambda ()
  192. (message "%s %s" invocation-name emacs-version)
  193. (message "Invocation directory: %s" default-directory)
  194. (message "%s was taken to initialize emacs." (emacs-init-time))
  195. (switch-to-buffer "*Messages*")))
  196. (cd ".") ; when using windows use / instead of \ in `default-directory'
  197. ;; locale
  198. (set-language-environment "Japanese")
  199. (set-default-coding-systems 'utf-8-unix)
  200. (prefer-coding-system 'utf-8-unix)
  201. (setq system-time-locale "C")
  202. ;; my prefix map
  203. (defvar my-prefix-map nil
  204. "My prefix map.")
  205. (define-prefix-command 'my-prefix-map)
  206. (define-key ctl-x-map (kbd "C-x") 'my-prefix-map)
  207. (define-key my-prefix-map (kbd "C-q") 'quoted-insert)
  208. (define-key my-prefix-map (kbd "C-z") 'suspend-frame)
  209. ;; (comint-show-maximum-output)
  210. ;; kill scratch
  211. (call-after-init (lambda ()
  212. (let ((buf (get-buffer "*scratch*")))
  213. (when buf
  214. (kill-buffer buf)))))
  215. ;; modifier keys
  216. ;; (setq mac-option-modifier 'control)
  217. ;; display
  218. (setq visible-bell t)
  219. (setq ring-bell-function 'ignore)
  220. (mouse-avoidance-mode 'banish)
  221. (setq echo-keystrokes 0.1)
  222. (defun reload-init-file ()
  223. "Reload Emacs init file."
  224. (interactive)
  225. (when (and user-init-file
  226. (file-readable-p user-init-file))
  227. (load-file user-init-file)))
  228. (safe-require-or-eval 'session)
  229. ;; server
  230. (set-variable 'server-name (concat "server"
  231. (number-to-string (emacs-pid))))
  232. ;; In Cygwin Environment `server-runnning-p' stops when server-use-tcp is nil
  233. ;; In Darwin environment, init fails with message like 'Service name too long'
  234. ;; when server-use-tcp is nil
  235. (when (or (eq system-type
  236. 'cygwin)
  237. (eq system-type
  238. 'darwin))
  239. (set-variable 'server-use-tcp t))
  240. ;; MSYS2 fix
  241. (when (eq system-type
  242. 'windows-nt)
  243. (setq shell-file-name
  244. (executable-find "bash"))
  245. '(setq function-key-map
  246. `(,@function-key-map ([pause] . [?\C-c])
  247. ))
  248. (define-key key-translation-map
  249. (kbd "<pause>")
  250. (kbd "C-c"))
  251. '(keyboard-translate [pause]
  252. (kbd "C-c")p)
  253. ;; TODO: move to other place later
  254. (when (not window-system)
  255. (setq interprogram-paste-function nil)
  256. (setq interprogram-cut-function nil)))
  257. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  258. ;; global keys
  259. (global-set-key (kbd "<up>") 'scroll-down-line)
  260. (global-set-key (kbd "<down>") 'scroll-up-line)
  261. (global-set-key (kbd "<left>") 'scroll-down)
  262. (global-set-key (kbd "<right>") 'scroll-up)
  263. ;; (define-key my-prefix-map (kbd "C-h") help-map)
  264. (global-set-key (kbd "C-\\") help-map)
  265. (define-key ctl-x-map (kbd "DEL") help-map)
  266. (define-key ctl-x-map (kbd "C-h") help-map)
  267. (define-key help-map "a" 'apropos)
  268. ;; disable annoying keys
  269. (global-set-key [prior] 'ignore)
  270. (global-set-key (kbd "<next>") 'ignore)
  271. (global-set-key [menu] 'ignore)
  272. (global-set-key [down-mouse-1] 'ignore)
  273. (global-set-key [down-mouse-2] 'ignore)
  274. (global-set-key [down-mouse-3] 'ignore)
  275. (global-set-key [mouse-1] 'ignore)
  276. (global-set-key [mouse-2] 'ignore)
  277. (global-set-key [mouse-3] 'ignore)
  278. (global-set-key (kbd "<eisu-toggle>") 'ignore)
  279. (global-set-key (kbd "C-<eisu-toggle>") 'ignore)
  280. (when (safe-require-or-eval 'which-key)
  281. (which-key-mode))
  282. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  283. ;; editting
  284. (defun my-copy-whole-line ()
  285. "Copy whole line."
  286. (interactive)
  287. (kill-new (concat (buffer-substring (point-at-bol)
  288. (point-at-eol))
  289. "\n")))
  290. (setq require-final-newline t)
  291. (setq kill-whole-line t)
  292. (setq scroll-conservatively 35
  293. scroll-margin 2
  294. scroll-step 0)
  295. (setq-default major-mode 'text-mode)
  296. (setq next-line-add-newlines nil)
  297. (setq kill-read-only-ok t)
  298. (setq truncate-partial-width-windows nil) ; when splitted horizontally
  299. ;; (setq-default line-spacing 0.2)
  300. (setq-default indicate-empty-lines t) ; when using x indicate empty line
  301. (setq-default tab-width 4)
  302. (setq-default indent-tabs-mode nil)
  303. (setq-default indent-line-function nil)
  304. (setq-default truncate-lines nil)
  305. ;; (pc-selection-mode 1) ; make some already defined keybind back to default
  306. (delete-selection-mode 1)
  307. (cua-mode 0)
  308. (setq line-move-visual nil)
  309. ;; key bindings
  310. ;; moving around
  311. ;; (global-set-key (kbd "M-j") 'next-line)
  312. ;; (global-set-key (kbd "M-k") 'previous-line)
  313. ;; (global-set-key (kbd "M-h") 'backward-char)
  314. ;; (global-set-key (kbd "M-l") 'forward-char)
  315. ;;(keyboard-translate ?\M-j ?\C-j)
  316. ;; (global-set-key (kbd "M-p") 'backward-paragraph)
  317. (define-key esc-map "p" 'backward-paragraph)
  318. ;; (global-set-key (kbd "M-n") 'forward-paragraph)
  319. (define-key esc-map "n" 'forward-paragraph)
  320. (global-set-key (kbd "C-<up>") 'scroll-down-line)
  321. (global-set-key (kbd "C-<down>") 'scroll-up-line)
  322. (global-set-key (kbd "C-<left>") 'scroll-down)
  323. (global-set-key (kbd "C-<right>") 'scroll-up)
  324. (global-set-key (kbd "<select>") 'ignore) ; 'previous-line-mark)
  325. (define-key ctl-x-map (kbd "ESC x") 'execute-extended-command)
  326. (define-key ctl-x-map (kbd "ESC :") 'eval-expression)
  327. ;; C-h and DEL
  328. (global-set-key (kbd "C-h") (kbd "DEL"))
  329. (global-set-key (kbd "C-m") 'reindent-then-newline-and-indent)
  330. (global-set-key (kbd "C-o") (kbd "C-e C-m"))
  331. (define-key esc-map "k" 'my-copy-whole-line)
  332. ;; (global-set-key "\C-z" 'undo) ; undo is M-u
  333. (define-key esc-map "u" 'undo)
  334. (define-key esc-map "i" (kbd "ESC TAB"))
  335. ;; (global-set-key (kbd "C-r") 'query-replace-regexp)
  336. (global-set-key (kbd "C-s") 'isearch-forward-regexp)
  337. (global-set-key (kbd "C-r") 'isearch-backward-regexp)
  338. (define-key my-prefix-map (kbd "C-o") 'occur)
  339. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  340. ;; title and mode-line
  341. (when (safe-require-or-eval 'terminal-title)
  342. ;; if TERM is not screen use default value
  343. (if (getenv "TMUX")
  344. ;; if use tmux locally just basename of current dir
  345. (set-variable 'terminal-title-format
  346. '((file-name-nondirectory (directory-file-name
  347. default-directory))))
  348. (if (and (let ((tty-type (frame-parameter nil
  349. 'tty-type)))
  350. (and tty-type
  351. (equal (car (split-string tty-type
  352. "-"))
  353. "screen")))
  354. (not (getenv "SSH_CONNECTION")))
  355. (set-variable 'terminal-title-format
  356. '((file-name-nondirectory (directory-file-name
  357. default-directory))))
  358. ;; seems that TMUX is used locally and ssh to remote host
  359. (set-variable 'terminal-title-format
  360. `("em:"
  361. ,user-login-name
  362. "@"
  363. ,(car (split-string system-name
  364. "\\."))
  365. ":"
  366. default-directory))
  367. )
  368. )
  369. (terminal-title-mode))
  370. (setq eol-mnemonic-dos "\\r\\n")
  371. (setq eol-mnemonic-mac "\\r")
  372. (setq eol-mnemonic-unix "\\n")
  373. (which-function-mode 0)
  374. (line-number-mode 0)
  375. (column-number-mode 0)
  376. (size-indication-mode 0)
  377. (setq mode-line-position
  378. '(:eval (format "L%%l/%d,C%%c"
  379. (count-lines (point-max)
  380. (point-min)))))
  381. (when (safe-require-or-eval 'git-ps1-mode)
  382. (git-ps1-mode))
  383. ;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title
  384. ;; display date
  385. (when (safe-require-or-eval 'time)
  386. (setq display-time-interval 29)
  387. (setq display-time-day-and-date t)
  388. (setq display-time-format "%Y/%m/%d %a %H:%M")
  389. ;; (if window-system
  390. ;; (display-time-mode 0)
  391. ;; (display-time-mode 1))
  392. (when display-time-mode
  393. (display-time-update)))
  394. ;; ;; current directory
  395. ;; (let ((ls (member 'mode-line-buffer-identification
  396. ;; mode-line-format)))
  397. ;; (setcdr ls
  398. ;; (cons '(:eval (concat " ("
  399. ;; (abbreviate-file-name default-directory)
  400. ;; ")"))
  401. ;; (cdr ls))))
  402. ;; ;; display last modified time
  403. ;; (let ((ls (member 'mode-line-buffer-identification
  404. ;; mode-line-format)))
  405. ;; (setcdr ls
  406. ;; (cons '(:eval (concat " "
  407. ;; my-buffer-file-last-modified-time))
  408. ;; (cdr ls))))
  409. (defun buffer-list-not-start-with-space ()
  410. "Return a list of buffers that not start with whitespaces."
  411. (let ((bl (buffer-list))
  412. b nbl)
  413. (while bl
  414. (setq b (pop bl))
  415. (unless (string-equal " "
  416. (substring (buffer-name b)
  417. 0
  418. 1))
  419. (add-to-list 'nbl b)))
  420. nbl))
  421. ;; http://www.masteringemacs.org/articles/2012/09/10/hiding-replacing-modeline-strings/
  422. ;; (add-to-list 'minor-mode-alist
  423. ;; '(global-whitespace-mode ""))
  424. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  425. ;; minibuffer
  426. (setq insert-default-directory t)
  427. (setq completion-ignore-case t
  428. read-file-name-completion-ignore-case t
  429. read-buffer-completion-ignore-case t)
  430. (setq resize-mini-windows t)
  431. (temp-buffer-resize-mode 1)
  432. (savehist-mode 1)
  433. (fset 'yes-or-no-p 'y-or-n-p)
  434. ;; complete symbol when `eval'
  435. (define-key read-expression-map (kbd "TAB") 'completion-at-point)
  436. (define-key minibuffer-local-map (kbd "C-u")
  437. (lambda () (interactive) (delete-region (point-at-bol) (point))))
  438. ;; I dont know these bindings are good
  439. (define-key minibuffer-local-map (kbd "C-p") (kbd "ESC p"))
  440. (define-key minibuffer-local-map (kbd "C-n") (kbd "ESC n"))
  441. (when (safe-require-or-eval 'minibuffer-line)
  442. (set-face-underline 'minibuffer-line nil)
  443. (set-variable 'minibuffer-line-refresh-interval
  444. 25)
  445. (set-variable 'minibuffer-line-format
  446. `(,(concat user-login-name
  447. "@"
  448. (car (split-string system-name
  449. "\\."))
  450. ":")
  451. (:eval (abbreviate-file-name (or buffer-file-name
  452. default-directory)))
  453. (:eval (and (fboundp 'git-ps1-mode-get-current)
  454. (git-ps1-mode-get-current " [GIT:%s]")))
  455. " "
  456. (:eval (format-time-string display-time-format))))
  457. (minibuffer-line-mode 1)
  458. )
  459. (when (safe-require-or-eval 'prompt-text)
  460. (set-variable 'prompt-text-format
  461. `(,(concat ""
  462. user-login-name
  463. "@"
  464. (car (split-string system-name
  465. "\\."))
  466. ":")
  467. (:eval (abbreviate-file-name (or buffer-file-name
  468. default-directory)))
  469. (:eval (and (fboundp 'git-ps1-mode-get-current)
  470. (git-ps1-mode-get-current " [GIT:%s]")))
  471. " "
  472. (:eval (format-time-string display-time-format))
  473. "\n"
  474. (:eval (symbol-name this-command))
  475. ": "))
  476. (prompt-text-mode 1))
  477. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  478. ;; letters, font-lock mode and fonts
  479. ;; (set-face-background 'vertical-border (face-foreground 'mode-line))
  480. ;; (set-window-margins (selected-window) 1 1)
  481. (and (or (eq system-type 'Darwin)
  482. (eq system-type 'darwin))
  483. (fboundp 'mac-set-input-method-parameter)
  484. (mac-set-input-method-parameter 'japanese 'cursor-color "red")
  485. (mac-set-input-method-parameter 'roman 'cursor-color "black"))
  486. (when (and (boundp 'input-method-activate-hook) ; i dont know this is correct
  487. (boundp 'input-method-inactivate-hook))
  488. (add-hook 'input-method-activate-hook
  489. (lambda () (set-cursor-color "red")))
  490. (add-hook 'input-method-inactivate-hook
  491. (lambda () (set-cursor-color "black"))))
  492. (when (safe-require-or-eval 'paren)
  493. (show-paren-mode 1)
  494. (setq show-paren-delay 0.5
  495. show-paren-style 'parenthesis) ; mixed is hard to read
  496. ;; (set-face-background 'show-paren-match
  497. ;; "black")
  498. ;; ;; (face-foreground 'default))
  499. ;; (set-face-foreground 'show-paren-match
  500. ;; "white")
  501. ;; (set-face-inverse-video-p 'show-paren-match
  502. ;; t)
  503. )
  504. (transient-mark-mode 1)
  505. (global-font-lock-mode 1)
  506. (setq font-lock-global-modes
  507. '(not
  508. help-mode
  509. eshell-mode
  510. ;;term-mode
  511. Man-mode))
  512. ;; (standard-display-ascii ?\n "$\n")
  513. ;; (defvar my-eol-face
  514. ;; '(("\n" . (0 font-lock-comment-face t nil)))
  515. ;; )
  516. ;; (defvar my-tab-face
  517. ;; '(("\t" . '(0 highlight t nil))))
  518. (defvar my-jspace-face
  519. '(("\u3000" . '(0 highlight t nil))))
  520. (add-hook 'font-lock-mode-hook
  521. (lambda ()
  522. ;; (font-lock-add-keywords nil my-eol-face)
  523. (font-lock-add-keywords nil my-jspace-face)
  524. ))
  525. (when (safe-require-or-eval 'whitespace)
  526. (add-to-list 'whitespace-display-mappings ; not work
  527. `(tab-mark ?\t ,(vconcat "^I\t")))
  528. ;; (add-to-list 'whitespace-display-mappings
  529. ;; `(newline-mark ?\n ,(vconcat "$\n")))
  530. (setq whitespace-style '(face
  531. trailing ; trailing blanks
  532. newline ; newlines
  533. newline-mark ; use display table for newline
  534. tab-mark
  535. empty ; empty lines at beg or end of buffer
  536. lines-tail ; lines over 80
  537. ))
  538. ;; (setq whitespace-newline 'font-lock-comment-face)
  539. (set-variable 'whitespace-line-column nil)
  540. (global-whitespace-mode t)
  541. (add-hook 'dired-mode-hook
  542. (lambda ()
  543. (set (make-local-variable 'whitespace-style) nil)))
  544. (if (eq (display-color-cells)
  545. 256)
  546. (set-face-foreground 'whitespace-newline "color-109")
  547. ;; (progn
  548. ;; (set-face-bold-p 'whitespace-newline
  549. ;; t))
  550. ))
  551. (and nil
  552. (safe-require-or-eval 'fill-column-indicator)
  553. (setq fill-column-indicator))
  554. ;; highlight current line
  555. ;; http://wiki.riywo.com/index.php?Meadow
  556. (face-spec-set 'hl-line
  557. '((((min-colors 256)
  558. (background dark))
  559. (:background "color-234"))
  560. (((min-colors 256)
  561. (background light))
  562. (:background "color-234"))
  563. (t
  564. (:underline "black"))))
  565. (set-variable 'hl-line-global-modes
  566. '(not
  567. term-mode))
  568. (global-hl-line-mode 1) ;; (hl-line-mode 1)
  569. (set-face-foreground 'font-lock-regexp-grouping-backslash "#666")
  570. (set-face-foreground 'font-lock-regexp-grouping-construct "#f60")
  571. ;;(safe-require-or-eval 'set-modeline-color)
  572. ;; (let ((fg (face-foreground 'default))
  573. ;; (bg (face-background 'default)))
  574. ;; (set-face-background 'mode-line-inactive
  575. ;; (if (face-inverse-video-p 'mode-line) fg bg))
  576. ;; (set-face-foreground 'mode-line-inactive
  577. ;; (if (face-inverse-video-p 'mode-line) bg fg)))
  578. ;; (set-face-underline 'mode-line-inactive
  579. ;; t)
  580. ;; (set-face-underline 'vertical-border
  581. ;; nil)
  582. (when (safe-require-or-eval 'end-mark)
  583. (global-end-mark-mode))
  584. (when (safe-require-or-eval 'auto-highlight-symbol)
  585. (set-variable 'ahs-idle-interval 0.6)
  586. (global-auto-highlight-symbol-mode 1))
  587. (when (safe-require-or-eval 'cyberpunk-theme)
  588. (load-theme 'cyberpunk t)
  589. (set-face-attribute 'button
  590. nil
  591. :inherit 'highlight)
  592. (set-face-foreground 'mode-line-inactive
  593. "white")
  594. )
  595. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  596. ;; file handling
  597. (when (safe-require-or-eval 'editorconfig)
  598. ;; (set-variable 'editorconfig-get-properties-function
  599. ;; 'editorconfig-core-get-properties-hash)
  600. (editorconfig-mode 1))
  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