From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: carlmarcos--- via Users list for the GNU Emacs text editor Newsgroups: gmane.emacs.help Subject: Re: result of completing-read contradicting require-match Date: Sat, 2 Jul 2022 23:13:38 +0200 (CEST) Message-ID: References: Reply-To: carlmarcos@tutanota.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="16629"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Help Gnu Emacs To: Jean Louis Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 02 23:14:44 2022 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o7kRv-0004Au-TZ for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 02 Jul 2022 23:14:43 +0200 Original-Received: from localhost ([::1]:38152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7kRt-0005s6-U2 for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 02 Jul 2022 17:14:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7kQw-0005Ja-1X for help-gnu-emacs@gnu.org; Sat, 02 Jul 2022 17:13:42 -0400 Original-Received: from w1.tutanota.de ([81.3.6.162]:33408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7kQt-0002sM-S2 for help-gnu-emacs@gnu.org; Sat, 02 Jul 2022 17:13:41 -0400 Original-Received: from w3.tutanota.de (unknown [192.168.1.164]) by w1.tutanota.de (Postfix) with ESMTP id 77891FA01C3; Sat, 2 Jul 2022 21:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1656796418; s=s1; d=tutanota.com; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=5vTL/+o52jYXp9Hr7sLNVPBMjQYBnRaH3qDtSCFiCL4=; b=Ia+1mAbvwzRPfzlyFXalnpboXmq1+BkyLVSMSaTtCuu3ce7Kkj5h/VKu2SbQKwBJ 3jAk5RexBU7OAVvOsjeZACn1wp+YZCABxaaB1X+gKth2UqvpWQkiTxgvmxYHfjme+F7 DbBcT3Bp/jITsmflhXtTcosYSH663Xsjq4ApthHNrfK9I1Rxliixw/eDBeEGx7q7LWj Bac310HPtWcj85Fv6SEzxuDjnttr2EHTNYTlzbaepajlrco055J9DfZE5HpHgh0ncdd dy8gear5BmuOFDnjMWMnez6FdE4d47L5CmoniF4frafV5BGHNhxtDIbrUs2L2e5afDo p3ZUkiZO4g== In-Reply-To: Received-SPF: pass client-ip=81.3.6.162; envelope-from=carlmarcos@tutanota.com; helo=w1.tutanota.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:138267 Archived-At: Jul 2, 2022, 19:20 by bugs@gnu.support: > * carlmarcos--- via Users list for the GNU Emacs text editor [2022-07-02 21:59]: > >> I am using completing-read=C2=A0that uses require-match, without initial= -input and withoutdef. >> >> If I press return so that the input is neither "name" or "name-mode", it= seems that an empty >> string is returned.=C2=A0 The result seems to contradict require-match b= eing `t'. >> > > (let* ((cseq '("name" "name-mode")) > (csel (completing-read "Type: " cseq nil t nil))) > csel) =E2=87=92 then after pressing ENTER I get: "" > > > REQUIRE-MATCH can take the following values: > - t means that the user is not allowed to exit unless the input is (or > completes to) an element of COLLECTION or is null. > - nil means that the user can exit with any input. > - =E2=80=98confirm=E2=80=99 means that the user can exit with any input, = but she needs > to confirm her choice if the input is not an element of COLLECTION. > - =E2=80=98confirm-after-completion=E2=80=99 means that the user can exit= with any > input, but she needs to confirm her choice if she called > =E2=80=98minibuffer-complete=E2=80=99 right before =E2=80=98minibuffer-c= omplete-and-exit=E2=80=99 > and the input is not an element of COLLECTION. > - 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. > - anything else behaves like t except that typing RET does not exit if it > does non-null completion. > Have been playing with REQUIRE-MATCH being 'confirm, but there is not infor= mation what to do if yao want to confirm. > I guess that simple pressing of ENTER means "null" in this case. > But if anything is chosen, then it must be an element of the > collection. > > If you then add default, then it would get the first value: > =20 > (let* ((cseq '("name" "name-mode")) > (csel (completing-read "Type: " cseq nil t nil nil (car cseq)))) > csel) =E2=87=92 then after pressing ENTER I get: "name" > > other way to persist asking until you get the true result is here: > =20 > (defun rcd-repeat-until-not-empty-string (function &rest args) > "Repeat FUNCTION with optional ARGS until result is not empty string." > (let ((result)) > (while (string-empty-p (setq result (apply function args)))) > result)) > > (defun my-fun () > (let* ((cseq '("name" "name-mode")) > (csel (completing-read "Type: " cseq nil t nil nil nil))) > csel)) > > In this case it will keep asking you until you enter something. > > (rcd-repeat-until-not-empty-string 'my-fun) =E2=87=92 "name-mode" > > > --=20 > Jean > > Take action in Free Software Foundation campaigns: > https://www.fsf.org/campaigns > > In support of Richard M. Stallman > https://stallmansupport.org/ >