From: Lute Kamstra <Lute.Kamstra.lists@xs4all.nl>
Cc: emacs-devel@gnu.org
Subject: Re: debug declaration.
Date: Fri, 25 Mar 2005 12:06:05 +0100 [thread overview]
Message-ID: <87wtrwf0iq.fsf@xs4all.nl> (raw)
In-Reply-To: <jwvacoumdsr.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 23 Mar 2005 13:18:32 -0500")
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> (declare (debug (sexp form form form form form &optional stringp)))
>
>> X(define-generic-mode my-mode
>> (list ?# ?% (+ 50 9))
>> (list "abba" "ebbe" (concat "ob" "bo"))
>> nil
>> X(list "\\.mm\\'")X
>> nil
>> "This is My mode.")X
>
> That's because when you execute the call to define-generic-mode, only the
> fourth argument is actually evaluated. All the others will only be
> evaluated when the defined function is actually called. I.e. it's normal.
>
> OTOH, with your definition you'll get bugs when you actually call my-mode
> because the instrumented code that's then executed is executed in an
> environment where edebugging is not expected. To fix this problem, you need
> to use `def-form' instead of `form' for them.
It's dawning on me now...
> Try (debug (sexp def-form def-form def-form form def-form [&optional stringp]))
This does indeed work. (The brackets are not necessary, are they?)
The node "Specification List" in the lisp manual says that def-form
can only be used after &define, however. And when I do that, things
seem to break.
I used:
(declare (debug (&define sexp def-form def-form def-form form def-form &optional stringp)))
for define-generic-mode. Then I did C-u C-M-x on this call:
(define-generic-mode my-mode
(list ?# ?% (+ 50 9))
(list "abba" "ebbe" (concat "ob" "bo"))
nil
(list "\\.mm\\'")
nil
"This is My mode.")
Now I get an error:
Debugger entered--Lisp error: (wrong-type-argument consp nil)
edebug-before(8)
(edebug-after (edebug-before 8) 9 (list "\\.mm\\'"))
(let ((--dolist-temp-- ...) re) (while --dolist-temp-- (setq re ...) (setq --dolist-temp-- ...) (add-to-list ... ...)))
(dolist (re (edebug-after ... 9 ...)) (add-to-list (quote auto-mode-alist) (cons re ...)))
(progn (add-to-list (quote generic-mode-list) "my-mode") (dolist (re ...) (add-to-list ... ...)) (defun my-mode nil "This is My mode." (interactive) (generic-mode-internal ... ... ... ... ...)))
(define-generic-mode my-mode (edebug-enter (quote my-mode) nil (function ...)) (edebug-enter (quote my-mode) nil (function ...)) (edebug-enter (quote my-mode) nil (function ...)) (edebug-after (edebug-before 8) 9 (list "\\.mm\\'")) (edebug-enter (quote my-mode) nil (function ...)) "This is My mode.")
eval((define-generic-mode my-mode (edebug-enter (quote my-mode) nil (function ...)) (edebug-enter (quote my-mode) nil (function ...)) (edebug-enter (quote my-mode) nil (function ...)) (edebug-after (edebug-before 8) 9 (list "\\.mm\\'")) (edebug-enter (quote my-mode) nil (function ...)) "This is My mode."))
eval-defun((4))
call-interactively(eval-defun)
> Another option is to evaluate those arguments before you plug them in the
> body of your major mode function, so they're only evaluated once, when
> the major mode is defined, thus reproducing the "pre-macro" behavior.
Considering backward compatibility, that's probably the right thing to do.
Thanks for the help,
Lute.
next prev parent reply other threads:[~2005-03-25 11:06 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-23 15:54 debug declaration Lute Kamstra
2005-03-23 18:18 ` Stefan Monnier
2005-03-25 11:06 ` Lute Kamstra [this message]
2005-03-25 15:14 ` Stefan Monnier
2005-03-27 3:52 ` Richard Stallman
2005-03-30 8:12 ` Lute Kamstra
2005-03-31 18:21 ` Richard Stallman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wtrwf0iq.fsf@xs4all.nl \
--to=lute.kamstra.lists@xs4all.nl \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.