Subject: bug#3984: 23.0.96; defadvice of call-interactively defeats interactive-p

From: "Drew Adams" <[email-masked]>
Date: Tue, 11 Oct 2011 07:26:39 -0700

> From: Kai Tetzlaff Sent: Sunday, October 09, 2011 11:00 PM
> 
> I'm using icicles and just ran into this bug with emacs compiled from
> bzr. The function count-words-region has been changed to use
> called-interactively-p to check for interactive use. As reported, the
> check fails when icicles is turned on. As there are >300 places under
> the emacs lisp/ directory alone which use called-interactively-p, it
> would really be great, if it could be made more robust.

For info, this is the defadvice that exposes the `called-interactively' bug
(#3984):

(defadvice call-interactively (after icicle-save-to-history
                               disable activate)
  "Save command to `icicle-interactive-history'."
  ;; If command's input is not a parameterized (e.g. mouse)
  ;; event, record it.
  (let* ((fn   (ad-get-arg 0))
         (int  (interactive-form fn)))
    (when (and (symbolp fn)
               (consp int)
               (or (not (stringp (cadr int)))
                   (string= (cadr int) "")
                   (not (eq ?e (aref (cadr int) 0)))))
      (pushnew (symbol-name fn) icicle-interactive-history))))

This behavior is optional, so Icicles users can turn it off (it is off by
default) via option `icicle-populate-interactive-history-flag'.  And the doc
string of that option refers to Emacs bug #3948.  Still, it would be good to get
this Emacs bug fixed - especially, as Kai remarks, since the Emacs source code
now uses `called-interactively-p' all over the place.