all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stephen Berman <stephen.berman@gmx.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 14702@debbugs.gnu.org
Subject: bug#14702: 24.3.50; Byte-compiling called-interactively-p inside catch
Date: Tue, 25 Jun 2013 15:56:13 +0200	[thread overview]
Message-ID: <87obaujnuq.fsf@rosalinde.fritz.box> (raw)
In-Reply-To: <jwvehbrc6si.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 24 Jun 2013 21:39:21 -0400")

On Mon, 24 Jun 2013 21:39:21 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>>    (defun baz ()
>>      (interactive)
>>      (catch 'test
>>        (if (called-interactively-p 'any)
>
> If it hurts, don't do that.
> Internally, the byte-compiled form of catch ends up wrapping its body
> inside a lambda, 

Ah, knowing that I now understand what the disassembled code shows,
which I didn't before, even though there's a hint to that effect in the
Emacs Lisp manual (i.e., "If it is a lambda expression, `disassemble'
compiles it and disassembles the resulting compiled code.").

>                  so the called-interactively-p test refers to the
> implicit lambda added, rather than to the enclosing function
> you defined.
>
> It would be good to avoid this intermediate lambda for performance
> reasons (which would incidentally also fix this particular issue), but
> in the mean time (and more generally) either avoid
> called-interactively-p (pass an extra argument instead), or avoid
> placing it "deep" within your function (e.g. inside
> a catch/unwind-protect/condition-case/save-foobar/...).

At the moment I don't see a way to do either of these: I can't use an
extra argument, because the command where I use called-interactively-p
already uses a prefix argument for another purpose; and I don't see an
alternative to something like `catch', because I need to stop execution
of the command in the middle, when certain conditions obtain (this is my
current fix for the recently reported Todo mode bug -- though I'm trying
to come up with something better, so maybe `catch' will then be
dispensable).

But maybe I can use (eq this-command '<COMMAND-NAME>) instead of
called-interactively-p, since evidently this-command is not effected by
the intervening lambda.  Or can that sexp ever return t when
<COMMAND-NAME> is not called interactively?

Steve Berman





  reply	other threads:[~2013-06-25 13:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-24 14:29 bug#14702: 24.3.50; Byte-compiling called-interactively-p inside catch Stephen Berman
2013-06-25  1:39 ` Stefan Monnier
2013-06-25 13:56   ` Stephen Berman [this message]
2013-06-25 14:04     ` Stefan Monnier
2013-06-25 14:18       ` Stephen Berman

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=87obaujnuq.fsf@rosalinde.fritz.box \
    --to=stephen.berman@gmx.net \
    --cc=14702@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /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.