2798 |
(mapcar 'comint-quote-filename completions))))) |
(mapcar 'comint-quote-filename completions))))) |
2799 |
|
|
2800 |
|
|
2801 |
|
;; This is bound locally in a *Completions* buffer to the list of |
2802 |
|
;; completions displayed, and is used to detect the case where the same |
2803 |
|
;; command is repeatedly used without the set of completions changing. |
2804 |
|
(defvar comint-displayed-dynamic-completions nil) |
2805 |
|
|
2806 |
(defun comint-dynamic-list-completions (completions) |
(defun comint-dynamic-list-completions (completions) |
2807 |
"List in help buffer sorted COMPLETIONS. |
"List in help buffer sorted COMPLETIONS. |
2808 |
Typing SPC flushes the help buffer." |
Typing SPC flushes the help buffer." |
2809 |
(let ((window (get-buffer-window "*Completions*"))) |
(let ((window (get-buffer-window "*Completions*"))) |
2810 |
(if (and (eq last-command this-command) |
(if (and (eq last-command this-command) |
2811 |
window (window-live-p window) (window-buffer window) |
window (window-live-p window) (window-buffer window) |
2812 |
(buffer-name (window-buffer window))) |
(buffer-name (window-buffer window)) |
2813 |
|
;; The above tests are not sufficient to detect the case where we |
2814 |
|
;; should scroll, because the top-level interactive command may |
2815 |
|
;; not have displayed a completions window the last time it was |
2816 |
|
;; invoked, and there may be such a window left over from a |
2817 |
|
;; previous completion command with a different set of |
2818 |
|
;; completions. To detect that case, we also test that the set |
2819 |
|
;; of displayed completions is in fact the same as the previously |
2820 |
|
;; displayed set. |
2821 |
|
(equal completions |
2822 |
|
(buffer-local-value 'comint-displayed-dynamic-completions |
2823 |
|
(window-buffer window)))) |
2824 |
;; If this command was repeated, and |
;; If this command was repeated, and |
2825 |
;; there's a fresh completion window with a live buffer, |
;; there's a fresh completion window with a live buffer, |
2826 |
;; and this command is repeated, scroll that window. |
;; and this command is repeated, scroll that window. |
2838 |
(let (key first) |
(let (key first) |
2839 |
(if (save-excursion |
(if (save-excursion |
2840 |
(set-buffer (get-buffer "*Completions*")) |
(set-buffer (get-buffer "*Completions*")) |
2841 |
|
(set (make-local-variable |
2842 |
|
'comint-displayed-dynamic-completions) |
2843 |
|
completions) |
2844 |
(setq key (read-key-sequence nil) |
(setq key (read-key-sequence nil) |
2845 |
first (aref key 0)) |
first (aref key 0)) |
2846 |
(and (consp first) (consp (event-start first)) |
(and (consp first) (consp (event-start first)) |