1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-25 07:28:20 +00:00

* lisp/minibuffer.el (completion-cycling): New var.

(minibuffer-complete, completion--do-completion):
Use completion--flush-all-sorted-completions.
(minibuffer-complete): Only cycle if completion-cycling is set.
(completion--flush-all-sorted-completions): Unset completion-cycling.
(minibuffer-force-complete): Set completion-cycling.
(completion-all-sorted-completions): Move declaration before first use.

Fixes: debbugs:7266
This commit is contained in:
Stefan Monnier 2010-10-27 22:22:29 -04:00
parent 19677c7126
commit 6175cd0824
2 changed files with 42 additions and 30 deletions

View File

@ -1,3 +1,13 @@
2010-10-28 Stefan Monnier <monnier@iro.umontreal.ca>
* minibuffer.el (completion-cycling): New var (bug#7266).
(minibuffer-complete, completion--do-completion):
Use completion--flush-all-sorted-completions.
(minibuffer-complete): Only cycle if completion-cycling is set.
(completion--flush-all-sorted-completions): Unset completion-cycling.
(minibuffer-force-complete): Set completion-cycling.
(completion-all-sorted-completions): Move declaration before first use.
2010-10-28 Leo <sdl.web@gmail.com>
* iswitchb.el (iswitchb-kill-buffer): Avoid `iswitchb-make-buflist'

View File

@ -526,6 +526,10 @@ candidates than this number."
(const :tag "Always cycle" t)
(integer :tag "Threshold")))
(defvar completion-all-sorted-completions nil)
(make-variable-buffer-local 'completion-all-sorted-completions)
(defvar completion-cycling nil)
(defun completion--do-completion (&optional try-completion-function)
"Do the completion and return a summary of what happened.
M = completion was performed, the text was Modified.
@ -558,7 +562,7 @@ E = after completion we now have an Exact match.
((eq t comp)
(minibuffer-hide-completions)
(goto-char (field-end))
(minibuffer--bitset nil nil t)) ;Exact and unique match.
(minibuffer--bitset nil nil t)) ;Exact and unique match.
(t
;; `completed' should be t if some completion was done, which doesn't
;; include simply changing the case of the entered string. However,
@ -578,11 +582,11 @@ E = after completion we now have an Exact match.
(forward-char (- comp-pos (length completion)))
(if (not (or unchanged completed))
;; The case of the string changed, but that's all. We're not sure
;; whether this is a unique completion or not, so try again using
;; the real case (this shouldn't recurse again, because the next
;; time try-completion will return either t or the exact string).
(completion--do-completion try-completion-function)
;; The case of the string changed, but that's all. We're not sure
;; whether this is a unique completion or not, so try again using
;; the real case (this shouldn't recurse again, because the next
;; time try-completion will return either t or the exact string).
(completion--do-completion try-completion-function)
;; It did find a match. Do we match some possibility exactly now?
(let ((exact (test-completion completion
@ -605,35 +609,34 @@ E = after completion we now have an Exact match.
""))
comp-pos)))
(completion-all-sorted-completions))))
(setq completion-all-sorted-completions nil)
(completion--flush-all-sorted-completions)
(cond
((and (not (ignore-errors
((and (consp (cdr comps)) ;; There's something to cycle.
(not (ignore-errors
;; This signal an (intended) error if comps is too
;; short or if completion-cycle-threshold is t.
(consp (nthcdr completion-cycle-threshold comps))))
;; More than 1, so there's something to cycle.
(consp (cdr comps)))
(consp (nthcdr completion-cycle-threshold comps)))))
;; Fewer than completion-cycle-threshold remaining
;; completions: let's cycle.
(setq completed t exact t)
(setq completion-all-sorted-completions comps)
(minibuffer-force-complete))
(completed
;; We could also decide to refresh the completions,
;; if they're displayed (and assuming there are
;; completions left).
;; We could also decide to refresh the completions,
;; if they're displayed (and assuming there are
;; completions left).
(minibuffer-hide-completions))
;; Show the completion table, if requested.
((not exact)
(if (case completion-auto-help
(lazy (eq this-command last-command))
(t completion-auto-help))
(minibuffer-completion-help)
(minibuffer-message "Next char not unique")))
;; If the last exact completion and this one were the same, it
;; means we've already given a "Next char not unique" message
;; and the user's hit TAB again, so now we give him help.
((eq this-command last-command)
;; Show the completion table, if requested.
((not exact)
(if (case completion-auto-help
(lazy (eq this-command last-command))
(t completion-auto-help))
(minibuffer-completion-help)
(minibuffer-message "Next char not unique")))
;; If the last exact completion and this one were the same, it
;; means we've already given a "Next char not unique" message
;; and the user's hit TAB again, so now we give him help.
((eq this-command last-command)
(if completion-auto-help (minibuffer-completion-help))))
(minibuffer--bitset completed t exact))))))))
@ -648,7 +651,7 @@ scroll the window of possible completions."
;; If the previous command was not this,
;; mark the completion buffer obsolete.
(unless (eq this-command last-command)
(setq completion-all-sorted-completions nil)
(completion--flush-all-sorted-completions)
(setq minibuffer-scroll-window nil))
(cond
@ -664,7 +667,7 @@ scroll the window of possible completions."
(scroll-other-window))
nil)))
;; If we're cycling, keep on cycling.
(completion-all-sorted-completions
((and completion-cycling completion-all-sorted-completions)
(minibuffer-force-complete)
t)
(t (case (completion--do-completion)
@ -675,10 +678,8 @@ scroll the window of possible completions."
t)
(t t)))))
(defvar completion-all-sorted-completions nil)
(make-variable-buffer-local 'completion-all-sorted-completions)
(defun completion--flush-all-sorted-completions (&rest ignore)
(setq completion-cycling nil)
(setq completion-all-sorted-completions nil))
(defun completion-all-sorted-completions ()
@ -720,6 +721,7 @@ Repeated uses step through the possible completions."
(all (completion-all-sorted-completions)))
(if (not (consp all))
(minibuffer-message (if all "No more completions" "No completions"))
(setq completion-cycling t)
(goto-char end)
(insert (car all))
(delete-region (+ start (cdr (last all))) end)