[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: called-interactively-p
From: |
Stefan Monnier |
Subject: |
Re: called-interactively-p |
Date: |
Thu, 05 Nov 2009 14:13:12 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) |
> 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).
(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