all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Better alternative to completing-read-multiple
@ 2024-04-19 21:18 Ilya Chernyshov
  2024-04-20  6:16 ` Thierry Volpiatto
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ilya Chernyshov @ 2024-04-19 21:18 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]


Hello

In completing-read-multiple, the resulting list of chosen strings is made
by splitting the input string with crm-separator regular expression variable.

This approach is not suitable for a list of candidates where a candidate
string might contain a character that is currently treated as a
separator.  Imagine a situation where you read a list of Org headings
from user.  In an Org heading you can have any character including the
default separator ",".  Changing the value of crm-separator locally is
not a solution here.

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>

This functionality definitely could be helpful at least in org, org-ql packages
(for completion over org headings).

I am not an Elisp expert, but here's some drafts.  If you are interested,
please comment.

Test the function:

(ic-completing-read-multiple "Prompt: " '("first" "second" "third"))


[-- Attachment #2: ic-read-multiple.el --]
[-- Type: application/emacs-lisp, Size: 2160 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: Better alternative to completing-read-multiple
@ 2024-04-21 22:16 Иван С
  0 siblings, 0 replies; 5+ messages in thread
From: Иван С @ 2024-04-21 22:16 UTC (permalink / raw)
  To: ichernyshovvv; +Cc: 87o7a59hks.fsf, emacs-devel

There is nothing wrong with completing-read-multiple. completing-read
is for reading *strings*, and completing-read-multiple is a wrapper
that allows you to narrow the completion to *the portion of the
string* after the specified regex.

I don't think your solution is general enough to justify its adoption right now.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-04-21 22:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-19 21:18 Better alternative to completing-read-multiple Ilya Chernyshov
2024-04-20  6:16 ` Thierry Volpiatto
2024-04-20 15:22 ` [External] : " Drew Adams
2024-04-20 17:20 ` Adam Porter
  -- strict thread matches above, loose matches on Subject: below --
2024-04-21 22:16 Иван С

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.