diff options
| author | Federico Tedin | 2019-12-05 10:30:17 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-12-05 10:30:28 +0100 |
| commit | 3586fef263ccf3b68cc1289d55ef44a3d9ac7e1d (patch) | |
| tree | 9afa19b840fbef8fc61a3efbc4e148904195596c /src | |
| parent | 9027084793831031926c12d3bdfa132ec6ac4e60 (diff) | |
| download | emacs-3586fef263ccf3b68cc1289d55ef44a3d9ac7e1d.tar.gz emacs-3586fef263ccf3b68cc1289d55ef44a3d9ac7e1d.zip | |
Make HIST arg of read-from-minibuffer work with buffer-local vars
* lisp/simple.el (minibuffer-history-values): New function, should be
used to access the minibuffer input history variable when the
minibuffer might be active. If the variable is buffer-local, the
previous buffer's value will be used.
(goto-history-element): Use the new function to access the minibuffer
history.
(minibuffer-history-isearch-wrap): Use the new function to access the
minibuffer history.
* src/minibuf.c (read_minibuf): Switch to previous buffer temporarily
before updating history list (Bug#38317).
(read-from-minibuffer): Extend documentation to mention that the
result of using the command will be added to the history list by
default.
* doc/lispref/minibuf.texi (Minibuffer History): Mention the
possibility of using a buffer-local variable as history.
* etc/NEWS: Announce changes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/minibuf.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/minibuf.c b/src/minibuf.c index 1e87c5044af..bdae01dbc58 100644 --- a/src/minibuf.c +++ b/src/minibuf.c | |||
| @@ -353,7 +353,7 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, | |||
| 353 | Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, | 353 | Lisp_Object histvar, Lisp_Object histpos, Lisp_Object defalt, |
| 354 | bool allow_props, bool inherit_input_method) | 354 | bool allow_props, bool inherit_input_method) |
| 355 | { | 355 | { |
| 356 | Lisp_Object val; | 356 | Lisp_Object val, previous_buffer = Fcurrent_buffer (); |
| 357 | ptrdiff_t count = SPECPDL_INDEX (); | 357 | ptrdiff_t count = SPECPDL_INDEX (); |
| 358 | Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; | 358 | Lisp_Object mini_frame, ambient_dir, minibuffer, input_method; |
| 359 | Lisp_Object enable_multibyte; | 359 | Lisp_Object enable_multibyte; |
| @@ -698,7 +698,20 @@ read_minibuf (Lisp_Object map, Lisp_Object initial, Lisp_Object prompt, | |||
| 698 | 698 | ||
| 699 | /* Add the value to the appropriate history list, if any. */ | 699 | /* Add the value to the appropriate history list, if any. */ |
| 700 | if (! (NILP (Vhistory_add_new_input) || NILP (histstring))) | 700 | if (! (NILP (Vhistory_add_new_input) || NILP (histstring))) |
| 701 | call2 (intern ("add-to-history"), Vminibuffer_history_variable, histstring); | 701 | { |
| 702 | ptrdiff_t count2 = SPECPDL_INDEX (); | ||
| 703 | |||
| 704 | /* If possible, switch back to the previous buffer first, in | ||
| 705 | case the history variable is buffer-local. */ | ||
| 706 | if (BUFFER_LIVE_P (XBUFFER (previous_buffer))) | ||
| 707 | { | ||
| 708 | record_unwind_current_buffer (); | ||
| 709 | Fset_buffer (previous_buffer); | ||
| 710 | } | ||
| 711 | |||
| 712 | call2 (intern ("add-to-history"), Vminibuffer_history_variable, histstring); | ||
| 713 | unbind_to (count2, Qnil); | ||
| 714 | } | ||
| 702 | 715 | ||
| 703 | /* If Lisp form desired instead of string, parse it. */ | 716 | /* If Lisp form desired instead of string, parse it. */ |
| 704 | if (expflag) | 717 | if (expflag) |
| @@ -879,6 +892,9 @@ Fifth arg HIST, if non-nil, specifies a history list and optionally | |||
| 879 | starting from 1 at the beginning of the list. If HIST is the symbol | 892 | starting from 1 at the beginning of the list. If HIST is the symbol |
| 880 | `t', history is not recorded. | 893 | `t', history is not recorded. |
| 881 | 894 | ||
| 895 | If `history-add-new-input' is non-nil (the default), the result will | ||
| 896 | be added to the history list using `add-to-history'. | ||
| 897 | |||
| 882 | Sixth arg DEFAULT-VALUE, if non-nil, should be a string, which is used | 898 | Sixth arg DEFAULT-VALUE, if non-nil, should be a string, which is used |
| 883 | as the default to `read' if READ is non-nil and the user enters | 899 | as the default to `read' if READ is non-nil and the user enters |
| 884 | empty input. But if READ is nil, this function does _not_ return | 900 | empty input. But if READ is nil, this function does _not_ return |