emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r102133: * lisp/minibuffer.el (comple


From: Stefan Monnier
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r102133: * lisp/minibuffer.el (completion-cycling): New var.
Date: Wed, 27 Oct 2010 22:22:29 -0400
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 102133
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Wed 2010-10-27 22:22:29 -0400
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/minibuffer.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-10-28 01:30:01 +0000
+++ b/lisp/ChangeLog    2010-10-28 02:22:29 +0000
@@ -1,3 +1,13 @@
+2010-10-28  Stefan Monnier  <address@hidden>
+
+       * 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  <address@hidden>
 
        * iswitchb.el (iswitchb-kill-buffer): Avoid `iswitchb-make-buflist'

=== modified file 'lisp/minibuffer.el'
--- a/lisp/minibuffer.el        2010-10-19 11:44:07 +0000
+++ b/lisp/minibuffer.el        2010-10-28 02:22:29 +0000
@@ -526,6 +526,10 @@
           (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 @@
      ((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 @@
        (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 @@
                                          ""))
                                    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 @@
   ;; 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-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 @@
                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 @@
          (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)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]