[Top][All Lists]

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

Re: Making `interactive' conditional

From: Clément Pit--Claudel
Subject: Re: Making `interactive' conditional
Date: Sun, 10 Jan 2016 05:09:32 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0

On 01/10/2016 04:02 AM, Lars Magne Ingebrigtsen wrote:
> 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.

I think this is converging to what Stefan pointed earlier (which I found very 
convincing/exciting): in its most basic form, this proposal could supersede a 
lot of ad-hoc checking that many many commands do (by calling 
`barf-if-buffer-read-only', for example).

Similarly, there are many commands that are marked interactive because they are 
bound to keys in certain contexts, but make no sense (and will just immediately 
error out if called from M-x) otherwise. I find it reasonable to think that if 
a command is just going to exit in error as soon as I call it I probably don't 
want it to feature prominently among M-x completions.


Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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