mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-11-26 07:33:47 +00:00
Don't show matches with no input for nil icomplete-show-matches-on-no-input
* lisp/icomplete.el (icomplete-show-matches-on-no-input): Fix docstring. (icomplete--initial-input): New internal variable. (icomplete-minibuffer-setup): Set buffer-local icomplete--initial-input to icomplete--field-string. (icomplete-ret, icomplete-force-complete-and-exit) (icomplete--sorted-completions, icomplete-exhibit): Compare icomplete--initial-input with icomplete--field-string to detect no input. (Bug#19031) etc/NEWS: Remove duplicate entry.
This commit is contained in:
parent
755a9f2a8b
commit
dc6e616dfe
10
etc/NEWS
10
etc/NEWS
@ -1553,12 +1553,6 @@ both modes are on).
|
||||
This works like 'report-emacs-bug', but is more geared towards sending
|
||||
patches to the Emacs issue tracker.
|
||||
|
||||
---
|
||||
*** 'icomplete-show-matches-on-no-input' behavior change.
|
||||
Previously, choosing a different completion with commands like 'C-.'
|
||||
and then hitting 'RET' would choose the default completion. Doing
|
||||
this will now choose the completion under point.
|
||||
|
||||
+++
|
||||
*** The user can now customize how "default" values are prompted for.
|
||||
The new utility function 'format-prompt' has been added which uses the
|
||||
@ -1609,7 +1603,9 @@ horizontally and vertically, respectively.
|
||||
*** Change in meaning of 'icomplete-show-matches-on-no-input'.
|
||||
Previously, choosing a different completion with commands like 'C-.'
|
||||
and then hitting 'RET' would choose the default completion. Doing this
|
||||
will now choose the completion under point instead.
|
||||
will now choose the completion under point instead. Also when this option
|
||||
is nil, completions are not shown when the minibuffer reads a file name
|
||||
with initial input as the default directory.
|
||||
|
||||
---
|
||||
*** The width of the buffer-name column in 'list-buffers' is now dynamic.
|
||||
|
@ -75,7 +75,9 @@ everything preceding the ~/ is discarded so the interactive
|
||||
selection process starts again from the user's $HOME.")
|
||||
|
||||
(defcustom icomplete-show-matches-on-no-input nil
|
||||
"When non-nil, show completions when the minibuffer is empty.
|
||||
"When non-nil, show completions when first prompting for input.
|
||||
This means to show completions even when the current minibuffer contents
|
||||
is the same as was the initial input after minibuffer activation.
|
||||
This also means that if you traverse the list of completions with
|
||||
commands like `C-.' and just hit RET without typing any
|
||||
characters, the match under point will be chosen instead of the
|
||||
@ -146,6 +148,10 @@ icompletion is occurring."
|
||||
(defvar icomplete-overlay (make-overlay (point-min) (point-min) nil t t)
|
||||
"Overlay used to display the list of completions.")
|
||||
|
||||
(defvar icomplete--initial-input nil
|
||||
"Initial input in the minibuffer when icomplete-mode was activated.
|
||||
Used to implement the option `icomplete-show-matches-on-no-input'.")
|
||||
|
||||
(defun icomplete-pre-command-hook ()
|
||||
(let ((non-essential t))
|
||||
(icomplete-tidy)))
|
||||
@ -169,7 +175,7 @@ icompletion is occurring."
|
||||
(interactive)
|
||||
(if (and icomplete-show-matches-on-no-input
|
||||
(car completion-all-sorted-completions)
|
||||
(eql (icomplete--field-end) (icomplete--field-beg)))
|
||||
(equal (icomplete--field-string) icomplete--initial-input))
|
||||
(icomplete-force-complete-and-exit)
|
||||
(minibuffer-complete-and-exit)))
|
||||
|
||||
@ -189,7 +195,7 @@ the default otherwise."
|
||||
(if (or
|
||||
;; there's some input, meaning the default in off the table by
|
||||
;; definition; OR
|
||||
(> (icomplete--field-end) (icomplete--field-beg))
|
||||
(not (equal (icomplete--field-string) icomplete--initial-input))
|
||||
;; there's no input, but there's also no minibuffer default
|
||||
;; (and the user really wants to see completions on no input,
|
||||
;; meaning he expects a "force" to be at least attempted); OR
|
||||
@ -441,6 +447,7 @@ Conditions are:
|
||||
"Run in minibuffer on activation to establish incremental completion.
|
||||
Usually run by inclusion in `minibuffer-setup-hook'."
|
||||
(when (and icomplete-mode (icomplete-simple-completing-p))
|
||||
(setq-local icomplete--initial-input (icomplete--field-string))
|
||||
(setq-local completion-show-inline-help nil)
|
||||
(use-local-map (make-composed-keymap icomplete-minibuffer-map
|
||||
(current-local-map)))
|
||||
@ -486,7 +493,7 @@ Usually run by inclusion in `minibuffer-setup-hook'."
|
||||
;; `completing-read' invocations, described below:
|
||||
for fn in (cond ((and minibuffer-default
|
||||
(stringp minibuffer-default) ; bug#38992
|
||||
(= (icomplete--field-end) (icomplete--field-beg)))
|
||||
(equal (icomplete--field-string) icomplete--initial-input))
|
||||
;; Here, we have a non-nil string default and
|
||||
;; no input whatsoever. We want to make sure
|
||||
;; that the default is bubbled to the top so
|
||||
@ -579,7 +586,8 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
|
||||
(goto-char (point-max))
|
||||
; Insert the match-status information:
|
||||
(when (and (or icomplete-show-matches-on-no-input
|
||||
(> (icomplete--field-end) (icomplete--field-beg)))
|
||||
(not (equal (icomplete--field-string)
|
||||
icomplete--initial-input)))
|
||||
(or
|
||||
;; Don't bother with delay after certain number of chars:
|
||||
(> (- (point) (icomplete--field-beg))
|
||||
@ -602,7 +610,7 @@ See `icomplete-mode' and `minibuffer-setup-hook'."
|
||||
(or (>= (- (point) (overlay-end rfn-eshadow-overlay)) 2)
|
||||
(eq ?/ (char-before (- (point) 2)))))
|
||||
(delete-region (overlay-start rfn-eshadow-overlay)
|
||||
(overlay-end rfn-eshadow-overlay)) )
|
||||
(overlay-end rfn-eshadow-overlay)))
|
||||
(let* ((field-string (icomplete--field-string))
|
||||
;; Not sure why, but such requests seem to come
|
||||
;; every once in a while. It's not fully
|
||||
|
Loading…
Reference in New Issue
Block a user