aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2021-04-20 10:14:40 +0000
committerAlan Mackenzie2021-04-20 10:14:40 +0000
commit55db25b2579e5d84dfcf3a15957fc7a827abf25f (patch)
treefb6e10d4f8cc64ded0af807b8c6384a99b4392fc
parent296ef2e99b7cd83ad236230ddc941c7dbc8766e6 (diff)
downloademacs-55db25b2579e5d84dfcf3a15957fc7a827abf25f.tar.gz
emacs-55db25b2579e5d84dfcf3a15957fc7a827abf25f.zip
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.
-rw-r--r--doc/emacs/mini.texi3
-rw-r--r--doc/lispref/minibuf.texi8
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/minibuffer.el10
-rw-r--r--src/minibuf.c22
5 files changed, 39 insertions, 8 deletions
diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index 1eba7074f76..03db6698fe5 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}
247to show the current recursion depth in the minibuffer prompt 247to show the current recursion depth in the minibuffer prompt
248on recursive use of the minibuffer. 248on recursive use of the minibuffer.
249 249
250 When active, the minibuffer is usually in @code{minibuffer-mode}.
251This is an internal Emacs mode without any special features.
252
250@findex minibuffer-inactive-mode 253@findex minibuffer-inactive-mode
251 When not active, the minibuffer is in @code{minibuffer-inactive-mode}, 254 When not active, the minibuffer is in @code{minibuffer-inactive-mode},
252and clicking @kbd{mouse-1} there shows the @file{*Messages*} buffer. 255and clicking @kbd{mouse-1} there shows the @file{*Messages*} buffer.
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index e922f1836b3..b8618199852 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
97minibuffer local maps. @xref{Completion Commands}, for the minibuffer 97minibuffer local maps. @xref{Completion Commands}, for the minibuffer
98local maps for completion. 98local maps for completion.
99 99
100@cindex active minibuffer
101 An active minibuffer usually has major mode @code{minibuffer-mode}.
102This is an Emacs internal mode without any special features. To
103customize the setup of minibuffers, we suggest you use
104@code{minibuffer-setup-hook} (@pxref{Minibuffer Misc}) rather than
105@code{minibuffer-mode-hook}, since the former is run later, after the
106minibuffer has been fully initialized.
107
100@cindex inactive minibuffer 108@cindex inactive minibuffer
101 When a minibuffer is inactive, its major mode is 109 When a minibuffer is inactive, its major mode is
102@code{minibuffer-inactive-mode}, with keymap 110@code{minibuffer-inactive-mode}, with keymap
diff --git a/etc/NEWS b/etc/NEWS
index b641e8d95f7..3e5767c953e 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2393,6 +2393,10 @@ This affects the suffix specified by completion 'annotation-function'.
2393The mark will be set to point to the end of the new buffer. 2393The mark will be set to point to the end of the new buffer.
2394 2394
2395+++ 2395+++
2396** An active minibuffer now has major mode 'minibuffer-mode', not the
2397erroneous 'minibuffer-inactive-mode' it formerly had.
2398
2399+++
2396** Some properties from completion tables are now preserved. 2400** Some properties from completion tables are now preserved.
2397If 'minibuffer-allow-text-properties' is non-nil, doing completion 2401If 'minibuffer-allow-text-properties' is non-nil, doing completion
2398over a table of strings with properties will no longer remove all the 2402over a table of strings with properties will no longer remove all the
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 4ed596430c6..9bbc22b6ea0 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2499,6 +2499,16 @@ not active.")
2499 "Major mode to use in the minibuffer when it is not active. 2499 "Major mode to use in the minibuffer when it is not active.
2500This is only used when the minibuffer area has no active minibuffer.") 2500This is only used when the minibuffer area has no active minibuffer.")
2501 2501
2502(define-derived-mode minibuffer-mode nil "Minibuffer"
2503 "Major mode used for active minibuffers.
2504
2505For customizing this mode, it is better to use
2506`minibuffer-setup-hook' and `minibuffer-exit-hook' rather than
2507the mode hook of this mode."
2508 :syntax-table nil
2509 :abbrev-table nil
2510 :interactive nil)
2511
2502;;; Completion tables. 2512;;; Completion tables.
2503 2513
2504(defun minibuffer--double-dollars (str) 2514(defun minibuffer--double-dollars (str)
diff --git a/src/minibuf.c b/src/minibuf.c
index f0258172766..b823224a5f2 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -567,7 +567,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
567 in previous recursive minibuffer, but was not set explicitly 567 in previous recursive minibuffer, but was not set explicitly
568 to t for this invocation, so set it to nil in this minibuffer. 568 to t for this invocation, so set it to nil in this minibuffer.
569 Save the old value now, before we change it. */ 569 Save the old value now, before we change it. */
570 specbind (intern ("minibuffer-completing-file-name"), 570 specbind (Qminibuffer_completing_file_name,
571 Vminibuffer_completing_file_name); 571 Vminibuffer_completing_file_name);
572 if (EQ (Vminibuffer_completing_file_name, Qlambda)) 572 if (EQ (Vminibuffer_completing_file_name, Qlambda))
573 Vminibuffer_completing_file_name = Qnil; 573 Vminibuffer_completing_file_name = Qnil;
@@ -920,13 +920,13 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt,
920 && !EQ (XWINDOW (XFRAME (calling_frame)->minibuffer_window) 920 && !EQ (XWINDOW (XFRAME (calling_frame)->minibuffer_window)
921 ->frame, 921 ->frame,
922 calling_frame)))) 922 calling_frame))))
923 call2 (intern ("select-frame-set-input-focus"), calling_frame, Qnil); 923 call2 (Qselect_frame_set_input_focus, calling_frame, Qnil);
924 924
925 /* Add the value to the appropriate history list, if any. This is 925 /* Add the value to the appropriate history list, if any. This is
926 done after the previous buffer has been made current again, in 926 done after the previous buffer has been made current again, in
927 case the history variable is buffer-local. */ 927 case the history variable is buffer-local. */
928 if (! (NILP (Vhistory_add_new_input) || NILP (histstring))) 928 if (! (NILP (Vhistory_add_new_input) || NILP (histstring)))
929 call2 (intern ("add-to-history"), histvar, histstring); 929 call2 (Qadd_to_history, histvar, histstring);
930 930
931 /* If Lisp form desired instead of string, parse it. */ 931 /* If Lisp form desired instead of string, parse it. */
932 if (expflag) 932 if (expflag)
@@ -965,13 +965,13 @@ set_minibuffer_mode (Lisp_Object buf, EMACS_INT depth)
965 Fset_buffer (buf); 965 Fset_buffer (buf);
966 if (depth > 0) 966 if (depth > 0)
967 { 967 {
968 if (!NILP (Ffboundp (intern ("fundamental-mode")))) 968 if (!NILP (Ffboundp (Qminibuffer_mode)))
969 call0 (intern ("fundamental-mode")); 969 call0 (Qminibuffer_mode);
970 } 970 }
971 else 971 else
972 { 972 {
973 if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode")))) 973 if (!NILP (Ffboundp (Qminibuffer_inactive_mode)))
974 call0 (intern ("minibuffer-inactive-mode")); 974 call0 (Qminibuffer_inactive_mode);
975 else 975 else
976 Fkill_all_local_variables (); 976 Fkill_all_local_variables ();
977 } 977 }
@@ -1163,7 +1163,7 @@ read_minibuf_unwind (void)
1163 dead, we may keep displaying this buffer (tho it's inactive), so reset it, 1163 dead, we may keep displaying this buffer (tho it's inactive), so reset it,
1164 to make sure we don't leave around bindings and stuff which only 1164 to make sure we don't leave around bindings and stuff which only
1165 made sense during the read_minibuf invocation. */ 1165 made sense during the read_minibuf invocation. */
1166 call0 (intern ("minibuffer-inactive-mode")); 1166 call0 (Qminibuffer_inactive_mode);
1167 1167
1168 /* We've exited the recursive edit, so switch the current windows 1168 /* We've exited the recursive edit, so switch the current windows
1169 away from the expired minibuffer window, both in the current 1169 away from the expired minibuffer window, both in the current
@@ -2333,6 +2333,12 @@ syms_of_minibuf (void)
2333 /* A frame parameter. */ 2333 /* A frame parameter. */
2334 DEFSYM (Qminibuffer_exit, "minibuffer-exit"); 2334 DEFSYM (Qminibuffer_exit, "minibuffer-exit");
2335 2335
2336 DEFSYM (Qminibuffer_mode, "minibuffer-mode");
2337 DEFSYM (Qminibuffer_inactive_mode, "minibuffer-inactive-mode");
2338 DEFSYM (Qminibuffer_completing_file_name, "minibuffer-completing-file-name");
2339 DEFSYM (Qselect_frame_set_input_focus, "select-frame-set-input-focus");
2340 DEFSYM (Qadd_to_history, "add-to-history");
2341
2336 DEFVAR_LISP ("read-expression-history", Vread_expression_history, 2342 DEFVAR_LISP ("read-expression-history", Vread_expression_history,
2337 doc: /* A history list for arguments that are Lisp expressions to evaluate. 2343 doc: /* A history list for arguments that are Lisp expressions to evaluate.
2338For example, `eval-expression' uses this. */); 2344For example, `eval-expression' uses this. */);