From: Thierry Volpiatto <thievol@posteo.net>
To: Ilya Chernyshov <ichernyshovvv@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Better alternative to completing-read-multiple
Date: Sat, 20 Apr 2024 06:16:57 +0000 [thread overview]
Message-ID: <8734rg5zja.fsf@posteo.net> (raw)
In-Reply-To: <87o7a59hks.fsf@gmail.com> (Ilya Chernyshov's message of "Sat, 20 Apr 2024 04:18:59 +0700")
Ilya Chernyshov <ichernyshovvv@gmail.com> writes:
> 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>
You can provide this feature to Helm users:
--8<---------------cut here---------------start------------->8---
(defvar helm-comp-read-use-marked)
(let ((lst '(a b c d e)))
(if (boundp 'helm-comp-read-use-marked)
(let ((helm-comp-read-use-marked t))
(completing-read "test: " lst))
(completing-read-multiple "test: " lst)))
--8<---------------cut here---------------end--------------->8---
The completing-read will return a list of marked candidates, if Helm is
not available fallback to CRM.
> 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"))
>
>
--
Thierry
next prev parent reply other threads:[~2024-04-20 6:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-19 21:18 Better alternative to completing-read-multiple Ilya Chernyshov
2024-04-20 6:16 ` Thierry Volpiatto [this message]
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 Иван С
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=8734rg5zja.fsf@posteo.net \
--to=thievol@posteo.net \
--cc=emacs-devel@gnu.org \
--cc=ichernyshovvv@gmail.com \
/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.