2010年4月26日月曜日

最小の.emacs

viper モードを卒業しつつある今日この頃。
限界まで設定を絞る。

ポイントは、
- vim の * 代わりの C-l
- C-w で単語削除 or リージョン削除(マーク有りの場合)
- TAB でインデント or 補完(前に文字、後ろに文字無しの場合)


(ffap-bindings)

(define-key isearch-mode-map (kbd "C-l") 'my-isearch-yank-symbol)
(defun my-isearch-yank-symbol ()
"*Put symbol at current point into search string."
(interactive)
(let ((sym (symbol-at-point)))
(if sym
(progn
(setq isearch-regexp t
isearch-string (concat "\\_<" (regexp-quote (symbol-name sym)) "\\_>")
isearch-message (mapconcat 'isearch-text-char-description isearch-string "")
isearch-yank-flag t))
(ding)))
(isearch-search-and-update))

(global-set-key (kbd "C-c C-m") 'execute-extended-command)

(global-set-key (kbd "C-w") 'my-kill-word-or-region)
(defun my-kill-word-or-region (arg)
(interactive "p")
(if (use-region-p)
(kill-region (point) (mark))
(backward-kill-word arg)))

(global-set-key (kbd "C-i") 'my-auto-hippie-expand)
(defun my-auto-hippie-expand (&optional arg)
(interactive)
(if (and (not (bolp))
(not (use-region-p))
(string-match "[a-zA-Z0-9-_]"
(char-to-string (char-before)))
(or (not (char-after))
(not (string-match "[a-zA-Z0-9-_]"
(char-to-string (char-after))))))
(hippie-expand arg)
(indent-for-tab-command arg)))

(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.
'(hippie-expand-try-functions-list (quote (try-complete-file-name-partially try-complete-file-name try-expand-all-abbrevs try-expand-dabbrev try-expand-dabbrev-all-buffers try-expand-dabbrev-from-kill try-complete-lisp-symbol-partially try-complete-lisp-symbol)))
'(iswitchb-mode t)
'(kill-whole-line t)
'(partial-completion-mode t)
'(read-file-name-completion-ignore-case t)
'(show-paren-mode t)
'(x-select-enable-clipboard 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.
)