all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#46583: 28.0.50; nested minibuffers
@ 2021-02-17  4:03 Richard Stallman
  2021-02-17 18:48 ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Stallman @ 2021-02-17  4:03 UTC (permalink / raw)
  To: 46583


I save a file that is read-only, so I am asked

  File phones is write-protected; try to save anyway? (yes or no) 

Then I type C-x b and it tries to read a buffer name.

But enable-recursive-minibuffers is nil!



In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 2.24.32, cairo version 1.15.10)
 of 2020-12-08 built on freetop
Repository revision: 0155bd0fdb166c97a2ce76cc5bc64fd195a676d3
Repository branch: master
System Description: Trisquel GNU/Linux Etiona (9.0)

Configured using:
 'configure --with-gnutls=ifavailable 'CFLAGS=-O0 -g''

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF ZLIB
TOOLKIT_SCROLL_BARS GTK2 X11 XDBE XIM MODULES THREADS PDUMPER

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Mail

Minor modes in effect:
  shell-dirtrack-mode: t
  gpm-mouse-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Load-path shadows:
None found.

Features:
(shadow emacsbug novice quail help-mode shr kinsoku svg xml dom
mule-util epa-mail shell pcomplete thingatpt files-x grep compile
comint ansi-color ring rmailsum dabbrev qp misearch multi-isearch
mailalias sendmail rmailkwd rmailout rmailmm message rmc puny rfc822
mml mml-sec epa epg epg-config gnus-util text-property-search
time-date mm-decode mm-bodies mm-encode mailabbrev gmm-utils
mailheader mail-parse rfc2231 rmail rmail-loaddefs rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mail-utils dired-aux dired
dired-loaddefs t-mouse term/linux view derived paren cus-start
cus-load advice finder-inf package easymenu browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie url-domsuf
url-util mailcap url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
url-vars seq byte-opt gv bytecomp byte-compile cconv cl-loaddefs
cl-lib iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode elisp-mode lisp-mode prog-mode register page tab-bar
menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock
font-lock syntax facemenu font-core term/tty-colors frame minibuffer
cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai
tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian
slovak czech european ethiopic indian cyrillic chinese composite
charscript charprop case-table epa-hook jka-cmpr-hook help simple
abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face
macroexp files window text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
threads dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 468665 79574)
 (symbols 48 23339 4)
 (strings 32 95476 13396)
 (string-bytes 1 2287671)
 (vectors 16 30546)
 (vector-slots 8 1438917 257443)
 (floats 8 55 269)
 (intervals 56 85633 1433)
 (buffers 984 53))
[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]


-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-17  4:03 bug#46583: 28.0.50; nested minibuffers Richard Stallman
@ 2021-02-17 18:48 ` Juri Linkov
  2021-02-17 19:46   ` Eli Zaretskii
                     ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Juri Linkov @ 2021-02-17 18:48 UTC (permalink / raw)
  To: Richard Stallman; +Cc: 46583

> I save a file that is read-only, so I am asked
>
>   File phones is write-protected; try to save anyway? (yes or no) 
>
> Then I type C-x b and it tries to read a buffer name.
>
> But enable-recursive-minibuffers is nil!

Let-binding enable-recursive-minibuffers temporarily to t was necessary
to fix bug#17272/bug#19064.

So when the minibuffer is already activated, and a minibuffer command
wants to ask a question, displaying another recursive minibuffer with
such question should override the value of enable-recursive-minibuffers.

But you found the problem that is a side-effect of this fix.

The problem is that currently it's impossible for a command
to override enable-recursive-minibuffers only for its own use,
while keeping it disabled for more recursive minibuffer calls.

Maybe enable-recursive-minibuffers should support a numeric value
that is decremented in every recursive minibuffer calls
until reaching zero value that disables more recursive calls?

