[mew-int 00570] Using Edebug w/ Mew
sen_ml at example.com
sen_ml at example.com
Wed Nov 14 10:12:55 JST 2001
When studying and debugging Mew I find the use of Edebug [1] to be
quite helpful and useful. However, in order for Edebug to handle
macros, it is necessary to provide Edebug with additional information
about which subexpressions of the macro call are forms to be evaluated
[2]. If the information is not provided, Edebug will just step over
the macro call; the call happens, but the user is not able to step
through the expressions passed to the macro -- this makes the process
of using Edebug to debug and study code that contains macros
frustrating to say the least.
Mew defines and uses a number of macros, so in order to use Edebug
comfortably w/ Mew, it's helpful to provide the information which
Edebug needs to handle Mew's macros. Happily, AFAICT, all of Mew's
macros evaluate all of their subexpressions so it's pretty easy to
tell Edebug what it needs to know.
For example, for the macro `mew-summary-only', all that is necessary
is that the following expression be evaluated before using Edebug:
(def-edebug-spec mew-summary-only t)
I was unable to find Edebug macro support w/in Mew, so I've gone
through Mew 2.1's .el files to find macro definitions, and put
together a .el file (mew-edebug.el) which evaluates `def-edebug-spec'
for each of Mew's macros. I've tested this out for a bit and for the
most part, it seems to work fine [3].
Usage instructions are:
1) Put mew-edebug.el in a directory in your load-path.
2) Put:
(add-hook 'mew-init-hook
'(lambda ()
(require 'mew-edebug.el)))
in your .emacs.
Below is the code for mew-edebug.el
P.S. If there's already a way to do this in Mew, please tell me!
;; mew-edebug.el --- Help for using edebug for macros in Mew
;; Author: Sen Nagata <sen at example.com>
;; Created: Nov 11, 2001
;; Version: 0.3
;; Set-up:
;;
;; Put this file somewhere in your `load-path' and the following in
;; your .emacs:
;;
;; (add-hook 'mew-init-hook
;; '(lambda ()
;; (require 'mew-edebug.el)))
;;
;; Upon instrumenting a function with `edebug-defun',
;; `mew-edebug-macro-init' will be run to instrument Mew macros.
;; Issues:
;;
;; I've tested many of the macros below with edebug. Although most
;; appear to work, I experienced problems with some
;; (e.g. `mew-time-rfc-*'). I don't know what the problem is yet, but
;; my current suspicion is that it has something to do with
;; `defsubst'.
;;; Code:
(require 'mew)
(defvar mew-macro-names
'(
mew-header-encode-cond
mew-header-encode-cond2
mew-decode-narrow-to-header
mew-summary-header-mode
mew-add-first
mew-insert-after
mew-replace-with
mew-remove-entry
mew-elet
mew-filter
mew-time-rfc-day
mew-time-rfc-mon
mew-time-rfc-year
mew-time-rfc-hour
mew-time-rfc-min
mew-time-rfc-sec
mew-time-rfc-tmzn
mew-rendezvous
mew-addrstr-parse-syntax-list-check-depth
mew-mark-alist-set
mew-mode-input-file-name
mew-mode-input-directory-name
mew-plet
mew-piolet
mew-pioalet
mew-flet
mew-frwlet
mew-summary-msg-or-part
mew-summary-msg
mew-summary-part
mew-summary-multi-msgs
mew-summary-prepare-draft
mew-summary-only
mew-virtual-only
mew-thread-only
mew-summary-or-thread
mew-summary-not-in-queue
mew-summary-not-in-draft
mew-summary-not-in-mdrop
))
(defun mew-edebug-macro-init ()
"Call `def-edebug-spec' for each macro in `mew-macro-names'.
This function should be invoked before instrumenting a function for
use with edebug."
(interactive)
(let ((macro-names mew-macro-names))
(while macro-names
(eval `(def-edebug-spec ,(car macro-names) t))
(setq macro-names (cdr macro-names)))))
;; instrument Mew macros when edebug is used
(add-hook 'edebug-setup-hook
'(lambda ()
(mew-edebug-macro-init)))
(provide 'mew-edebug)
;;; mew-edebug.el ends here
[1] Edebug is a source-level debugger for Emacs Lisp programs.
[2] Paraphrased from the Info node "Instrumenting Macro Calls" w/in
the Elisp Info files. Of course, it'd be nice if this information
was providing in the macro definition to begin with, but there
does not appear to be a way to do this in Emacs currently.
[3] I initially encountered some problems w/ the `mew-time-rfc-*'
macros, but I have not been able to reproduce them lately.
More information about the Mew-int
mailing list