C-xC-eでdefvar, defcustomの値を設定しなおす。
普通に elisp を書いてると defvar, defcustom の値を設定し直したい事がよくある。例えば作ってる途中の elisp で keymap に新しい定義を追加した時とか。今まではコピって eval-expression してたんだけど、さすがに面倒になってきたから無理矢理設定できるコマンドを作った。
これで defvar, defcustom の後ろで普通に C-xC-e すると定義されてても評価しなおしてくれる。結構便利。実は標準でありそうだけどね。
ソース
(defun eval-last-sexp-force (eval-last-sexp-arg-internal) "Do `eval-last-sexp', but force bound variable to symbol, if previous form is `defvar' or `defcustom'." (interactive "P") (save-excursion (with-syntax-table emacs-lisp-mode-syntax-table (backward-sexp 1) (let ((form (read (current-buffer)))) (when (and (memq (car form) '(defvar defcustom))) (makunbound (cadr form)))))) (eval-last-sexp eval-last-sexp-arg-internal)) (global-set-key "\C-x\C-e" 'eval-last-sexp-force)