diff options
author | Richard M. Stallman <rms@gnu.org> | 2002-01-12 06:59:02 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2002-01-12 06:59:02 +0000 |
commit | 40e0410be9beac0360a0a6ae7f9391779268b734 (patch) | |
tree | 25ade68d55823c2ba64e0e939dbe13da7bc18401 /lisp/comint.el | |
parent | 306da12ebe2bb259894e704df7c28055b2648bed (diff) | |
download | emacs-40e0410be9beac0360a0a6ae7f9391779268b734.tar.gz |
(comint-dynamic-list-completions): Repeating the command
after displaying a completion list scrolls the list.
Diffstat (limited to 'lisp/comint.el')
-rw-r--r-- | lisp/comint.el | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/lisp/comint.el b/lisp/comint.el index e6f0fade801..e289166fe94 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -2795,27 +2795,41 @@ See also `comint-dynamic-complete-filename'." (defun comint-dynamic-list-completions (completions) "List in help buffer sorted COMPLETIONS. Typing SPC flushes the help buffer." - (let ((conf (current-window-configuration))) - (with-output-to-temp-buffer "*Completions*" - (display-completion-list (sort completions 'string-lessp))) - (message "Hit space to flush") - (let (key first) - (if (save-excursion - (set-buffer (get-buffer "*Completions*")) - (setq key (read-key-sequence nil) - first (aref key 0)) - (and (consp first) (consp (event-start first)) - (eq (window-buffer (posn-window (event-start first))) - (get-buffer "*Completions*")) - (eq (key-binding key) 'mouse-choose-completion))) - ;; If the user does mouse-choose-completion with the mouse, - ;; execute the command, then delete the completion window. - (progn - (mouse-choose-completion first) - (set-window-configuration conf)) - (if (eq first ?\ ) - (set-window-configuration conf) - (setq unread-command-events (listify-key-sequence key))))))) + (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))) + ;; If this command was repeated, and + ;; there's a fresh completion window with a live buffer, + ;; and this command is repeated, scroll that window. + (with-current-buffer (window-buffer window) + (if (pos-visible-in-window-p (point-max) window) + (set-window-start window (point-min)) + (save-selected-window + (select-window window) + (scroll-up)))) + + (let ((conf (current-window-configuration))) + (with-output-to-temp-buffer "*Completions*" + (display-completion-list (sort completions 'string-lessp))) + (message "Type space to flush; repeat completion command to scroll") + (let (key first) + (if (save-excursion + (set-buffer (get-buffer "*Completions*")) + (setq key (read-key-sequence nil) + first (aref key 0)) + (and (consp first) (consp (event-start first)) + (eq (window-buffer (posn-window (event-start first))) + (get-buffer "*Completions*")) + (eq (key-binding key) 'mouse-choose-completion))) + ;; If the user does mouse-choose-completion with the mouse, + ;; execute the command, then delete the completion window. + (progn + (mouse-choose-completion first) + (set-window-configuration conf)) + (if (eq first ?\ ) + (set-window-configuration conf) + (setq unread-command-events (listify-key-sequence key))))))))) (defun comint-get-next-from-history () |