all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Is there a way to instrument for edebug a form (say, a progn) given to `eval'?
Date: Tue, 05 Jan 2016 10:16:50 +0100	[thread overview]
Message-ID: <87io38s7wd.fsf@mbork.pl> (raw)
In-Reply-To: <87d1th9bac.fsf@web.de>



On 2016-01-05, at 00:26, Michael Heerdegen <michael_heerdegen@web.de> wrote:

> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> (eval
>>  '(progn
>>     (message "foo")
>>     (message "bar")))
>>
>> and see how Edebug doesn't step into the progn.
>
> That's expected, the argument to eval can be anything, in particular,
> something that is not written down in some buffer.  In the above case,
> you call eval on a constant, and edebug can't know where this constant
> comes from.
>
> Paste the progn form somewhere and hit C-u C-M-x if you want to use
> edebug.

I guess you misunderstood me.  It's not that I have this in actual code,
or that I really want to edebug _this_ progn.  I have (more or less)
this in actual code:

(defun conditional-save-excursion-1-function (arg form)
  "If ARG is non-nil, eval FORM inside a `save-excursion'."
  (if arg
      (save-excursion
        (eval form))
    (eval form)))

I was curious whether it is possible to step with edebug through
`form'.

Also, this is not "actual code" in a sense that I want to actually use
it anywhere.  Disclosure: it comes from the draft of my Emacs book,
chapter on macros, where I try to explain why a macro is better than
a function in such a case.  One of the reasons is that you can't use
edebug if you use a function and not a macro like this:

(defmacro conditional-save-excursion-1 (arg form)
  "If ARG is non-nil, wrap FORM in `save-excursion'."
  (declare (indent 1) (debug t))
  (if arg
      `(save-excursion ,form)
    form))

(BTW, this macro is inspired by a real use-case.)

My question was because I do not want to write it in the book if I'm not
100% sure I'm right, and I wasn't sure.  (Though it seems that I was
right after all - Stefan's trick with replacing the backquote with its
edebug-compliant variant doesn't count, I guess;-).)

> Michael.

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



  reply	other threads:[~2016-01-05  9:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-30 12:35 Is there a way to instrument for edebug a form (say, a progn) given to `eval'? Marcin Borkowski
2015-12-30 17:11 ` Drew Adams
2015-12-30 17:29 ` Michael Heerdegen
2016-01-04 22:30   ` Marcin Borkowski
2016-01-04 22:58     ` Drew Adams
2016-01-05  9:26       ` Marcin Borkowski
2016-01-04 23:26     ` Michael Heerdegen
2016-01-05  9:16       ` Marcin Borkowski [this message]
2016-01-05 20:00         ` Michael Heerdegen
2016-01-05 20:08           ` Marcin Borkowski
2016-01-05  4:41     ` Stefan Monnier
2016-01-05  9:04       ` Marcin Borkowski
2016-01-05 12:43         ` Stefan Monnier
2016-01-01 13:48 ` Thorsten Jolitz
2016-01-01 14:22   ` Stefan Monnier
2016-01-01 15:59     ` Thorsten Jolitz
2016-01-02 17:39       ` Stefan Monnier

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=87io38s7wd.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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.