Discussion:
[VM] vm-interactive-p no longer working
Piet van Oostrum
2014-11-11 11:45:04 UTC
Permalink
Environment: Aquamacs 3.0 / Mac OS X 10.6.8 / VM 8.2.0b

I recently noticed that the vm-follow-summary-cursor behaviour was no
longer working. I used to move my cursor in the VM Summary buffer and
then hit s or d or so. But now it no longer operated on the message
where the cursor was positioned, but on the current message instead.

I could trace this back to (vm-interactive-p) no longer giving t in an
interactive call to for example vm-delete-message. It appears no longer
to work in Emacs 24 (Aquamacs 3.0 is based on Emacs 24).

In Emacs 24 interactive-p is obsolete and the VM code tries to cope with
that but it fails. The code in vm-misc.el is:

(fset 'vm-interactive-p
(if (fboundp 'interactive-p) ; Xemacs or Gnu Emacs under obsolescence
'interactive-p
(lambda () (called-interactively-p 'any))))

Now in Emacs 24 interactive-p is a function that itself calls
called-interactively-p. To cope with the extra layer of indirection
called-interactively-p has a special test to see if it was called from
interactive-p and then skips this stack frame to inspect the function
that called interactive-p. However, this only works when the function is
really called interactive-p, and not with a function fset to
interactive-p.

Also the alternative definition (lambda () (called-interactively-p
'any)) would not work either as then called-interactively-p is called
from that lambda fedined funcion and not from the actual interactively
called function like vm-delete-message. There is an indirection level
too much.

I think this can only be solved by making vm-interactive-p a macro
rather than a function. I found the following solution works:

(if (fboundp 'called-interactively-p)
(defmacro vm-interactive-p ()
'(called-interactively-p 'any))
(defmacro vm-interactive-p ()
'(interactive-p)))

(I reversed the test that chooses the proper definition).

I think all files using vm-interactive-p have directly or indirectly an
(eval-when-compile
(require 'vm-misc)

I also noticed that there are a few instances where interactive-p is
called directly. For a future release these should also be changed to
vm-interactive-p, I think. Otherwise a future Emacs version might
completely obliterate interactive-p and we then have a problem.
--
Piet van Oostrum <***@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
Loading...