From: Drew Adams <drew.adams@oracle.com>
To: John Wiegley <johnw@gnu.org>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: RE: Making `interactive' conditional (was: Leaving out non-applicable commands on Mx)
Date: Mon, 11 Jan 2016 04:02:16 -0800 (PST) [thread overview]
Message-ID: <24db4424-1491-4da3-bfdf-d0a604f70a8b@default> (raw)
In-Reply-To: <96ccb9a0-d9a0-4c8b-9d19-b3a051d31f77@default>
I do think that there can be some value in letting commands,
such as `M-x', that provide completion for command names,
take invocation-context information into account.
I think we should be more specific about what is involved -
how this is done. And I think we should be more flexible
than what I've heard proposed so far. In particular, we
should be flexible about how such invocation-context info
can be provided and used.
Let me make a hopefully more constructive contribution to
the suggestions about this than what I've written so far.
Here's how I see such a new feature.
1. It would:
a. Provide information about a specific command
regarding its invocation contexts.
This info can indicate which contexts "make sense" or
which do not. But it can also indicate anything else
about a context in which one might try to invoke the
command.
The form of the info would be a Lisp sexp, and a
value of nil would be equivalent to an absence (no
context information).
Its interpretation would be up to (1b) - no fixed
or predefined interpretation.
b. Use this information in `M-x', and possibly in other
contexts.
(I'll write `M-x' for short, but this should be
understood as any context that uses the (1a) info.
And even when thinking of it as `M-x, understand a
new, `M-x'-like command.)
2. (1a) and (1b) are two different things, and we need not
be rigid about either their relationship or just how
`M-x' or other contexts might use the (1a) info.
3. The (1a) info can be a predicate that `M-x' can apply to
each completion candidate. It can use the resulting
value to remove the candidate or to display it
differently or to do something else that is specific to
it. Likewise for any other (1b) context: it is up to
that context to do with info (1a) whatever it wants.
4. The (1a) info could be something other than a predicate
and nil. This is left unspecified, but it should not be
assumed that it is always a function.
5. A predicate return value of nil, or an absence of (1a)
info for a given candidate, would mean treat the command
candidate normally (classically). A non-nil return
value would mean treat it specially in some way - see (3).
6. The predicate can test anything. It should be possible
to invoke it with any number of arguments, which are
unspecified. It can access the target command's symbol
as the value of variable `current-cmd' (or some better
name). (We could require passing the command as a first
argument, but that would make using some existing
predicates more cumbersome.)
7. It should be easy to add, modify, or remove info (1a)
from a command using Lisp at any time, and without
modifying or otherwise accessing the source code that
defines the command.
8. The command's `interactive' spec is not the right place
to provide the (1a) info (e.g. predicate). This is not
about interactive use in general. It is info about
invocation contexts. A `declare' form is also the wrong
place for the (1a) info.
It should be possible to create or remove such an
association in source code but also interactively (e.g.,
using `M-:').
9. I propose putting info (1a) on the command symbol as a
property. This is a limitation only for commands not
associated with a name (which are not used by `M-x', at
least). Example:
(put 'kill-line
'cmd-context
(lambda (cmd) (not buffer-read-only)))
This association is purposely separate from the defun.
10. `execute-extended-command' (`M-x') would provide its
usual behavior by default. A user option would let it
take info (1a) into account. Later, the default
behavior (and default option value) could be switched if
we decide that is better.
11. We can provide a minibuffer key, when `M-x' is used, to
toggle the option value (for (a) the `M-x' duration or
(b) definitively, so that it effects subsequent `M-x').
A user might do this for clarity, or to see more context
info or more candidates, or to improve performance if
taking (1a) info into account slows things down
appreciably.
12. When `M-x' takes info (1a) into account, it treats a
completion-candidate command name specially if info (1a)
is present, according to the value of a user option
(e.g., `cmd-context'). Possible behaviors could
include:
. Removing the command as a completion candidate if info
(1a) is a predicate and invoking it returns nil.
. Showing the (1a) info (e.g., the predicate sexp or
symbol) next to the candidate command in
*Completions*, as an annotation.
. Displaying the candidate in a different face according
to the nature of info (1a). E.g., if a predicate and
invoking it returns nil, then dim the candidate.
13. Since a given (1b) context such as `M-x' can do anything
it likes with (1a) info, it could, in particular, handle
that info differently depending on the current set of
completion candidates. For example, it could
automatically turn off taking (1a) info into account
when the number of candidates is particularly large or
small.
14. If a (1b) context such as `M-x' wants to improve
performance by, say, byte-compiling a (1a) predicate, it
can do so, but it must not replace the source (1a)
value, which should remain a Lisp sexp. This is so we
keep things flexible and we do not shut the door on
possible uses of info (1a).
next prev parent reply other threads:[~2016-01-11 12:02 UTC|newest]
Thread overview: 141+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-25 6:21 4K Bugs Lars Ingebrigtsen
2015-12-25 7:46 ` Eli Zaretskii
2015-12-25 17:00 ` John Wiegley
2015-12-25 17:30 ` Lars Ingebrigtsen
2015-12-25 17:51 ` John Wiegley
2015-12-25 17:53 ` Lars Ingebrigtsen
2015-12-25 17:59 ` John Wiegley
2015-12-25 18:27 ` jpff
2015-12-25 18:35 ` Lars Ingebrigtsen
2015-12-25 18:33 ` Dmitry Gutov
2015-12-25 18:40 ` Lars Ingebrigtsen
2015-12-25 18:54 ` Lars Ingebrigtsen
2015-12-25 19:46 ` Dmitry Gutov
2015-12-25 20:06 ` Lars Ingebrigtsen
2015-12-25 19:36 ` John Wiegley
2015-12-25 19:56 ` Dmitry Gutov
2015-12-25 20:05 ` Eli Zaretskii
2015-12-25 20:26 ` Lars Ingebrigtsen
2015-12-26 13:16 ` Michael Albinus
2015-12-26 8:07 ` Andreas Röhler
2015-12-26 10:29 ` Eli Zaretskii
2015-12-26 15:14 ` Andreas Röhler
2015-12-26 16:34 ` Eli Zaretskii
2015-12-26 16:41 ` Lars Ingebrigtsen
2015-12-26 16:52 ` Eli Zaretskii
2015-12-26 16:59 ` Lars Ingebrigtsen
2015-12-26 17:55 ` Ivan Shmakov
2015-12-26 17:58 ` Lars Ingebrigtsen
2015-12-26 18:12 ` Ivan Shmakov
2015-12-26 18:21 ` Lars Ingebrigtsen
2015-12-26 18:42 ` Ivan Shmakov
2015-12-26 18:48 ` Lars Ingebrigtsen
2015-12-27 22:41 ` Per Starbäck
2015-12-28 9:44 ` Andreas Röhler
2015-12-28 20:18 ` John Wiegley
2015-12-26 16:59 ` Paul Eggert
2015-12-26 17:48 ` Lars Ingebrigtsen
2015-12-28 20:15 ` John Wiegley
2015-12-26 14:55 ` Lars Ingebrigtsen
2015-12-27 2:52 ` Richard Stallman
2015-12-27 6:07 ` Lars Ingebrigtsen
2016-01-07 20:10 ` Phillip Lord
2016-01-07 22:38 ` Phillip Lord
2016-01-09 4:26 ` Andrew Hyatt
2016-01-09 9:20 ` Michael Albinus
2016-01-07 23:32 ` John Wiegley
2016-01-08 0:17 ` Xue Fuqiao
2016-01-08 12:49 ` Phillip Lord
2016-01-08 1:41 ` Alexis
2016-01-08 1:50 ` Richard Copley
2016-01-08 2:41 ` Alexis
2016-01-09 1:51 ` John Wiegley
2016-01-08 12:48 ` Phillip Lord
2016-01-08 13:06 ` Michael Albinus
2016-01-08 13:59 ` Phillip Lord
2016-01-08 14:12 ` Michael Albinus
2016-01-09 2:52 ` Alexis
2016-01-10 15:58 ` Michael Albinus
2016-01-11 8:05 ` Alexis
2016-01-08 8:28 ` Lars Magne Ingebrigtsen
2016-01-08 12:57 ` Phillip Lord
2016-01-08 13:37 ` Michael Albinus
2016-01-08 13:52 ` Lars Magne Ingebrigtsen
2016-01-11 13:52 ` Phillip Lord
2016-01-11 16:18 ` Lars Magne Ingebrigtsen
2016-01-08 15:05 ` Stefan Monnier
2016-01-08 23:16 ` Leaving out non-applicable commands on Mx (was: 4K Bugs) Óscar Fuentes
2016-01-09 0:22 ` Leaving out non-applicable commands on Mx John Wiegley
2016-01-09 0:55 ` Óscar Fuentes
2016-01-09 1:46 ` John Wiegley
2016-01-09 1:54 ` Spencer Boucher
2016-01-09 3:09 ` Drew Adams
2016-01-09 3:37 ` Óscar Fuentes
2016-01-09 2:15 ` Óscar Fuentes
2016-01-09 3:09 ` Drew Adams
2016-01-09 3:49 ` Óscar Fuentes
2016-01-09 4:14 ` Stefan Monnier
2016-01-09 3:09 ` Drew Adams
2016-01-09 3:08 ` Drew Adams
2016-01-09 3:33 ` Óscar Fuentes
2016-01-09 9:05 ` Yuri Khan
2016-01-09 19:27 ` Drew Adams
2016-01-09 20:55 ` Making `interactive' conditional (was: Leaving out non-applicable commands on Mx) John Wiegley
2016-01-09 21:53 ` Drew Adams
2016-01-11 12:02 ` Drew Adams [this message]
2016-01-10 9:02 ` Making `interactive' conditional Lars Magne Ingebrigtsen
2016-01-10 10:09 ` Clément Pit--Claudel
2016-01-10 17:55 ` Drew Adams
[not found] ` <CAAdUY-Kfm-0JbOLpi4KE5wkmp6hfG+-y3V-_vTExaFkmF5RmEg@mail.gmail.com>
2016-01-10 12:36 ` Artur Malabarba
2016-01-11 3:46 ` Richard Stallman
2016-01-11 15:13 ` Lars Magne Ingebrigtsen
2016-01-11 6:13 ` Stefan Monnier
2016-01-11 6:48 ` Óscar Fuentes
2016-01-11 14:08 ` Herring, Davis
2016-01-11 16:34 ` Óscar Fuentes
2016-01-12 4:46 ` Herring, Davis
2016-01-12 4:59 ` Óscar Fuentes
2016-01-11 15:15 ` Lars Magne Ingebrigtsen
2016-01-12 2:14 ` Clément Pit--Claudel
2016-01-10 15:27 ` Making `interactive' conditional (was: Leaving out non-applicable commands on Mx) Alan Mackenzie
2016-01-10 16:47 ` Making `interactive' conditional Óscar Fuentes
2016-01-10 18:23 ` Drew Adams
2016-01-10 19:31 ` Óscar Fuentes
2016-01-10 22:40 ` Drew Adams
2016-01-10 23:19 ` Óscar Fuentes
2016-01-10 18:22 ` Making `interactive' conditional (was: Leaving out non-applicable commands on Mx) Drew Adams
2016-01-11 6:29 ` Making `interactive' conditional Stefan Monnier
2016-01-11 11:48 ` Drew Adams
2016-01-10 18:33 ` Clément Pit--Claudel
2016-01-10 22:28 ` Making `interactive' conditional (was: Leaving out non-applicable commands on Mx) Marcin Borkowski
2016-01-11 6:19 ` Making `interactive' conditional Stefan Monnier
2016-01-19 6:24 ` John Wiegley
2016-01-19 10:11 ` Lars Magne Ingebrigtsen
2016-01-19 11:17 ` Lars Magne Ingebrigtsen
2016-01-19 13:31 ` Stefan Monnier
2016-01-19 16:52 ` Drew Adams
2016-01-19 15:28 ` Óscar Fuentes
2016-01-19 16:07 ` Lars Magne Ingebrigtsen
2016-01-19 20:24 ` Óscar Fuentes
2016-01-19 16:20 ` John Wiegley
2016-01-19 17:55 ` Lars Magne Ingebrigtsen
2016-01-19 18:39 ` John Wiegley
2016-01-19 19:02 ` Lars Magne Ingebrigtsen
2016-01-19 20:23 ` Óscar Fuentes
2016-01-09 8:06 ` Leaving out non-applicable commands on Mx Lars Magne Ingebrigtsen
2016-01-09 14:50 ` Óscar Fuentes
2016-01-09 17:32 ` Stefan Monnier
2016-01-10 8:53 ` Lars Magne Ingebrigtsen
2016-01-10 16:05 ` Stefan Monnier
2016-02-04 3:19 ` Lars Ingebrigtsen
2016-01-10 16:07 ` Stefan Monnier
2016-01-10 16:14 ` Óscar Fuentes
2016-01-08 10:50 ` 4K Bugs Michael Albinus
2016-01-08 13:21 ` Phillip Lord
2016-01-08 13:33 ` Michael Albinus
2016-01-08 14:08 ` Phillip Lord
2016-01-09 4:21 ` Andrew Hyatt
2016-01-09 8:42 ` Michael Albinus
2016-01-11 13:54 ` Phillip Lord
2016-01-08 19:27 ` Stephen Leake
2016-01-08 20:52 ` Michael Albinus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=24db4424-1491-4da3-bfdf-d0a604f70a8b@default \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=johnw@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.