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

2438 linhas
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. (flyspell-mode)
  859. (set (make-local-variable 'comment-start) ";"))))
  860. ;; http://d.hatena.ne.jp/emergent/20070203/1170512717
  861. ;; c-mode
  862. ;; (setq c-default-style "bsd")
  863. (add-hook 'c-mode-common-hook
  864. (lambda ()
  865. (setq c-basic-offset 4
  866. indent-tabs-mode nil)
  867. ;; (set-face-foreground 'font-lock-keyword-face "blue")
  868. (c-toggle-hungry-state -1)
  869. ;; (and (require 'gtags nil t)
  870. ;; (gtags-mode 1))
  871. ))
  872. (when (fetch-library
  873. "https://raw.github.com/mooz/js2-mode/master/js2-mode.el"
  874. t)
  875. (lazy-load-eval 'js2-mode)
  876. ;; (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
  877. ;; (add-to-list 'auto-mode-alist '("\\.jsm\\'" . js2-mode))
  878. (add-hook 'js2-mode-hook
  879. (lambda ()
  880. (define-key js2-mode-map (kbd "C-m") (lambda ()
  881. (interactive)
  882. (js2-enter-key)
  883. (indent-for-tab-command)))
  884. ;; (add-hook (kill-local-variable 'before-save-hook)
  885. ;; 'js2-before-save)
  886. ;; (add-hook 'before-save-hook
  887. ;; 'my-indent-buffer
  888. ;; nil
  889. ;; t)
  890. )))
  891. (require 'js-doc nil t)
  892. (when (require 'uniquify nil t)
  893. (setq uniquify-buffer-name-style 'post-forward-angle-brackets)
  894. (setq uniquify-ignore-buffers-re "*[^*]+*")
  895. (setq uniquify-min-dir-content 1))
  896. (add-hook 'view-mode-hook
  897. (lambda()
  898. (define-key view-mode-map "j"
  899. (lambda() (interactive) (scroll-up 1)))
  900. (define-key view-mode-map "k"
  901. (lambda() (interactive) (scroll-down 1)))
  902. (define-key view-mode-map "v" 'toggle-read-only)
  903. (define-key view-mode-map "q" 'bury-buffer)
  904. ;; (define-key view-mode-map "/" 'nonincremental-re-search-forward)
  905. ;; (define-key view-mode-map "?" 'nonincremental-re-search-backward)
  906. ;; (define-key view-mode-map
  907. ;; "n" 'nonincremental-repeat-search-forward)
  908. ;; (define-key view-mode-map
  909. ;; "N" 'nonincremental-repeat-search-backward)
  910. (define-key view-mode-map "/" 'isearch-forward-regexp)
  911. (define-key view-mode-map "?" 'isearch-backward-regexp)
  912. (define-key view-mode-map "n" 'isearch-repeat-forward)
  913. (define-key view-mode-map "N" 'isearch-repeat-backward)
  914. (define-key view-mode-map (kbd "C-m") 'my-rgrep-symbol-at-point)
  915. ))
  916. (global-set-key "\M-r" 'view-mode)
  917. (setq view-read-only t)
  918. ;; (defun my-view-mode-search-word (word)
  919. ;; "Search for word current directory and subdirectories.
  920. ;; If called intearctively, find word at point."
  921. ;; (interactive (list (thing-at-point 'symbol)))
  922. ;; (if word
  923. ;; (if (and (require 'gtags nil t)
  924. ;; (gtags-get-rootpath))
  925. ;; (gtags-goto-tag word "s")
  926. ;; (my-rgrep word))
  927. ;; (message "No word at point.")
  928. ;; nil))
  929. (add-hook 'Man-mode-hook
  930. (lambda ()
  931. (view-mode 1)
  932. (setq truncate-lines nil)))
  933. (setq Man-notify-method (if window-system
  934. 'newframe
  935. 'aggressive))
  936. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  937. ;; python
  938. (when (lazy-load-eval 'python '(python-mode))
  939. (setq python-python-command (or (executable-find "python3")
  940. (executable-find "python")))
  941. ;; (defun my-python-run-as-command ()
  942. ;; ""
  943. ;; (interactive)
  944. ;; (shell-command (concat python-python-command " " buffer-file-name)))
  945. (defun my-python-display-python-buffer ()
  946. ""
  947. (interactive)
  948. (set-window-text-height (display-buffer python-buffer
  949. t)
  950. 7))
  951. (add-hook 'python-mode-hook
  952. (lambda ()
  953. (define-key python-mode-map
  954. (kbd "C-c C-e") 'my-python-run-as-command)
  955. (define-key python-mode-map
  956. (kbd "C-c C-b") 'my-python-display-python-buffer)
  957. (define-key python-mode-map (kbd "C-m") 'newline-and-indent)))
  958. (add-hook 'inferior-python-mode-hook
  959. (lambda ()
  960. (my-python-display-python-buffer)
  961. (define-key inferior-python-mode-map
  962. (kbd "<up>") 'comint-previous-input)
  963. (define-key inferior-python-mode-map
  964. (kbd "<down>") 'comint-next-input))))
  965. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  966. ;; GNU GLOBAL(gtags)
  967. ;; http://uguisu.skr.jp/Windows/gtags.html
  968. ;; http://eigyr.dip.jp/gtags.html
  969. ;; http://cha.la.coocan.jp/doc/gnu_global.html
  970. (let ((d "/opt/local/share/gtags/"))
  971. (and (file-directory-p d)
  972. (add-to-list 'load-path
  973. d)))
  974. (when (lazy-load-eval 'gtags '(gtags-mode))
  975. (add-hook 'gtags-mode-hook
  976. (lambda ()
  977. (view-mode gtags-mode)
  978. (setq gtags-select-buffer-single t)
  979. ;; (local-set-key "\M-t" 'gtags-find-tag)
  980. ;; (local-set-key "\M-r" 'gtags-find-rtag)
  981. ;; (local-set-key "\M-s" 'gtags-find-symbol)
  982. ;; (local-set-key "\C-t" 'gtags-pop-stack)
  983. (define-key gtags-mode-map (kbd "C-x t h")
  984. 'gtags-find-tag-from-here)
  985. (define-key gtags-mode-map (kbd "C-x t t") 'gtags-find-tag)
  986. (define-key gtags-mode-map (kbd "C-x t r") 'gtags-find-rtag)
  987. (define-key gtags-mode-map (kbd "C-x t s") 'gtags-find-symbol)
  988. (define-key gtags-mode-map (kbd "C-x t p") 'gtags-find-pattern)
  989. (define-key gtags-mode-map (kbd "C-x t f") 'gtags-find-file)
  990. (define-key gtags-mode-map (kbd "C-x t b") 'gtags-pop-stack) ;back
  991. ))
  992. (add-hook 'gtags-select-mode-hook
  993. (lambda ()
  994. (define-key gtags-select-mode-map (kbd "C-m") 'gtags-select-tag)
  995. ))
  996. )
  997. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  998. ;; term mode
  999. ;; (setq multi-term-program shell-file-name)
  1000. (and (fetch-library "http://www.emacswiki.org/emacs/download/multi-term.el"
  1001. t)
  1002. (lazy-load-eval 'multi-term)
  1003. (progn
  1004. (setq multi-term-switch-after-close nil)
  1005. (setq multi-term-dedicated-select-after-open-p t)
  1006. (setq multi-term-dedicated-window-height 20)))
  1007. (when (lazy-load-eval 'term '(term ansi-term))
  1008. (defun my-term-quit-or-send-raw ()
  1009. ""
  1010. (interactive)
  1011. (if (get-buffer-process (current-buffer))
  1012. (call-interactively 'term-send-raw)
  1013. (kill-buffer)))
  1014. ;; http://d.hatena.ne.jp/goinger/20100416/1271399150
  1015. ;; (setq term-ansi-default-program shell-file-name)
  1016. (add-hook 'term-setup-hook
  1017. (lambda ()
  1018. (setq term-display-table (make-display-table))))
  1019. (add-hook 'term-mode-hook
  1020. (lambda ()
  1021. (unless (memq (current-buffer)
  1022. (and (featurep 'multi-term)
  1023. ;; current buffer is not multi-term buffer
  1024. (multi-term-list)))
  1025. ;; (define-key term-raw-map "\C-q" 'move-beginning-of-line)
  1026. ;; (define-key term-raw-map "\C-r" 'term-send-raw)
  1027. ;; (define-key term-raw-map "\C-s" 'term-send-raw)
  1028. ;; (define-key term-raw-map "\C-f" 'forward-char)
  1029. ;; (define-key term-raw-map "\C-b" 'backward-char)
  1030. ;; (define-key term-raw-map "\C-t" 'set-mark-command)
  1031. (define-key term-raw-map
  1032. "\C-x" (lookup-key (current-global-map) "\C-x"))
  1033. (define-key term-raw-map
  1034. "\C-z" (lookup-key (current-global-map) "\C-z"))
  1035. )
  1036. ;; (define-key term-raw-map "\C-xl" 'term-line-mode)
  1037. ;; (define-key term-mode-map "\C-xc" 'term-char-mode)
  1038. (define-key term-raw-map (kbd "<up>")
  1039. (lambda () (interactive) (scroll-down 1)))
  1040. (define-key term-raw-map (kbd "<down>")
  1041. (lambda () (interactive) (scroll-up 1)))
  1042. (define-key term-raw-map (kbd "<right>") 'scroll-up)
  1043. (define-key term-raw-map (kbd "<left>") 'scroll-down)
  1044. (define-key term-raw-map (kbd "C-p") 'term-send-raw)
  1045. (define-key term-raw-map (kbd "C-n") 'term-send-raw)
  1046. (define-key term-raw-map "q" 'my-term-quit-or-send-raw)
  1047. ;; (define-key term-raw-map (kbd "ESC") 'term-send-raw)
  1048. (define-key term-raw-map [delete] 'term-send-raw)
  1049. (define-key term-raw-map (kbd "DEL") 'term-send-backspace)
  1050. (define-key term-raw-map "\C-y" 'term-paste)
  1051. (define-key term-raw-map
  1052. "\C-c" 'term-send-raw) ;; 'term-interrupt-subjob)
  1053. '(define-key term-mode-map (kbd "C-x C-q") 'term-pager-toggle)
  1054. ;; (dolist (key '("<up>" "<down>" "<right>" "<left>"))
  1055. ;; (define-key term-raw-map (read-kbd-macro key) 'term-send-raw))
  1056. ;; (define-key term-raw-map "\C-d" 'delete-char)
  1057. (set (make-local-variable 'scroll-margin) 0)
  1058. ;; (set (make-local-variable 'cua-enable-cua-keys) nil)
  1059. ;; (cua-mode 0)
  1060. ;; (and cua-mode
  1061. ;; (local-unset-key (kbd "C-c")))
  1062. ;; (define-key cua--prefix-override-keymap
  1063. ;;"\C-c" 'term-interrupt-subjob)
  1064. (set (make-local-variable 'hl-line-range-function)
  1065. (lambda ()
  1066. '(0 . 0)))
  1067. ))
  1068. ;; (add-hook 'term-exec-hook 'forward-char)
  1069. )
  1070. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1071. ;; buffer switching
  1072. (when (lazy-load-eval 'bs '(bs-show)
  1073. ;; (add-to-list 'bs-configurations
  1074. ;; '("processes" nil get-buffer-process ".*" nil nil))
  1075. (add-to-list 'bs-configurations
  1076. '("this-frame" nil (lambda (buf)
  1077. (memq buf (my-frame-buffer-get)))
  1078. ".*" nil nil))
  1079. (add-to-list 'bs-configurations
  1080. '("files-and-terminals" nil nil nil
  1081. (lambda (buf)
  1082. (and (bs-visits-non-file buf)
  1083. (save-excursion
  1084. (set-buffer buf)
  1085. (not (memq major-mode
  1086. '(term-mode
  1087. eshell-mode))))))))
  1088. ;; (setq bs-configurations (list
  1089. ;; '("processes" nil get-buffer-process ".*" nil nil)
  1090. ;; '("files-and-scratch" "^\\*scratch\\*$" nil nil
  1091. ;; bs-visits-non-file bs-sort-buffer-interns-are-last)))
  1092. )
  1093. ;; (global-set-key "\C-x\C-b" 'bs-show)
  1094. (defalias 'list-buffers 'bs-show)
  1095. (setq bs-default-configuration "files-and-terminals")
  1096. (setq bs-default-sort-name "by nothing")
  1097. (add-hook 'bs-mode-hook
  1098. (lambda ()
  1099. ;; (setq bs-default-configuration "files")
  1100. ;; (and bs--show-all
  1101. ;; (call-interactively 'bs-toggle-show-all))
  1102. (set (make-local-variable 'scroll-margin) 0))))
  1103. (iswitchb-mode 1)
  1104. (defun iswitchb-buffer-display-other-window ()
  1105. "Do iswitchb in other window."
  1106. (interactive)
  1107. (let ((iswitchb-default-method 'display))
  1108. (call-interactively 'iswitchb-buffer)))
  1109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1110. ;; sdic
  1111. (when (lazy-load-eval 'sdic '(sdic-describe-word-at-point))
  1112. ;; (define-key my-prefix-map "\C-w" 'sdic-describe-word)
  1113. (define-key my-prefix-map "\C-t" 'sdic-describe-word-at-point-echo)
  1114. (defun sdic-describe-word-at-point-echo ()
  1115. ""
  1116. (interactive)
  1117. (save-window-excursion
  1118. (sdic-describe-word-at-point))
  1119. (save-excursion
  1120. (set-buffer sdic-buffer-name)
  1121. (message (buffer-substring (point-min)
  1122. (progn (goto-char (point-min))
  1123. (or (and (re-search-forward "^\\w"
  1124. nil
  1125. t
  1126. 4)
  1127. (progn (previous-line) t)
  1128. (point-at-eol))
  1129. (point-max)))))))
  1130. (setq sdic-eiwa-dictionary-list '((sdicf-client "/usr/share/dict/gene.sdic")))
  1131. (setq sdic-waei-dictionary-list
  1132. '((sdicf-client "/usr/share/dict/jedict.sdic" (add-keys-to-headword t))))
  1133. (setq sdic-disable-select-window t)
  1134. (setq sdic-window-height 7))
  1135. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1136. ;; vc
  1137. ;; (require 'vc)
  1138. (setq vc-handled-backends '())
  1139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1140. ;; gauche-mode
  1141. ;; http://d.hatena.ne.jp/kobapan/20090305/1236261804
  1142. ;; http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el
  1143. (when (and (fetch-library
  1144. "http://www.katch.ne.jp/~leque/software/repos/gauche-mode/gauche-mode.el"
  1145. t)
  1146. (lazy-load-eval 'gauche-mode '(gauche-mode run-scheme)))
  1147. (let ((s (executable-find "gosh")))
  1148. (setq scheme-program-name s
  1149. gauche-program-name s))
  1150. (defun run-gauche-other-window ()
  1151. "Run gauche on other window"
  1152. (interactive)
  1153. (switch-to-buffer-other-window
  1154. (get-buffer-create "*scheme*"))
  1155. (run-gauche))
  1156. (defun run-gauche ()
  1157. "run gauche"
  1158. (run-scheme gauche-program-name)
  1159. )
  1160. (defun scheme-send-buffer ()
  1161. ""
  1162. (interactive)
  1163. (scheme-send-region (point-min) (point-max))
  1164. (my-scheme-display-scheme-buffer)
  1165. )
  1166. (defun my-scheme-display-scheme-buffer ()
  1167. ""
  1168. (interactive)
  1169. (set-window-text-height (display-buffer scheme-buffer
  1170. t)
  1171. 7))
  1172. (add-hook 'scheme-mode-hook
  1173. (lambda ()
  1174. nil))
  1175. (add-hook 'inferior-scheme-mode-hook
  1176. (lambda ()
  1177. ;; (my-scheme-display-scheme-buffer)
  1178. ))
  1179. (setq auto-mode-alist
  1180. (cons '("\.gosh\\'" . gauche-mode) auto-mode-alist))
  1181. (setq auto-mode-alist
  1182. (cons '("\.gaucherc\\'" . gauche-mode) auto-mode-alist))
  1183. (add-hook 'gauche-mode-hook
  1184. (lambda ()
  1185. (define-key gauche-mode-map
  1186. (kbd "C-c C-z") 'run-gauche-other-window)
  1187. (define-key scheme-mode-map
  1188. (kbd "C-c C-c") 'scheme-send-buffer)
  1189. (define-key scheme-mode-map
  1190. (kbd "C-c C-b") 'my-scheme-display-scheme-buffer))))
  1191. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1192. ;; recentf-mode
  1193. (setq recentf-save-file (expand-file-name "~/.emacs.d/recentf")
  1194. recentf-max-menu-items 20
  1195. recentf-max-saved-items 30
  1196. recentf-show-file-shortcuts-flag nil)
  1197. (when (require 'recentf nil t)
  1198. (add-to-list 'recentf-exclude (regexp-quote recentf-save-file))
  1199. (define-key ctl-x-map (kbd "C-r") 'recentf-open-files)
  1200. (add-hook 'find-file-hook
  1201. 'recentf-save-list
  1202. t) ; save to file immediately after adding file to recentf list
  1203. (add-hook 'kill-emacs-hook
  1204. 'recentf-load-list)
  1205. ;;(run-with-idle-timer 5 t 'recentf-save-list)
  1206. ;; (add-hook 'find-file-hook
  1207. ;; (lambda ()
  1208. ;; (recentf-add-file default-directory)))
  1209. (and (fetch-library
  1210. "https://raw.github.com/10sr/emacs-lisp/master/recentf-show.el"
  1211. t)
  1212. (lazy-load-eval 'recentf-show)
  1213. (define-key ctl-x-map (kbd "C-r") 'recentf-show)
  1214. (add-hook 'recentf-show-before-listing-hook
  1215. 'recentf-load-list))
  1216. (recentf-mode 1)
  1217. (add-hook 'recentf-dialog-mode-hook
  1218. (lambda ()
  1219. ;; (recentf-save-list)
  1220. ;; (define-key recentf-dialog-mode-map (kbd "C-x C-f")
  1221. ;; 'my-recentf-cd-and-find-file)
  1222. (define-key recentf-dialog-mode-map (kbd "<up>") 'previous-line)
  1223. (define-key recentf-dialog-mode-map (kbd "<down>") 'next-line)
  1224. (define-key recentf-dialog-mode-map "p" 'previous-line)
  1225. (define-key recentf-dialog-mode-map "n" 'next-line)
  1226. (cd "~/"))))
  1227. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1228. ;; dired
  1229. (when (lazy-load-eval 'dired nil)
  1230. (defun my-dired-echo-file-head (arg)
  1231. ""
  1232. (interactive "P")
  1233. (let ((f (dired-get-filename)))
  1234. (message "%s"
  1235. (with-temp-buffer
  1236. (insert-file-contents f)
  1237. (buffer-substring-no-properties
  1238. (point-min)
  1239. (progn (goto-line (if arg
  1240. (prefix-numeric-value arg)
  1241. 10))
  1242. (point-at-eol)))))))
  1243. (defun my-dired-diff ()
  1244. ""
  1245. (interactive)
  1246. (let ((files (dired-get-marked-files nil nil nil t)))
  1247. (if (eq (car files)
  1248. t)
  1249. (diff (cadr files) (dired-get-filename))
  1250. (message "One files must be marked!"))))
  1251. (defun my-pop-to-buffer-erase-noselect (buffer-or-name)
  1252. "pop up buffer using `display-buffer' and return that buffer."
  1253. (let ((bf (get-buffer-create buffer-or-name)))
  1254. (with-current-buffer bf
  1255. (cd ".")
  1256. (erase-buffer))
  1257. (display-buffer bf)
  1258. bf))
  1259. (defun my-replace-nasi-none ()
  1260. ""
  1261. (save-excursion
  1262. (let ((buffer-read-only nil))
  1263. (goto-char (point-min))
  1264. (while (search-forward "なし" nil t)
  1265. (replace-match "none")))))
  1266. (defun dired-get-file-info ()
  1267. "dired get file info"
  1268. (interactive)
  1269. (let ((f (shell-quote-argument (dired-get-filename t))))
  1270. (if (file-directory-p f)
  1271. (progn
  1272. (message "Calculating disk usage...")
  1273. (shell-command (concat "du -hsD "
  1274. f)))
  1275. (shell-command (concat "file "
  1276. f)))))
  1277. (defun my-dired-scroll-up ()
  1278. ""
  1279. (interactive)
  1280. (my-dired-previous-line (- (window-height) 1)))
  1281. (defun my-dired-scroll-down ()
  1282. ""
  1283. (interactive)
  1284. (my-dired-next-line (- (window-height) 1)))
  1285. ;; (defun my-dired-forward-line (arg)
  1286. ;; ""
  1287. ;; (interactive "p"))
  1288. (defun my-dired-previous-line (arg)
  1289. ""
  1290. (interactive "p")
  1291. (if (> arg 0)
  1292. (progn
  1293. (if (eq (line-number-at-pos)
  1294. 1)
  1295. (goto-char (point-max))
  1296. (forward-line -1))
  1297. (my-dired-previous-line (if (or (dired-get-filename nil t)
  1298. (dired-get-subdir))
  1299. (- arg 1)
  1300. arg)))
  1301. (dired-move-to-filename)))
  1302. (defun my-dired-next-line (arg)
  1303. ""
  1304. (interactive "p")
  1305. (if (> arg 0)
  1306. (progn
  1307. (if (eq (point)
  1308. (point-max))
  1309. (goto-char (point-min))
  1310. (forward-line 1))
  1311. (my-dired-next-line (if (or (dired-get-filename nil t)
  1312. (dired-get-subdir))
  1313. (- arg 1)
  1314. arg)))
  1315. (dired-move-to-filename)))
  1316. (defun my-dired-print-current-dir-and-file ()
  1317. (message "%s %s"
  1318. default-directory
  1319. (buffer-substring-no-properties (point-at-bol)
  1320. (point-at-eol))))
  1321. (defun dired-do-execute-as-command ()
  1322. ""
  1323. (interactive)
  1324. (let ((file (dired-get-filename t)))
  1325. (if (file-executable-p file)
  1326. (start-process file nil file)
  1327. (when (y-or-n-p
  1328. "this file cant be executed. mark as executable and go? : ")
  1329. (set-file-modes file
  1330. (file-modes-symbolic-to-number "u+x" (file-modes file)))
  1331. (start-process file nil file)))))
  1332. ;;http://bach.istc.kobe-u.ac.jp/lect/tamlab/ubuntu/emacs.html
  1333. (defun my-dired-x-open ()
  1334. ""
  1335. (interactive)
  1336. (my-x-open (dired-get-filename t t)))
  1337. (if (eq window-system 'mac)
  1338. (setq dired-listing-switches "-lhF")
  1339. (setq dired-listing-switches "-lhF --time-style=long-iso")
  1340. )
  1341. (setq dired-listing-switches "-lhF")
  1342. (put 'dired-find-alternate-file 'disabled nil)
  1343. ;; when using dired-find-alternate-file
  1344. ;; reuse current dired buffer for the file to open
  1345. (setq dired-ls-F-marks-symlinks t)
  1346. (when (require 'ls-lisp nil t)
  1347. (setq ls-lisp-use-insert-directory-program nil) ; always use ls-lisp
  1348. (setq ls-lisp-dirs-first t)
  1349. (setq ls-lisp-use-localized-time-format t)
  1350. (setq ls-lisp-format-time-list
  1351. '("%Y-%m-%d %H:%M"
  1352. "%Y-%m-%d ")))
  1353. (setq dired-dwim-target t)
  1354. ;; (add-hook 'dired-after-readin-hook
  1355. ;; 'my-replace-nasi-none)
  1356. ;; (add-hook 'after-init-hook
  1357. ;; (lambda ()
  1358. ;; (dired ".")))
  1359. (add-hook 'dired-mode-hook
  1360. (lambda ()
  1361. (define-key dired-mode-map "o" 'my-dired-x-open)
  1362. (define-key dired-mode-map "i" 'dired-get-file-info)
  1363. (define-key dired-mode-map "f" 'find-file)
  1364. (define-key dired-mode-map "!" 'shell-command)
  1365. (define-key dired-mode-map "&" 'async-shell-command)
  1366. (define-key dired-mode-map "X" 'dired-do-async-shell-command)
  1367. (define-key dired-mode-map "=" 'my-dired-diff)
  1368. (define-key dired-mode-map "B" 'gtkbm-add-current-dir)
  1369. (define-key dired-mode-map "b" 'gtkbm)
  1370. (define-key dired-mode-map "h" 'my-dired-echo-file-head)
  1371. (define-key dired-mode-map "@" (lambda ()
  1372. (interactive) (my-x-open ".")))
  1373. (define-key dired-mode-map (kbd "TAB") 'other-window)
  1374. ;; (define-key dired-mode-map "P" 'my-dired-do-pack-or-unpack)
  1375. (define-key dired-mode-map "/" 'dired-isearch-filenames)
  1376. (define-key dired-mode-map (kbd "DEL") 'dired-up-directory)
  1377. (define-key dired-mode-map (kbd "C-h") 'dired-up-directory)
  1378. (substitute-key-definition 'dired-next-line
  1379. 'my-dired-next-line dired-mode-map)
  1380. (substitute-key-definition 'dired-previous-line
  1381. 'my-dired-previous-line dired-mode-map)
  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. (let ((file "._Icon\015"))
  1387. (when nil (file-readable-p file)
  1388. (delete-file file)))))
  1389. (and (fetch-library "https://raw.github.com/10sr/emacs-lisp/master/pack.el"
  1390. t)
  1391. (lazy-load-eval 'pack '(dired-do-pack-or-unpack pack))
  1392. (add-hook 'dired-mode-hook
  1393. (lambda ()
  1394. (define-key dired-mode-map "P" 'dired-do-pack-or-unpack))))
  1395. (and (fetch-library
  1396. "https://raw.github.com/10sr/emacs-lisp/master/dired-list-all-mode.el"
  1397. t)
  1398. (lazy-load-eval 'dired-list-all-mode)
  1399. (setq dired-listing-switches "-lhF")
  1400. (add-hook 'dired-mode-hook
  1401. (lambda ()
  1402. (define-key dired-mode-map "a" 'dired-list-all-mode)
  1403. )))
  1404. ) ; when dired locate
  1405. ;; http://blog.livedoor.jp/tek_nishi/archives/4693204.html
  1406. (defun my-dired-toggle-mark()
  1407. (let ((cur (cond ((eq (following-char) dired-marker-char) ?\040)
  1408. (t dired-marker-char))))
  1409. (delete-char 1)
  1410. (insert cur)))
  1411. (defun my-dired-mark (arg)
  1412. "Toggle mark the current (or next ARG) files.
  1413. If on a subdir headerline, mark all its files except `.' and `..'.
  1414. Use \\[dired-unmark-all-files] to remove all marks
  1415. and \\[dired-unmark] on a subdir to remove the marks in
  1416. this subdir."
  1417. (interactive "P")
  1418. (if (dired-get-subdir)
  1419. (save-excursion (dired-mark-subdir-files))
  1420. (let ((inhibit-read-only t))
  1421. (dired-repeat-over-lines
  1422. (prefix-numeric-value arg)
  1423. 'my-dired-toggle-mark))))
  1424. (defun my-dired-mark-backward (arg)
  1425. "In Dired, move up lines and toggle mark there.
  1426. Optional prefix ARG says how many lines to unflag; default is one line."
  1427. (interactive "p")
  1428. (my-dired-mark (- arg)))
  1429. (add-hook 'dired-mode-hook
  1430. (lambda ()
  1431. (local-set-key (kbd "SPC") 'my-dired-mark)
  1432. (local-set-key (kbd "S-SPC") 'my-dired-mark-backward))
  1433. )
  1434. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1435. ;; eshell
  1436. (lazy-load-eval 'eshell nil
  1437. (defun my-eshell-backward-delete-char ()
  1438. (interactive)
  1439. (when (< (save-excursion
  1440. (eshell-bol)
  1441. (point))
  1442. (point))
  1443. (backward-delete-char 1)))
  1444. (defun my-file-owner-p (file)
  1445. "t if FILE is owned by me."
  1446. (eq (user-uid) (nth 2 (file-attributes file))))
  1447. "http://www.bookshelf.jp/pukiwiki/pukiwiki.php\
  1448. ?Eshell%A4%F2%BB%C8%A4%A4%A4%B3%A4%CA%A4%B9"
  1449. ;; ;; written by Stefan Reichoer <reichoer@web.de>
  1450. ;; (defun eshell/less (&rest args)
  1451. ;; "Invoke `view-file' on the file.
  1452. ;; \"less +42 foo\" also goes to line 42 in the buffer."
  1453. ;; (if args
  1454. ;; (while args
  1455. ;; (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
  1456. ;; (let* ((line (string-to-number (match-string 1 (pop args))))
  1457. ;; (file (pop args)))
  1458. ;; (view-file file)
  1459. ;; (goto-line line))
  1460. ;; (view-file (pop args))))))
  1461. (defun eshell/o (&optional file)
  1462. (my-x-open (or file ".")))
  1463. ;; (defun eshell/vi (&rest args)
  1464. ;; "Invoke `find-file' on the file.
  1465. ;; \"vi +42 foo\" also goes to line 42 in the buffer."
  1466. ;; (while args
  1467. ;; (if (string-match "\\`\\+\\([0-9]+\\)\\'" (car args))
  1468. ;; (let* ((line (string-to-number (match-string 1 (pop args))))
  1469. ;; (file (pop args)))
  1470. ;; (find-file file)
  1471. ;; (goto-line line))
  1472. ;; (find-file (pop args)))))
  1473. (defun eshell/clear ()
  1474. "Clear the current buffer, leaving one prompt at the top."
  1475. (interactive)
  1476. (let ((inhibit-read-only t))
  1477. (erase-buffer)))
  1478. (defun eshell-clear ()
  1479. (interactive)
  1480. (let ((inhibit-read-only t))
  1481. (erase-buffer)
  1482. (insert (funcall eshell-prompt-function))))
  1483. (defun eshell/d (&optional dirname switches)
  1484. "if first arg is omitted open current directory."
  1485. (dired (or dirname ".") switches))
  1486. (defun eshell/v ()
  1487. (view-mode 1))
  1488. ;; (defun eshell/aaa (&rest args)
  1489. ;; (message "%S"
  1490. ;; args))
  1491. (defvar eshell/git-cat-command
  1492. nil
  1493. "List of git commands that cat just return strings as results.")
  1494. (setq eshell/git-cat-command
  1495. '("status" "st" "b" "branch" "ls" "ls-files")
  1496. )
  1497. (defun eshell/git (&rest args)
  1498. (if (member (car args)
  1499. eshell/git-cat-command)
  1500. (shell-command-to-string (mapconcat 'shell-quote-argument
  1501. `("git"
  1502. "-c"
  1503. "color.ui=always"
  1504. ,@args)
  1505. " "))
  1506. ;; (eshell-git-shell-command-to-string args)
  1507. (if (require 'git-command nil t)
  1508. (git-command (mapconcat 'shell-quote-argument
  1509. args
  1510. " "))
  1511. (apply 'eshell-exec-visual "git" args))))
  1512. ;; (defun eshell-git-shell-command-to-string (args)
  1513. ;; "Return string of output of ARGS."
  1514. ;; (let ((sargs (mapconcat 'shell-quote-argument
  1515. ;; args
  1516. ;; " ")))
  1517. ;; (if (require 'ansi-color nil t)
  1518. ;; (identity
  1519. ;; (shell-command-to-string (concat "git "
  1520. ;; "-c color.ui=always "
  1521. ;; sargs)))
  1522. ;; (shell-command-to-string (concat "git "
  1523. ;; sargs)))))
  1524. (defalias 'eshell/g 'eshell/git)
  1525. (defalias 'eshell/: 'ignore)
  1526. (defalias 'eshell/type 'eshell/which)
  1527. ;; (defalias 'eshell/vim 'eshell/vi)
  1528. (defalias 'eshell/ff 'find-file)
  1529. (defalias 'eshell/q 'eshell/exit)
  1530. (defun eshell-goto-prompt ()
  1531. ""
  1532. (interactive)
  1533. (goto-char (point-max)))
  1534. (defun eshell-delete-char-or-logout (n)
  1535. (interactive "p")
  1536. (if (equal (eshell-get-old-input)
  1537. "")
  1538. (progn
  1539. (insert "exit")
  1540. (eshell-send-input))
  1541. (delete-char n)))
  1542. (defun eshell-kill-input ()
  1543. (interactive)
  1544. (delete-region (point)
  1545. (progn (eshell-bol)
  1546. (point))))
  1547. (defalias 'eshell/logout 'eshell/exit)
  1548. (defun eshell-cd-default-directory (&optional eshell-buffer-or-name)
  1549. "open eshell and change wd
  1550. if arg given, use that eshell buffer, otherwise make new eshell buffer."
  1551. (interactive)
  1552. (let ((dir (expand-file-name default-directory)))
  1553. (switch-to-buffer (or eshell-buffer-or-name
  1554. (eshell t)))
  1555. (unless (equal dir (expand-file-name default-directory))
  1556. ;; (cd dir)
  1557. ;; (eshell-interactive-print (concat "cd " dir "\n"))
  1558. ;; (eshell-emit-prompt)
  1559. (goto-char (point-max))
  1560. (eshell-kill-input)
  1561. (insert "cd " dir)
  1562. (eshell-send-input))))
  1563. (defadvice eshell-next-matching-input-from-input
  1564. ;; do not cycle history
  1565. (around eshell-history-do-not-cycle activate)
  1566. (if (= 0
  1567. (or eshell-history-index
  1568. 0))
  1569. (progn
  1570. (delete-region eshell-last-output-end (point))
  1571. (insert-and-inherit eshell-matching-input-from-input-string)
  1572. (setq eshell-history-index nil))
  1573. ad-do-it))
  1574. (setq eshell-directory-name "~/.emacs.d/eshell/")
  1575. (setq eshell-term-name "eterm-color")
  1576. (setq eshell-scroll-to-bottom-on-input t)
  1577. (setq eshell-cmpl-ignore-case t)
  1578. (setq eshell-cmpl-cycle-completions nil)
  1579. (setq eshell-highlight-prompt nil)
  1580. (setq eshell-ls-initial-args '("-hCFG"
  1581. "--color=auto"
  1582. "--time-style=long-iso")) ; "-hF")
  1583. (setq eshell-prompt-function
  1584. 'my-eshell-prompt-function)
  1585. (defun my-eshell-prompt-function ()
  1586. (with-temp-buffer
  1587. (let (p1 p2 p3 p4)
  1588. (insert ":: [")
  1589. (setq p1 (point))
  1590. (insert user-login-name
  1591. "@"
  1592. (car (split-string system-name
  1593. "\\."))
  1594. )
  1595. (setq p2 (point))
  1596. (insert ":")
  1597. (setq p3 (point))
  1598. (insert (abbreviate-file-name default-directory))
  1599. (setq p4 (point))
  1600. (insert "]")
  1601. (insert "\n:: ")
  1602. (unless (eq 0
  1603. eshell-last-command-status)
  1604. (insert (format "[STATUS:%d] "
  1605. eshell-last-command-status)))
  1606. (insert (if (= (user-uid)
  1607. 0)
  1608. "# "
  1609. "$ "))
  1610. (add-text-properties p1
  1611. p2
  1612. '(face underline))
  1613. (add-text-properties p3
  1614. p4
  1615. '(face underline))
  1616. (buffer-substring (point-min)
  1617. (point-max)))))
  1618. (add-hook 'eshell-mode-hook
  1619. (lambda ()
  1620. ;; (define-key eshell-mode-map (kbd "C-x C-x") (lambda ()
  1621. ;; (interactive)
  1622. ;; (switch-to-buffer (other-buffer))))
  1623. ;; (define-key eshell-mode-map (kbd "C-g") (lambda ()
  1624. ;; (interactive)
  1625. ;; (eshell-goto-prompt)
  1626. ;; (keyboard-quit)))
  1627. (define-key eshell-mode-map (kbd "C-u")
  1628. 'eshell-kill-input)
  1629. (define-key eshell-mode-map (kbd "C-d")
  1630. 'eshell-delete-char-or-logout)
  1631. ;; (define-key eshell-mode-map (kbd "C-l")
  1632. ;; 'eshell-clear)
  1633. (define-key eshell-mode-map (kbd "DEL")
  1634. 'my-eshell-backward-delete-char)
  1635. (define-key eshell-mode-map
  1636. (kbd "C-p") 'eshell-previous-matching-input-from-input)
  1637. (define-key eshell-mode-map
  1638. (kbd "C-n") 'eshell-next-matching-input-from-input)
  1639. (apply 'eshell/addpath exec-path)
  1640. (set (make-local-variable 'scroll-margin) 0)
  1641. ;; (eshell/export "GIT_PAGER=")
  1642. ;; (eshell/export "GIT_EDITOR=")
  1643. (eshell/export "LC_MESSAGES=C")
  1644. (switch-to-buffer (current-buffer)) ; move buffer top of list
  1645. (set (make-local-variable 'hl-line-range-function)
  1646. (lambda ()
  1647. '(0 . 0)))
  1648. (add-to-list 'eshell-virtual-targets
  1649. '("/dev/less"
  1650. (lambda (str)
  1651. (if str
  1652. (with-current-buffer nil)))
  1653. nil))
  1654. ))
  1655. (add-hook 'eshell-mode-hook
  1656. (lambda ()
  1657. (add-to-list 'eshell-visual-commands "vim")
  1658. ;; (add-to-list 'eshell-visual-commands "git")
  1659. (add-to-list 'eshell-output-filter-functions
  1660. 'eshell-truncate-buffer)
  1661. (mapcar (lambda (alias)
  1662. (add-to-list 'eshell-command-aliases-list
  1663. alias))
  1664. '(
  1665. ; ("ll" "ls -l $*")
  1666. ; ("la" "ls -a $*")
  1667. ; ("lla" "ls -al $*")
  1668. ("eless"
  1669. (concat "cat >>> (with-current-buffer "
  1670. "(get-buffer-create \"*eshell output\") "
  1671. "(erase-buffer) "
  1672. "(setq buffer-read-only nil) "
  1673. "(current-buffer)) "
  1674. "(view-buffer (get-buffer \"*eshell output*\"))")
  1675. ))
  1676. )))
  1677. ) ; eval after load eshell
  1678. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1679. ;; frame buffer
  1680. ;; todo: work well when opening files already opened on another window
  1681. (add-hook 'after-make-frame-functions
  1682. (lambda (f)
  1683. (set-window-buffer (frame-selected-window f)
  1684. "*Messages*")))
  1685. (defun make-frame-command-with-name (name)
  1686. "Make frame with NAME specified."
  1687. (interactive "sName for new frame: ")
  1688. (set-frame-parameter (make-frame-command)
  1689. 'name
  1690. name))
  1691. (defvar my-frame-buffer-plist nil)
  1692. (defun my-frame-buffer-add (&optional buf frame)
  1693. "Add BUF to buffer list for FRAME."
  1694. (setq my-frame-buffer-plist
  1695. (plist-put my-frame-buffer-plist
  1696. (or frame
  1697. (selected-frame))
  1698. (let ((lst (my-frame-buffer-get frame)))
  1699. (if lst
  1700. (add-to-list 'lst
  1701. (or buf
  1702. (current-buffer)))
  1703. (list (or buf
  1704. (current-buffer))))))))
  1705. (defun my-frame-buffer-remove (&optional buf frame)
  1706. "Remove BUF from bufferlist for FRAME."
  1707. (setq my-frame-buffer-plist
  1708. (plist-put my-frame-buffer-plist
  1709. (or frame
  1710. (selected-frame))
  1711. (delq (or buf
  1712. (current-buffer))
  1713. (my-frame-buffer-get frame)))))
  1714. (defun my-frame-buffer-get (&optional frame)
  1715. "Get buffer list for FRAME."
  1716. (plist-get my-frame-buffer-plist
  1717. (or frame
  1718. (selected-frame))))
  1719. (defun my-frame-buffer-kill-all-buffer (&optional frame)
  1720. "Kill all buffer of FRAME."
  1721. (mapcar 'kill-buffer
  1722. (my-frame-buffer-get frame)))
  1723. (add-hook 'find-file-hook
  1724. 'my-frame-buffer-add)
  1725. ;; (add-hook 'term-mode-hook
  1726. ;; 'my-frame-buffer-add)
  1727. (add-hook 'eshell-mode-hook
  1728. 'my-frame-buffer-add)
  1729. (add-hook 'Man-mode-hook
  1730. 'my-frame-buffer-add)
  1731. (add-hook 'kill-buffer-hook
  1732. 'my-frame-buffer-remove)
  1733. (add-hook 'delete-frame-functions
  1734. 'my-frame-buffer-kill-all-buffer)
  1735. (defvar my-desktop-terminal "roxterm")
  1736. (defun my-execute-terminal ()
  1737. "Invole terminal program."
  1738. (interactive)
  1739. (if (and (or (eq system-type 'windows-nt)
  1740. window-system)
  1741. my-desktop-terminal
  1742. )
  1743. (let ((process-environment (cons "TERM=xterm" process-environment)))
  1744. (start-process "terminal"
  1745. nil
  1746. my-desktop-terminal))
  1747. (my-term)))
  1748. (defun my-delete-frame-or-kill-emacs ()
  1749. "Delete frame when opening multiple frame, kill Emacs when only one."
  1750. (interactive)
  1751. (if (eq 1
  1752. (length (frame-list)))
  1753. (save-buffers-kill-emacs)
  1754. (delete-frame)))
  1755. ;; (define-key my-prefix-map (kbd "C-s") 'my-execute-terminal)
  1756. (define-key my-prefix-map (kbd "C-f") 'make-frame-command-with-name)
  1757. (global-set-key (kbd "C-x C-c") 'my-delete-frame-or-kill-emacs)
  1758. (define-key my-prefix-map (kbd "C-x C-c") 'save-buffers-kill-emacs)
  1759. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1760. ;; my-term
  1761. (defvar my-term nil
  1762. "My terminal buffer.")
  1763. (defvar my-term-function nil
  1764. "Function to create terminal buffer.
  1765. This function accept no argument and return newly created buffer of terminal.")
  1766. (defun my-term (&optional arg)
  1767. "Open terminal buffer and return that buffer.
  1768. ARG is ignored."
  1769. (interactive "P")
  1770. (if (and my-term
  1771. (buffer-name my-term))
  1772. (pop-to-buffer my-term)
  1773. (setq my-term
  1774. (save-window-excursion
  1775. (funcall my-term-function)))
  1776. (and my-term
  1777. (my-term))))
  1778. ;; (setq my-term-function
  1779. ;; (lambda ()
  1780. ;; (if (eq system-type 'windows-nt)
  1781. ;; (eshell)
  1782. ;; (if (require 'multi-term nil t)
  1783. ;; (multi-term)
  1784. ;; (ansi-term shell-file-name)))))
  1785. (setq my-term-function 'eshell)
  1786. (define-key my-prefix-map (kbd "C-s") 'my-term)
  1787. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1788. ;; x open
  1789. (defvar my-filer nil)
  1790. (setq my-filer (or (executable-find "pcmanfm")
  1791. (executable-find "nautilus")))
  1792. (defun my-x-open (file)
  1793. "open FILE."
  1794. (interactive "FOpen File: ")
  1795. (setq file (expand-file-name file))
  1796. (message "Opening %s..." file)
  1797. (cond ((eq system-type 'windows-nt)
  1798. (call-process "cmd.exe" nil 0 nil
  1799. "/c" "start" "" (convert-standard-filename file)))
  1800. ((eq system-type 'darwin)
  1801. (call-process "open" nil 0 nil file))
  1802. ((getenv "DISPLAY")
  1803. (call-process (or my-filer "xdg-open") nil 0 nil file))
  1804. (t
  1805. (find-file file))
  1806. )
  1807. ;; (recentf-add-file file)
  1808. (message "Opening %s...done" file))
  1809. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1810. ;; misc funcs
  1811. (defun memo (&optional dir)
  1812. "Open memo.txt in DIR."
  1813. (interactive)
  1814. (pop-to-buffer (find-file-noselect (concat (if dir
  1815. (file-name-as-directory dir)
  1816. "")
  1817. "memo.txt"))))
  1818. (defvar my-rgrep-alist
  1819. `(
  1820. ;; gnu global
  1821. ("global"
  1822. (and (require 'gtags nil t)
  1823. (gtags-get-rootpath))
  1824. "global --result grep ")
  1825. ;; git grep
  1826. ("gitgrep"
  1827. (eq 0
  1828. (shell-command "git rev-parse --git-dir"))
  1829. "git --no-pager -c color.grep=false grep -nH -e ")
  1830. ;; the silver searcher
  1831. ("ag"
  1832. (executable-find "ag")
  1833. "ag --nocolor --nogroup --nopager ")
  1834. ;; ack
  1835. ("ack"
  1836. (executable-find "ack")
  1837. "ack --nocolor --nogroup --nopager ")
  1838. ;; grep
  1839. ("grep"
  1840. t
  1841. ,(concat "find . "
  1842. "-path '*/.git' -prune -o "
  1843. "-path '*/.svn' -prune -o "
  1844. "-type f -print0 | "
  1845. "xargs -0 grep -nH -e "))
  1846. )
  1847. "Alist of rgrep command.
  1848. Each element is in the form like (NAME SEXP COMMAND), where SEXP returns the
  1849. condition to choose COMMAND when evaluated.")
  1850. (defvar my-rgrep-default nil
  1851. "Default command name for my-rgrep.")
  1852. (defun my-rgrep-grep-command (&optional name alist)
  1853. "Return recursive grep command for current directory or nil.
  1854. If NAME is given, use that without testing.
  1855. Commands are searched from ALIST."
  1856. (if alist
  1857. (if name
  1858. ;; if name is given search that from alist and return the command
  1859. (nth 2 (assoc name
  1860. alist))
  1861. ;; if name is not given try test in 1th elem
  1862. (let ((car (car alist))
  1863. (cdr (cdr alist)))
  1864. (if (eval (nth 1 car))
  1865. ;; if the condition is true return the command
  1866. (nth 2 car)
  1867. ;; try next one
  1868. (and cdr
  1869. (my-rgrep-grep-command name cdr)))))
  1870. ;; if alist is not given set default value
  1871. (my-rgrep-grep-command name my-rgrep-alist)))
  1872. (my-rgrep-grep-command "ag" nil)
  1873. (defun my-rgrep (command-args)
  1874. "My recursive grep. Run COMMAND-ARGS."
  1875. (interactive (let ((cmd (my-rgrep-grep-command my-rgrep-default
  1876. nil)))
  1877. (if cmd
  1878. (list (read-shell-command "grep command: "
  1879. cmd
  1880. 'grep-find-history))
  1881. (error "my-rgrep: Command for rgrep not found")
  1882. )))
  1883. (compilation-start command-args
  1884. 'grep-mode))
  1885. ;; (defun my-rgrep-symbol-at-point (command-args)
  1886. ;; "My recursive grep. Run COMMAND-ARGS."
  1887. ;; (interactive (list (read-shell-command "grep command: "
  1888. ;; (concat (my-rgrep-grep-command)
  1889. ;; " "
  1890. ;; (thing-at-point 'symbol))
  1891. ;; 'grep-find-history)))
  1892. ;; (compilation-start command-args
  1893. ;; 'grep-mode))
  1894. (defun my-rgrep-ack ()
  1895. "My recursive grep by ack."
  1896. (interactive)
  1897. (let ((my-rgrep-default "ack"))
  1898. (if (called-interactively-p 'any)
  1899. (call-interactively 'my-rgrep)
  1900. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1901. (defun my-rgrep-ag ()
  1902. "My recursive grep by ack."
  1903. (interactive)
  1904. (let ((my-rgrep-default "ag"))
  1905. (if (called-interactively-p 'any)
  1906. (call-interactively 'my-rgrep)
  1907. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1908. (defun my-rgrep-gitgrep ()
  1909. "My recursive grep by ack."
  1910. (interactive)
  1911. (let ((my-rgrep-default "gitgrep"))
  1912. (if (called-interactively-p 'any)
  1913. (call-interactively 'my-rgrep)
  1914. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1915. (defun my-rgrep-grep ()
  1916. "My recursive grep by ack."
  1917. (interactive)
  1918. (let ((my-rgrep-default "grep"))
  1919. (if (called-interactively-p 'any)
  1920. (call-interactively 'my-rgrep)
  1921. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1922. (defun my-rgrep-global ()
  1923. "My recursive grep by ack."
  1924. (interactive)
  1925. (let ((my-rgrep-default "global"))
  1926. (if (called-interactively-p 'any)
  1927. (call-interactively 'my-rgrep)
  1928. (error "Not intended to be called noninteractively. Use `my-rgrep'"))))
  1929. (define-key ctl-x-map "s" 'my-rgrep)
  1930. ;; (defun make ()
  1931. ;; "Run \"make -k\" in current directory."
  1932. ;; (interactive)
  1933. ;; (compile "make -k"))
  1934. (defalias 'make 'compile)
  1935. (defvar sed-in-place-history nil
  1936. "History of `sed-in-place'.")
  1937. (defvar sed-in-place-command "sed --in-place=.bak -e")
  1938. (defun sed-in-place (command)
  1939. "Issue sed in place COMMAND."
  1940. (interactive (list (read-shell-command "sed in place: "
  1941. (concat sed-in-place-command " ")
  1942. 'sed-in-place-history)))
  1943. (shell-command command
  1944. "*sed in place*"))
  1945. (defun dired-do-sed-in-place (&optional arg)
  1946. "Issue sed in place dired. If ARG is given, use the next ARG files."
  1947. (interactive "p")
  1948. (require 'dired-aux)
  1949. (let* ((files (dired-get-marked-files t arg))
  1950. (expr (dired-mark-read-string "Run sed-in-place for %s: "
  1951. nil
  1952. 'sed-in-place
  1953. arg
  1954. files)))
  1955. (if (equal expr
  1956. "")
  1957. (error "No expression specified")
  1958. (shell-command (concat sed-in-place-command
  1959. " '"
  1960. expr
  1961. "' "
  1962. (mapconcat 'shell-quote-argument
  1963. files
  1964. " "))
  1965. "*sed in place*"))))
  1966. (defun dir-show (&optional dir)
  1967. "Show DIR list."
  1968. (interactive)
  1969. (let ((bf (get-buffer-create "*dir show*"))
  1970. (list-directory-brief-switches "-C"))
  1971. (with-current-buffer bf
  1972. (list-directory (or nil
  1973. default-directory)
  1974. nil))
  1975. ))
  1976. (defun my-convmv-sjis2utf8-test ()
  1977. "Run `convmv -r -f sjis -t utf8 *'.
  1978. this is test, does not rename files."
  1979. (interactive)
  1980. (shell-command "convmv -r -f sjis -t utf8 *"))
  1981. (defun my-convmv-sjis2utf8-notest ()
  1982. "Run `convmv -r -f sjis -t utf8 * --notest'."
  1983. (interactive)
  1984. (shell-command "convmv -r -f sjis -t utf8 * --notest"))
  1985. (defun kill-ring-save-buffer-file-name ()
  1986. "Get current filename."
  1987. (interactive)
  1988. (let ((file buffer-file-name))
  1989. (if file
  1990. (progn (kill-new file)
  1991. (message file))
  1992. (message "not visiting file."))))
  1993. (defvar kill-ring-buffer-name "*kill-ring*"
  1994. "Buffer name for `kill-ring-buffer'.")
  1995. (defun open-kill-ring-buffer ()
  1996. "Open kill- ring buffer."
  1997. (interactive)
  1998. (pop-to-buffer
  1999. (with-current-buffer (get-buffer-create kill-ring-buffer-name)
  2000. (erase-buffer)
  2001. (yank)
  2002. (text-mode)
  2003. (current-local-map)
  2004. (goto-char (point-min)))))
  2005. ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2006. ;; ;; savage emacs
  2007. ;; ;; when enabled emacs fails to complete
  2008. ;; ;; http://e-arrows.sakura.ne.jp/2010/05/emacs-should-be-more-savage.html
  2009. ;; (defadvice message (before message-for-stupid (arg &rest arg2) activate)
  2010. ;; (setq arg
  2011. ;; (concat arg
  2012. ;; (if (eq nil
  2013. ;; (string-match "\\. *$"
  2014. ;; arg))
  2015. ;; ".")
  2016. ;; " Stupid!")))
  2017. (defvar my-system-info
  2018. nil
  2019. "System info in the form of \"[user@host] \".")
  2020. (setq my-system-info
  2021. (concat "["
  2022. user-login-name
  2023. "@"
  2024. (car (split-string system-name
  2025. "\\."))
  2026. "] "))
  2027. (defadvice read-from-minibuffer (before info-in-prompt activate)
  2028. "Show system info when use `read-from-minibuffer'."
  2029. (ad-set-arg 0
  2030. (concat my-system-info
  2031. (ad-get-arg 0))))
  2032. (defadvice read-string (before info-in-prompt activate)
  2033. "Show system info when use `read-string'."
  2034. (ad-set-arg 0
  2035. (concat my-system-info
  2036. (ad-get-arg 0))))
  2037. (when (< emacs-major-version 24)
  2038. (defadvice completing-read (before info-in-prompt activate)
  2039. "Show system info when use `completing-read'."
  2040. (ad-set-arg 0
  2041. (concat my-system-info
  2042. (ad-get-arg 0)))))
  2043. (defun my-real-function-subr-p (function)
  2044. "Return t if FUNCTION is a built-in function even if it is advised."
  2045. (let* ((advised (and (symbolp function)
  2046. (featurep 'advice)
  2047. (ad-get-advice-info function)))
  2048. (real-function
  2049. (or (and advised (let ((origname (cdr (assq 'origname advised))))
  2050. (and (fboundp origname)
  2051. origname)))
  2052. function))
  2053. (def (if (symbolp real-function)
  2054. (symbol-function real-function)
  2055. function)))
  2056. (subrp def)))
  2057. ;; (my-real-function-subr-p 'my-real-function-subr-p)
  2058. ;;;;;;;;;;;;;;;;;;;;;;;;
  2059. ;; ilookup
  2060. (when (fetch-library
  2061. "https://raw.github.com/10sr/emacs-lisp/master/ilookup.el"
  2062. t)
  2063. (lazy-load-eval 'ilookup
  2064. '(ilookup-open)
  2065. (setq ilookup-dict-alist
  2066. '(
  2067. ("en" . (lambda (word)
  2068. (shell-command-to-string
  2069. (format "sdcv -n -u dictd_www.dict.org_gcide '%s'"
  2070. word))))
  2071. ("ja" . (lambda (word)
  2072. (shell-command-to-string
  2073. (format "sdcv -n -u EJ-GENE95 -u jmdict-en-ja '%s'"
  2074. word))))
  2075. ("jaj" . (lambda (word)
  2076. (shell-command-to-string
  2077. (format "sdcv -n -u jmdict-en-ja '%s'"
  2078. word))))
  2079. ("jag" .
  2080. (lambda (word)
  2081. (with-temp-buffer
  2082. (insert (shell-command-to-string
  2083. (format "sdcv -n -u 'Genius English-Japanese' '%s'"
  2084. word)))
  2085. (html2text)
  2086. (buffer-substring (point-min)
  2087. (point-max)))))
  2088. ("alc" . (lambda (word)
  2089. (shell-command-to-string
  2090. (format "alc '%s' | head -n 20"
  2091. word))))
  2092. ("app" . (lambda (word)
  2093. (shell-command-to-string
  2094. (format "dict_app '%s'"
  2095. word))))
  2096. ;; letters broken
  2097. ("ms" .
  2098. (lambda (word)
  2099. (let ((url (concat
  2100. "http://api.microsofttranslator.com/V2/Ajax.svc/"
  2101. "Translate?appId=%s&text=%s&to=%s"))
  2102. (apikey "3C9778666C5BA4B406FFCBEE64EF478963039C51")
  2103. (target "ja")
  2104. (eword (url-hexify-string word)))
  2105. (with-current-buffer (url-retrieve-synchronously
  2106. (format url
  2107. apikey
  2108. eword
  2109. target))
  2110. (message "")
  2111. (goto-char (point-min))
  2112. (search-forward-regexp "^$"
  2113. nil
  2114. t)
  2115. (url-unhex-string (buffer-substring-no-properties
  2116. (point)
  2117. (point-max)))))))
  2118. ))
  2119. ;; (funcall (cdr (assoc "ms"
  2120. ;; ilookup-alist))
  2121. ;; "dictionary")
  2122. ;; (switch-to-buffer (url-retrieve-synchronously "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=3C9778666C5BA4B406FFCBEE64EF478963039C51&text=dictionary&to=ja"))
  2123. ;; (switch-to-buffer (url-retrieve-synchronously "http://google.com"))
  2124. (setq ilookup-default "ja")))
  2125. ;;; emacs.el ends here