unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "47150@debbugs.gnu.org" <47150@debbugs.gnu.org>,
	Sheng Yang <styang@fastmail.com>
Subject: bug#47150: [External] : bug#47150: 28.0.50; Incorrect major-mode in minibuffer
Date: Mon, 19 Apr 2021 17:30:30 +0000	[thread overview]
Message-ID: <YH2+Ngutv73f9q3Y@ACM> (raw)
In-Reply-To: <YH1OUDYr9eOGODyc@ACM>

Hello, everybody.

On Mon, Apr 19, 2021 at 09:33:04 +0000, Alan Mackenzie wrote:

[ .... ]

> I posted a patch for this yesterday.  In the documentation bit, I
> strongly advised against using minibuffer-mode-hook, instead directing
> users to minibuffer-setup-hook and minibuffer-exit-hook.  Was this the
> right thing to write?

Apologies.  That post didn't make it out, after all.  Here is the patch I
meant to send.  I invite Sheng, in particular, to report how well it
fixes the bug.  Thanks!


diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 1eba7074f7..6f2935f1f6 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -247,6 +247,9 @@ Minibuffer Edit
 to show the current recursion depth in the minibuffer prompt
 on recursive use of the minibuffer.
 
+  When active, the minibuffer is in @code{minibuffer-mode}.  This is
+an internal Emacs mode without any features for the user.
+
 @findex minibuffer-inactive-mode
   When not active, the minibuffer is in @code{minibuffer-inactive-mode},
 and clicking @kbd{mouse-1} there shows the @file{*Messages*} buffer.
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index d16409d6c8..edb46bbefe 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -97,6 +97,13 @@ Intro to Minibuffers
 minibuffer local maps.  @xref{Completion Commands}, for the minibuffer
 local maps for completion.
 
+@cindex active minibuffer
+  An active minibuffer has major mode @code{minibuffer-mode}.  This is
+an Emacs internal mode, and there is never any point in calling it or
+otherwise trying to manipulate it.  Rather than using
+@code{minibuffer-mode-hook}, you should use
+@code{minibuffer-setup-hook} (@pxref{Minibuffer Misc}).
+
 @cindex inactive minibuffer
   When a minibuffer is inactive, its major mode is
 @code{minibuffer-inactive-mode}, with keymap
diff --git a/etc/NEWS b/etc/NEWS
index b641e8d95f..3e5767c953 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2392,6 +2392,10 @@ This affects the suffix specified by completion 'annotation-function'.
 ** 'set-process-buffer' now updates the process mark.
 The mark will be set to point to the end of the new buffer.
 
++++
+** An active minibuffer now has major mode 'minibuffer-mode', not the
+erroneous 'minibuffer-inactive-mode' it formerly had.
+
 +++
 ** Some properties from completion tables are now preserved.
 If 'minibuffer-allow-text-properties' is non-nil, doing completion
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c900b0d7ce..1a719a12cc 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2474,6 +2474,16 @@ minibuffer-inactive-mode
   "Major mode to use in the minibuffer when it is not active.
 This is only used when the minibuffer area has no active minibuffer.")
 
+(define-derived-mode minibuffer-mode nil "Minibuffer"
+  "Major mode used only in active minibuffers.
+This mode is used internally, and should not be set by user code
+in any way, although it may be tested by such code.  Use
+`minibuffer-setup-hook' and `minibuffer-exit-hook' rather than
+the mode hook of this mode."
+  :syntax-table nil
+  :abbrev-table nil
+  :interactive nil)
+
 ;;; Completion tables.
 
 (defun minibuffer--double-dollars (str)
diff --git a/src/minibuf.c b/src/minibuf.c
index a3c1b99bf3..439addc9a9 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -567,7 +567,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
      in previous recursive minibuffer, but was not set explicitly
      to t for this invocation, so set it to nil in this minibuffer.
      Save the old value now, before we change it.  */
-  specbind (intern ("minibuffer-completing-file-name"),
+  specbind (Qminibuffer_completing_file_name,
 	    Vminibuffer_completing_file_name);
   if (EQ (Vminibuffer_completing_file_name, Qlambda))
     Vminibuffer_completing_file_name = Qnil;
@@ -920,13 +920,13 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
 	      && !EQ (XWINDOW (XFRAME (calling_frame)->minibuffer_window)
 		      ->frame,
 		      calling_frame))))
-    call2 (intern ("select-frame-set-input-focus"), calling_frame, Qnil);
+    call2 (Qselect_frame_set_input_focus, calling_frame, Qnil);
 
   /* Add the value to the appropriate history list, if any.  This is
      done after the previous buffer has been made current again, in
      case the history variable is buffer-local.  */
   if (! (NILP (Vhistory_add_new_input) || NILP (histstring)))
-    call2 (intern ("add-to-history"), histvar, histstring);
+    call2 (Qadd_to_history, histvar, histstring);
 
   /* If Lisp form desired instead of string, parse it.  */
   if (expflag)
