emacs-devel
[Top][All Lists]
Advanced

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

RE: [External] : Better alternative to completing-read-multiple


From: Drew Adams
Subject: RE: [External] : Better alternative to completing-read-multiple
Date: Sat, 20 Apr 2024 15:22:41 +0000

> A much better solution could be a completion command where a chosen
> candidate is appended to a list (displayed in the prompt) when a user
> presses RET and then returned when a user presses something like
> C-RET.  Already chosen candidates could be erased via C-<backspace>


FWIW, Icicles does something similar
(since 2005): "multi-completion".
____

https://www.emacswiki.org/emacs/Icicles_-_Multi-Completions#multi-completion
____

Multi-completion differs from
`completing-read-multiple' in several ways. 
In particular, it completes each input
pattern against a _different_ set of
candidates.  `completing-read-multiple' 
completes all input patterns against the
same set of candidates in the completion
domain.

E.g., Icicles' version of `C-x C-f' can
match both file names (first component)
and file content (second component).

In effect, completion candidates are
themselves multipart.  But a command can
optionally hide any parts from display
in buffer `*Completions*'.  E.g.,
`C-x C-f' hides file-content matches.
____

The key used to prompt for another input
pattern, to match the next completion
component, is, by default, `C-M-j'.

That inserts the chars that are the current
value of variable `icicle-list-join-string'.
Its default value is the string "^G^J", i.e.
Control-G followed by Control-J.

That odd value is the default because:

* It's unlikely to be part of a completion 
  candidate.
* A newline (C-j) visually separates the
  multiple component input patterns.
* It's not difficult to type, using either
  `C-M-j' or `C-q C-g C-j'.

Icicles displays the separator string as
just a newline (`C-j').  (The default
value of  `icicle-list-join-string' has
property `(display "")' on its first char.)

A user can of course use a different
separator string.  Likewise, different
commands can use different separator
strings - e.g., if input patterns are
expected to be short and simple, then
just a space or a comma can make sense.



reply via email to

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