From: Yuri Khan <yuri.v.khan@gmail.com>
To: Yuri Khan <yuri.v.khan@gmail.com>,
carlmarcos@tutanota.com, Help Gnu Emacs <help-gnu-emacs@gnu.org>
Subject: Re: result of completing-read contradicting require-match
Date: Sun, 3 Jul 2022 03:38:31 +0700 [thread overview]
Message-ID: <CAP_d_8W6c33bq==fhOUFmRYRJ4vc9gXU_hfZe8YoZBKZRdLwfQ@mail.gmail.com> (raw)
In-Reply-To: <YsClbXsaeYoicPxI@protected.localdomain>
On Sun, 3 Jul 2022 at 03:07, Jean Louis <bugs@gnu.support> wrote:
> > Based on the quoted part of the docstring, you could probably pass a
> > function that returns t for an allowed value, and nil for disallowed
> > values, including an empty string or nil.
>
> Do you mean from `completing-read':
>
> "- a function, which will be called with the input as the parameter.
> If it returns a non-nil value, the minibuffer is exited with that value."
I do.
> Do you mean this:
>
> (let* ((cseq '("name" "name-mode"))
> (csel (completing-read "Type: " cseq nil FUNCTION-HERE? nil )))
> csel)
I do.
> and what would be value name for function to check it?
I meant a closure over the list of valid strings, something like this:
(let* ((choices '("name" "name-mode"))
(is-valid (lambda (s) (member s choices)))
(choice (completing-read "Type: " choices nil is-valid)))
choice)
I took the liberty to give variables sane names.
I did not test this as my currently installed Emacs does not accept
functions as the REQUIRE-MATCH argument. (Or, rather, it does but
treats them as the “anything else” case.)
next prev parent reply other threads:[~2022-07-02 20:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-02 18:58 result of completing-read contradicting require-match carlmarcos--- via Users list for the GNU Emacs text editor
2022-07-02 19:20 ` Jean Louis
2022-07-02 19:54 ` Yuri Khan
2022-07-02 20:07 ` Jean Louis
2022-07-02 20:38 ` Yuri Khan [this message]
2022-07-02 21:58 ` Jean Louis
2022-07-09 13:17 ` Jean Louis
2022-07-10 14:36 ` [External] : " Drew Adams
2022-07-10 17:56 ` Jean Louis
2022-07-02 21:13 ` carlmarcos--- via Users list for the GNU Emacs text editor
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP_d_8W6c33bq==fhOUFmRYRJ4vc9gXU_hfZe8YoZBKZRdLwfQ@mail.gmail.com' \
--to=yuri.v.khan@gmail.com \
--cc=carlmarcos@tutanota.com \
--cc=help-gnu-emacs@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).