emacs-devel
[Top][All Lists]
Advanced

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

Re: called-interactively-p


From: Carsten Dominik
Subject: Re: called-interactively-p
Date: Mon, 9 Nov 2009 17:28:57 +0100


On Nov 5, 2009, at 8:13 PM, Stefan Monnier wrote:

Well, it turns out that I don't know a good way to take care of this.
I would like to have Org be compatible with Emacs 22 and also XEmacs,
and I don't know how I can do this with the new `called- interactively',
except for creating diverging code bases.

Yes, this is a problem.  The best I can offer is to use a macro that
expands to either of the alternatives (a function wouldn't work because
it would cause interactive-p to always return nil).

And a macro will only work if the user runs compiled code, right?

- Carsten


(defmacro org-called-interactively-p (kind)
 (condition-case nil
     (progn (called-interactively-p nil)
            ;; If the call didn't signal an error, then the new form
            ;; is supported: use it.
            `(called-interactively-p ,kind))
   (wrong-number-of-arguments
    ;; Probably Emacs-23.1.
    (if (equal (eval kind) 'interactive)
        `(interactive-p)
      `(called-interactively-p)))
   (error
    ;; called-interactively-p seems not to be supported, fallback
    ;; on the good ol' interactive-p.
    `(interactive-p))))

Of course the above code is guaranteed 100% untested.


       Stefan

- Carsten







reply via email to

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