[Top][All Lists]

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

Re: Making `interactive' conditional

From: Lars Magne Ingebrigtsen
Subject: Re: Making `interactive' conditional
Date: Sun, 10 Jan 2016 10:02:55 +0100
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.1.50 (gnu/linux)

John Wiegley <address@hidden> writes:

> Right now, functions are interactive if declared with `interactive', and not
> otherwise. The suggestion at hand is to allow `interactive' forms to become
> conditional -- possibly in multiple ways. I like this concept, and think the
> right place for it is indeed in core.
> The question is how to declare such conditionality. We can do this rather
> easily by accepting new keyword arguments to `interactive':
>     (interactive "sDirectory: " [:mode foo-mode] [:when <function>])

That does sound kinda exciting.  To take a random example, `M-x
delete-matching-lines' could have a :when of `buffer-writable-p' and not
auto-complete when in a read-only buffer.  Etc.

> This way, all new modes can take advantage of this support as it becomes
> available. I've already tested on 24.5, and keyword arguments are silently
> ignored by present-day GNU Emacs. This gives us transparent compatibility in
> both directions.

Does this also work when transforming (interactive) without parameters,
or do we need to put a nil in there?

> We could also do it with (declare); I'm open to that too, and it also
> gives us such compatibility.

I think the interactive with keywords sounds nice, but both are fine by

> At first, I imagine nothing delivered with Emacs will be conditional, because
> it requires annotating packages retroactively. We could alleviate some of that
> by writing code to automatically consider every interactive function *without
> an autoload token* as being conditional on any modes defined in the same
> package (likely determined by prefix matching). The use of such automation
> would be configurable and off by default, at least until we believe it's ready
> for prime-time.

Hm...  I think that sounds a bit too magical to be workable in general.
I may be wrong, but I think that would probably lead to undesirable side
effects (i.e., commands that should be available globally not being

Magic is nice if you can get it to work, but explicit marking is

(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no

reply via email to

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