You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

2433 rivejä
83 KiB

  1. ;;; emacs.el --- 10sr emacs initialization
  2. ;;; Commentary:
  3. ;;; Code:
  4. ;; (and (file-readable-p "~/.dotfiles/emacs.el")
  5. ;; (load-file "~/.dotfiles/emacs.el"))
  6. ;; make directories
  7. (unless (file-directory-p (expand-file-name user-emacs-directory))
  8. (make-directory (expand-file-name user-emacs-directory)))
  9. (let ((d (expand-file-name (concat user-emacs-directory
  10. "lisp"))))
  11. (unless (file-directory-p d)
  12. (make-directory d))
  13. (add-to-list 'load-path d))
  14. (eval-when-compile
  15. (require 'cl nil t))
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. ;; download library from web
  18. (defun fetch-library (url &optional byte-compile-p force-download-p)
  19. "Download a library from URL and locate it in \"~/emacs.d/lisp/\".
  20. Return nil if library unfound and failed to download,
  21. otherwise the path where the library installed.
  22. If BYTE-COMPILE-P is t byte compile the file after downloading.
  23. If FORCE-DOWNLOAD-P it t ignore exisiting library and always download."
  24. (let* ((dir (expand-file-name (concat user-emacs-directory "lisp/")))
  25. (lib (file-name-sans-extension (file-name-nondirectory url)))
  26. (lpath (concat dir lib ".el"))
  27. (locate-p (locate-library lib)))
  28. (if (or force-download-p (not locate-p))
  29. (if (progn (message "Downloading %s..."
  30. url)
  31. (download-file url
  32. lpath
  33. t))
  34. (progn (message "Downloading %s...done"
  35. url)
  36. (when (and byte-compile-p
  37. (require 'bytecomp nil t))
  38. (and (file-exists-p (byte-compile-dest-file lpath))
  39. (delete-file (byte-compile-dest-file lpath)))
  40. (byte-compile-file lpath)))
  41. (progn (and (file-writable-p lpath)
  42. (delete-file lpath))
  43. (message "Downloading %s...failed"
  44. url))))
  45. (locate-library lib)))
  46. (defun download-file (url path &optional ok-if-already-exists)
  47. "Download file from URL and output to PATH.
  48. IF OK-IF-ALREADY-EXISTS is true force download."
  49. (or
  50. (let ((curl (executable-find "curl")))
  51. (when curl
  52. (if (and (not ok-if-already-exists)
  53. (file-exists-p path))
  54. nil
  55. (and (eq 0
  56. (call-process curl
  57. nil
  58. nil
  59. nil
  60. "--output"
  61. path
  62. url
  63. ))
  64. path))))
  65. (ignore-errors
  66. (require 'url)
  67. (url-copy-file url
  68. path
  69. ok-if-already-exists)
  70. path)))
  71. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  72. ;; package
  73. (defvar my-package-list nil
  74. "Package list just for me.")
  75. (setq my-package-list
  76. '(
  77. markdown-mode
  78. yaml-mode
  79. ;; ack
  80. color-moccur
  81. gtags
  82. )
  83. )
  84. (when (require 'package nil t)
  85. (add-to-list 'package-archives
  86. '("ELPA" . "http://tromey.com/elpa/"))
  87. (add-to-list 'package-archives
  88. '("melpa" . "http://melpa.milkbox.net/packages/")
  89. t)
  90. (add-to-list 'package-archives
  91. '("marmalade" . "http://marmalade-repo.org/packages/"))
  92. (package-initialize)
  93. ;; (package-refresh-contents)
  94. (defun my-auto-install-package ()
  95. "Install packages semi-automatically."
  96. (interactive)
  97. (mapc (lambda (pkg)
  98. (or (package-installed-p pkg)
  99. (locate-library (symbol-name pkg))
  100. (package-install pkg)))
  101. my-package-list))
  102. )
  103. ;; (lazy-load-eval 'sudoku)
  104. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  105. ;; autoload
  106. (defmacro lazy-load-eval (feature &optional functions &rest body)
  107. "Define autoloading FEATURE that defines FUNCTIONS.
  108. FEATURE is a symbol. FUNCTIONS is a list of symbols. If FUNCTIONS is nil,
  109. the function same as FEATURE is defined as autoloaded function. BODY is passed
  110. to `eval-after-load'.
  111. When this macro is evaluated, this returns the path to library if FEATURE
  112. found, otherwise returns nil."
  113. (let* ((libname (symbol-name (eval feature)))
  114. (libpath (locate-library libname)))
  115. (and libpath
  116. `(progn
  117. ,@(mapcar (lambda (f)
  118. (unless (fboundp f)
  119. `(progn
  120. (message "Autoloaded function `%S' defined (%s)"
  121. (quote ,f)
  122. ,libpath)
  123. (autoload (quote ,f)
  124. ,libname
  125. ,(concat "Autoloaded function defined in \""
  126. libpath
  127. "\".")
  128. t))))
  129. (or (eval functions)
  130. `(,(eval feature))))
  131. (eval-after-load ,feature
  132. (quote (progn
  133. ,@body)))
  134. (locate-library ,libname)))))
  135. (put 'lazy-load-eval 'lisp-indent-function 2)
  136. (when (lazy-load-eval 'tetris nil
  137. (message "Tetris loaded!"))
  138. (message "Tetris found!"))
  139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  140. ;; my-idle-hook
  141. (defvar my-idle-hook nil
  142. "Hook run when idle for several secs.")
  143. (defvar my-idle-hook-sec 5
  144. "Second to run `my-idle-hook'.")
  145. (run-with-idle-timer my-idle-hook-sec
  146. t
  147. (lambda ()
  148. (run-hooks 'my-idle-hook)))
  149. ;; (add-hook 'my-idle-hook
  150. ;; (lambda ()
  151. ;; (message "idle hook message")))
  152. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  153. ;; start and quit
  154. (setq inhibit-startup-message t)
  155. (setq confirm-kill-emacs 'y-or-n-p)
  156. (setq gc-cons-threshold (* 1024 1024 4))
  157. (when window-system
  158. (add-to-list 'default-frame-alist '(cursor-type . box))
  159. (add-to-list 'default-frame-alist '(background-color . "white"))
  160. (add-to-list 'default-frame-alist '(foreground-color . "gray10"))
  161. ;; (add-to-list 'default-frame-alist '(alpha . (80 100 100 100)))
  162. ;; does not work?
  163. )
  164. ;; (add-to-list 'default-frame-alist '(cursor-type . box))
  165. (if window-system (menu-bar-mode 1) (menu-bar-mode 0))
  166. (and (fboundp 'tool-bar-mode)
  167. (tool-bar-mode 0))
  168. (and (fboundp 'set-scroll-bar-mode)
  169. (set-scroll-bar-mode nil))
  170. (add-hook 'kill-emacs-hook
  171. ;; load init file when terminating emacs to ensure file is not broken
  172. 'reload-init-file)
  173. (add-hook 'after-init-hook
  174. (lambda ()
  175. (message "%s %s" invocation-name emacs-version)
  176. (message "%s was taken to initialize emacs." (emacs-init-time))
  177. (switch-to-buffer "*Messages*")
  178. ))
  179. (cd ".") ; when using windows use / instead of \ in `default-directory'
  180. ;; locale
  181. (set-language-environment "Japanese")
  182. (set-default-coding-systems 'utf-8-unix)
  183. (prefer-coding-system 'utf-8-unix)
  184. (setq system-time-locale "C")
  185. ;; my prefix map
  186. (defvar my-prefix-map nil
  187. "My prefix map.")
  188. (define-prefix-command 'my-prefix-map)
  189. (define-key ctl-x-map (kbd "C-x") 'my-prefix-map)
  190. (define-key my-prefix-map (kbd "C-q") 'quoted-insert)
  191. (define-key my-prefix-map (kbd "C-z") 'suspend-frame)
  192. ;; (comint-show-maximum-output)
  193. ;; kill scratch
  194. (add-hook 'after-init-hook
  195. (lambda ()
  196. (kill-buffer "*scratch*")))
  197. ;; modifier keys
  198. ;; (setq mac-option-modifier 'control)
  199. ;; display
  200. (setq redisplay-dont-pause t)
  201. (setq visible-bell t)
  202. (setq ring-bell-function 'ignore)
  203. (mouse-avoidance-mode 'banish)
  204. (and window-system
  205. (fetch-library
  206. "https://raw.github.com/10sr/emacs-lisp/master/save-window-size.el"
  207. t)
  208. (require 'save-window-size nil t))
  209. (defun reload-init-file ()
  210. "Reload Emacs init file."
  211. (interactive)
  212. (when (file-readable-p user-init-file)
  213. (load-file user-init-file)))
  214. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  215. ;; for windows
  216. (defun start-ckw-bash ()
  217. "Start ckw in windows."
  218. (interactive)
  219. (start-process
  220. "ckw_bash"
  221. nil
  222. "C:/Documents and Settings/sr/Application Data/dbx/apps/ckw/ckw.exe"))
  223. ;; command seems to have to be in c drive
  224. (defun my-w32-add-export-path (&rest args)
  225. "Add pathes ARGS for windows."
  226. (mapc (lambda (path)
  227. (add-to-list 'exec-path (expand-file-name path)))
  228. (reverse args))
  229. (setenv "PATH"
  230. (mapconcat 'convert-standard-filename
  231. exec-path
  232. ";")))
  233. (when (eq system-type 'windows-nt)
  234. ;; (setq scheme-program-name "\"c:/Program Files/Gauche/bin/gosh.exe\" -i")
  235. ;; (setq python-python-command "c:/Python26/python.exe")
  236. ;; (define-key my-prefix-map (kbd "C-c") 'start-ckw-bash)
  237. (my-w32-add-export-path "c:/Windows/system"
  238. "c:/Windows/System32"
  239. "c:/Program Files/Git/bin"
  240. "c:/MinGW/bin"
  241. "c:/MinGW/mingw32/bin"
  242. (expand-file-name "~/.local/bin")
  243. (expand-file-name "~/dbx/apps/bin"))
  244. (when window-system
  245. (setq w32-enable-synthesized-fonts t))
  246. (setq w32-apps-modifier 'meta)
  247. (setq file-name-coding-system 'sjis))
  248. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  249. ;; global keys
  250. (global-set-key (kbd "<up>") (lambda() (interactive) (scroll-down 1)))
  251. (global-set-key (kbd "<down>") (lambda() (interactive) (scroll-up 1)))
  252. (global-set-key (kbd "<left>") 'scroll-down)
  253. (global-set-key (kbd "<right>") 'scroll-up)
  254. ;; (define-key my-prefix-map (kbd "C-h") help-map)
  255. (global-set-key (kbd "C-\\") help-map)
  256. (define-key ctl-x-map (kbd "DEL") help-map)
  257. (define-key ctl-x-map (kbd "C-h") help-map)
  258. (define-key help-map "a" 'apropos)
  259. ;; disable annoying keys
  260. (global-set-key [prior] 'ignore)
  261. (global-set-key (kbd "<next>") 'ignore)
  262. (global-set-key [menu] 'ignore)
  263. (global-set-key [down-mouse-1] 'ignore)
  264. (global-set-key [down-mouse-2] 'ignore)
  265. (global-set-key [down-mouse-3] 'ignore)
  266. (global-set-key [mouse-1] 'ignore)
  267. (global-set-key [mouse-2] 'ignore)
  268. (global-set-key [mouse-3] 'ignore)
  269. (global-set-key (kbd "<eisu-toggle>") 'ignore)
  270. (global-set-key (kbd "C-<eisu-toggle>") 'ignore)
  271. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  272. ;; title and mode-line
  273. (when (fetch-library
  274. "https://raw.github.com/10sr/emacs-lisp/master/terminal-title.el"
  275. t)
  276. (require 'terminal-title nil t)
  277. ;; if TERM is not screen use default value
  278. (if (getenv "TMUX")
  279. ;; if use tmux locally just basename of current dir
  280. (setq terminal-title-format
  281. '((file-name-nondirectory (directory-file-name
  282. default-directory))))
  283. (when (equal (car (split-string (frame-parameter nil
  284. 'tty-type)
  285. "-"))
  286. "screen")
  287. (if (getenv "SSH_CONNECTION")
  288. ;; TMUX is not set but TERM is screen:
  289. ;; it seems that TMUX is used by locally and ssh to remote host
  290. (setq terminal-title-format
  291. `("em:"
  292. ,user-login-name
  293. "@"
  294. ,(car (split-string system-name
  295. "\\."))
  296. ":"
  297. (file-name-nondirectory (directory-file-name
  298. default-directory))))
  299. ;; this wont happen? (TMUX is not set, TERM is screen, not ssh-ed)
  300. (setq terminal-title-format
  301. '((file-name-nondirectory (directory-file-name
  302. default-directory)))))))
  303. (terminal-title-mode))
  304. (setq eol-mnemonic-dos "\\r\\n")
  305. (setq eol-mnemonic-mac "\\r")
  306. (setq eol-mnemonic-unix "\\n")
  307. (which-function-mode 0)
  308. (line-number-mode 0)
  309. (column-number-mode 0)
  310. (size-indication-mode 0)
  311. (setq mode-line-position
  312. '(:eval (format "L%%l/%d,C%%c"
  313. (count-lines (point-max)
  314. (point-min)))))
  315. ;; http://www.geocities.jp/simizu_daisuke/bunkei-meadow.html#frame-title
  316. ;; display date
  317. (add-hook 'after-init-hook
  318. (lambda ()
  319. (when display-time-mode
  320. (display-time-update))
  321. ))
  322. (when (require 'time nil t)
  323. (setq display-time-interval 29)
  324. (setq display-time-day-and-date t)
  325. (setq display-time-format "%a, %d %b %Y %T")
  326. (if window-system
  327. (display-time-mode 0)
  328. (display-time-mode 1)))
  329. ;; ;; current directory
  330. ;; (let ((ls (member 'mode-line-buffer-identification
  331. ;; mode-line-format)))
  332. ;; (setcdr ls
  333. ;; (cons '(:eval (concat " ("
  334. ;; (abbreviate-file-name default-directory)
  335. ;; ")"))
  336. ;; (cdr ls))))
  337. ;; ;; display last modified time
  338. ;; (let ((ls (member 'mode-line-buffer-identification
  339. ;; mode-line-format)))
  340. ;; (setcdr ls
  341. ;; (cons '(:eval (concat " "
  342. ;; my-buffer-file-last-modified-time))
  343. ;; (cdr ls))))
  344. (defun buffer-list-not-start-with-space ()
  345. "Return a list of buffers that not start with whitespaces."
  346. (let ((bl (buffer-list))
  347. b nbl)
  348. (while bl
  349. (setq b (pop bl))
  350. (unless (string-equal " "
  351. (substring (buffer-name b)
  352. 0
  353. 1))
  354. (add-to-list 'nbl b)))
  355. nbl))
  356. ;; http://www.masteringemacs.org/articles/2012/09/10/hiding-replacing-modeline-strings/
  357. ;; (add-to-list 'minor-mode-alist
  358. ;; '(global-whitespace-mode ""))
  359. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  360. ;; system info
  361. (defun my-message-current-info ()
  362. "Echo current login name, hostname and directory."
  363. (interactive)
  364. (message "%s@%s:%s"
  365. user-login-name
  366. system-name
  367. (abbreviate-file-name default-directory)))
  368. ;; (run-with-idle-timer 3
  369. ;; t
  370. ;; 'my-message-current-info)
  371. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  372. ;; minibuffer
  373. (setq insert-default-directory t)
  374. (setq completion-ignore-case t
  375. read-file-name-completion-ignore-case t
  376. read-buffer-completion-ignore-case t)
  377. (setq resize-mini-windows t)
  378. (temp-buffer-resize-mode 1)
  379. (savehist-mode 1)
  380. (fset 'yes-or-no-p 'y-or-n-p)
  381. ;; complete symbol when `eval'
  382. (define-key read-expression-map (kbd "TAB") 'lisp-complete-symbol)
  383. (define-key minibuffer-local-map (kbd "C-u")
  384. (lambda () (interactive) (delete-region (point-at-bol) (point))))
  385. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  386. ;; letters, font-lock mode and fonts
  387. ;; (set-face-background 'vertical-border (face-foreground 'mode-line))
  388. ;; (set-window-margins (selected-window) 1 1)
  389. (and (or (eq system-type 'Darwin)
  390. (eq system-type 'darwin))
  391. (fboundp 'mac-set-input-method-parameter)
  392. (mac-set-input-method-parameter 'japanese 'cursor-color "red")
  393. (mac-set-input-method-parameter 'roman 'cursor-color "black"))
  394. (when (and (boundp 'input-method-activate-hook) ; i dont know this is correct
  395. (boundp 'input-method-inactivate-hook))
  396. (add-hook 'input-method-activate-hook
  397. (lambda () (set-cursor-color "red")))
  398. (add-hook 'input-method-inactivate-hook
  399. (lambda () (set-cursor-color "black"))))
  400. (when (require 'paren nil t)
  401. (show-paren-mode 1)
  402. (setq show-paren-delay 0.5
  403. show-paren-style 'parenthesis) ; mixed is hard to read
  404. (set-face-background 'show-paren-match
  405. (face-foreground 'default))
  406. (set-face-inverse-video-p 'show-paren-match
  407. t))
  408. (transient-mark-mode 1)
  409. (global-font-lock-mode 1)
  410. (setq font-lock-global-modes
  411. '(not
  412. help-mode
  413. eshell-mode
  414. term-mode
  415. Man-mode))
  416. ;; (standard-display-ascii ?\n "$\n")
  417. (defvar my-eol-face
  418. '(("\n" . (0 font-lock-comment-face t nil)))
  419. )
  420. (defvar my-tab-face
  421. '(("\t" . '(0 highlight t nil))))
  422. (defvar my-jspace-face
  423. '(("\u3000" . '(0 highlight t nil))))
  424. (add-hook 'font-lock-mode-hook
  425. (lambda ()
  426. ;; (font-lock-add-keywords nil my-eol-face)
  427. (font-lock-add-keywords nil my-jspace-face)
  428. ))
  429. (when (require 'whitespace nil t)
  430. (add-to-list 'whitespace-display-mappings ; not work
  431. `(tab-mark ?\t ,(vconcat "^I\t")))
  432. (add-to-list 'whitespace-display-mappings
  433. `(newline-mark ?\n ,(vconcat "$\n")))
  434. (setq whitespace-style '(face
  435. trailing ; trailing blanks
  436. newline ; newlines
  437. newline-mark ; use display table for newline
  438. ;; tab-mark
  439. empty ; empty lines at beg or end of buffer
  440. lines-tail ; lines over 80
  441. ))
  442. ;; (setq whitespace-newline 'font-lock-comment-face)
  443. (global-whitespace-mode t)
  444. (when (eq (display-color-cells)
  445. 256)
  446. (set-face-foreground 'whitespace-newline "brightblack")))
  447. (and nil
  448. (fetch-library
  449. "http://www.emacswiki.org/emacs/download/fill-column-indicator.el"
  450. t)
  451. (require 'fill-column-indicator nil t)
  452. (setq fill-column-indicator))
  453. ;; highlight current line
  454. ;; http://wiki.riywo.com/index.php?Meadow
  455. (defface my-hl-line
  456. '((((min-colors 256)
  457. (background dark))
  458. (:background "color-234"))
  459. (((min-colors 256)
  460. (background light))
  461. (:background "color-234"))
  462. (t
  463. (:underline "black")))
  464. "*Face used by hl-line.")
  465. (setq hl-line-face 'my-hl-line) ;; (setq hl-line-face nil)
  466. (global-hl-line-mode 1) ;; (hl-line-mode 1)
  467. (setq hl-line-global-modes
  468. '(not
  469. term-mode))
  470. (set-face-foreground 'font-lock-regexp-grouping-backslash "#666")
  471. (set-face-foreground 'font-lock-regexp-grouping-construct "#f60")
  472. ;; fonts
  473. (defun my-set-ascii-and-jp-font (list)
  474. "Set font configuration List."
  475. (let ((fspec1 (if (> emacs-major-version 22)
  476. ;; font spec is available in emacs23 and later
  477. (font-spec :family (nth 2 list) :size (nth 3 list))
  478. (cons (nth 2 list) "jisx0208.*")))
  479. (fspec2 (if (> emacs-major-version 22)
  480. (font-spec :family (nth 2 list) :size (nth 3 list))
  481. (cons (nth 2 list) "jisx0201.*"))))
  482. (set-face-attribute 'default nil
  483. :family (nth 0 list)
  484. :height (nth 1 list))
  485. (set-fontset-font "fontset-default"
  486. 'japanese-jisx0208
  487. fspec1)
  488. (set-fontset-font "fontset-default"
  489. 'katakana-jisx0201
  490. fspec2)))
  491. ;; (my-set-ascii-and-jp-font '("dejavu sans mono" 90 "takaogothic" 13))
  492. ;; (my-set-ascii-and-jp-font '("dejavu sans mono" 100 "takaogothic" 14))
  493. ;; (my-set-ascii-and-jp-font '("dejavu sans mono" 100 "ms gothic" 14))
  494. ;; (my-set-ascii-and-jp-font '("monaco" 75 "takaogothic" 11))
  495. ;; (my-set-ascii-and-jp-font '("monaco" 90 "takaogothic" 13))
  496. ;; (my-set-ascii-and-jp-font '("ProggyCleanTTSZ" 120 "takaogothic" 11))
  497. ;; あ a
  498. (and (fetch-library
  499. "https://raw.github.com/10sr/emacs-lisp/master/set-modeline-color.el"
  500. t)
  501. (progn
  502. (require 'set-modeline-color nil t)))
  503. (let ((fg (face-foreground 'default))
  504. (bg (face-background 'default)))
  505. (set-face-background 'mode-line-inactive
  506. (if (face-inverse-video-p 'mode-line) fg bg))
  507. (set-face-foreground 'mode-line-inactive
  508. (if (face-inverse-video-p 'mode-line) bg fg)))
  509. (set-face-underline 'mode-line-inactive
  510. t)
  511. (set-face-underline 'vertical-border
  512. nil)
  513. (and (fetch-library
  514. "https://raw.github.com/tarao/elisp/master/end-mark.el"
  515. t)
  516. (require 'end-mark nil t)
  517. (global-end-mark-mode))
  518. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  519. ;; file handling
  520. (setq revert-without-query '(".+"))
  521. ;; save cursor position
  522. (setq save-place-file (concat user-emacs-directory
  523. "places"))
  524. (when (require 'saveplace nil t)
  525. (setq-default save-place t))
  526. ;; http://www.bookshelf.jp/soft/meadow_24.html#SEC260
  527. (setq make-backup-files t)
  528. ;; (make-directory (expand-file-name "~/.emacsbackup"))
  529. (setq backup-directory-alist
  530. (cons (cons "\\.*$" (expand-file-name "~/.emacs.d/backup"))
  531. backup-directory-alist))
  532. (setq version-control 'never)
  533. (setq delete-old-versions t)
  534. (setq auto-save-list-file-prefix (expand-file-name "~/.emacs.d/auto-save/"))
  535. (setq delete-auto-save-files t)
  536. (add-to-list 'completion-ignored-extensions ".bak")
  537. ;; (setq delete-by-moving-to-trash t
  538. ;; trash-directory "~/.emacs.d/trash")
  539. (add-hook 'after-save-hook
  540. 'executable-make-buffer-file-executable-if-script-p)
  541. (setq bookmark-default-file "~/.emacs.d/bmk")
  542. (add-hook 'recentf-load-hook
  543. (lambda ()
  544. (add-to-list 'recentf-exclude
  545. (regexp-quote bookmark-default-file))))
  546. (and (fetch-library
  547. "https://raw.github.com/10sr/emacs-lisp/master/read-only-only-mode.el"
  548. t)
  549. (lazy-load-eval 'read-only-only-mode))
  550. (and (fetch-library
  551. "https://raw.github.com/10sr/emacs-lisp/master/smart-revert.el"
  552. t)
  553. (require 'smart-revert nil t)
  554. (smart-revert-on))
  555. ;; autosave
  556. (and (fetch-library
  557. "https://raw.github.com/10sr/emacs-lisp/master/autosave.el"
  558. t)
  559. (require 'autosave nil t)
  560. (autosave-set 2))
  561. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  562. ;; editting
  563. (defun my-copy-whole-line ()
  564. "Copy whole line."
  565. (interactive)
  566. (kill-new (concat (buffer-substring (point-at-bol)
  567. (point-at-eol))
  568. "\n")))
  569. (setq require-final-newline t)
  570. (setq kill-whole-line t)
  571. (setq scroll-conservatively 35
  572. scroll-margin 2
  573. scroll-step 0)
  574. (setq-default major-mode 'text-mode)
  575. (setq next-line-add-newlines nil)
  576. (setq kill-read-only-ok t)
  577. (setq truncate-partial-width-windows nil) ; when splitted horizontally
  578. ;; (setq-default line-spacing 0.2)
  579. (setq-default indicate-empty-lines t) ; when using x indicate empty line
  580. (setq-default tab-width 4)
  581. (setq-default indent-tabs-mode nil)
  582. (setq-default indent-line-function nil)
  583. ;; (pc-selection-mode 1) ; make some already defined keybind back to default
  584. (delete-selection-mode 1)
  585. (cua-mode 0)
  586. (setq line-move-visual nil)
  587. ;; key bindings
  588. ;; moving around
  589. ;; (global-set-key (kbd "M-j") 'next-line)
  590. ;; (global-set-key (kbd "M-k") 'previous-line)
  591. ;; (global-set-key (kbd "M-h") 'backward-char)
  592. ;; (global-set-key (kbd "M-l") 'forward-char)
  593. ;;(keyboard-translate ?\M-j ?\C-j)
  594. ;; (global-set-key (kbd "M-p") 'backward-paragraph)
  595. (define-key esc-map "p" 'backward-paragraph)
  596. ;; (global-set-key (kbd "M-n") 'forward-paragraph)
  597. (define-key esc-map "n" 'forward-paragraph)
  598. (global-set-key (kbd "C-<up>") (lambda () (interactive)(scroll-down 1)))
  599. (global-set-key (kbd "C-<down>") (lambda () (interactive)(scroll-up 1)))
  600. (global-set-key (kbd "C-<left>") 'scroll-down)
  601. (global-set-key (kbd "C-<right>") 'scroll-up)
  602. (global-set-key (kbd "<select>") 'ignore) ; 'previous-line-mark)
  603. (define-key ctl-x-map (kbd "ESC x") 'execute-extended-command)
  604. (define-key ctl-x-map (kbd "ESC :") 'eval-expression)
  605. ;; C-h and DEL
  606. (global-set-key (kbd "C-h") (kbd "DEL"))
  607. (global-set-key (kbd "C-m") 'reindent-then-newline-and-indent)
  608. (global-set-key (kbd "C-o") (kbd "C-e C-m"))
  609. (define-key esc-map "k" 'my-copy-whole-line)
  610. ;; (global-set-key "\C-z" 'undo) ; undo is M-u
  611. (define-key esc-map "u" 'undo)
  612. (define-key esc-map "i" (kbd "ESC TAB"))
  613. ;; (global-set-key (kbd "C-r") 'query-replace-regexp)
  614. (global-set-key (kbd "C-s") 'isearch-forward-regexp)
  615. (global-set-key (kbd "C-r") 'isearch-backward-regexp)
  616. (define-key my-prefix-map (kbd "C-o") 'occur)
  617. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  618. ;; japanese input method
  619. (defun my-load-scim ()
  620. "Use scim-bridge.el as japanese im."
  621. ;; Load scim-bridge.
  622. (when (require 'scim-bridge nil t)
  623. ;; Turn on scim-mode automatically after loading .emacs
  624. (add-hook 'after-init-hook 'scim-mode-on)
  625. (setq scim-cursor-color "red")
  626. (scim-define-preedit-key ?\^h t)
  627. (scim-define-common-key ?\* nil)
  628. (scim-define-common-key ?\^/ nil)))
  629. (defun my-load-anthy ()
  630. "Use anthy.el as japanese im."
  631. ;; anthy
  632. (when (require 'anthy nil t)
  633. (global-set-key
  634. (kbd "<muhenkan>") (lambda () (interactive) (anthy-mode-off)))
  635. (global-set-key (kbd "<henkan>") (lambda () (interactive) (anthy-mode-on)))
  636. (when (>= emacs-major-version 23)
  637. (setq anthy-accept-timeout 1))))
  638. ;; quail
  639. ;; aproposs input-method for some information
  640. ;; (setq default-input-method "japanese")
  641. (defun my-load-mozc-el ()
  642. "Use mozc.el as japanese im."
  643. (setq mozc-leim-title "[MZ]")
  644. (when (require 'mozc nil t)
  645. (setq defauit-input-method "japanese-mozc")
  646. ))
  647. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  648. ;; gmail
  649. (setq mail-interactive t
  650. send-mail-function 'smtpmail-send-it
  651. ;; message-send-mail-function 'smtpmail-send-it
  652. smtpmail-smtp-server "smtp.gmail.com"
  653. smtpmail-smtp-service 587
  654. smtpmail-starttls-credentials '(("smtp.gmail.com" 587
  655. "8.slashes@gmail.com" nil))
  656. smtpmail-auth-credentials '(("smtp.gmail.com" 587
  657. "8.slashes@gmail.com" nil))
  658. user-mail-address "8.slashes@gmail.com")
  659. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  660. ;; buffer killing
  661. ;; (defun my-delete-window-killing-buffer () nil)
  662. (defun my-query-kill-current-buffer ()
  663. "Interactively kill current buffer."
  664. (interactive)
  665. (if (y-or-n-p (concat "kill current buffer? :"))
  666. (kill-buffer (current-buffer))))
  667. (substitute-key-definition 'kill-buffer
  668. 'my-query-kill-current-buffer
  669. global-map)
  670. ;;(global-set-key "\C-xk" 'my-query-kill-current-buffer)
  671. (defun my-kill-buffers ()
  672. "Kill buffers that visit files."
  673. (interactive)
  674. (mapcar (lambda (buf)
  675. (when (buffer-file-name buf)
  676. (kill-buffer buf)))
  677. (buffer-list)))
  678. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  679. ;; share clipboard with x
  680. ;; this page describes this in details, but only these sexps seem to be needed
  681. ;; http://garin.jp/doc/Linux/xwindow_clipboard
  682. (and (not window-system)
  683. (not (eq window-system 'mac))
  684. (getenv "DISPLAY")
  685. (not (equal (getenv "DISPLAY") ""))
  686. (executable-find "xclip")
  687. ;; (< emacs-major-version 24)
  688. (fetch-library "http://www.emacswiki.org/emacs/download/xclip.el" t)
  689. (require 'xclip nil t)
  690. (turn-on-xclip))
  691. (and (eq system-type 'darwin)
  692. (fetch-library
  693. "https://raw.github.com/10sr/emacs-lisp/master/pasteboard.el"
  694. t)
  695. (require 'pasteboard nil t)
  696. (turn-on-pasteboard)
  697. (getenv "TMUX")
  698. (pasteboard-enable-rtun))
  699. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  700. ;; https://github.com/lunaryorn/flycheck
  701. (when (require 'flycheck nil t)
  702. (add-hook 'after-init-hook 'global-flycheck-mode))
  703. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  704. ;; window
  705. (and (fetch-library
  706. "https://raw.github.com/10sr/emacs-lisp/master/window-organizer.el"
  707. t)
  708. (lazy-load-eval 'window-organizer)
  709. (define-key ctl-x-map (kbd "w") 'window-organizer))
  710. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  711. ;; some modes and hooks
  712. (and (fetch-library
  713. "https://raw.github.com/10sr/emacs-lisp/master/remember-major-modes-mode.el"
  714. t)
  715. (require 'remember-major-modes-mode nil t)
  716. (remember-major-modes-mode 1)
  717. )
  718. ;; Detect file type from shebang and set major-mode.
  719. (add-to-list 'interpreter-mode-alist
  720. '("python3" . python-mode))
  721. (add-to-list 'interpreter-mode-alist
  722. '("python2" . python-mode))
  723. ;; http://fukuyama.co/foreign-regexp
  724. '(and (fetch-library
  725. "https://raw.github.com/k-talo/foreign-regexp.el/master/foreign-regexp.el"
  726. t)
  727. (require 'foreign-regexp nil t)
  728. (progn
  729. (setq foreign-regexp/regexp-type 'perl)
  730. '(setq reb-re-syntax 'foreign-regexp)
  731. ))
  732. (require 'session nil t)
  733. (lazy-load-eval 'sql '(sql-mode)
  734. (require 'sql-indent nil t))
  735. (and (fetch-library "https://raw.github.com/10sr/emacs-lisp/master/gtkbm.el"
  736. t)
  737. (lazy-load-eval 'gtkbm)
  738. (global-set-key (kbd "C-x C-d") 'gtkbm))
  739. (and (fetch-library
  740. "https://raw.github.com/10sr/emacs-lisp/master/git-command.el"
  741. t)
  742. (lazy-load-eval 'git-command
  743. nil
  744. (add-to-list 'git-command-major-mode-alist
  745. '("di" . diff-mode))
  746. (add-to-list 'git-command-major-mode-alist
  747. '("graph" . fundamental-mode))
  748. (add-to-list 'git-command-major-mode-alist
  749. '("log" . fundamental-mode)))
  750. ;; (setq git-command-default-options "-c color.ui=always")
  751. (define-key ctl-x-map "g" 'git-command))
  752. (and (fetch-library
  753. "http://www.emacswiki.org/emacs/download/sl.el"
  754. t)
  755. (lazy-load-eval 'sl))
  756. (defalias 'qcalc 'quick-calc)
  757. (require 'simple nil t)
  758. (add-hook 'makefile-mode-hook
  759. (lambda ()
  760. (define-key makefile-mode-map (kbd "C-m") 'newline-and-indent)
  761. ;; this functions is set in write-file-functions, i cannot find any
  762. ;; good way to remove this.
  763. (fset 'makefile-warn-suspicious-lines 'ignore)
  764. ))
  765. (add-hook 'verilog-mode-hook
  766. (lambda ()
  767. (define-key verilog-mode-map ";" 'self-insert-command)))
  768. (setq diff-switches "-u")
  769. (add-hook 'diff-mode-hook
  770. (lambda ()
  771. (view-mode 1)
  772. (set-face-attribute 'diff-header nil
  773. :foreground nil
  774. :background nil
  775. :weight 'bold)
  776. (set-face-attribute 'diff-file-header nil
  777. :foreground nil
  778. :background nil
  779. :weight 'bold)
  780. (set-face-foreground 'diff-index-face "blue")
  781. (set-face-attribute 'diff-hunk-header nil
  782. :foreground "cyan"
  783. :weight 'normal)
  784. (set-face-attribute 'diff-context nil
  785. ;; :foreground "white"
  786. :foreground nil
  787. :weight 'normal)
  788. (set-face-foreground 'diff-removed-face "red")
  789. (set-face-foreground 'diff-added-face "green")
  790. (set-face-background 'diff-removed-face nil)
  791. (set-face-background 'diff-added-face nil)
  792. (set-face-attribute 'diff-changed nil
  793. :foreground "magenta"
  794. :weight 'normal)
  795. ))
  796. ;; (ffap-bindings)
  797. (add-hook 'sh-mode-hook
  798. (lambda ()
  799. (define-key sh-mode-map
  800. (kbd "C-x C-e")
  801. 'my-execute-shell-command-current-line)))
  802. (setq sh-here-document-word "__EOC__")
  803. (defun my-execute-shell-command-current-line ()
  804. "Run current line as shell command"
  805. (interactive)
  806. (shell-command (buffer-substring-no-properties (point-at-bol)
  807. (point))))
  808. (setq auto-mode-alist
  809. `(("autostart\\'" . sh-mode)
  810. ("xinitrc\\'" . sh-mode)
  811. ("xprograms\\'" . sh-mode)
  812. ("PKGBUILD\\'" . sh-mode)
  813. ,@auto-mode-alist))
  814. (and (lazy-load-eval 'pkgbuild-mode)
  815. (setq auto-mode-alist (append '(("PKGBUILD\\'" . pkgbuild-mode))
  816. auto-mode-alist)))
  817. (add-hook 'html-mode-hook
  818. (lambda ()
  819. (define-key html-mode-map (kbd "C-m")
  820. 'reindent-then-newline-and-indent)))
  821. (add-hook 'text-mode-hook
  822. (lambda ()
  823. (define-key text-mode-map (kbd "C-m") 'newline)))
  824. (add-to-list 'Info-default-directory-list
  825. (expand-file-name "~/.info/emacs-ja"))
  826. (add-hook 'apropos-mode-hook
  827. (lambda ()
  828. (define-key apropos-mode-map "n" 'next-line)
  829. (define-key apropos-mode-map "p" 'previous-line)
  830. ))
  831. (add-hook 'isearch-mode-hook
  832. (lambda ()
  833. ;; (define-key isearch-mode-map
  834. ;; (kbd "C-j") 'isearch-other-control-char)
  835. ;; (define-key isearch-mode-map
  836. ;; (kbd "C-k") 'isearch-other-control-char)
  837. ;; (define-key isearch-mode-map
  838. ;; (kbd "C-h") 'isearch-other-control-char)
  839. (define-key isearch-mode-map (kbd "C-h") 'isearch-delete-char)
  840. (define-key isearch-mode-map (kbd "M-r")
  841. 'isearch-query-replace-regexp)))
  842. (add-hook 'outline-mode-hook
  843. (lambda ()
  844. (if (string-match "\\.md\\'" buffer-file-name)
  845. (set (make-local-variable 'outline-regexp) "#+ "))))
  846. (add-to-list 'auto-mode-alist (cons "\\.ol\\'" 'outline-mode))
  847. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'outline-mode))
  848. (when (fetch-library
  849. "http://jblevins.org/projects/markdown-mode/markdown-mode.el"
  850. t)
  851. (lazy-load-eval 'markdown-mode)
  852. (setq markdown-command (or (executable-find "markdown")
  853. (executable-find "markdown.pl")))
  854. (add-to-list 'auto-mode-alist (cons "\\.md\\'" 'markdown-mode))
  855. (add-hook 'markdown-mode-hook
  856. (lambda ()
  857. (outline-minor-mode 1)
  858. (set (make-local-variable 'comment-start) ";"))))
  859. ;; http://d.hatena.ne.jp/emergent/20070203/1170512717
  860. ;; c-mode
  861. ;; (setq c-default-style "bsd")
  862. (add-hook 'c-mode-common-hook
  863. (lambda ()
  864. (setq c-basic-offset 4
  865. indent-tabs-mode nil)
  866. ;; (set-face-foreground 'font-lock-keyword-face "blue")
  867. (c-toggle-hungry-state -1)
  868. ;; (and (require 'gtags nil t)
  869. ;; (gtags-mode 1))
  870. ))
  871. (when (fetch-library
  872. "https://raw.github.com/mooz/js2-mode/master/js2-mode.el"
  873. t)
  874. (lazy-load-eval 'js2-mode)
  875. ;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  876. ;; (add-to-list 'auto-mode-alist '("\\.jsm\\'" . js2-mode))
  877. (add-hook 'js2-mode-hook
  878. (lambda ()
  879. (define-key js2-mode-map (kbd "C-m") (lambda ()
  880. (interactive)
  881. (js2-enter-key)
  882. (indent-for-tab-command)))
  883. ;; (add-hook (kill-local-variable 'before-save-hook)
  884. ;; 'js2-before-save)
  885. ;; (add-hook 'before-save-hook
  886. ;; 'my-indent-buffer
  887. ;; nil
  888. ;; t)
  889. )))
  890. (require 'js-doc nil t)
  891. (when (require 'uniquify nil t)
  892. (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
  893. (setq uniquify-ignore-buffers-re "*[^*]+*")
  894. (setq uniquify-min-dir-content 1))
  895. (add-hook 'view-mode-hook
  896. (lambda()
  897. (define-key view-mode-map "j"
  898. (lambda() (interactive) (scroll-up 1)))
  899. (define-key view-mode-map "k"
  900. (lambda() (interactive) (scroll-down 1)))
  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. ))
  915. (global-set-key "\M-r" 'view-mode)
  916. (setq view-read-only t)
  917. ;; (defun my-view-mode-search-word (word)
  918. ;; "Search for word current directory and subdirectories.
  919. ;; If called intearctively, find word at point."
  920. ;; (interactive (list (thing-at-point 'symbol)))
  921. ;; (if word
  922. ;; (if (and (require 'gtags nil t)
  923. ;; (gtags-get-rootpath))
  924. ;; (gtags-goto-tag word "s")
  925. ;; (my-rgrep word))
  926. ;; (message "No word at point.")
  927. ;; nil))
  928. (add-hook 'Man-mode-hook
  929. (lambda ()
  930. (view-mode 1)
  931. (setq truncate-lines nil)))
  932. (setq Man-notify-method (if window-system
  933. 'newframe
  934. 'aggressive))
  935. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  936. ;; python
  937. (when (lazy-load-eval 'python '(python-mode))
  938. (setq 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. (set-window-text-height (display-buffer python-buffer
  948. t)
  949. 7))
  950. (add-hook 'python-mode-hook
  951. (lambda ()
  952. (define-key python-mode-map
  953. (kbd "C-c C-e") 'my-python-run-as-command)
  954. (define-key python-mode-map
  955. (kbd "C-c C-b") 'my-python-display-python-buffer)
  956. (define-key python-mode-map (kbd "C-m") 'newline-and-indent)))
  957. (add-hook 'inferior-python-mode-hook
  958. (lambda ()
  959. (my-python-display-python-buffer)
  960. (define-key inferior-python-mode-map
  961. (kbd "<up>") 'comint-previous-input)
  962. (define-key inferior-python-mode-map
  963. (kbd "<down>") 'comint-next-input))))
  964. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  965. ;; GNU GLOBAL(gtags)
  966. ;; http://uguisu.skr.jp/Windows/gtags.html
  967. ;; http://eigyr.dip.jp/gtags.html
  968. ;; http://cha.la.coocan.jp/doc/gnu_global.html
  969. (let ((d "/opt/local/share/gtags/"))
  970. (and (file-directory-p d)
  971. (add-to-list 'load-path
  972. d)))
  973. (when (lazy-load-eval 'gtags '(gtags-mode))
  974. (add-hook 'gtags-mode-hook
  975. (lambda ()
  976. (view-mode gtags-mode)
  977. (setq gtags-select-buffer-single t)
  978. ;; (local-set-key "\M-t" 'gtags-find-tag)
  979. ;; (local-set-key "\M-r" 'gtags-find-rtag)
  980. ;; (local-set-key "\M-s" 'gtags-find-symbol)
  981. ;; (local-set-key "\C-t" 'gtags-pop-stack)
  982. (define-key gtags-mode-map (kbd "C-x t h")
  983. 'gtags-find-tag-from-here)
  984. (define-key gtags-mode-map (kbd "C-x t t") 'gtags-find-tag)
  985. (define-key gtags-mode-map (kbd "C-x t r") 'gtags-find-rtag)
  986. (define-key gtags-mode-map (kbd "C-x t s") 'gtags-find-symbol)
  987. (define-key gtags-mode-map (kbd "C-x t p") 'gtags-find-pattern)
  988. (define-key gtags-mode-map (kbd "C-x t f") 'gtags-find-file)
  989. (define-key gtags-mode-map (kbd "C-x t b") 'gtags-pop-stack) ;back
  990. ))
  991. (add-hook 'gtags-select-mode-hook
  992. (lambda ()
  993. (define-key gtags-select-mode-map (kbd "C-m") 'gtags-select-tag)
  994. ))
  995. )
  996. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  997. ;; term mode
  998. ;; (setq multi-term-program shell-file-name)
  999. (and (fetch-library "http://www.emacswiki.org/emacs/download/multi-term.el"
  1000. t)
  1001. (lazy-load-eval 'multi-term)
  1002. (progn
  1003. (setq multi-term-switch-after-close nil)
  1004. (setq multi-term-dedicated-select-after-open-p t)
  1005. (setq multi-term-dedicated-window-height 20)))
  1006. (when (lazy-load-eval 'term '(term ansi-term))
  1007. (defun my-term-quit-or-send-raw ()
  1008. ""
  1009. (interactive)
  1010. (if (get-buffer-process (current-buffer))
  1011. (call-interactively 'term-send-raw)
  1012. (kill-buffer)))
  1013. ;; http://d.hatena.ne.jp/goinger/20100416/1271399150
  1014. ;; (setq term-ansi-default-program shell-file-name)
  1015. (add-hook 'term-setup-hook
  1016. (lambda ()
  1017. (setq term-display-table (make-display-table))))
  1018. (add-hook 'term-mode-hook
  1019. (lambda ()
  1020. (unless (memq (current-buffer)
  1021. (and (featurep 'multi-term)
  1022. ;; current buffer is not multi-term buffer
  1023. (multi-term-list)))
  1024. ;; (define-key term-raw-map "\C-q" 'move-beginning-of-line)
  1025. ;; (define-key term-raw-map "\C-r" 'term-send-raw)
  1026. ;; (define-key term-raw-map "\C-s" 'term-send-raw)
  1027. ;; (define-key term-raw-map "\C-f" 'forward-char)
  1028. ;; (define-key term-raw-map "\C-b" 'backward-char)
  1029. ;; (define-key term-raw-map "\C-t" 'set-mark-command)
  1030. (define-key term-raw-map
  1031. "\C-x" (lookup-key (current-global-map) "\C-x"))
  1032. (define-key term-raw-map
  1033. "\C-z" (lookup-key (current-global-map) "\C-z"))
  1034. )
  1035. ;; (define-key term-raw-map "\C-xl" 'term-line-mode)
  1036. ;; (define-key term-mode-map "\C-xc" 'term-char-mode)
  1037. (define-key term-raw-map (kbd "<up>")
  1038. (lambda () (interactive) (scroll-down 1)))
  1039. (define-key term-raw-map (kbd "<down>")
  1040. (lambda () (interactive) (scroll-up 1)))
  1041. (define-key term-raw-map (kbd "<right>") 'scroll-up)
  1042. (define-key term-raw-map (kbd "<left>") 'scroll-down)
  1043. (define-key term-raw-map (kbd "C-p") 'term-send-raw)
  1044. (define-key term-raw-map (kbd "C-n") 'term-send-raw)
  1045. (define-key term-raw-map "q" 'my-term-quit-or-send-raw)
  1046. ;; (define-key term-raw-map (kbd "ESC") 'term-send-raw)
  1047. (define-key term-raw-map [delete] 'term-send-raw)
  1048. (define-key term-raw-map (kbd "DEL") 'term-send-backspace)
  1049. (define-key term-raw-map "\C-y" 'term-paste)
  1050. (define-key term-raw-map
  1051. "\C-c" 'term-send-raw) ;; 'term-interrupt-subjob)
  1052. '(define-key term-mode-map (kbd "C-x C-q") 'term-pager-toggle)
  1053. ;; (dolist (key '("<up>" "<down>" "<right>" "<left>"))
  1054. ;; (define-key term-raw-map (read-kbd-macro key) 'term-send-raw))
  1055. ;; (define-key term-raw-map "\C-d" 'delete-char)
  1056. (set (make-local-variable 'scroll-margin) 0)
  1057. ;; (set (make-local-variable 'cua-enable-cua-keys) nil)
  1058. ;; (cua-mode 0)
  1059. ;; (and cua-mode
  1060. ;; (local-unset-key (kbd "C-c")))
  1061. ;; (define-key cua--prefix-override-keymap
  1062. ;;"\C-c" 'term-interrupt-subjob)
  1063. (set (make-local-variable 'hl-line-range-function)
  1064. (lambda ()
  1065. '(0 . 0)))
  1066. ))
  1067. ;; (add-hook 'term-exec-hook 'forward-char)
  1068. )
  1069. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1070. ;; buffer switching
  1071. (when (lazy-load-eval 'bs '(bs-show)
  1072. ;; (add-to-list 'bs-configurations
  1073. ;; '("processes" nil get-buffer-process ".*" nil nil))
  1074. (add-to-list 'bs-configurations
  1075. '("this-frame" nil (lambda (buf)
  1076. (memq buf (my-frame-buffer-get)))
  1077. ".*" nil nil))
  1078. (add-to-list 'bs-configurations
  1079. '("files-and-terminals" nil nil nil
  1080. (lambda (buf)
  1081. (and (bs-visits-non-file buf)
  1082. (save-excursion
  1083. (set-buffer buf)
  1084. (not (memq major-mode
  1085. '(term-mode
  1086. eshell-mode))))))))
  1087. ;; (setq bs-configurations (list
  1088. ;; '("processes" nil get-buffer-process ".*" nil nil)
  1089. ;; '("files-and-scratch" "^\\*scratch\\*$" nil nil
  1090. ;; bs-visits-non-file bs-sort-buffer-interns-are-last)))
  1091. )
  1092. ;; (global-set-key "\C-x\C-b" 'bs-show)
  1093. (defalias 'list-buffers 'bs-show)
  1094. (setq bs-default-configuration "files-and-terminals")
  1095. (setq bs-default-sort-name "by nothing")
  1096. (add-hook 'bs-mode-hook
  1097. (lambda ()
  1098. ;; (setq bs-default-configuration "files")
  1099. ;; (and bs--show-all
  1100. ;; (call-interactively 'bs-toggle-show-all))
  1101. (set (make-local-variable 'scroll-margin) 0))))
  1102. (iswitchb-mode 1)
  1103. (defun iswitchb-buffer-display-other-window ()
  1104. "Do iswitchb in other window."
  1105. (interactive)
  1106. (let ((iswitchb-default-method 'display))
  1107. (call-interactively 'iswitchb-buffer)))
  1108. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1109. ;; sdic
  1110. (when (lazy-load-eval 'sdic '(sdic-describe-word-at-point))
  1111. ;; (define-key my-prefix-map "\C-w" 'sdic-describe-word)
  1112. (define-key my-prefix-map "\C-t" 'sdic-describe-word-at-point-echo)
  1113. (defun sdic-describe-word-at-point-echo ()
  1114. ""
  1115. (interactive)
  1116. (save-window-excursion
  1117. (sdic-describe-word-at-point))
  1118. (save-excursion
  1119. (set-buffer sdic-buffer-name)
  1120. (message (buffer-substring (point-min)
  1121. (progn (goto-char (point-min))
  1122. (or (and (re-search-forward "^\\w"
  1123. nil
  1124. t
  1125. 4)
  1126. (progn (previous-line) t)
  1127. (point-at-eol))
  1128. (point-max)))))))
  1129. (setq sdic-eiwa-dictionary-list '((sdicf-client "/usr/share/dict/gene.sdic")))
  1130. (setq sdic-waei-dictionary-list
  1131. '((sdicf-client "/usr/share/dict/jedict.sdic" (add-keys-to-headword t))))
  1132. (setq sdic-disable-select-window t)
  1133. (setq sdic-window-height 7))
  1134. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1135. ;; vc
  1136. ;; (require 'vc)
  1137. (setq vc-handled-backends '())
  1138. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1139. ;; gauche-mode
  1140. ;; http://d.hatena.ne.jp/kobapan/20090305/1236261804
  1141. ;; http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el
  1142. (when (and (fetch-library
  1143. "http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el"
  1144. t)
  1145. (lazy-load-eval 'gauche-mode '(gauche-mode run-scheme)))
  1146. (let ((s (executable-find "gosh")))
  1147. (setq scheme-program-name s
  1148. gauche-program-name s))
  1149. (defun run-gauche-other-window ()
  1150. "Run gauche on other window"
  1151. (interactive)
  1152. (switch-to-buffer-other-window
  1153. (get-buffer-create "*scheme*"))
  1154. (run-gauche))
  1155. (defun run-gauche ()
  1156. "run gauche"
  1157. (run-scheme gauche-program-name)
  1158. )
  1159. (defun scheme-send-buffer ()
  1160. ""
  1161. (interactive)
  1162. (scheme-send-region (point-min) (point-max))
  1163. (my-scheme-display-scheme-buffer)
  1164. )
  1165. (defun my-scheme-display-scheme-buffer ()
  1166. ""
  1167. (interactive)
  1168. (set-window-text-height (display-buffer scheme-buffer
  1169. t)
  1170. 7))
  1171. (add-hook 'scheme-mode-hook
  1172. (lambda ()
  1173. nil))
  1174. (add-hook 'inferior-scheme-mode-hook
  1175. (lambda ()
  1176. ;; (my-scheme-display-scheme-buffer)
  1177. ))
  1178. (setq auto-mode-alist
  1179. (cons '("\.gosh\\'" . gauche-mode) auto-mode-alist))
  1180. (setq auto-mode-alist
  1181. (cons '("\.gaucherc\\'" . gauche-mode) auto-mode-alist))
  1182. (add-hook 'gauche-mode-hook
  1183. (lambda ()
  1184. (define-key gauche-mode-map
  1185. (kbd "C-c C-z") 'run-gauche-other-window)
  1186. (define-key scheme-mode-map
  1187. (kbd "C-c C-c") 'scheme-send-buffer)
  1188. (define-key scheme-mode-map
  1189. (kbd "C-c C-b") 'my-scheme-display-scheme-buffer))))
  1190. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1191. ;; recentf-mode
  1192. (setq recentf-save-file (expand-file-name "~/.emacs.d/recentf")
  1193. recentf-max-menu-items 20
  1194. recentf-max-saved-items 30
  1195. recentf-show-file-shortcuts-flag nil)
  1196. (when (require 'recentf nil t)
  1197. (add-to-list 'recentf-exclude (regexp-quote recentf-save-file))
  1198. (define-key ctl-x-map (kbd "C-r") 'recentf-open-files)
  1199. (add-hook 'find-file-hook
  1200. 'recentf-save-list
  1201. t) ; save to file immediately after adding file to recentf list
  1202. (add-hook 'kill-emacs-hook
  1203. 'recentf-load-list)
  1204. ;;(run-with-idle-timer 5 t 'recentf-save-list)
  1205. ;; (add-hook 'find-file-hook
  1206. ;; (lambda ()
  1207. ;; (recentf-add-file default-directory)))
  1208. (and (fetch-library
  1209. "https://raw.github.com/10sr/emacs-lisp/master/recentf-show.el"
  1210. t)
  1211. (lazy-load-eval 'recentf-show)
  1212. (define-key ctl-x-map (kbd "C-r") 'recentf-show)
  1213. (add-hook 'recentf-show-before-listing-hook
  1214. 'recentf-load-list))
  1215. (recentf-mode 1)
  1216. (add-hook 'recentf-dialog-mode-hook
  1217. (lambda ()
  1218. ;; (recentf-save-list)
  1219. ;; (define-key recentf-dialog-mode-map (kbd "C-x C-f")
  1220. ;; 'my-recentf-cd-and-find-file)
  1221. (define-key recentf-dialog-mode-map (kbd "<up>") 'previous-line)
  1222. (define-key recentf-dialog-mode-map (kbd "<down>") 'next-line)
  1223. (define-key recentf-dialog-mode-map "p" 'previous-line)
  1224. (define-key recentf-dialog-mode-map "n" 'next-line)
  1225. (cd "~/"))))
  1226. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1227. ;; dired
  1228. (when (lazy-load-eval 'dired nil)
  1229. (defun my-dired-echo-file-head (arg)
  1230. ""
  1231. (interactive "P")
  1232. (let ((f (dired-get-filename)))
  1233. (message "%s"
  1234. (with-temp-buffer
  1235. (insert-file-contents f)
  1236. (buffer-substring-no-properties
  1237. (point-min)
  1238. (progn (goto-line (if arg
  1239. (prefix-numeric-value arg)
  1240. 10))
  1241. (point-at-eol)))))))
  1242. (defun my-dired-diff ()
  1243. ""
  1244. (interactive)
  1245. (let ((files (dired-get-marked-files nil nil nil t)))
  1246. (if (eq (car files)
  1247. t)
  1248. (diff (cadr files) (dired-get-filename))
  1249. (message "One files must be marked!"))))
  1250. (defun my-pop-to-buffer-erase-noselect (buffer-or-name)
  1251. "pop up buffer using `display-buffer' and return that buffer."
  1252. (let ((bf (get-buffer-create buffer-or-name)))
  1253. (with-current-buffer bf
  1254. (cd ".")
  1255. (erase-buffer))
  1256. (display-buffer bf)
  1257. bf))
  1258. (defun my-replace-nasi-none ()
  1259. ""
  1260. (save-excursion
  1261. (let ((buffer-read-only nil))
  1262. (goto-char (point-min))
  1263. (while (search-forward "なし" nil t)
  1264. (replace-match "none")))))
  1265. (defun dired-get-file-info ()
  1266. "dired get file info"
  1267. (interactive)
  1268. (let ((f (shell-quote-argument (dired-get-filename t))))
  1269. (if (file-directory-p f)
  1270. (progn
  1271. (message "Calculating disk usage...")
  1272. (shell-command (concat "du -hsD "
  1273. f)))
  1274. (shell-command (concat "file "
  1275. f)))))
  1276. (defun my-dired-scroll-up ()
  1277. ""
  1278. (interactive)
  1279. (my-dired-previous-line (- (window-height) 1)))
  1280. (defun my-dired-scroll-down ()
  1281. ""
  1282. (interactive)
  1283. (my-dired-next-line (- (window-height) 1)))
  1284. ;; (defun my-dired-forward-line (arg)
  1285. ;; ""
  1286. ;; (interactive "p"))
  1287. (defun my-dired-previous-line (arg)
  1288. ""
  1289. (interactive "p")
  1290. (if (> arg 0)
  1291. (progn
  1292. (if (eq (line-number-at-pos)
  1293. 1)
  1294. (goto-char (point-max))
  1295. (forward-line -1))
  1296. (my-dired-previous-line (if (or (dired-get-filename nil t)
  1297. (dired-get-subdir))
  1298. (- arg 1)
  1299. arg)))
  1300. (dired-move-to-filename)))
  1301. (defun my-dired-next-line (arg)
  1302. ""
  1303. (interactive "p")
  1304. (if (> arg 0)
  1305. (progn
  1306. (if (eq (point)
  1307. (point-max))
  1308. (goto-char (point-min))
  1309. (forward-line 1))
  1310. (my-dired-next-line (if (or (dired-get-filename nil t)
  1311. (dired-get-subdir))
  1312. (- arg 1)
  1313. arg)))
  1314. (dired-move-to-filename)))
  1315. (defun my-dired-print-current-dir-and-file ()
  1316. (message "%s %s"
  1317. default-directory
  1318. (buffer-substring-no-properties (point-at-bol)
  1319. (point-at-eol))))
  1320. (defun dired-do-execute-as-command ()
  1321. ""
  1322. (interactive)
  1323. (let ((file (dired-get-filename t)))
  1324. (if (file-executable-p file)
  1325. (start-process file nil file)
  1326. (when (y-or-n-p
  1327. "this file cant be executed. mark as executable and go? : ")
  1328. (set-file-modes file
  1329. (file-modes-symbolic-to-number "u+x" (file-modes file)))
  1330. (start-process file nil file)))))
  1331. ;;http://bach.istc.kobe-u.ac.jp/lect/tamlab/ubuntu/emacs.html
  1332. (defun my-dired-x-open ()
  1333. ""
  1334. (interactive)
  1335. (my-x-open (dired-get-filename t t)))
  1336. (if (eq window-system 'mac)
  1337. (setq dired-listing-switches "-lhF")
  1338. (setq dired-listing-switches "-lhF --time-style=long-iso")
  1339. )
  1340. (setq dired-listing-switches "-lhF")
  1341. (put 'dired-find-alternate-file 'disabled nil)
  1342. ;; when using dired-find-alternate-file
  1343. ;; reuse current dired buffer for the file to open
  1344. (setq dired-ls-F-marks-symlinks t)
  1345. (when (require 'ls-lisp nil t)
  1346. (setq ls-lisp-use-insert-directory-program nil) ; always use ls-lisp
  1347. (setq ls-lisp-dirs-first t)
  1348. (setq ls-lisp-use-localized-time-format t)
  1349. (setq ls-lisp-format-time-list
  1350. '("%Y-%m-%d %H:%M"
  1351. "%Y-%m-%d ")))
  1352. (setq dired-dwim-target t)
  1353. ;; (add-hook 'dired-after-readin-hook
  1354. ;; 'my-replace-nasi-none)
  1355. ;; (add-hook 'after-init-hook
  1356. ;; (lambda ()
  1357. ;; (dired ".")))
  1358. (add-hook 'dired-mode-hook
  1359. (lambda ()
  1360. (define-key dired-mode-map "o" 'my-dired-x-open)
  1361. (define-key dired-mode-map "i" 'dired-get-file-info)
  1362. (define-key dired-mode-map "f" 'find-file)
  1363. (define-key dired-mode-map "!" 'shell-command)
  1364. (define-key dired-mode-map "&" 'async-shell-command)
  1365. (define-key dired-mode-map "X" 'dired-do-async-shell-command)
  1366. (define-key dired-mode-map "=" 'my-dired-diff)
  1367. (define-key dired-mode-map "B" 'gtkbm-add-current-dir)
  1368. (define-key dired-mode-map "b" 'gtkbm)
  1369. (define-key dired-mode-map "h" 'my-dired-echo-file-head)
  1370. (define-key dired-mode-map "@" (lambda ()
  1371. (interactive) (my-x-open ".")))
  1372. (define-key dired-mode-map (kbd "TAB") 'other-window)
  1373. ;; (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack)
  1374. (define-key dired-mode-map "/" 'dired-isearch-filenames)
  1375. (define-key dired-mode-map (kbd "DEL") 'dired-up-directory)
  1376. (define-key dired-mode-map (kbd "C-h") 'dired-up-directory)
  1377. (substitute-key-definition 'dired-next-line
  1378. 'my-dired-next-line dired-mode-map)
  1379. (substitute-key-definition 'dired-previous-line
  1380. 'my-dired-previous-line dired-mode-map)
  1381. (define-key dired-mode-map (kbd "<left>") 'my-dired-scroll-up)
  1382. (define-key dired-mode-map (kbd "<right>") 'my-dired-scroll-down)
  1383. (define-key dired-mode-map (kbd "ESC p") 'my-dired-scroll-up)
  1384. (define-key dired-mode-map (kbd "ESC n") 'my-dired-scroll-down)
  1385. (let ((file "._Icon\015"))
  1386. (when nil (file-readable-p file)
  1387. (delete-file file)))))
  1388. (and (fetch-library "https://raw.github.com/10sr/emacs-lisp/master/pack.el"
  1389. t)
  1390. (lazy-load-eval 'pack '(dired-do-pack-or-unpack pack))
  1391. (add-hook 'dired-mode-hook
  1392. (lambda ()
  1393. (define-key dired-mode-map "P" 'dired-do-pack-or-unpack))))
  1394. (and (fetch-library
  1395. "https://raw.github.com/10sr/emacs-lisp/master/dired-list-all-mode.el"
  1396. t)
  1397. (lazy-load-eval 'dired-list-all-mode)
  1398. (setq dired-listing-switches "-lhF")
  1399. (add-hook 'dired-mode-hook
  1400. (lambda ()
  1401. (define-key dired-mode-map "a" 'dired-list-all-mode)
  1402. )))
  1403. ) ; when dired locate
  1404. ;; http://blog.livedoor.jp/tek_nishi/archives/4693204.html
  1405. (defun my-dired-toggle-mark()
  1406. (let ((cur (cond ((eq (following-char) dired-marker-char) ?\040)
  1407. (t dired-marker-char))))
  1408. (delete-char 1)
  1409. (insert cur)))
  1410. (defun my-dired-mark (arg)
  1411. "Toggle mark the current (or next ARG) files.
  1412. If on a subdir headerline, mark all its files except `.' and `..'.
  1413. Use \\[dired-unmark-all-files] to remove all marks
  1414. and \\[dired-unmark] on a subdir to remove the marks in
  1415. this subdir."
  1416. (interactive "P")
  1417. (if (dired-get-subdir)
  1418. (save-excursion (dired-mark-subdir-files))
  1419. (let ((inhibit-read-only t))
  1420. (dired-repeat-over-lines
  1421. (prefix-numeric-value arg)
  1422. 'my-dired-toggle-mark))))
  1423. (defun my-dired-mark-backward (arg)
  1424. "In Dired, move up lines and toggle mark there.
  1425. Optional prefix ARG says how many lines to unflag; default is one line."
  1426. (interactive "p")
  1427. (my-dired-mark (- arg)))
  1428. (add-hook 'dired-mode-hook
  1429. (lambda ()
  1430. (local-set-key (kbd "SPC") 'my-dired-mark)
  1431. (local-set-key (kbd "S-SPC") 'my-dired-mark-backward))
  1432. )
  1433. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1434. ;; eshell
  1435. (lazy-load-eval 'eshell nil
  1436. (defun my-eshell-backward-delete-char ()
  1437. (interactive)
  1438. (when (< (save-excursion
  1439. (eshell-bol)
  1440. (point))
  1441. (point))
  1442. (backward-delete-char 1)))
  1443. (defun my-file-owner-p (file)
  1444. "t if FILE is owned by me."
  1445. (eq (user-uid) (nth 2 (file-attributes file))))
  1446. "http://www.bookshelf.jp/pukiwiki/pukiwiki.php\
  1447. ?Eshell%A4%F2%BB%C8%A4%A4%A4%B3%A4%CA%A4%B9"
  1448. ;; ;; written by Stefan Reichoer <reichoer@web.de>
  1449. ;; (defun eshell/less (&rest args)
  1450. ;; "Invoke `view-file' on the file.
  1451. ;; \"less +42 foo\" also goes to line 42 in the buffer."
  1452. ;; (if args
  1453. ;; (while args
  1454. ;; (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
  1455. ;; (let* ((line (string-to-number (match-string 1 (pop args))))
  1456. ;; (file (pop args)))
  1457. ;; (view-file file)
  1458. ;; (goto-line line))
  1459. ;; (view-file (pop args))))))
  1460. (defun eshell/o (&optional file)
  1461. (my-x-open (or file ".")))
  1462. ;; (defun eshell/vi (&rest args)
  1463. ;; "Invoke `find-file' on the file.
  1464. ;; \"vi +42 foo\" also goes to line 42 in the buffer."
  1465. ;; (while args
  1466. ;; (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
  1467. ;; (let* ((line (string-to-number (match-string 1 (pop args))))
  1468. ;; (file (pop args)))
  1469. ;; (find-file file)
  1470. ;; (goto-line line))
  1471. ;; (find-file (pop args)))))
  1472. (defun eshell/clear ()
  1473. "Clear the current buffer, leaving one prompt at the top."
  1474. (interactive)
  1475. (let ((inhibit-read-only t))
  1476. (erase-buffer)))
  1477. (defun eshell-clear ()
  1478. (interactive)
  1479. (let ((inhibit-read-only t))
  1480. (erase-buffer)
  1481. (insert (funcall eshell-prompt-function))))
  1482. (defun eshell/d (&optional dirname switches)
  1483. "if first arg is omitted open current directory."
  1484. (dired (or dirname ".") switches))
  1485. (defun eshell/v ()
  1486. (view-mode 1))
  1487. ;; (defun eshell/aaa (&rest args)
  1488. ;; (message "%S"
  1489. ;; args))
  1490. (defvar eshell/git-cat-command
  1491. nil
  1492. "List of git commands that cat just return strings as results.")
  1493. (setq eshell/git-cat-command
  1494. '("status" "st" "b" "branch" "ls" "ls-files")
  1495. )
  1496. (defun eshell/git (&rest args)
  1497. (if (member (car args)
  1498. eshell/git-cat-command)
  1499. (shell-command-to-string (mapconcat 'shell-quote-argument
  1500. `("git"
  1501. "-c"
  1502. "color.ui=always"
  1503. ,@args)
  1504. " "))
  1505. ;; (eshell-git-shell-command-to-string args)
  1506. (if (require 'git-command nil t)
  1507. (git-command (mapconcat 'shell-quote-argument
  1508. args
  1509. " "))
  1510. (apply 'eshell-exec-visual "git" args))))
  1511. ;; (defun eshell-git-shell-command-to-string (args)
  1512. ;; "Return string of output of ARGS."
  1513. ;; (let ((sargs (mapconcat 'shell-quote-argument
  1514. ;; args
  1515. ;; " ")))
  1516. ;; (if (require 'ansi-color nil t)
  1517. ;; (identity
  1518. ;; (shell-command-to-string (concat "git "
  1519. ;; "-c color.ui=always "
  1520. ;; sargs)))
  1521. ;; (shell-command-to-string (concat "git "
  1522. ;; sargs)))))
  1523. (defalias 'eshell/g 'eshell/git)
  1524. (defalias 'eshell/: 'ignore)
  1525. (defalias 'eshell/type 'eshell/which)
  1526. ;; (defalias 'eshell/vim 'eshell/vi)
  1527. (defalias 'eshell/ff 'find-file)
  1528. (defalias 'eshell/q 'eshell/exit)
  1529. (defun eshell-goto-prompt ()
  1530. ""
  1531. (interactive)
  1532. (goto-char (point-max)))
  1533. (defun eshell-delete-char-or-logout (n)
  1534. (interactive "p")
  1535. (if (equal (eshell-get-old-input)
  1536. "")
  1537. (progn
  1538. (insert "exit")
  1539. (eshell-send-input))
  1540. (delete-char n)))
  1541. (defun eshell-kill-input ()
  1542. (interactive)
  1543. (delete-region (point)
  1544. (progn (eshell-bol)
  1545. (point))))
  1546. (defalias 'eshell/logout 'eshell/exit)
  1547. (defun eshell-cd-default-directory (&optional eshell-buffer-or-name)
  1548. "open eshell and change wd
  1549. if arg given, use that eshell buffer, otherwise make new eshell buffer."
  1550. (interactive)
  1551. (let ((dir (expand-file-name default-directory)))
  1552. (switch-to-buffer (or eshell-buffer-or-name
  1553. (eshell t)))
  1554. (unless (equal dir (expand-file-name default-directory))
  1555. ;; (cd dir)
  1556. ;; (eshell-interactive-print (concat "cd " dir "\n"))
  1557. ;; (eshell-emit-prompt)
  1558. (goto-char (point-max))
  1559. (eshell-kill-input)
  1560. (insert "cd " dir)
  1561. (eshell-send-input))))
  1562. (defadvice eshell-next-matching-input-from-input
  1563. ;; do not cycle history
  1564. (around eshell-history-do-not-cycle activate)
  1565. (if (= 0
  1566. (or eshell-history-index
  1567. 0))
  1568. (progn
  1569. (delete-region eshell-last-output-end (point))
  1570. (insert-and-inherit eshell-matching-input-from-input-string)
  1571. (setq eshell-history-index nil))
  1572. ad-do-it))
  1573. (setq eshell-directory-name "~/.emacs.d/eshell/")
  1574. (setq eshell-term-name "eterm-color")
  1575. (setq eshell-scroll-to-bottom-on-input t)
  1576. (setq eshell-cmpl-ignore-case t)
  1577. (setq eshell-cmpl-cycle-completions nil)
  1578. (setq eshell-highlight-prompt nil)
  1579. (setq eshell-ls-initial-args '("-hCFG"
  1580. "--color=auto"
  1581. "--time-style=long-iso")) ; "-hF")
  1582. (setq eshell-prompt-function
  1583. (lambda ()
  1584. (with-temp-buffer
  1585. (let (p1 p2 p3 p4)
  1586. (insert ":: [")
  1587. (setq p1 (point))
  1588. (insert user-login-name
  1589. "@"
  1590. system-name
  1591. )
  1592. (setq p2 (point))
  1593. (insert ":")
  1594. (setq p3 (point))
  1595. (insert (abbreviate-file-name default-directory))
  1596. (setq p4 (point))
  1597. (insert "]")
  1598. (insert "\n:: ")
  1599. (unless (eq 0
  1600. eshell-last-command-status)
  1601. (insert (format "[STATUS:%d] "
  1602. eshell-last-command-status)))
  1603. (insert (if (= (user-uid)
  1604. 0)
  1605. "# "
  1606. "$ "))
  1607. (add-text-properties p1
  1608. p2
  1609. '(face underline))
  1610. (add-text-properties p3
  1611. p4
  1612. '(face underline))
  1613. (buffer-substring (point-min)
  1614. (point-max))))))
  1615. (add-hook 'eshell-mode-hook
  1616. (lambda ()
  1617. ;; (define-key eshell-mode-map (kbd "C-x C-x") (lambda ()
  1618. ;; (interactive)
  1619. ;; (switch-to-buffer (other-buffer))))
  1620. ;; (define-key eshell-mode-map (kbd "C-g") (lambda ()
  1621. ;; (interactive)
  1622. ;; (eshell-goto-prompt)
  1623. ;; (keyboard-quit)))
  1624. (define-key eshell-mode-map (kbd "C-u")
  1625. 'eshell-kill-input)
  1626. (define-key eshell-mode-map (kbd "C-d")
  1627. 'eshell-delete-char-or-logout)
  1628. ;; (define-key eshell-mode-map (kbd "C-l")
  1629. ;; 'eshell-clear)
  1630. (define-key eshell-mode-map (kbd "DEL")
  1631. 'my-eshell-backward-delete-char)
  1632. (define-key eshell-mode-map
  1633. (kbd "C-p") 'eshell-previous-matching-input-from-input)
  1634. (define-key eshell-mode-map
  1635. (kbd "C-n") 'eshell-next-matching-input-from-input)
  1636. (apply 'eshell/addpath exec-path)
  1637. (set (make-local-variable 'scroll-margin) 0)
  1638. ;; (eshell/export "GIT_PAGER=")
  1639. ;; (eshell/export "GIT_EDITOR=")
  1640. (eshell/export "LC_MESSAGES=C")
  1641. (switch-to-buffer (current-buffer)) ; move buffer top of list
  1642. (set (make-local-variable 'hl-line-range-function)
  1643. (lambda ()
  1644. '(0 . 0)))
  1645. (add-to-list 'eshell-virtual-targets
  1646. '("/dev/less"
  1647. (lambda (str)
  1648. (if str
  1649. (with-current-buffer nil)))
  1650. nil))
  1651. ))
  1652. (add-hook 'eshell-mode-hook
  1653. (lambda ()
  1654. (add-to-list 'eshell-visual-commands "vim")
  1655. ;; (add-to-list 'eshell-visual-commands "git")
  1656. (add-to-list 'eshell-output-filter-functions
  1657. 'eshell-truncate-buffer)
  1658. (mapcar (lambda (alias)
  1659. (add-to-list 'eshell-command-aliases-list
  1660. alias))
  1661. '(
  1662. ; ("ll" "ls -l $*")
  1663. ; ("la" "ls -a $*")
  1664. ; ("lla" "ls -al $*")
  1665. ("eless"
  1666. (concat "cat >>> (with-current-buffer "
  1667. "(get-buffer-create \"*eshell output\") "
  1668. "(erase-buffer) "
  1669. "(setq buffer-read-only nil) "
  1670. "(current-buffer)) "
  1671. "(view-buffer (get-buffer \"*eshell output*\"))")
  1672. ))
  1673. )))
  1674. ) ; eval after load eshell
  1675. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1676. ;; frame buffer
  1677. ;; todo: work well when opening files already opened on another window
  1678. (add-hook 'after-make-frame-functions
  1679. (lambda (f)
  1680. (set-window-buffer (frame-selected-window f)
  1681. "*Messages*")))
  1682. (defun make-frame-command-with-name (name)
  1683. "Make frame with NAME specified."
  1684. (interactive "sName for new frame: ")
  1685. (set-frame-parameter (make-frame-command)
  1686. 'name
  1687. name))
  1688. (defvar my-frame-buffer-plist nil)
  1689. (defun my-frame-buffer-add (&optional buf frame)
  1690. "Add BUF to buffer list for FRAME."
  1691. (setq my-frame-buffer-plist
  1692. (plist-put my-frame-buffer-plist
  1693. (or frame
  1694. (selected-frame))
  1695. (let ((lst (my-frame-buffer-get frame)))
  1696. (if lst
  1697. (add-to-list 'lst
  1698. (or buf
  1699. (current-buffer)))
  1700. (list (or buf
  1701. (current-buffer))))))))
  1702. (defun my-frame-buffer-remove (&optional buf frame)
  1703. "Remove BUF from bufferlist for FRAME."
  1704. (setq my-frame-buffer-plist
  1705. (plist-put my-frame-buffer-plist
  1706. (or frame
  1707. (selected-frame))
  1708. (delq (or buf
  1709. (current-buffer))
  1710. (my-frame-buffer-get frame)))))
  1711. (defun my-frame-buffer-get (&optional frame)
  1712. "Get buffer list for FRAME."
  1713. (plist-get my-frame-buffer-plist
  1714. (or frame
  1715. (selected-frame))))
  1716. (defun my-frame-buffer-kill-all-buffer (&optional frame)
  1717. "Kill all buffer of FRAME."
  1718. (mapcar 'kill-buffer
  1719. (my-frame-buffer-get frame)))
  1720. (add-hook 'find-file-hook
  1721. 'my-frame-buffer-add)
  1722. ;; (add-hook 'term-mode-hook
  1723. ;; 'my-frame-buffer-add)
  1724. (add-hook 'eshell-mode-hook
  1725. 'my-frame-buffer-add)
  1726. (add-hook 'Man-mode-hook
  1727. 'my-frame-buffer-add)
  1728. (add-hook 'kill-buffer-hook
  1729. 'my-frame-buffer-remove)
  1730. (add-hook 'delete-frame-functions
  1731. 'my-frame-buffer-kill-all-buffer)
  1732. (defvar my-desktop-terminal "roxterm")
  1733. (defun my-execute-terminal ()
  1734. "Invole terminal program."
  1735. (interactive)
  1736. (if (and (or (eq system-type 'windows-nt)
  1737. window-system)
  1738. my-desktop-terminal
  1739. )
  1740. (let ((process-environment (cons "TERM=xterm" process-environment)))
  1741. (start-process "terminal"
  1742. nil
  1743. my-desktop-terminal))
  1744. (my-term)))
  1745. (defun my-delete-frame-or-kill-emacs ()
  1746. "Delete frame when opening multiple frame, kill Emacs when only one."
  1747. (interactive)
  1748. (if (eq 1
  1749. (length (frame-list)))
  1750. (save-buffers-kill-emacs)
  1751. (delete-frame)))
  1752. ;; (define-key my-prefix-map (kbd "C-s") 'my-execute-terminal)
  1753. (define-key my-prefix-map (kbd "C-f") 'make-frame-command-with-name)
  1754. (global-set-key (kbd "C-x C-c") 'my-delete-frame-or-kill-emacs)
  1755. (define-key my-prefix-map (kbd "C-x C-c") 'save-buffers-kill-emacs)
  1756. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1757. ;; my-term
  1758. (defvar my-term nil
  1759. "My terminal buffer.")
  1760. (defvar my-term-function nil
  1761. "Function to create terminal buffer.
  1762. This function accept no argument and return newly created buffer of terminal.")
  1763. (defun my-term (&optional arg)
  1764. "Open terminal buffer and return that buffer.
  1765. ARG is ignored."
  1766. (interactive "P")
  1767. (if (and my-term
  1768. (buffer-name my-term))
  1769. (pop-to-buffer my-term)
  1770. (setq my-term
  1771. (save-window-excursion
  1772. (funcall my-term-function)))
  1773. (and my-term
  1774. (my-term))))
  1775. ;; (setq my-term-function
  1776. ;; (lambda ()
  1777. ;; (if (eq system-type 'windows-nt)
  1778. ;; (eshell)
  1779. ;; (if (require 'multi-term nil t)
  1780. ;; (multi-term)
  1781. ;; (ansi-term shell-file-name)))))
  1782. (setq my-term-function 'eshell)
  1783. (define-key my-prefix-map (kbd "C-s") 'my-term)
  1784. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1785. ;; x open
  1786. (defvar my-filer nil)
  1787. (setq my-filer (or (executable-find "pcmanfm")
  1788. (executable-find "nautilus")))
  1789. (defun my-x-open (file)
  1790. "open FILE."
  1791. (interactive "FOpen File: ")
  1792. (setq file (expand-file-name file))
  1793. (message "Opening %s..." file)
  1794. (cond ((eq system-type 'windows-nt)
  1795. (call-process "cmd.exe" nil 0 nil
  1796. "/c" "start" "" (convert-standard-filename file)))
  1797. ((eq system-type 'darwin)
  1798. (call-process "open" nil 0 nil file))
  1799. ((getenv "DISPLAY")
  1800. (call-process (or my-filer "xdg-open") nil 0 nil file))
  1801. (t
  1802. (find-file file))
  1803. )
  1804. ;; (recentf-add-file file)
  1805. (message "Opening %s...done" file))
  1806. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1807. ;; misc funcs
  1808. (defun memo (&optional dir)
  1809. "Open memo.txt in DIR."
  1810. (interactive)
  1811. (pop-to-buffer (find-file-noselect (concat (if dir
  1812. (file-name-as-directory dir)
  1813. "")
  1814. "memo.txt"))))
  1815. (defvar my-rgrep-alist
  1816. `(
  1817. ;; gnu global
  1818. ("global"
  1819. (and (require 'gtags nil t)
  1820. (gtags-get-rootpath))
  1821. "global --result grep ")
  1822. ;; git grep
  1823. ("gitgrep"
  1824. (eq 0
  1825. (shell-command "git rev-parse --git-dir"))
  1826. "git --no-pager -c color.grep=false grep -nH -e ")
  1827. ;; the silver searcher
  1828. ("ag"
  1829. (executable-find "ag")
  1830. "ag --nocolor --nogroup --nopager ")
  1831. ;; ack
  1832. ("ack"
  1833. (executable-find "ack")
  1834. "ack --nocolor --nogroup --nopager ")
  1835. ;; grep
  1836. ("grep"
  1837. t
  1838. ,(concat "find . "
  1839. "-path '*/.git' -prune -o "
  1840. "-path '*/.svn' -prune -o "
  1841. "-type f -print0 | "
  1842. "xargs -0 grep -nH -e "))
  1843. )
  1844. "Alist of rgrep command.
  1845. Each element is in the form like (NAME SEXP COMMAND), where SEXP returns the
  1846. condition to choose COMMAND when evaluated.")
  1847. (defvar my-rgrep-default nil
  1848. "Default command name for my-rgrep.")
  1849. (defun my-rgrep-grep-command (&optional name alist)
  1850. "Return recursive grep command for current directory or nil.
  1851. If NAME is given, use that without testing.
  1852. Commands are searched from ALIST."
  1853. (if alist
  1854. (if name
  1855. ;; if name is given search that from alist and return the command
  1856. (nth 2 (assoc name
  1857. alist))
  1858. ;; if name is not given try test in 1th elem
  1859. (let ((car (car alist))
  1860. (cdr (cdr alist)))
  1861. (if (eval (nth 1 car))
  1862. ;; if the condition is true return the command
  1863. (nth 2 car)
  1864. ;; try next one
  1865. (and cdr
  1866. (my-rgrep-grep-command name cdr)))))
  1867. ;; if alist is not given set default value
  1868. (my-rgrep-grep-command name my-rgrep-alist)))
  1869. (my-rgrep-grep-command "ag" nil)
  1870. (defun my-rgrep (command-args)
  1871. "My recursive grep. Run COMMAND-ARGS."
  1872. (interactive (let ((cmd (my-rgrep-grep-command my-rgrep-default
  1873. nil)))
  1874. (if cmd
  1875. (list (read-shell-command "grep command: "
  1876. cmd
  1877. 'grep-find-history))
  1878. (error "my-rgrep: Command for rgrep not found")
  1879. )))
  1880. (compilation-start command-args
  1881. 'grep-mode))
  1882. ;; (defun my-rgrep-symbol-at-point (command-args)
  1883. ;; "My recursive grep. Run COMMAND-ARGS."
  1884. ;; (interactive (list (read-shell-command "grep command: "
  1885. ;; (concat (my-rgrep-grep-command)
  1886. ;; " "
  1887. ;; (thing-at-point 'symbol))
  1888. ;; 'grep-find-history)))
  1889. ;; (compilation-start command-args
  1890. ;; 'grep-mode))
  1891. (defun my-rgrep-ack ()
  1892. "My recursive grep by ack."
  1893. (interactive)
  1894. (let ((my-rgrep-default "ack"))
  1895. (if (called-interactively-p 'any)
  1896. (call-interactively 'my-rgrep)
  1897. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1898. (defun my-rgrep-ag ()
  1899. "My recursive grep by ack."
  1900. (interactive)
  1901. (let ((my-rgrep-default "ag"))
  1902. (if (called-interactively-p 'any)
  1903. (call-interactively 'my-rgrep)
  1904. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1905. (defun my-rgrep-gitgrep ()
  1906. "My recursive grep by ack."
  1907. (interactive)
  1908. (let ((my-rgrep-default "gitgrep"))
  1909. (if (called-interactively-p 'any)
  1910. (call-interactively 'my-rgrep)
  1911. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1912. (defun my-rgrep-grep ()
  1913. "My recursive grep by ack."
  1914. (interactive)
  1915. (let ((my-rgrep-default "grep"))
  1916. (if (called-interactively-p 'any)
  1917. (call-interactively 'my-rgrep)
  1918. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1919. (defun my-rgrep-global ()
  1920. "My recursive grep by ack."
  1921. (interactive)
  1922. (let ((my-rgrep-default "global"))
  1923. (if (called-interactively-p 'any)
  1924. (call-interactively 'my-rgrep)
  1925. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1926. (define-key ctl-x-map "s" 'my-rgrep)
  1927. ;; (defun make ()
  1928. ;; "Run \"make -k\" in current directory."
  1929. ;; (interactive)
  1930. ;; (compile "make -k"))
  1931. (defalias 'make 'compile)
  1932. (defvar sed-in-place-history nil
  1933. "History of `sed-in-place'.")
  1934. (defvar sed-in-place-command "sed --in-place=.bak -e")
  1935. (defun sed-in-place (command)
  1936. "Issue sed in place COMMAND."
  1937. (interactive (list (read-shell-command "sed in place: "
  1938. (concat sed-in-place-command " ")
  1939. 'sed-in-place-history)))
  1940. (shell-command command
  1941. "*sed in place*"))
  1942. (defun dired-do-sed-in-place (&optional arg)
  1943. "Issue sed in place dired. If ARG is given, use the next ARG files."
  1944. (interactive "p")
  1945. (require 'dired-aux)
  1946. (let* ((files (dired-get-marked-files t arg))
  1947. (expr (dired-mark-read-string "Run sed-in-place for %s: "
  1948. nil
  1949. 'sed-in-place
  1950. arg
  1951. files)))
  1952. (if (equal expr
  1953. "")
  1954. (error "No expression specified")
  1955. (shell-command (concat sed-in-place-command
  1956. " '"
  1957. expr
  1958. "' "
  1959. (mapconcat 'shell-quote-argument
  1960. files
  1961. " "))
  1962. "*sed in place*"))))
  1963. (defun dir-show (&optional dir)
  1964. "Show DIR list."
  1965. (interactive)
  1966. (let ((bf (get-buffer-create "*dir show*"))
  1967. (list-directory-brief-switches "-C"))
  1968. (with-current-buffer bf
  1969. (list-directory (or nil
  1970. default-directory)
  1971. nil))
  1972. ))
  1973. (defun my-convmv-sjis2utf8-test ()
  1974. "Run `convmv -r -f sjis -t utf8 *'.
  1975. this is test, does not rename files."
  1976. (interactive)
  1977. (shell-command "convmv -r -f sjis -t utf8 *"))
  1978. (defun my-convmv-sjis2utf8-notest ()
  1979. "Run `convmv -r -f sjis -t utf8 * --notest'."
  1980. (interactive)
  1981. (shell-command "convmv -r -f sjis -t utf8 * --notest"))
  1982. (defun kill-ring-save-buffer-file-name ()
  1983. "Get current filename."
  1984. (interactive)
  1985. (let ((file buffer-file-name))
  1986. (if file
  1987. (progn (kill-new file)
  1988. (message file))
  1989. (message "not visiting file."))))
  1990. (defvar kill-ring-buffer-name "*kill-ring*"
  1991. "Buffer name for `kill-ring-buffer'.")
  1992. (defun open-kill-ring-buffer ()
  1993. "Open kill- ring buffer."
  1994. (interactive)
  1995. (pop-to-buffer
  1996. (with-current-buffer (get-buffer-create kill-ring-buffer-name)
  1997. (erase-buffer)
  1998. (yank)
  1999. (text-mode)
  2000. (current-local-map)
  2001. (goto-char (point-min)))))
  2002. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2003. ;; ;; savage emacs
  2004. ;; ;; when enabled emacs fails to complete
  2005. ;; ;; http://e-arrows.sakura.ne.jp/2010/05/emacs-should-be-more-savage.html
  2006. ;; (defadvice message (before message-for-stupid (arg &rest arg2) activate)
  2007. ;; (setq arg
  2008. ;; (concat arg
  2009. ;; (if (eq nil
  2010. ;; (string-match "\\. *$"
  2011. ;; arg))
  2012. ;; ".")
  2013. ;; " Stupid!")))
  2014. (defvar my-system-info
  2015. nil
  2016. "System info in the form of \"[user@host] \".")
  2017. (setq my-system-info
  2018. (concat "["
  2019. user-login-name
  2020. "@"
  2021. (car (split-string system-name
  2022. "\\."))
  2023. "] "))
  2024. (defadvice read-from-minibuffer (before info-in-prompt activate)
  2025. "Show system info when use `read-from-minibuffer'."
  2026. (ad-set-arg 0
  2027. (concat my-system-info
  2028. (ad-get-arg 0))))
  2029. (defadvice read-string (before info-in-prompt activate)
  2030. "Show system info when use `read-string'."
  2031. (ad-set-arg 0
  2032. (concat my-system-info
  2033. (ad-get-arg 0))))
  2034. (when (< emacs-major-version 24)
  2035. (defadvice completing-read (before info-in-prompt activate)
  2036. "Show system info when use `completing-read'."
  2037. (ad-set-arg 0
  2038. (concat my-system-info
  2039. (ad-get-arg 0)))))
  2040. (defun my-real-function-subr-p (function)
  2041. "Return t if FUNCTION is a built-in function even if it is advised."
  2042. (let* ((advised (and (symbolp function)
  2043. (featurep 'advice)
  2044. (ad-get-advice-info function)))
  2045. (real-function
  2046. (or (and advised (let ((origname (cdr (assq 'origname advised))))
  2047. (and (fboundp origname)
  2048. origname)))
  2049. function))
  2050. (def (if (symbolp real-function)
  2051. (symbol-function real-function)
  2052. function)))
  2053. (subrp def)))
  2054. ;; (my-real-function-subr-p 'my-real-function-subr-p)
  2055. ;;;;;;;;;;;;;;;;;;;;;;;;
  2056. ;; ilookup
  2057. (when (fetch-library
  2058. "https://raw.github.com/10sr/emacs-lisp/master/ilookup.el"
  2059. t)
  2060. (lazy-load-eval 'ilookup
  2061. '(ilookup-open)
  2062. (setq ilookup-dict-alist
  2063. '(
  2064. ("en" . (lambda (word)
  2065. (shell-command-to-string
  2066. (format "sdcv -n -u dictd_www.dict.org_gcide '%s'"
  2067. word))))
  2068. ("ja" . (lambda (word)
  2069. (shell-command-to-string
  2070. (format "sdcv -n -u EJ-GENE95 -u jmdict-en-ja '%s'"
  2071. word))))
  2072. ("jaj" . (lambda (word)
  2073. (shell-command-to-string
  2074. (format "sdcv -n -u jmdict-en-ja '%s'"
  2075. word))))
  2076. ("jag" .
  2077. (lambda (word)
  2078. (with-temp-buffer
  2079. (insert (shell-command-to-string
  2080. (format "sdcv -n -u 'Genius English-Japanese' '%s'"
  2081. word)))
  2082. (html2text)
  2083. (buffer-substring (point-min)
  2084. (point-max)))))
  2085. ("alc" . (lambda (word)
  2086. (shell-command-to-string
  2087. (format "alc '%s' | head -n 20"
  2088. word))))
  2089. ("app" . (lambda (word)
  2090. (shell-command-to-string
  2091. (format "dict_app '%s'"
  2092. word))))
  2093. ;; letters broken
  2094. ("ms" .
  2095. (lambda (word)
  2096. (let ((url (concat
  2097. "http://api.microsofttranslator.com/V2/Ajax.svc/"
  2098. "Translate?appId=%s&text=%s&to=%s"))
  2099. (apikey "3C9778666C5BA4B406FFCBEE64EF478963039C51")
  2100. (target "ja")
  2101. (eword (url-hexify-string word)))
  2102. (with-current-buffer (url-retrieve-synchronously
  2103. (format url
  2104. apikey
  2105. eword
  2106. target))
  2107. (message "")
  2108. (goto-char (point-min))
  2109. (search-forward-regexp "^$"
  2110. nil
  2111. t)
  2112. (url-unhex-string (buffer-substring-no-properties
  2113. (point)
  2114. (point-max)))))))
  2115. ))
  2116. ;; (funcall (cdr (assoc "ms"
  2117. ;; ilookup-alist))
  2118. ;; "dictionary")
  2119. ;; (switch-to-buffer (url-retrieve-synchronously "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=3C9778666C5BA4B406FFCBEE64EF478963039C51&text=dictionary&to=ja"))
  2120. ;; (switch-to-buffer (url-retrieve-synchronously "http://google.com"))
  2121. (setq ilookup-default "ja")))
  2122. ;;; emacs.el ends here