2007年11月29日木曜日

今日の.emacs


;;emacs=""C:\emacs\22.1\bin\emacsclientw.exe" -n "$F"$R"
(server-start)


;; 配色
;(require 'color-theme)
;(color-theme-initialize)

;(color-theme-charcoal-black)
;(color-theme-classic)

;(color-theme-gnome2)
;(color-theme-kingsajz)
;(color-theme-shaman)


(cond
;; mac
((featurep 'mac-carbon)
(mac-add-ignore-shortcut '(control))
(keyboard-translate ?\¥ ?\\)
(setq load-path
(append (list (expand-file-name "~/elisp")) load-path)))
;; それ以外
(t
(setenv "PATH" (concat "C:\\UnxUtils\\usr\\local\\wbin;" (getenv "PATH")))))

(global-set-key "\C-x\C-b" 'ibuffer) ;バッファ選択に ibuffer
(partial-completion-mode t) ;ファイル名の一部で補完
(setq dired-recursive-copies 'always) ;再帰コピー ok
(setq dired-recursive-deletes 'always) ;再帰削除 ok
(require 'dired-x) ;dired を拡張
(setq dired-listing-switches "-l") ;'.' ファイルを最初は表示しない
(ffap-bindings) ;find file at point
(setq read-file-name-completion-ignore-case t) ;大文字小文字を無視する(for linux)

(define-key minibuffer-local-completion-map "\C-w" 'backward-kill-word)
;; '.' を表示したい場合は C-u s で -la に変更

;; *scratch* バッファで kill-buffer したら無視
(add-hook 'kill-buffer-query-functions
(lambda () (not (string= "*scratch*" (buffer-name)))))

;; rgrep 用のテンプレート(UnxUtils 用)
(setq grep-find-template
"find . <X> -type f <F> -print0 | xargs -0 -s32000 grep <C> -nH -e <R> ")

;; find-dired 用のテンプレート(UnxUtils 用)
(setq find-ls-option
'("-print0 | xargs -0 -s32000 ls -ld | sed -e \"s#\\\\#/#g;\" " . "-ld"))


;; C-* C-s でカーソル下の単語を検索(vim のまね)
(setq my-isearch-repeated nil)
(defun my-isearch-symbol (&optional repeat backward)
(interactive "p")
(and (eq repeat 1)
(let ((wd (thing-at-point 'symbol)))
(when wd
(let ((rq_wd (regexp-quote wd)))
(isearch-update-ring
(concat (if (string= (substring rq_wd 0 1) "_")
"\\W" "\\<") rq_wd (if (string= (substring rq_wd -1) "_") "\\W" "\\>"))
t)))))
(cond (backward
(setq my-isearch-repeated 'backward)
(isearch-backward t))
(t
(setq my-isearch-repeated 'forward)
(isearch-forward t)))
(setq my-isearch-repeated nil))

(defun my-force-repeat ()
(cond ((eq my-isearch-repeated 'forward)
(isearch-repeat-forward))
((eq my-isearch-repeated 'backward)
(isearch-repeat-backward))))

(add-hook 'isearch-mode-hook 'my-force-repeat)

(global-set-key [?\C-*] 'my-isearch-symbol)
(global-set-key [f5] 'my-isearch-symbol)
(global-set-key [f6] (lambda (&optional repeat)
(interactive "p") (my-isearch-symbol repeat t)))
(define-key isearch-mode-map [f5]
(lambda ()
(interactive)
(and (not isearch-forward) (isearch-repeat-forward))
(isearch-repeat-forward)))
(define-key isearch-mode-map [f6]
(lambda ()
(interactive)
(and isearch-forward (isearch-repeat-backward))
(isearch-repeat-backward)))

;; viper
(when nil
(setq viper-mode t)
(require 'viper)
(viper-buffer-search-enable)

(defun my-viper-beginning-of-buffer ()
(interactive)
(beginning-of-buffer))
(define-key viper-vi-global-user-map [?g?g] 'my-viper-beginning-of-buffer)

(defun my-viper-moccur ()
(interactive)
(setq wd (thing-at-point 'symbol))
(moccur (concat "\\<" wd "\\>") 0))
(define-key viper-vi-global-user-map [?g?*] 'my-viper-moccur)

(defun my-viper-star ()
(interactive)
(let ((wd (concat "\\<" (thing-at-point 'symbol) "\\>")))
(setq viper-s-string wd)
(setq viper-s-forward t)
(viper-search wd t 1)))
(define-key viper-vi-global-user-map [?*] 'my-viper-star)

(defun my-viper-jump-tag ()
(interactive)
(let ((wd (thing-at-point 'symbol)))
(find-tag wd)))
(define-key viper-vi-global-user-map [?\C-\]] 'my-viper-jump-tag)

(defun my-viper-jump-tag-next ()
(interactive)
(let ((wd (thing-at-point 'symbol)))
(find-tag wd 0)))
(define-key viper-vi-global-user-map [?\C-:] 'my-viper-jump-tag-next)

(defun my-viper-pop-tag ()
(interactive)
(pop-tag-mark))
(define-key viper-vi-global-user-map [?\C-t] 'my-viper-pop-tag)

(defun my-viper-pop-mark ()
(interactive)
(set-mark-command -1))
(define-key viper-vi-global-user-map [?\C-o] 'my-viper-pop-mark)

(define-key viper-vi-global-user-map [?u] 'undo)
(define-key viper-insert-global-user-map [backspace]
'backward-delete-char-untabify)
(define-key viper-insert-global-user-map [delete] 'delete-char)
(define-key viper-emacs-global-user-map "\C-w\C-w" 'other-window)
(define-key viper-vi-global-user-map "\C-w\C-w" 'other-window)
(define-key viper-emacs-global-user-map "\C-w\C-o" 'delete-other-windows)
(define-key viper-vi-global-user-map "\C-w\C-o" 'delete-other-windows)

(define-key viper-dired-modifier-map "j" 'dired-next-line)
(define-key viper-dired-modifier-map "k" 'dired-previous-line)
(define-key viper-dired-modifier-map "/" 'dired-goto-file)
(define-key viper-dired-modifier-map "l"
'(lambda () (interactive) (dired-next-line 10)))
(define-key viper-dired-modifier-map "h"
'(lambda () (interactive) (dired-previous-line 10)))

;;%%% の viper-toggle-parse-sexp-ignore-comments を止める
(viper-set-parsing-style-toggling-macro t)

(setq ex-token-alist
(append '(("buffer" (iswitchb-buffer))
("Buffer" (iswitchb-buffer-other-window))
("split" (split-window-vertically))
("vsplit" (split-window-horizontally))
("quit" (if (one-window-p)
(ex-quit)
(delete-window))))
ex-token-alist))
)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; moccur
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq moccur-split-word t)
;(setq moccur-use-migemo t)
(setq color-moccur-default-ime-status nil)
(autoload 'moccur-grep "color-moccur" nil t)
(autoload 'moccur-grep-find "color-moccur" nil t)
(autoload 'isearch-moccur "color-moccur" nil t)
(autoload 'isearch-moccur-all "color-moccur" nil t)
(autoload 'occur-by-moccur "color-moccur" nil t)
(autoload 'moccur "color-moccur" nil t)
(autoload 'dmoccur "color-moccur" nil t)
(autoload 'dired-do-moccur "color-moccur" nil t)
(autoload 'Buffer-menu-moccur "color-moccur" nil t)
(autoload 'moccur-narrow-down "color-moccur" nil t)
(autoload 'grep-buffers "color-moccur" nil t)
(autoload 'search-buffers "color-moccur" nil t)
(autoload 'gresreg "gresreg" nil t)
(eval-after-load "color-moccur"
'(require 'moccur-edit))
(eval-after-load "ibuffer"
'(require 'color-moccur))
(setq *moccur-buffer-name-exclusion-list*
'(".*TAGS.*" "*Completions*" "*Messages*"
"newsrc.eld"
" *migemo*" ".bbdb"))

(add-hook 'dired-mode-hook
'(lambda ()
(local-set-key "O" 'dired-do-moccur)))
(define-key Buffer-menu-mode-map "O" 'Buffer-menu-moccur)
;;(global-set-key "\M-f" 'grep-buffers)
(global-set-key "\M-o" 'occur-by-moccur)
(global-set-key "\C-c\C-x\C-o" 'moccur)
;;(global-set-key "\C-c\C-o" 'search-buffers)

(setq dmoccur-recursive-search t)


;; カーソル付近の単語をデフォルトの検索文字列とする
(setq moccur-grep-default-word-near-point t)

;; *.c 編集中のデフォルトファイルマスク: \.[HhCc]$
(add-hook
'c-mode-common-hook
'(lambda ()
(setq moccur-grep-default-mask "\\.\[HhCc\]$")))
(add-hook
'perl-mode-hook
'(lambda ()
(setq moccur-grep-default-mask "\\.pl$")))
(setq moccur-grep-following-mode-toggle t)


;;;;;;;;;;;;;;;;
;; ac-mode
;;;;;;;;;;;;;;;;
(autoload 'ac-mode "ac-mode" "Minor mode for advanced completion." t nil)

;;;;;;;;;;;;;;;;
;; lookup
;;;;;;;;;;;;;;;;
(setq load-path (cons "~/elisp/lookup/" load-path))
(setq Info-default-directory-list
(cons "~/elisp/lookup/" Info-default-directory-list))

(autoload 'lookup-pattern "lookup" nil t)
(define-key ctl-x-map "\C-y" 'lookup-pattern)
(setq lookup-search-agents
'(
(ndeb "~/elisp/lookup/ASCDATES/")
(ndeb "~/elisp/lookup/FUMEIKAI/")
(ndeb "~/elisp/lookup/RYAKU/")
(ndeb "~/elisp/lookup/WDIC/")
(ndeb "~/elisp/lookup/WEB/")
(ndeb "~/elisp/lookup/WORDNET/")
))

;;;;;;;;;;;;;;;;;;
;; sdic
;;;;;;;;;;;;;;;;;;
;;; sdic-mode 用の設定
(setq load-path (cons "~/elisp/sdic" load-path))
(autoload 'sdic-describe-word "sdic" "英単語の意味を調べる" t nil)
(global-set-key "\C-cw" 'sdic-describe-word)
(autoload 'sdic-describe-word-at-point "sdic" "カーソルの位置の英単語の意味を調べる" t nil)
(global-set-key "\C-cW" 'sdic-describe-word-at-point)
;; 英和検索で使用する辞書
(setq sdic-eiwa-dictionary-list
'(
(sdicf-client
"~/elisp/sdic/gene.sdic")
(sdicf-client
"~/elisp/sdic/eedict.sdic")
))
;; 和英検索で使用する辞書
(setq sdic-waei-dictionary-list
'(
(sdicf-client
"~/elisp/sdic/jedict.sdic")
))

;;;;;;;;;;;;;;;;;;;;
;; ruby-mode
;;;;;;;;;;;;;;;;;;;;
;; Ruby
(autoload 'ruby-mode "ruby-mode"
"Mode for editing ruby source files" t)
(setq auto-mode-alist
(append '(("\\.rb$" . ruby-mode)) auto-mode-alist))
(setq interpreter-mode-alist (append '(("ruby" . ruby-mode))
interpreter-mode-alist))
(autoload 'run-ruby "inf-ruby"
"Run an inferior Ruby process")
(autoload 'inf-ruby-keys "inf-ruby"
"Set local key defs for inf-ruby in ruby-mode")
(add-hook 'ruby-mode-hook
(lambda ()
(inf-ruby-keys)))

;; ri
(setq ri-ruby-script (expand-file-name "~/elisp/ri-emacs.rb"))
(autoload 'ri (expand-file-name "~/elisp/ri-ruby.el") nil t)
(add-hook 'ruby-mode-hook (lambda ()
(local-set-key [\M-f1] 'ri)
(local-set-key "\M-\C-i" 'ri-ruby-complete-symbol)
(local-set-key [f4] 'ri-ruby-show-args)
))

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; etags-select
;;;;;;;;;;;;;;;;;;;;;;;;;;;
;(require 'etags-select)
(autoload 'etags-select-find-tag-at-point "etags-select"
"for etags-select")
(global-set-key [f7] 'etags-select-find-tag-at-point)
(global-set-key [f8] 'pop-tag-mark)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(iswitchb-mode t)
'(kill-whole-line t)
'(view-read-only t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)