emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 55db25b: Introduce and use minibuffer-mode. This fixes bug #47150


From: Alan Mackenzie
Subject: master 55db25b: Introduce and use minibuffer-mode. This fixes bug #47150
Date: Tue, 20 Apr 2021 06:15:55 -0400 (EDT)

branch: master
commit 55db25b2579e5d84dfcf3a15957fc7a827abf25f
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>

    Introduce and use minibuffer-mode.  This fixes bug #47150
    
    * lisp/minibuffer.el (minibuffer-mode): New derived mode.
    
    * src/minibuf.c (syms_of_minibuf): New DEFSYMs Qminibuffer_mode,
    Qminibuffer_inactive_mode, Qminibuffer_completing_file_name,
    Qselect_frame_set_input_focus, Qadd_to_history.
    (read_minibuf, set_minibuffer_mode, read_minibuf_unwind): Use the new 
DEFSYMs
    in place of continual interning.
    (set_minibuffer_mode): Put an active minibuffer into minibuffer-mode rather
    than fundamental-mode.
    
    * doc/emacs/mini.texi (Minibuffer Edit): Mention minibuffer-mode.
    
    * doc/lispref/minibuf.texi (Intro to Minibuffers): Add a paragraph about
    minibuffer-mode.
    
    * etc/NEWS (Incompatible Lisp Changes in Emacs 28.1): Add an entry.
---
 doc/emacs/mini.texi      |  3 +++
 doc/lispref/minibuf.texi |  8 ++++++++
 etc/NEWS                 |  4 ++++
 lisp/minibuffer.el       | 10 ++++++++++
 src/minibuf.c            | 22 ++++++++++++++--------
 5 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 1eba707..03db669 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -247,6 +247,9 @@ You might need also to enable 
@code{minibuffer-depth-indicate-mode}
 to show the current recursion depth in the minibuffer prompt
 on recursive use of the minibuffer.
 
+  When active, the minibuffer is usually in @code{minibuffer-mode}.
+This is an internal Emacs mode without any special features.
+
 @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 e922f18..b861819 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -97,6 +97,14 @@ to be done.  @xref{Text from Minibuffer}, for the 
non-completion
 minibuffer local maps.  @xref{Completion Commands}, for the minibuffer
 local maps for completion.
 
+@cindex active minibuffer
+  An active minibuffer usually has major mode @code{minibuffer-mode}.
+This is an Emacs internal mode without any special features.  To
+customize the setup of minibuffers, we suggest you use
+@code{minibuffer-setup-hook} (@pxref{Minibuffer Misc}) rather than
+@code{minibuffer-mode-hook}, since the former is run later, after the
+minibuffer has been fully initialized.
+
 @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 b641e8d..3e5767c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2393,6 +2393,10 @@ This affects the suffix specified by completion 
'annotation-function'.
 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
 over a table of strings with properties will no longer remove all the
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 4ed5964..9bbc22b 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2499,6 +2499,16 @@ not active.")
   "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 for active minibuffers.
+
+For customizing this mode, it is better to 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 f025817..b823224 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
@@ -2333,6 +2333,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.  */);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]