New commands previous-line-completion and next-line-completion (bug#59486)
* lisp/simple.el (completion-list-mode-map): Bind [up] to 'previous-line-completion', and [down] to 'next-line-completion'. (completion-auto-wrap): Mention `next-line-completion' and `previous-line-completion' in the docstring. (previous-line-completion, next-line-completion): New commands.
This commit is contained in:
parent
a3fcc4ed0f
commit
21b387c39b
2 changed files with 77 additions and 5 deletions
7
etc/NEWS
7
etc/NEWS
|
@ -1757,9 +1757,10 @@ the second one will switch to the "*Completions*" buffer.
|
||||||
|
|
||||||
---
|
---
|
||||||
*** New user option 'completion-auto-wrap'.
|
*** New user option 'completion-auto-wrap'.
|
||||||
When non-nil, the commands 'next-completion' and 'previous-completion'
|
When non-nil, the commands 'next-completion', 'previous-completion',
|
||||||
automatically wrap around on reaching the beginning or the end of
|
'next-line-completion' and 'previous-line-completion' automatically
|
||||||
the "*Completions*" buffer.
|
wrap around on reaching the beginning or the end of the "*Completions*"
|
||||||
|
buffer.
|
||||||
|
|
||||||
+++
|
+++
|
||||||
*** New values for the 'completion-auto-help' user option.
|
*** New values for the 'completion-auto-help' user option.
|
||||||
|
|
|
@ -9572,6 +9572,8 @@ makes it easier to edit it."
|
||||||
(define-key map "\C-m" 'choose-completion)
|
(define-key map "\C-m" 'choose-completion)
|
||||||
(define-key map "\e\e\e" 'delete-completion-window)
|
(define-key map "\e\e\e" 'delete-completion-window)
|
||||||
(define-key map [remap keyboard-quit] #'delete-completion-window)
|
(define-key map [remap keyboard-quit] #'delete-completion-window)
|
||||||
|
(define-key map [up] 'previous-line-completion)
|
||||||
|
(define-key map [down] 'next-line-completion)
|
||||||
(define-key map [left] 'previous-completion)
|
(define-key map [left] 'previous-completion)
|
||||||
(define-key map [right] 'next-completion)
|
(define-key map [right] 'next-completion)
|
||||||
(define-key map [?\t] 'next-completion)
|
(define-key map [?\t] 'next-completion)
|
||||||
|
@ -9631,8 +9633,10 @@ Go to the window from which completion was requested."
|
||||||
|
|
||||||
(defcustom completion-auto-wrap t
|
(defcustom completion-auto-wrap t
|
||||||
"Non-nil means to wrap around when selecting completion options.
|
"Non-nil means to wrap around when selecting completion options.
|
||||||
This affects the commands `next-completion' and `previous-completion'.
|
This affects the commands `next-completion', `previous-completion',
|
||||||
When `completion-auto-select' is t, it wraps through the minibuffer."
|
`next-line-completion' and `previous-line-completion'.
|
||||||
|
When `completion-auto-select' is t, it wraps through the minibuffer
|
||||||
|
for the commands bound to the TAB key."
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:version "29.1"
|
:version "29.1"
|
||||||
:group 'completion)
|
:group 'completion)
|
||||||
|
@ -9736,6 +9740,73 @@ Also see the `completion-auto-wrap' variable."
|
||||||
(when (/= 0 n)
|
(when (/= 0 n)
|
||||||
(switch-to-minibuffer))))
|
(switch-to-minibuffer))))
|
||||||
|
|
||||||
|
(defun previous-line-completion (&optional n)
|
||||||
|
"Move to the item on the previous line in the completion list.
|
||||||
|
With prefix argument N, move back N items line-wise (negative N
|
||||||
|
means move forward).
|
||||||
|
|
||||||
|
Also see the `completion-auto-wrap' variable."
|
||||||
|
(interactive "p")
|
||||||
|
(next-line-completion (- n)))
|
||||||
|
|
||||||
|
(defun next-line-completion (&optional n)
|
||||||
|
"Move to the item on the next line in the completion list.
|
||||||
|
With prefix argument N, move N items line-wise (negative N
|
||||||
|
means move backward).
|
||||||
|
|
||||||
|
Also see the `completion-auto-wrap' variable."
|
||||||
|
(interactive "p")
|
||||||
|
(let ((column (current-column))
|
||||||
|
pos)
|
||||||
|
(catch 'bound
|
||||||
|
(while (> n 0)
|
||||||
|
(setq pos nil)
|
||||||
|
(save-excursion
|
||||||
|
(while (and (not pos) (not (eobp)))
|
||||||
|
(forward-line 1)
|
||||||
|
(when (and (not (eobp))
|
||||||
|
(eq (move-to-column column) column)
|
||||||
|
(get-text-property (point) 'mouse-face))
|
||||||
|
(setq pos (point)))))
|
||||||
|
(if pos (goto-char pos)
|
||||||
|
(when completion-auto-wrap
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-min))
|
||||||
|
(when (and (eq (move-to-column column) column)
|
||||||
|
(get-text-property (point) 'mouse-face))
|
||||||
|
(setq pos (point)))
|
||||||
|
(while (and (not pos) (not (eobp)))
|
||||||
|
(forward-line 1)
|
||||||
|
(when (and (eq (move-to-column column) column)
|
||||||
|
(get-text-property (point) 'mouse-face))
|
||||||
|
(setq pos (point)))))
|
||||||
|
(if pos (goto-char pos))))
|
||||||
|
(setq n (1- n)))
|
||||||
|
|
||||||
|
(while (< n 0)
|
||||||
|
(setq pos nil)
|
||||||
|
(save-excursion
|
||||||
|
(while (and (not pos) (not (bobp)))
|
||||||
|
(forward-line -1)
|
||||||
|
(when (and (not (bobp))
|
||||||
|
(eq (move-to-column column) column)
|
||||||
|
(get-text-property (point) 'mouse-face))
|
||||||
|
(setq pos (point)))))
|
||||||
|
(if pos (goto-char pos)
|
||||||
|
(when completion-auto-wrap
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (point-max))
|
||||||
|
(when (and (eq (move-to-column column) column)
|
||||||
|
(get-text-property (point) 'mouse-face))
|
||||||
|
(setq pos (point)))
|
||||||
|
(while (and (not pos) (not (bobp)))
|
||||||
|
(forward-line -1)
|
||||||
|
(when (and (eq (move-to-column column) column)
|
||||||
|
(get-text-property (point) 'mouse-face))
|
||||||
|
(setq pos (point)))))
|
||||||
|
(if pos (goto-char pos))))
|
||||||
|
(setq n (1+ n))))))
|
||||||
|
|
||||||
(defun choose-completion (&optional event no-exit no-quit)
|
(defun choose-completion (&optional event no-exit no-quit)
|
||||||
"Choose the completion at point.
|
"Choose the completion at point.
|
||||||
If EVENT, use EVENT's position to determine the starting position.
|
If EVENT, use EVENT's position to determine the starting position.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue