2795 |
(defun comint-dynamic-list-completions (completions) |
(defun comint-dynamic-list-completions (completions) |
2796 |
"List in help buffer sorted COMPLETIONS. |
"List in help buffer sorted COMPLETIONS. |
2797 |
Typing SPC flushes the help buffer." |
Typing SPC flushes the help buffer." |
2798 |
(let ((conf (current-window-configuration))) |
(let ((window (get-buffer-window "*Completions*"))) |
2799 |
(with-output-to-temp-buffer "*Completions*" |
(if (and (eq last-command this-command) |
2800 |
(display-completion-list (sort completions 'string-lessp))) |
window (window-live-p window) (window-buffer window) |
2801 |
(message "Hit space to flush") |
(buffer-name (window-buffer window))) |
2802 |
(let (key first) |
;; If this command was repeated, and |
2803 |
(if (save-excursion |
;; there's a fresh completion window with a live buffer, |
2804 |
(set-buffer (get-buffer "*Completions*")) |
;; and this command is repeated, scroll that window. |
2805 |
(setq key (read-key-sequence nil) |
(with-current-buffer (window-buffer window) |
2806 |
first (aref key 0)) |
(if (pos-visible-in-window-p (point-max) window) |
2807 |
(and (consp first) (consp (event-start first)) |
(set-window-start window (point-min)) |
2808 |
(eq (window-buffer (posn-window (event-start first))) |
(save-selected-window |
2809 |
(get-buffer "*Completions*")) |
(select-window window) |
2810 |
(eq (key-binding key) 'mouse-choose-completion))) |
(scroll-up)))) |
2811 |
;; If the user does mouse-choose-completion with the mouse, |
|
2812 |
;; execute the command, then delete the completion window. |
(let ((conf (current-window-configuration))) |
2813 |
(progn |
(with-output-to-temp-buffer "*Completions*" |
2814 |
(mouse-choose-completion first) |
(display-completion-list (sort completions 'string-lessp))) |
2815 |
(set-window-configuration conf)) |
(message "Type space to flush; repeat completion command to scroll") |
2816 |
(if (eq first ?\ ) |
(let (key first) |
2817 |
(set-window-configuration conf) |
(if (save-excursion |
2818 |
(setq unread-command-events (listify-key-sequence key))))))) |
(set-buffer (get-buffer "*Completions*")) |
2819 |
|
(setq key (read-key-sequence nil) |
2820 |
|
first (aref key 0)) |
2821 |
|
(and (consp first) (consp (event-start first)) |
2822 |
|
(eq (window-buffer (posn-window (event-start first))) |
2823 |
|
(get-buffer "*Completions*")) |
2824 |
|
(eq (key-binding key) 'mouse-choose-completion))) |
2825 |
|
;; If the user does mouse-choose-completion with the mouse, |
2826 |
|
;; execute the command, then delete the completion window. |
2827 |
|
(progn |
2828 |
|
(mouse-choose-completion first) |
2829 |
|
(set-window-configuration conf)) |
2830 |
|
(if (eq first ?\ ) |
2831 |
|
(set-window-configuration conf) |
2832 |
|
(setq unread-command-events (listify-key-sequence key))))))))) |
2833 |
|
|
2834 |
|
|
2835 |
(defun comint-get-next-from-history () |
(defun comint-get-next-from-history () |