@@ -965,13 +965,13 @@ set_minibuffer_mode (Lisp_Object buf, EMACS_INT depth)
   Fset_buffer (buf);
   if (depth > 0)
     {
-      if (!NILP (Ffboundp (intern ("fundamental-mode"))))
-	call0 (intern ("fundamental-mode"));
+      if (!NILP (Ffboundp (Qminibuffer_mode)))
+	call0 (Qminibuffer_mode);
     }
   else
     {
-      if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode"))))
-	call0 (intern ("minibuffer-inactive-mode"));
+      if (!NILP (Ffboundp (Qminibuffer_inactive_mode)))
+	call0 (Qminibuffer_inactive_mode);
       else
 	Fkill_all_local_variables ();
     }
@@ -1163,7 +1163,7 @@ read_minibuf_unwind (void)
      dead, we may keep displaying this buffer (tho it's inactive), so reset it,
      to make sure we don't leave around bindings and stuff which only
      made sense during the read_minibuf invocation.  */
-  call0 (intern ("minibuffer-inactive-mode"));
+  call0 (Qminibuffer_inactive_mode);
 
   /* We've exited the recursive edit, so switch the current windows
      away from the expired minibuffer window, both in the current
@@ -2332,6 +2332,12 @@ syms_of_minibuf (void)
   /* A frame parameter.  */
   DEFSYM (Qminibuffer_exit, "minibuffer-exit");
 
+  DEFSYM (Qminibuffer_mode, "minibuffer-mode");
+  DEFSYM (Qminibuffer_inactive_mode, "minibuffer-inactive-mode");
+  DEFSYM (Qminibuffer_completing_file_name, "minibuffer-completing-file-name");
+  DEFSYM (Qselect_frame_set_input_focus, "select-frame-set-input-focus");
+  DEFSYM (Qadd_to_history, "add-to-history");
+
   DEFVAR_LISP ("read-expression-history", Vread_expression_history,
 	       doc: /* A history list for arguments that are Lisp expressions to evaluate.
 For example, `eval-expression' uses this.  */);



[ .... ]

-- 
Alan Mackenzie (Nuremberg, Germany).





  reply	other threads:[~2021-04-19 17:30 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15  0:57 bug#47150: 28.0.50; Incorrect major-mode in minibuffer styang
2021-03-15  1:02 ` bug#47150: Emacs bug#47150 " Sheng Yang
2021-03-15  7:59 ` bug#47150: " Alan Mackenzie
2021-03-15 18:15   ` Sheng Yang
2021-03-15 21:30     ` Alan Mackenzie
2021-03-15 21:58       ` Sheng Yang
2021-03-22 15:12         ` Alan Mackenzie
2021-03-22 15:52           ` bug#47150: [External] : " Drew Adams
2021-03-22 16:27             ` Alan Mackenzie
2021-03-22 17:09               ` Drew Adams
     [not found]                 ` <878s6ft5ze.fsf_-_@miha-pc>
2021-03-22 18:38                   ` bug#47150: [External] : " Drew Adams
2021-03-22 21:57                 ` bug#47150: [External] : " Alan Mackenzie
2021-03-22 23:06                   ` Drew Adams
2021-03-23 13:05                     ` Alan Mackenzie
2021-03-23 15:44                       ` Drew Adams
2021-03-22 18:12         ` Stefan Monnier
2021-03-22 18:08       ` Stefan Monnier
2021-03-22 18:40         ` bug#47150: [External] : " Drew Adams
2021-03-22 19:30           ` Stefan Monnier
2021-03-22 19:42             ` Drew Adams
2021-03-22 20:11               ` Stefan Monnier
2021-03-22 21:36                 ` Drew Adams
2021-04-09  8:57                   ` Sheng Yang
2021-04-12 10:18                     ` Alan Mackenzie
2021-04-12 12:02                       ` Sheng Yang
2021-04-12 14:01                         ` Stefan Monnier
2021-04-12 16:15                           ` Alan Mackenzie
2021-04-12 17:10                             ` Stefan Monnier
2021-04-12 18:34                               ` Alan Mackenzie
2021-04-12 20:46                                 ` Stefan Monnier
2021-04-18 11:14                                   ` Alan Mackenzie
2021-04-18 15:22                                     ` Stefan Monnier
2021-04-19  9:33                                       ` Alan Mackenzie
2021-04-19 17:30                                         ` Alan Mackenzie [this message]
2021-04-19 18:22                                           ` Stefan Monnier
2021-04-19 19:18                                             ` Sheng Yang
2021-04-19 19:35                                               ` Stefan Monnier
2021-04-19 19:47                                                 ` Sheng Yang
2021-04-19 20:36                                                   ` Stefan Monnier
2021-04-19 20:42                                                     ` Sheng Yang
2021-04-20 10:25                                               ` Alan Mackenzie
2021-03-22 19:42         ` Alan Mackenzie
2021-03-22 20:03           ` Stefan Monnier
2021-03-22 18:24 ` bug#47150: [External] : " jakanakaevangeli
2021-03-23  7:18 ` bug#47150: [External] : " jakanakaevangeli

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=YH2+Ngutv73f9q3Y@ACM \
    --to=acm@muc.de \
    --cc=47150@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=styang@fastmail.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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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).