Edebug を使った Emacs Lisp のデバッグ(書きかけ)
『改訂版 やさしいEmacs-Lisp講座』を読んで Edebug の存在を知ったけど、Edebugの終わらせ方が分からず調べたので、そのメモ。
出典
17.2 Edebug
Edebug - GNU Emacs Lisp Reference Manual
17.2.2 Instrumenting for Edebug
Instrumenting - GNU Emacs Lisp Reference Manual
Edebug の始め方
C-u C-M-x (eval-defun)
デバッグしたい関数やマクロの定義の中で C-u C-M-x するとコードが instrument される。 instrument とは、どうやらデバッグ用のコードを裏でこっそり組み込む事らしい。 そして、そのデバッグ機能付きの関数がEmacsにロードされる。
※ eval-defun は Edebug によって置き換えられていて edebug-eval-defun が実行される。
Edebug の終わらせ方
C-M-x (eval-defun)
デバッグ機能付きの関数は、そのままだとずっとデバッグ機能付きのままなので、呼ばれれば関数の先頭でブレークしてしまう。それをやめさせたいときは、デバッグ用のコードを組み込む前の、元の関数をEmacsにロードすれば良い。
いやー、そう言われれば分かるけど、気付かなかったなあ。
上の 17.2.2 Instrumenting for Edebug では M-x load するか M-: (eval-expression) すると書かれている
To remove instrumentation from a definition, simply re-evaluate its definition in a way that does not instrument. There are two ways of evaluating forms that never instrument them: from a file with load, and from the minibuffer with eval-expression (M-:).