From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#46583: 28.0.50; nested minibuffers Date: Thu, 18 Feb 2021 19:17:13 +0200 Organization: LINKOV.NET Message-ID: <87tuq9fmpi.fsf@mail.linkov.net> References: <87v9aqil93.fsf@mail.linkov.net> <83zh025vg8.fsf@gnu.org> <87v9aqe9am.fsf@mail.linkov.net> <83o8gi5t6a.fsf@gnu.org> <87a6s1n1rx.fsf@mail.linkov.net> <83im6p5tx8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37647"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (x86_64-pc-linux-gnu) Cc: rms@gnu.org, 46583@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Feb 18 18:59:40 2021 Return-path: Envelope-to: geb-bug-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 1lCnaV-0009hJ-OU for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Feb 2021 18:59:39 +0100 Original-Received: from localhost ([::1]:56548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lCnaU-0002BB-Nj for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 18 Feb 2021 12:59:38 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:33544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lCnDf-00049h-PQ for bug-gnu-emacs@gnu.org; Thu, 18 Feb 2021 12:36:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lCnDe-0004qt-8e for bug-gnu-emacs@gnu.org; Thu, 18 Feb 2021 12:36:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lCnDe-0004Wc-5G for bug-gnu-emacs@gnu.org; Thu, 18 Feb 2021 12:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 18 Feb 2021 17:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46583 X-GNU-PR-Package: emacs Original-Received: via spool by 46583-submit@debbugs.gnu.org id=B46583.161366970117297 (code B ref 46583); Thu, 18 Feb 2021 17:36:02 +0000 Original-Received: (at 46583) by debbugs.gnu.org; 18 Feb 2021 17:35:01 +0000 Original-Received: from localhost ([127.0.0.1]:47888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lCnCf-0004Uo-AQ for submit@debbugs.gnu.org; Thu, 18 Feb 2021 12:35:01 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:56005) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lCnCd-0004Ua-KS for 46583@debbugs.gnu.org; Thu, 18 Feb 2021 12:35:00 -0500 X-Originating-IP: 91.129.96.116 Original-Received: from mail.gandi.net (m91-129-96-116.cust.tele2.ee [91.129.96.116]) (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 1BBB6FF809; Thu, 18 Feb 2021 17:34:51 +0000 (UTC) In-Reply-To: <83im6p5tx8.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 18 Feb 2021 16:31:31 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:200277 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit >> I could send a patch that fixes this bug. > > Thanks. I hoped first to understand why we bind > enable-recursive-minibuffers in these cases, but if you prefer to > begin with a patch, please do, and let's take it from there. To understand the problem, it's better to start from the manual. The node (info "(elisp) Recursive Mini") says: If a command name has a property ‘enable-recursive-minibuffers’ that is non-‘nil’, then the command can use the minibuffer to read arguments even if it is invoked from the minibuffer. A command can also achieve this by binding ‘enable-recursive-minibuffers’ to ‘t’ in the interactive declaration (*note Using Interactive::). The minibuffer command ‘next-matching-history-element’ (normally ‘M-s’ in the minibuffer) does the latter. And indeed the command ‘next-matching-history-element’ (‘M-s’) mentioned as an example in the documentation, exhibits the same problem reported by Richard: 0. emacs -Q 1. M-x ;; execute-extended-command 2. M-s ;; next-matching-history-element 3. C-x b ;; switch-to-buffer And it tries to read a buffer name, ignoring the default nil value of ‘enable-recursive-minibuffers’. This is because the manual documents the official way by binding ‘enable-recursive-minibuffers’ to ‘t’ that next-matching-history-element does: (defun next-matching-history-element (regexp n) (interactive (let* ((enable-recursive-minibuffers t) (regexp (read-from-minibuffer "Next element matching (regexp): " ... One possible solution is to support an additional value ‘transient’ for the variable ‘enable-recursive-minibuffers’. Then this value could have its effect only for the next invocation of read-from-minibuffer. Afterwards it will be set to ‘nil’ for any further recursive calls of read-from-minibuffer. PS: Such transient value is similar to the value ‘lambda’ of ‘transient-mark-mode’ described in (info "(elisp) The Mark"). Currently this patch fixes the reported problem only for the commands yes-or-no-p and next-matching-history-element: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=transient-enable-recursive-minibuffers.patch diff --git a/src/minibuf.c b/src/minibuf.c index 4b1f4b1ff7..8a46693846 100644 --- a/src/minibuf.c +++ b/src/minibuf.c @@ -592,7 +592,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, if (!STRINGP (prompt)) prompt = empty_unibyte_string; - if (!enable_recursive_minibuffers + if (NILP (Venable_recursive_minibuffers) && minibuf_level > 0) { Lisp_Object str @@ -604,6 +604,9 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, Fthrow (Qexit, str); } + if (EQ (Venable_recursive_minibuffers, Qtransient)) + specbind (Qenable_recursive_minibuffers, Qnil); + if ((noninteractive /* In case we are running as a daemon, only do this before detaching from the terminal. */ @@ -2242,6 +2245,7 @@ syms_of_minibuf (void) DEFSYM (Qcase_fold_search, "case-fold-search"); DEFSYM (Qmetadata, "metadata"); DEFSYM (Qcycle_sort_function, "cycle-sort-function"); + DEFSYM (Qtransient, "transient"); /* A frame parameter. */ DEFSYM (Qminibuffer_exit, "minibuffer-exit"); @@ -2311,12 +2315,12 @@ syms_of_minibuf (void) controls the behavior, rather than this variable. */); completion_ignore_case = 0; - DEFVAR_BOOL ("enable-recursive-minibuffers", enable_recursive_minibuffers, + DEFVAR_LISP ("enable-recursive-minibuffers", Venable_recursive_minibuffers, doc: /* Non-nil means to allow minibuffer commands while in the minibuffer. This variable makes a difference whenever the minibuffer window is active. Also see `minibuffer-depth-indicate-mode', which may be handy if this variable is non-nil. */); - enable_recursive_minibuffers = 0; + Venable_recursive_minibuffers = Qnil; DEFVAR_LISP ("minibuffer-completion-table", Vminibuffer_completion_table, doc: /* Alist or obarray used for completion in the minibuffer. diff --git a/src/fns.c b/src/fns.c index f51ef2781d..4744fddf27 100644 --- a/src/fns.c +++ b/src/fns.c @@ -2882,7 +2882,8 @@ DEFUN ("yes-or-no-p", Fyes_or_no_p, Syes_or_no_p, 1, 1, 0, prompt = CALLN (Fconcat, prompt, yes_or_no); ptrdiff_t count = SPECPDL_INDEX (); - specbind (Qenable_recursive_minibuffers, Qt); + if (NILP (Venable_recursive_minibuffers)) + specbind (Qenable_recursive_minibuffers, Qtransient); while (1) { diff --git a/lisp/simple.el b/lisp/simple.el index 7eee65e204..99b959b2fc 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -2370,7 +2370,7 @@ next-matching-history-element `case-fold-search' is non-nil, but an uppercase letter in REGEXP makes the search case-sensitive." (interactive - (let* ((enable-recursive-minibuffers t) + (let* ((enable-recursive-minibuffers (or enable-recursive-minibuffers 'transient)) (regexp (read-from-minibuffer "Next element matching (regexp): " nil minibuffer-local-map --=-=-=--