mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-01 11:14:55 +00:00
(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.
This commit is contained in:
parent
6cb26914cc
commit
dde69dbec8
@ -2583,8 +2583,9 @@ it were the arg to `interactive' (which see) to interactively read the value."
|
||||
(define-key map [mouse-2] 'mouse-choose-completion)
|
||||
(define-key map [down-mouse-2] nil)
|
||||
(define-key map "\C-m" 'choose-completion)
|
||||
(define-key map [return] 'choose-completion)
|
||||
(define-key map "\e\e\e" 'delete-completion-window)
|
||||
(define-key map [left] 'previous-completion)
|
||||
(define-key map [right] 'next-completion)
|
||||
(setq completion-list-mode-map map)))
|
||||
|
||||
;; Completion mode is suitable only for specially formatted data.
|
||||
@ -2607,6 +2608,34 @@ Go to the window from which completion was requested."
|
||||
(if (get-buffer-window buf)
|
||||
(select-window (get-buffer-window buf)))))
|
||||
|
||||
(defun previous-completion (n)
|
||||
"Move to the previous item in the completion list."
|
||||
(interactive "p")
|
||||
(next-completion (- n)))
|
||||
|
||||
(defun next-completion (n)
|
||||
"Move to the next item in the completion list.
|
||||
WIth prefix argument N, move N items (negative N means move backward)."
|
||||
(interactive "p")
|
||||
(while (and (> n 0) (not (eobp)))
|
||||
(let ((prop (get-text-property (point) 'mouse-face)))
|
||||
;; If in a completion, move to the end of it.
|
||||
(if prop
|
||||
(goto-char (next-single-property-change (point) 'mouse-face)))
|
||||
;; Move to start of next one.
|
||||
(goto-char (next-single-property-change (point) 'mouse-face)))
|
||||
(setq n (1- n)))
|
||||
(while (and (< n 0) (not (bobp)))
|
||||
(let ((prop (get-text-property (1- (point)) 'mouse-face)))
|
||||
;; If in a completion, move to the start of it.
|
||||
(if prop
|
||||
(goto-char (previous-single-property-change (point) 'mouse-face)))
|
||||
;; Move to end of the previous completion.
|
||||
(goto-char (previous-single-property-change (point) 'mouse-face))
|
||||
;; Move to the start of that one.
|
||||
(goto-char (previous-single-property-change (point) 'mouse-face)))
|
||||
(setq n (1+ n))))
|
||||
|
||||
(defun choose-completion ()
|
||||
"Choose the completion that point is in or next to."
|
||||
(interactive)
|
||||
@ -2715,6 +2744,23 @@ select the completion near point.\n\n"))
|
||||
(goto-char end))))))
|
||||
|
||||
(add-hook 'completion-setup-hook 'completion-setup-function)
|
||||
|
||||
(define-key minibuffer-local-completion-map [prior]
|
||||
'switch-to-completions)
|
||||
(define-key minibuffer-local-must-match-map [prior]
|
||||
'switch-to-completions)
|
||||
(define-key minibuffer-local-completion-map "\M-v"
|
||||
'switch-to-completions)
|
||||
(define-key minibuffer-local-must-match-map "\M-v"
|
||||
'switch-to-completions)
|
||||
|
||||
(defun switch-to-completions ()
|
||||
"Select the completion list window."
|
||||
(interactive)
|
||||
(select-window (get-buffer-window "*Completions*"))
|
||||
(goto-char (point-min))
|
||||
(search-forward "\n\n")
|
||||
(forward-line 1))
|
||||
|
||||
;;;; Keypad support.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user