completing-read: If HIST is the symbol `t', history is not recorded.

* lisp/minibuffer.el (completion-all-sorted-completions): Check if
`minibuffer-history-variable` is `t`
* src/minibuf.c (completing-read): Update docstring
* doc/lispref/minibuf.texi: Update documentation of
`read-from-minibuffer` and `completing-read`
This commit is contained in:
Daniel Mendler 2021-04-19 08:20:50 +02:00 committed by Stefan Monnier
parent 0a4dc70830
commit 077dae3b4c
3 changed files with 11 additions and 7 deletions

View file

@ -167,8 +167,10 @@ various applications such as completion.
The argument @var{history} specifies a history list variable to use
for saving the input and for history commands used in the minibuffer.
It defaults to @code{minibuffer-history}. You can optionally specify
a starting position in the history list as well. @xref{Minibuffer History}.
It defaults to @code{minibuffer-history}. If @var{history} is the
symbol @code{t}, history is not recorded. You can optionally specify
a starting position in the history list as well. @xref{Minibuffer
History}.
If the variable @code{minibuffer-allow-text-properties} is
non-@code{nil}, then the string that is returned includes whatever text
@ -1107,9 +1109,10 @@ The function @code{completing-read} uses
@code{minibuffer-local-must-match-map} if @var{require-match} is
non-@code{nil}. @xref{Completion Commands}.
The argument @var{history} specifies which history list variable to use for
saving the input and for minibuffer history commands. It defaults to
@code{minibuffer-history}. @xref{Minibuffer History}.
The argument @var{history} specifies which history list variable to
use for saving the input and for minibuffer history commands. It
defaults to @code{minibuffer-history}. If @var{history} is the symbol
@code{t}, history is not recorded. @xref{Minibuffer History}.
The argument @var{initial} is mostly deprecated; we recommend using a
non-@code{nil} value only in conjunction with specifying a cons cell

View file

@ -1390,7 +1390,7 @@ scroll the window of possible completions."
(t
;; Prefer shorter completions, by default.
(setq all (sort all (lambda (c1 c2) (< (length c1) (length c2)))))
(if (minibufferp)
(if (and (minibufferp) (not (eq minibuffer-history-variable t)))
;; Prefer recently used completions and put the default, if
;; it exists, on top.
(let ((hist (symbol-value minibuffer-history-variable)))

View file

@ -2023,7 +2023,8 @@ HIST, if non-nil, specifies a history list and optionally the initial
(This is the only case in which you should use INITIAL-INPUT instead
of DEF.) Positions are counted starting from 1 at the beginning of
the list. The variable `history-length' controls the maximum length
of a history list.
of a history list. If HIST is the symbol `t', history is not
recorded.
DEF, if non-nil, is the default value or the list of default values.