summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2010-10-27 22:22:29 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2010-10-27 22:22:29 -0400
commit6175cd08242e41213592e4736b3c974bcc1a865d (patch)
tree6830fd09c712496e86aa281468dc408754df9b46
parent19677c71262113e3993b545259aeb2fc3c397fb7 (diff)
downloademacs-6175cd08242e41213592e4736b3c974bcc1a865d.tar.gz
emacs-6175cd08242e41213592e4736b3c974bcc1a865d.tar.bz2
emacs-6175cd08242e41213592e4736b3c974bcc1a865d.zip
* 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
-rw-r--r--lisp/ChangeLog10
-rw-r--r--lisp/minibuffer.el62
2 files changed, 42 insertions, 30 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 758d75bb688..0a8870dbf4f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -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'
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index ee1fcae3119..2612dfd672c 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -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)