From: "Drew Adams" <drew.adams@oracle.com>
To: <rms@gnu.org>
Cc: emacs-devel@gnu.org
Subject: RE: propose adding Icicles to Emacs
Date: Mon, 11 Jun 2007 11:33:40 -0700 [thread overview]
Message-ID: <BDEIJAFNGDOAGCJIPKPBOEAHCFAA.drew.adams@oracle.com> (raw)
In-Reply-To: <E1HxgRW-0008Iy-LO@fencepost.gnu.org>
> If integrated with Emacs, this could be done by changing
> `completing-read' etc. to act differently when `icicle-mode'
> is on, unless that is a no-no.
>
> It is not out of the question to do this. However, it would be nicer
> to find a cleaner way. Can you do most of these changes through key
> bindings? Which changes are left, that can't be done that way (or not
> cleanly)? Can we find non-ad-hoc ways of implementing them?
I'd propose adding Icicles first as an optional library, without trying to
integrate any of it deeply with Emacs. Later, we could look into a possible
tighter integration. We might even want later to move some of the behavior
to vanilla Emacs completion.
The `completing-read' code is here:
http://www.emacswiki.org/cgi-bin/wiki/icicles-fn.el. Perhaps others more
familiar with Emacs implementation can advise whether some of this
redefinition could or should be moved to the vanilla definition of
`completing-read' or what might be a "cleaner way" to do what is done now
this way. I would advise just leaving this code as is, at least for now.
> it can replace some top-level commands with Icicles
> versions (e.g. `find-file' with `icicle-find-file').
>
I should be clear that this is not about redefining commands; it is about
remapping their bindings: the bindings for `find-file' are mapped to
`icicle-find-file'.
> Why does it do this?
Because those replacements are enhanced versions. They are typically
multi-commands that 1) keep the same behavior as the original, as long as
you don't use any special Icicles minibuffer bindings, but also 2) let you
take advantage of those minibuffer bindings (e.g. `C-RET') to get the
multi-command behavior.
With the replacement, for instance, you can open any number of files, using
completion, with one invocation of `C-x C-f', and you can optionally delete
selected matching files on the fly (with `S-delete'). You can of course
change your minibuffer input during that one invocation, to match different
file names. (`M-k' clears the minibuffer.)
Again, this binding replacement is, in any case, optional for a user (option
`icicle-bind-top-level-commands-flag'), and it is only for
`icicle-mode-map'.
> > * Multi-commands: Define a command that acts on one foobar,
> > and be able to use it also on multiple foobars in a single
> > invocation.
> >
> > How is that implemented?
>
> A minibuffer key binding, `C-RET' (or `C-mouse-2' in
> `completion-list-mode-map'), calls a command that acts on the
> current completion candidate, where "current" is determined by
> cycling or matching.
>
> How does it know what to call? Is it the same command that invoked
> the minibuffer? Do you have to define a new function for this,
> one for each command that uses the feature?
A global variable, `icicle-candidate-fn', is bound to the function to use
for the action. If it is bound to nil, then `C-RET' etc. are associated with
the default action, which is to simply display individual help about the
candidate. (The help action is also always available on `C-M-RET' etc.)
Candidate help tries to DTRT, depending on the type of candidate (see
command `icicle-help-on-candidate').
Yes, you must define a new command, in order to adapt a given existing
command to multi-command use. This is a good thing, as some commands might
not lend themselves well to multi-command use (i.e. it might make no sense
for them, adding nothing). And, more often, it is appropriate for some
commands to have a slightly different action function for candidates during
completion than after completion (for instance, because the
buffer/window/frame context or the use context might be different).
The command used for the `C-RET' action can be any command. Sometimes
`C-RET' performs the same action as the command invoking completion would
carry out on the candidate chosen finally. Sometimes the action performed is
a bit different or even quite different.
The particular command and its context of use determines what is appropriate
(most useful). The devil is in the details of the particular command and its
use cases. We can generalize to some extent (that is what the
multi-command-defining macros are for), but the best definition of a given
multi-command should be decided case by case.
Also, the command that invoked completion is not the same thing as the part
of that command that actually acts on the candidate that is chosen - what I
call the action function, bound to `icicle-candidate-action-fn'. Also,
because of the difference in context (completion has not yet ended when the
action is carried out), some window, buffer, etc. management needs to be
taken into account.
You can take a look at the multi-commands that I have defined. They are all
in file icicles-cmd.el. You can find them by searching for any of these:
1. icicle-define-command
2. icicle-define-file-command
3. icicle-candidate-action-fn
#1 and #2 are those multi-commands that use the same action function for
final action and action during completion. #3 are other commands, which bind
`icicle-candidate-action-fn' explicitly.
The macro expansion of a multi-command defined using #1 or #2 is quite
complex. Some of its definition implements context management (window,
frame, buffer), and some of it implements treatment of possible errors from
application of the action function. For example, the original buffer,
window, or frame, to which we often want to return, might have been deleted
by application of the action to a particular candidate (e.g. if the action
is to kill the buffer, and the candidate acted on is the original buffer).
And we usually want to keep the focus after action application on the
minibuffer's frame, so that we can possibly keep using `C-RET' etc. on other
candidates.
To see what I mean about the complex definition, load icicles-cmd.el (not
.elc) and then use `symbol-function' on a command defined with one of the
macros. Or take a look at the macro definitions themselves, in
icicles-mac.el.
The optional alternative action function and the optional deletion-action
are treated similarly. For instance, binding
`icicle-candidate-alternative-action-fn' provides an alternative action,
bound to `C-S-RET' etc.
See
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Defining_Icicles_Commands
for more about defining multi-commands. See
http://www.emacswiki.org/cgi-bin/wiki/Icicles_-_Multi-Commands_the_Hard_Way
for more about how the macros work.
> It sounds like an ugly mechanism,
What does? Why?
> so if this feature is worth adding,
> I would rather it be implemented differently. The cleanest way I can
> think of is to set a flag telling call-interactively to call the
> function then loop around, keeping the same prefix argument.
Sorry, I don't understand this. Please elaborate. It "sounds like" you are
redesigning without even being familiar with the design.
I am not into redesigning Icicles or re-implementing the basic design. If
others wish to do that later, that's another matter. A lot of time, testing,
and use has gone into the current design and implementation. It works well,
and I think it is quite clean. When not in Icicle mode, a user cannot tell
that s?he was ever in it. And when in Icicle mode, s?he can still use Emacs
in the same way as usual, with no real perception of a difference, as long
as s?he doesn't use any of the extra minibuffer bindings.
In some ways, the implementation is non-trivial - you don't want to make
cavalier changes, and you must retest lots of scenarios after a fundamental
change. Icicles is very general, which means that it has lots of different
use scenarios. There are some global variables that hold various kinds of
state, which means that some parts of the code are tightly coupled with
other parts. I haven't done that gratuitously, but only when I felt it was
necessary. That doesn't mean that there might not sometimes be a better way;
it means only that one must be careful making changes to the core
implementation.
I'm not against making minor changes that I become convinced would be
improvements, but I don't want to start over or possibly jeopardize things
that work well by making fundamental changes that are not simple. Vague "do
it this way instead" or "n'y a qu'a" suggestions won't convince me. If you
want to discuss concrete implementation details, that's fine. I'm open to
change, but I don't want to break things just because someone thinks s?he
has a better idea (without making an effor to try out that idea or discuss
it concretely).
If Icicles does not break anything, and it does not have a lasting effect
when you leave Icicle mode, then I think how it is implemented should not be
a concern. How it is implemented can of course be examined to help determine
if it breaks something.
After FSF owns the code, others can take responsibility for breaking
Icicles, if they like. Or I can continue to maintain it for FSF - which I
prefer. I intend anyway to maintain and enhance my own version of Icicles,
which I will continue to make available on Emacs Wiki. If my own version and
the Emacs version begin to diverge so much that I cannot work on the former,
then I'll go back to working on just the latter.
> keeping the same prefix argument.
Wrt prefix args: C-u is treated specially during completion, so that, for
instance, you can apply it to individual candidates that you act on using
`C-RET'. That is, you can use a different prefix argument each time you act
on a candidate, if you like. Remember, that, by default, you can act on the
same candidate multiple times. Sometimes that makes sense, sometimes it does
not. You can bind `icicle-use-candidates-only-once-flag' to control this.
See `icicles-mcmd.el' for the code (e.g. `icicle-universal-argument').
> This should work with ALL commands and avoid the need to define
> separate multi-commands.
Sorry, I don't agree.
1. It's not equally appropriate for all commands. It's not necessary for all
commands.
2. It's appropriate, for many commands, to specialize the action behavior
during completion. See the commands that explicitly bind
`icicle-candidate-action-fn', as opposed to just using
`icicle-define-command'. Command `icicle-search', for instance, could not be
defined using `icicle-define-command'.
> Once multi-commands are gone, does Icicles need to
> redefine any commands? Is it just a matter of changes
> inside completing-read?
Sorry, I don't understand what you mean. Multi-commands will not be "gone".
Multi-commandness will not be extended automatically to all commands. That
is not appropriate.
Are you asking for a list of Emacs commands that Icicles redefines when you
are in Icicle mode (and restores when you exit that mode)? This is the
list - it is also in the header of `icicles.el':
completing-read, display-completion-list, exit-minibuffer,
minibuffer-complete-and-exit, read-file-name,
read-from-minibuffer, read-string, dabbrev-completion,
lisp-complete-symbol, mouse-choose-completion,
choose-completion-string, completion-setup-function,
switch-to-completions, next-history-element (advised only),
repeat-complex-command
It's possible that some of these redefinitions could be moved to vanilla
Emacs permanently. Typically, the original definition is extended only
slightly. For instance, the `repeat-complex-command' definition is extended
to read the command to be repeated using `completing-read', so that you can
use completion on the history list and use `C-,' to sort the candidate list
(in *Completions*) in different ways.
If `icicle-bind-top-level-commands-flag' is non-nil, then various top-level
bindings are redefined for use in Icicle mode - the list is in
`icicles-mode.el'. In `icicle-mode-map', for example, `abort-recursive-edit'
is remapped to `icicle-abort-minibuffer-input'. The original binding is
restored when Icicle minor mode is exited.
As another example, `completion-setup-function' is modified so that it does
not print the help lines at the top of *Completions*. That printing is done
instead in `display-completion-list', so that the *Completions* window can
be fit to the buffer. Icicles formats the *Completions* display
"intelligently", determining a useful number of columns and height, and it
fits the window to the formatted buffer. (This formatting, e.g. column
spread and default window width, is under the control of user options.) That
is an enhancement that we might want to consider for vanilla Emacs.
As a third example, `switch-to-completions' is extended to always select the
*Completions* window, even when it is on another frame.
In sum, any attempt to integrate such changes tightly with the vanilla Emacs
code needs to be done on a case-by-case basis. I suggest that there is no
need to do that at all now, but it could be done over time, if some such
extensions were deemed useful to vanilla Emacs also.
next prev parent reply other threads:[~2007-06-11 18:33 UTC|newest]
Thread overview: 212+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-26 0:19 [drew.adams@oracle.com: RE: cannot find :enable in Elisp manual index] Richard Stallman
2007-05-26 6:05 ` Eli Zaretskii
2007-05-29 4:01 ` [drew.adams@oracle.com: RE: cannot find :enable in Elisp manualindex] Drew Adams
2007-05-29 19:12 ` Eli Zaretskii
2007-05-29 20:05 ` Stephen Berman
2007-05-29 20:58 ` Eli Zaretskii
2007-05-29 21:20 ` Stephen Berman
2007-05-29 21:25 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Drew Adams
2007-05-29 21:03 ` [drew.adams@oracle.com: RE: cannot find :enable in Elisp manualindex] Drew Adams
2007-05-30 3:20 ` Eli Zaretskii
2007-05-30 4:43 ` Drew Adams
2007-05-30 5:26 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Drew Adams
2007-05-30 15:17 ` [drew.adams@oracle.com: RE: cannot find :enable in Elisp manualindex] Johan Bockgård
2007-05-30 23:09 ` Eli Zaretskii
2007-05-30 5:23 ` David Kastrup
2007-05-30 23:01 ` Eli Zaretskii
2007-05-30 23:14 ` Eli Zaretskii
2007-06-02 2:54 ` Richard Stallman
2007-06-02 9:18 ` Jason Rumney
2007-06-02 17:29 ` Richard Stallman
2007-06-02 10:12 ` Robert J. Chassell
2007-06-02 17:29 ` Richard Stallman
2007-06-02 23:47 ` Robert J. Chassell
2007-06-03 21:27 ` Richard Stallman
2007-06-02 10:18 ` Alan Mackenzie
2007-06-02 14:36 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Drew Adams
2007-06-02 17:26 ` [drew.adams@oracle.com: RE: cannot find :enable in Elisp manualindex] Eli Zaretskii
2007-06-02 23:47 ` Alan Mackenzie
2007-06-02 23:48 ` Jason Rumney
2007-06-02 17:29 ` Richard Stallman
2007-06-02 18:10 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Drew Adams
2007-06-03 21:27 ` Richard Stallman
2007-06-04 5:30 ` [drew.adams@oracle.com: RE: cannot find :enable inElispmanualindex] Drew Adams
2007-06-02 23:01 ` [drew.adams@oracle.com: RE: cannot find :enable in Elisp manualindex] Miles Bader
2007-06-03 0:00 ` Karl Berry
2007-06-03 21:27 ` Richard Stallman
2007-06-03 22:52 ` Juri Linkov
2007-06-03 23:55 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Drew Adams
2007-06-04 5:01 ` Richard Stallman
2007-06-04 5:42 ` [drew.adams@oracle.com: RE: cannot find :enable inElispmanualindex] Drew Adams
2007-06-04 23:20 ` Richard Stallman
2007-06-05 0:10 ` [drew.adams@oracle.com: RE: cannot find :enableinElispmanualindex] Drew Adams
2007-06-06 0:50 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Stefan Monnier
2007-06-06 2:12 ` Drew Adams
2007-06-06 12:26 ` Stefan Monnier
2007-06-06 13:54 ` Drew Adams
2007-06-06 15:06 ` [drew.adams@oracle.com: RE: cannot find :enable inElispmanualindex] Drew Adams
2007-06-06 18:44 ` Juri Linkov
2007-06-06 20:01 ` Stefan Monnier
2007-06-06 20:51 ` Juri Linkov
2007-06-06 21:18 ` Stefan Monnier
2007-06-06 22:01 ` Juri Linkov
2007-06-06 22:24 ` Stefan Monnier
2007-06-06 22:40 ` Karl Berry
2007-06-07 12:37 ` Stefan Monnier
2007-06-07 22:22 ` Karl Berry
2007-06-08 1:00 ` Stefan Monnier
2007-06-08 2:28 ` Karl Berry
2007-06-08 6:58 ` csant
2007-06-08 15:42 ` Stefan Monnier
2007-06-08 7:12 ` Stefan Monnier
2007-06-08 8:34 ` Juri Linkov
2007-06-06 22:04 ` Karl Berry
2007-06-08 7:11 ` Richard Stallman
2007-06-08 8:32 ` Juri Linkov
2007-06-08 15:46 ` Stefan Monnier
2007-06-08 15:52 ` propose adding Icicles to Emacs Drew Adams
2007-06-10 13:19 ` Richard Stallman
2007-06-10 17:16 ` Drew Adams
2007-06-10 18:22 ` Sean O'Rourke
2007-06-11 0:09 ` Drew Adams
2007-06-11 9:44 ` Richard Stallman
2007-06-11 18:33 ` Drew Adams [this message]
2007-06-11 19:17 ` Stefan Monnier
2007-06-11 20:53 ` Drew Adams
2007-06-11 21:46 ` Stefan Monnier
2007-06-11 23:21 ` Drew Adams
2007-06-13 8:06 ` Richard Stallman
2007-06-14 7:48 ` Richard Stallman
2007-06-14 15:51 ` Drew Adams
2007-06-14 16:07 ` Stefan Monnier
2007-06-15 0:39 ` Drew Adams
2007-06-15 19:22 ` Richard Stallman
2007-06-15 21:04 ` Drew Adams
2007-06-16 18:51 ` Richard Stallman
2007-06-16 18:51 ` Richard Stallman
2007-06-16 18:51 ` Richard Stallman
2007-06-16 20:53 ` Drew Adams
2007-06-17 8:54 ` Richard Stallman
2007-06-17 18:48 ` Juri Linkov
2007-06-17 20:39 ` Drew Adams
2007-06-17 21:18 ` Juri Linkov
2007-06-17 23:07 ` Drew Adams
2007-06-18 21:17 ` Juri Linkov
2007-06-18 23:31 ` Drew Adams
2007-06-19 8:16 ` Juri Linkov
2007-06-19 14:47 ` Drew Adams
2007-06-18 14:56 ` Stefan Monnier
2007-06-19 22:26 ` Richard Stallman
2007-06-20 6:46 ` Stefan Monnier
2007-06-28 2:41 ` Stefan Monnier
2007-06-28 15:47 ` Drew Adams
2007-06-28 19:25 ` Richard Stallman
2007-06-28 20:03 ` Stefan Monnier
2007-06-29 5:10 ` Richard Stallman
2007-06-18 21:31 ` Richard Stallman
2007-06-19 3:52 ` Stefan Monnier
2007-06-19 22:26 ` Richard Stallman
2007-06-19 23:11 ` Drew Adams
2007-06-20 1:19 ` Stefan Monnier
2007-06-19 22:47 ` Drew Adams
2007-06-19 23:15 ` Drew Adams
2007-06-20 14:19 ` Juri Linkov
2007-06-20 15:13 ` Drew Adams
2007-06-20 15:13 ` Stefan Monnier
2007-06-20 15:34 ` Drew Adams
2007-06-20 15:50 ` Juri Linkov
2007-06-20 16:02 ` Juanma Barranquero
2007-06-20 16:38 ` Drew Adams
2007-06-20 17:28 ` Drew Adams
2007-06-20 17:51 ` Juri Linkov
2007-06-21 1:07 ` Richard Stallman
2007-06-19 22:48 ` Drew Adams
2007-06-20 17:36 ` Richard Stallman
2007-06-16 18:51 ` Richard Stallman
2007-06-16 19:58 ` Drew Adams
2007-06-16 18:51 ` Richard Stallman
2007-06-16 22:36 ` Drew Adams
2007-06-17 21:49 ` Richard Stallman
2007-06-16 18:51 ` Richard Stallman
2007-06-16 22:29 ` Drew Adams
2007-06-17 21:48 ` Richard Stallman
2007-06-17 22:18 ` Drew Adams
2007-06-18 16:15 ` Drew Adams
2007-06-25 13:19 ` Richard Stallman
2007-06-25 14:57 ` Drew Adams
2007-06-25 19:52 ` Richard Stallman
2007-06-25 21:40 ` Drew Adams
2007-06-26 16:57 ` Richard Stallman
2007-06-26 17:36 ` Drew Adams
2007-07-01 20:40 ` Richard Stallman
2007-07-01 21:54 ` Drew Adams
2007-07-02 19:47 ` Richard Stallman
2007-07-02 22:19 ` Drew Adams
2007-07-03 4:24 ` Richard Stallman
2007-07-03 7:56 ` Drew Adams
2007-07-04 3:43 ` Richard Stallman
2007-07-04 6:13 ` Drew Adams
2007-06-25 20:47 ` Juri Linkov
2007-06-21 18:35 ` Davis Herring
2007-06-21 18:39 ` Lennart Borgman (gmail)
2007-06-21 20:42 ` Drew Adams
2007-06-21 22:27 ` Davis Herring
2007-06-22 0:20 ` Drew Adams
2007-06-24 14:40 ` Richard Stallman
2007-06-15 8:48 ` Richard Stallman
2007-06-15 13:23 ` Drew Adams
2007-06-15 22:45 ` Richard Stallman
2007-06-13 16:21 ` Richard Stallman
2007-06-13 16:22 ` Richard Stallman
2007-06-13 19:00 ` Drew Adams
2007-06-14 16:19 ` Richard Stallman
2007-06-15 1:01 ` Drew Adams
2007-06-15 19:22 ` Richard Stallman
2007-06-15 21:04 ` Drew Adams
2007-06-16 18:50 ` Richard Stallman
2007-06-17 18:46 ` Juri Linkov
2007-06-17 19:35 ` Drew Adams
2007-06-18 21:31 ` Richard Stallman
2007-06-11 9:44 ` Richard Stallman
2007-06-11 17:29 ` Drew Adams
2007-06-11 18:10 ` Stefan Monnier
2007-06-13 8:07 ` Richard Stallman
2007-06-13 15:23 ` Drew Adams
2007-06-14 7:49 ` Richard Stallman
2007-06-15 0:41 ` Drew Adams
2007-06-15 19:22 ` Richard Stallman
2007-06-15 21:04 ` Drew Adams
2007-06-16 18:51 ` Richard Stallman
2007-06-16 22:30 ` Drew Adams
2007-06-13 8:07 ` Richard Stallman
2007-06-11 3:49 ` Miles Bader
2007-06-11 7:24 ` Drew Adams
2007-06-11 16:25 ` Richard Stallman
2007-06-11 9:44 ` Richard Stallman
2007-06-11 18:41 ` Drew Adams
2007-06-12 0:43 ` Miles Bader
2007-06-12 8:08 ` Kim F. Storm
2007-06-12 9:18 ` joakim
2007-06-12 11:04 ` Kim F. Storm
2007-06-12 11:16 ` joakim
2007-06-12 13:30 ` Drew Adams
2007-06-12 14:06 ` keys that work on terminals (was: Re: propose adding Icicles to Emacs) Dan Nicolaescu
2007-06-12 14:45 ` keys that work on terminals joakim
2007-06-12 13:22 ` propose adding Icicles to Emacs Drew Adams
2007-06-06 15:43 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Stefan Monnier
2007-06-04 5:01 ` [drew.adams@oracle.com: RE: cannot find :enable in Elisp manualindex] Richard Stallman
2007-06-04 23:51 ` Juri Linkov
2007-06-05 3:55 ` Miles Bader
2007-06-05 16:29 ` Juri Linkov
2007-06-05 17:12 ` [drew.adams@oracle.com: RE: cannot find :enable in Elispmanualindex] Drew Adams
2007-06-05 19:17 ` [drew.adams@oracle.com: RE: cannot find :enable in Elisp manualindex] Richard Stallman
2007-06-05 22:32 ` Richard Stallman
2007-06-06 0:32 ` Karl Berry
2007-06-06 22:10 ` Richard Stallman
2007-06-06 22:21 ` Karl Berry
2007-06-02 22:34 ` Juri Linkov
2007-06-02 22:42 ` Juri Linkov
2007-06-03 3:07 ` Eli Zaretskii
2007-06-03 9:34 ` Juri Linkov
2007-06-03 21:23 ` Karl Berry
2007-06-03 21:27 ` Richard Stallman
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=BDEIJAFNGDOAGCJIPKPBOEAHCFAA.drew.adams@oracle.com \
--to=drew.adams@oracle.com \
--cc=emacs-devel@gnu.org \
--cc=rms@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.