unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#11747: 24.1.50; called-interactively-p vs. advice
@ 2012-06-19 18:21 Michael Heerdegen
  2012-06-25  1:14 ` Glenn Morris
  2013-02-08 22:41 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Heerdegen @ 2012-06-19 18:21 UTC (permalink / raw)
  To: 11747

Hi,

`called-interactively-p' returns wrong values when called inside
commands that are adviced.

Example:

(defun interactive-test ()
  (interactive)
  (message "Called %sinteractively"
           (if (called-interactively-p 'any) "" "non-")))

M-x interactive-test

  ==>

  Called interactively

M-: (interactive-test)

  ==>

  Called non-interactively


Now eval e.g. this:

(defadvice interactive-test (before foo activate)
  (sleep-for 1))

Then:

M-x interactive-test

  ==>

  Called non-interactively


This is quite surprising, and may cause surprising effects if the user
decides to advice such a command.

I found nothing in the doc about his behavior.  If this is not a bug,
maybe explain this behavior somewhere.


This last paragraph in the docstring of `called-interactively-p' seems
somewhat (but not directly) related:

| This function is meant for implementing advice and other
| function-modifying features.  Instead of using this, it is sometimes
| cleaner to give your function an extra optional argument whose
| `interactive' spec specifies non-nil unconditionally ("p" is a good
| way to do this), or via (not (or executing-kbd-macro noninteractive)). 

It seems a bit confusing - is there a "not" missing in the first
sentence?


Thanks,

Michael.


In GNU Emacs 24.1.50.1 (i486-pc-linux-gnu, GTK+ Version 3.4.2)
 of 2012-06-15 on zelenka, modified by Debian
 (emacs-snapshot package, version 2:20120615-1)
Windowing system distributor `The X.Org Foundation', version 11.0.11201902
Configured using:
 `configure '--build' 'i486-linux-gnu' '--host' 'i486-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs-snapshot:/etc/emacs:/usr/local/share/emacs/24.1.50/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.1.50/site-lisp:/usr/share/emacs/site-lisp'
 '--without-compress-info' '--with-crt-dir=/usr/lib/i386-linux-gnu/'
 '--with-x=yes' '--with-x-toolkit=gtk3' '--with-imagemagick=yes'
 'build_alias=i486-linux-gnu' 'host_alias=i486-linux-gnu'
 'CFLAGS=-DDEBIAN -DSITELOAD_PURESIZE_EXTRA=5000 -g -O2' 'LDFLAGS=-g
 -Wl,--as-needed -znocombreloc' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: de_DE.utf8
  value of $LC_TIME: C
  value of $LANG: de_DE.utf8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t






^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-02-08 22:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-19 18:21 bug#11747: 24.1.50; called-interactively-p vs. advice Michael Heerdegen
2012-06-25  1:14 ` Glenn Morris
2012-06-25 17:54   ` Michael Heerdegen
2012-06-25 23:40     ` Glenn Morris
2013-02-08 22:41 ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).