Then a command that needs to use the recursive minibuffer
could let-bind enable-recursive-minibuffers to 1,
allowing this only for own use, while it will be 0
in more recursive calls.





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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-17 18:48 ` Juri Linkov
@ 2021-02-17 19:46   ` Eli Zaretskii
  2021-02-17 20:20     ` Juri Linkov
  2021-02-19  5:41   ` Richard Stallman
  2022-06-17 15:23   ` Lars Ingebrigtsen
  2 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2021-02-17 19:46 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rms, 46583

> From: Juri Linkov <juri@linkov.net>
> Date: Wed, 17 Feb 2021 20:48:08 +0200
> Cc: 46583@debbugs.gnu.org
> 
> Let-binding enable-recursive-minibuffers temporarily to t was necessary
> to fix bug#17272/bug#19064.
> 
> So when the minibuffer is already activated, and a minibuffer command
> wants to ask a question, displaying another recursive minibuffer with
> such question should override the value of enable-recursive-minibuffers.

Those bugs are about an echo-area message overwriting the minibuffer
prompt, are they not?  If so, doesn't the set-message-function feature
we now have fixed those bugs indirectly, this removing the need for
let-binding enable-recursive-minibuffers?





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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-17 19:46   ` Eli Zaretskii
@ 2021-02-17 20:20     ` Juri Linkov
  2021-02-17 20:35       ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2021-02-17 20:20 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rms, 46583

>> Let-binding enable-recursive-minibuffers temporarily to t was necessary
>> to fix bug#17272/bug#19064.
>> 
>> So when the minibuffer is already activated, and a minibuffer command
>> wants to ask a question, displaying another recursive minibuffer with
>> such question should override the value of enable-recursive-minibuffers.
>
> Those bugs are about an echo-area message overwriting the minibuffer
> prompt, are they not?  If so, doesn't the set-message-function feature
> we now have fixed those bugs indirectly, this removing the need for
> let-binding enable-recursive-minibuffers?

This problem is not fixed by set-message-function that only improves
messaging.  The problem was reported by João in the same bug report
https://debbugs.gnu.org/17272#114

Emacs -Q
M-x fido-mode
C-x b
C-k ;; to kill the Messages buffer

This affects yes-or-no-p that C-k needs to use from the minibuffer
in fido-mode.





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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-17 20:20     ` Juri Linkov
@ 2021-02-17 20:35       ` Eli Zaretskii
  2021-02-18  9:39         ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2021-02-17 20:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rms, 46583

> From: Juri Linkov <juri@linkov.net>
> Cc: rms@gnu.org,  46583@debbugs.gnu.org
> Date: Wed, 17 Feb 2021 22:20:01 +0200
> 
> >> Let-binding enable-recursive-minibuffers temporarily to t was necessary
> >> to fix bug#17272/bug#19064.
> >> 
> >> So when the minibuffer is already activated, and a minibuffer command
> >> wants to ask a question, displaying another recursive minibuffer with
> >> such question should override the value of enable-recursive-minibuffers.
> >
> > Those bugs are about an echo-area message overwriting the minibuffer
> > prompt, are they not?  If so, doesn't the set-message-function feature
> > we now have fixed those bugs indirectly, this removing the need for
> > let-binding enable-recursive-minibuffers?
> 
> This problem is not fixed by set-message-function that only improves
> messaging.

It prevents messages from overwriting minibuffer prompts.  And both of
the bugs you mentioned seem to be about messages that overwrite such
prompts.  So what am I missing?

> The problem was reported by João in the same bug report
> https://debbugs.gnu.org/17272#114
> 
> Emacs -Q
> M-x fido-mode
> C-x b
> C-k ;; to kill the Messages buffer
> 
> This affects yes-or-no-p that C-k needs to use from the minibuffer
> in fido-mode.

Sorry, I don't understand: how is this related to what I asked about?





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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-17 20:35       ` Eli Zaretskii
@ 2021-02-18  9:39         ` Juri Linkov
  2021-02-18 14:31           ` Eli Zaretskii
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2021-02-18  9:39 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rms, 46583

> It prevents messages from overwriting minibuffer prompts.  And both of
> the bugs you mentioned seem to be about messages that overwrite such
> prompts.  So what am I missing?

Sorry for mentioning old bugs that added confusion to this bug report.
What we have now is a new bug found by Richard:

  I save a file that is read-only, so I am asked

    File phones is write-protected; try to save anyway? (yes or no) 

  Then I type C-x b and it tries to read a buffer name.

