]> git.eshelyaron.com Git - emacs.git/commitdiff
(comint-displayed-dynamic-completions): New variable.
authorMiles Bader <miles@gnu.org>
Thu, 4 Jul 2002 06:44:45 +0000 (06:44 +0000)
committerMiles Bader <miles@gnu.org>
Thu, 4 Jul 2002 06:44:45 +0000 (06:44 +0000)
(comint-dynamic-list-completions): Be more careful about choosing
when to scroll an existing completions window.

lisp/ChangeLog
lisp/comint.el

index 28847f723be1540a20a62c7e73703ea6e1eb9282..b47761de024856d68370843a20394f851ce41dc5 100644 (file)
@@ -1,3 +1,9 @@
+2002-07-04  Miles Bader  <miles@gnu.org>
+
+       * comint.el (comint-displayed-dynamic-completions): New variable.
+       (comint-dynamic-list-completions): Be more careful about choosing
+       when to scroll an existing completions window.
+
 2002-07-03  Andreas Schwab  <schwab@suse.de>
 
        * net/tramp.el (tramp-handle-ange-ftp): Move interactive spec
index bdbe2fdb709aa34bca435df6716ec9416827756a..3c0be25c1996dccb5201fb1716866538e4b1c126 100644 (file)
@@ -2798,13 +2798,29 @@ See also `comint-dynamic-complete-filename'."
        (mapcar 'comint-quote-filename completions)))))
 
 
+;; This is bound locally in a *Completions* buffer to the list of
+;; completions displayed, and is used to detect the case where the same
+;; command is repeatedly used without the set of completions changing.
+(defvar comint-displayed-dynamic-completions nil)
+
 (defun comint-dynamic-list-completions (completions)
   "List in help buffer sorted COMPLETIONS.
 Typing SPC flushes the help buffer."
   (let ((window (get-buffer-window "*Completions*")))
     (if (and (eq last-command this-command)
             window (window-live-p window) (window-buffer window)
-            (buffer-name (window-buffer window)))
+            (buffer-name (window-buffer window))
+            ;; The above tests are not sufficient to detect the case where we
+            ;; should scroll, because the top-level interactive command may
+            ;; not have displayed a completions window the last time it was
+            ;; invoked, and there may be such a window left over from a
+            ;; previous completion command with a different set of
+            ;; completions.  To detect that case, we also test that the set
+            ;; of displayed completions is in fact the same as the previously
+            ;; displayed set.
+            (equal completions
+                   (buffer-local-value 'comint-displayed-dynamic-completions
+                                       (window-buffer window))))
        ;; If this command was repeated, and
        ;; there's a fresh completion window with a live buffer,
        ;; and this command is repeated, scroll that window.
@@ -2822,6 +2838,9 @@ Typing SPC flushes the help buffer."
        (let (key first)
          (if (save-excursion
                (set-buffer (get-buffer "*Completions*"))
+               (set (make-local-variable
+                     'comint-displayed-dynamic-completions)
+                    completions)
                (setq key (read-key-sequence nil)
                      first (aref key 0))
                (and (consp first) (consp (event-start first))