[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Select completions from the minibuffer
From: |
Juri Linkov |
Subject: |
Re: Select completions from the minibuffer |
Date: |
Thu, 10 Mar 2022 21:51:46 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) |
>> Here is a non-intrusive patch that doesn't change the default behavior
>> while provides navigation of completions from the minibuffer
>> like web browsers do on their address bar.
>
> [...]
>
>> + "M-<up>" #'minibuffer-completion-previous
>> + "M-<down>" #'minibuffer-completion-next
>> + "M-RET" #'minibuffer-completion-choose)
>
> If I'm reading this patch correctly, then this looks like just what I've
> wanted for decades. 😀
>
> [...]
>
>> + (choose-completion nil t t)))
>
> But this doesn't seem quite correct? The function only takes a single
> parameter... Or is that part of the patch missing?
Oops, it depends on another patch:
diff --git a/lisp/simple.el b/lisp/simple.el
index accc119e2b..65fc2c94a3 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9039,6 +9039,7 @@ completion-list-mode-map
(define-key map [follow-link] 'mouse-face)
(define-key map [down-mouse-2] nil)
(define-key map "\C-m" 'choose-completion)
+ (define-key map [C-return] 'choose-completion-no-auto-exit)
(define-key map "\e\e\e" 'delete-completion-window)
(define-key map [remap keyboard-quit] #'delete-completion-window)
(define-key map [left] 'previous-completion)
@@ -9151,10 +9152,12 @@ next-completion
(when (/= 0 n)
(switch-to-minibuffer))))
-(defun choose-completion (&optional event)
+(defun choose-completion (&optional event no-exit no-quit)
"Choose the completion at point.
-If EVENT, use EVENT's position to determine the starting position."
- (interactive (list last-nonmenu-event))
+If EVENT, use EVENT's position to determine the starting position.
+With the prefix NO-EXIT, insert the completion at point to the minibuffer
+and quit the completion window without exiting the minibuffer."
+ (interactive (list last-nonmenu-event current-prefix-arg))
;; In case this is run via the mouse, give temporary modes such as
;; isearch a chance to turn off.
(run-hooks 'mouse-leave-buffer-hook)
@@ -9162,6 +9165,7 @@ choose-completion
(let ((buffer completion-reference-buffer)
(base-position completion-base-position)
(insert-function completion-list-insert-choice-function)
+ (completion-no-auto-exit (if no-exit t completion-no-auto-exit))
(choice
(save-excursion
(goto-char (posn-point (event-start event)))
@@ -9179,7 +9184,8 @@ choose-completion
(unless (buffer-live-p buffer)
(error "Destination buffer is dead"))
- (quit-window nil (posn-window (event-start event)))
+ (unless no-quit
+ (quit-window nil (posn-window (event-start event))))
(with-current-buffer buffer
(choose-completion-string
@@ -9189,6 +9195,14 @@ choose-completion
(list (choose-completion-guess-base-position choice)))
insert-function)))))
+(defun choose-completion-no-auto-exit (&optional event)
+ "Insert the completion at point to the minibuffer without exiting it.
+Like `choose-completion', it chooses the completion at point,
+inserts it to the minibuffer, but doesn't exit the minibuffer."
+ (interactive (list last-nonmenu-event))
+ (let ((completion-no-auto-exit t))
+ (choose-completion event)))
+
;; Delete the longest partial match for STRING
;; that can be found before POINT.
(defun choose-completion-guess-base-position (string)
- Select completions from the minibuffer, Juri Linkov, 2022/03/10
- Re: Select completions from the minibuffer, Lars Ingebrigtsen, 2022/03/10
- Re: Select completions from the minibuffer,
Juri Linkov <=
- Re: Select completions from the minibuffer, Lars Ingebrigtsen, 2022/03/10
- Re: Select completions from the minibuffer, Juri Linkov, 2022/03/11
- Re: Select completions from the minibuffer, Lars Ingebrigtsen, 2022/03/12
- Re: Select completions from the minibuffer, Juri Linkov, 2022/03/12
- Re: Select completions from the minibuffer, Lars Ingebrigtsen, 2022/03/13
- Re: Select completions from the minibuffer, Juri Linkov, 2022/03/13
- Re: Select completions from the minibuffer, Lars Ingebrigtsen, 2022/03/14
- Re: Select completions from the minibuffer, Juri Linkov, 2022/03/21
- Re: Select completions from the minibuffer, Lars Ingebrigtsen, 2022/03/21
- Re: Select completions from the minibuffer, Juri Linkov, 2022/03/22