[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#11747: 24.1.50; called-interactively-p vs. advice

From: Michael Heerdegen
Subject: bug#11747: 24.1.50; called-interactively-p vs. advice
Date: Tue, 19 Jun 2012 20:21:06 +0200


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


(defun interactive-test ()
  (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))


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



In GNU Emacs (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'
 '--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'
 -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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]