aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-12-29 18:53:25 +0000
committerRichard M. Stallman1994-12-29 18:53:25 +0000
commitdde69dbec88a89e9288aab03909d01c31aae3644 (patch)
tree0b4927ce0303bcdab05a68bfe885ecefc77b3728
parent6cb26914ccbe2c00a0724ed92d27d00d15b6671e (diff)
downloademacs-dde69dbec88a89e9288aab03909d01c31aae3644.tar.gz
emacs-dde69dbec88a89e9288aab03909d01c31aae3644.zip
(switch-to-completions): New command, with bindings in minibuf completion maps.
(next-completion, previous-completion): New commands. (completion-list-mode-map): Put them on left, right arrows. (completion-list-mode-map): Don't bind return, just C-m.
-rw-r--r--lisp/simple.el48
1 files changed, 47 insertions, 1 deletions
diff --git a/lisp/simple.el b/lisp/simple.el
index 125a64a9061..6583d0411ef 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2583,8 +2583,9 @@ it were the arg to `interactive' (which see) to interactively read the value."
2583 (define-key map [mouse-2] 'mouse-choose-completion) 2583 (define-key map [mouse-2] 'mouse-choose-completion)
2584 (define-key map [down-mouse-2] nil) 2584 (define-key map [down-mouse-2] nil)
2585 (define-key map "\C-m" 'choose-completion) 2585 (define-key map "\C-m" 'choose-completion)
2586 (define-key map [return] 'choose-completion)
2587 (define-key map "\e\e\e" 'delete-completion-window) 2586 (define-key map "\e\e\e" 'delete-completion-window)
2587 (define-key map [left] 'previous-completion)
2588 (define-key map [right] 'next-completion)
2588 (setq completion-list-mode-map map))) 2589 (setq completion-list-mode-map map)))
2589 2590
2590;; Completion mode is suitable only for specially formatted data. 2591;; Completion mode is suitable only for specially formatted data.
@@ -2607,6 +2608,34 @@ Go to the window from which completion was requested."
2607 (if (get-buffer-window buf) 2608 (if (get-buffer-window buf)
2608 (select-window (get-buffer-window buf))))) 2609 (select-window (get-buffer-window buf)))))
2609 2610
2611(defun previous-completion (n)
2612 "Move to the previous item in the completion list."
2613 (interactive "p")
2614 (next-completion (- n)))
2615
2616(defun next-completion (n)
2617 "Move to the next item in the completion list.
2618WIth prefix argument N, move N items (negative N means move backward)."
2619 (interactive "p")
2620 (while (and (> n 0) (not (eobp)))
2621 (let ((prop (get-text-property (point) 'mouse-face)))
2622 ;; If in a completion, move to the end of it.
2623 (if prop
2624 (goto-char (next-single-property-change (point) 'mouse-face)))
2625 ;; Move to start of next one.
2626 (goto-char (next-single-property-change (point) 'mouse-face)))
2627 (setq n (1- n)))
2628 (while (and (< n 0) (not (bobp)))
2629 (let ((prop (get-text-property (1- (point)) 'mouse-face)))
2630 ;; If in a completion, move to the start of it.
2631 (if prop
2632 (goto-char (previous-single-property-change (point) 'mouse-face)))
2633 ;; Move to end of the previous completion.
2634 (goto-char (previous-single-property-change (point) 'mouse-face))
2635 ;; Move to the start of that one.
2636 (goto-char (previous-single-property-change (point) 'mouse-face)))
2637 (setq n (1+ n))))
2638
2610(defun choose-completion () 2639(defun choose-completion ()
2611 "Choose the completion that point is in or next to." 2640 "Choose the completion that point is in or next to."
2612 (interactive) 2641 (interactive)
@@ -2715,6 +2744,23 @@ select the completion near point.\n\n"))
2715 (goto-char end)))))) 2744 (goto-char end))))))
2716 2745
2717(add-hook 'completion-setup-hook 'completion-setup-function) 2746(add-hook 'completion-setup-hook 'completion-setup-function)
2747
2748(define-key minibuffer-local-completion-map [prior]
2749 'switch-to-completions)
2750(define-key minibuffer-local-must-match-map [prior]
2751 'switch-to-completions)
2752(define-key minibuffer-local-completion-map "\M-v"
2753 'switch-to-completions)
2754(define-key minibuffer-local-must-match-map "\M-v"
2755 'switch-to-completions)
2756
2757(defun switch-to-completions ()
2758 "Select the completion list window."
2759 (interactive)
2760 (select-window (get-buffer-window "*Completions*"))
2761 (goto-char (point-min))
2762 (search-forward "\n\n")
2763 (forward-line 1))
2718 2764
2719;;;; Keypad support. 2765;;;; Keypad support.
2720 2766