I could send a patch that fixes this bug.





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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-18  9:39         ` Juri Linkov
@ 2021-02-18 14:31           ` Eli Zaretskii
  2021-02-18 17:17             ` Juri Linkov
  0 siblings, 1 reply; 12+ messages in thread
From: Eli Zaretskii @ 2021-02-18 14:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rms, 46583

> From: Juri Linkov <juri@linkov.net>
> Cc: rms@gnu.org,  46583@debbugs.gnu.org
> Date: Thu, 18 Feb 2021 11:39:54 +0200
> 
> > It prevents messages from overwriting minibuffer prompts.  And both of
> > the bugs you mentioned seem to be about messages that overwrite such
> > prompts.  So what am I missing?
> 
> Sorry for mentioning old bugs that added confusion to this bug report.
> What we have now is a new bug found by Richard:
> 
>   I save a file that is read-only, so I am asked
> 
>     File phones is write-protected; try to save anyway? (yes or no) 
> 
>   Then I type C-x b and it tries to read a buffer name.
> 
> 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.





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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-18 14:31           ` Eli Zaretskii
@ 2021-02-18 17:17             ` Juri Linkov
  0 siblings, 0 replies; 12+ messages in thread
From: Juri Linkov @ 2021-02-18 17:17 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: rms, 46583

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

>> 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:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: transient-enable-recursive-minibuffers.patch --]
[-- Type: text/x-diff, Size: 2841 bytes --]

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

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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-17 18:48 ` Juri Linkov
  2021-02-17 19:46   ` Eli Zaretskii
@ 2021-02-19  5:41   ` Richard Stallman
  2022-06-17 15:23   ` Lars Ingebrigtsen
  2 siblings, 0 replies; 12+ messages in thread
From: Richard Stallman @ 2021-02-19  5:41 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 46583

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]


  > The problem is that currently it's impossible for a command
  > to override enable-recursive-minibuffers only for its own use,
  > while keeping it disabled for more recursive minibuffer calls.

I see.  Thanks.

  > Maybe enable-recursive-minibuffers should support a numeric value
  > that is decremented in every recursive minibuffer calls
  > until reaching zero value that disables more recursive calls?

That should be a simple and adequate fix.

I don't see a need to support values greater than 1,
but I don't think they do any harm, and I see
no way to make this simpler by not supporting them.

-- 
Dr Richard Stallman
Chief GNUisance of the GNU Project (https://gnu.org)
Founder, Free Software Foundation (https://fsf.org)
Internet Hall-of-Famer (https://internethalloffame.org)







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

* bug#46583: 28.0.50; nested minibuffers
  2021-02-17 18:48 ` Juri Linkov
  2021-02-17 19:46   ` Eli Zaretskii
  2021-02-19  5:41   ` Richard Stallman
@ 2022-06-17 15:23   ` Lars Ingebrigtsen
  2022-06-17 19:20     ` Juri Linkov
  2 siblings, 1 reply; 12+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-17 15:23 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Richard Stallman, 46583

Juri Linkov <juri@linkov.net> writes:

> Maybe enable-recursive-minibuffers should support a numeric value
> that is decremented in every recursive minibuffer calls
> until reaching zero value that disables more recursive calls?

I think that makes sense...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#46583: 28.0.50; nested minibuffers
  2022-06-17 15:23   ` Lars Ingebrigtsen
@ 2022-06-17 19:20     ` Juri Linkov
  2022-06-18 11:33       ` Lars Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Juri Linkov @ 2022-06-17 19:20 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 46583

>> Maybe enable-recursive-minibuffers should support a numeric value
>> that is decremented in every recursive minibuffer calls
>> until reaching zero value that disables more recursive calls?
>
> I think that makes sense...

I don't know, later I sent a different patch that sets
the value 'transient' of enable-recursive-minibuffers
in yes-or-no-p.





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

* bug#46583: 28.0.50; nested minibuffers
  2022-06-17 19:20     ` Juri Linkov
@ 2022-06-18 11:33       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Ingebrigtsen @ 2022-06-18 11:33 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 46583

Juri Linkov <juri@linkov.net> writes:

> I don't know, later I sent a different patch that sets
> the value 'transient' of enable-recursive-minibuffers
> in yes-or-no-p.

I wasn't quite sure whether that patch would cover all the use cases...
but I didn't really look closely at this, so if you think that's the way
to go, that's fine with me.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

end of thread, other threads:[~2022-06-18 11:33 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-17  4:03 bug#46583: 28.0.50; nested minibuffers Richard Stallman
2021-02-17 18:48 ` Juri Linkov
2021-02-17 19:46   ` Eli Zaretskii
2021-02-17 20:20     ` Juri Linkov
2021-02-17 20:35       ` Eli Zaretskii
2021-02-18  9:39         ` Juri Linkov
2021-02-18 14:31           ` Eli Zaretskii
2021-02-18 17:17             ` Juri Linkov
2021-02-19  5:41   ` Richard Stallman
2022-06-17 15:23   ` Lars Ingebrigtsen
2022-06-17 19:20     ` Juri Linkov
2022-06-18 11:33       ` Lars Ingebrigtsen

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.