unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Select completions from the minibuffer
@ 2022-03-10 18:58 Juri Linkov
  2022-03-10 19:32 ` Lars Ingebrigtsen
  2022-03-10 19:58 ` Eli Zaretskii
  0 siblings, 2 replies; 92+ messages in thread
From: Juri Linkov @ 2022-03-10 18:58 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 176 bytes --]

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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: minibuffer-completion-next-previous.patch --]
[-- Type: text/x-diff, Size: 2313 bytes --]

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 36b8d80841..e92bb0f885 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -2681,7 +2766,10 @@ minibuffer-local-completion-map
   "?"         #'minibuffer-completion-help
   "<prior>"   #'switch-to-completions
   "M-v"       #'switch-to-completions
-  "M-g M-c"   #'switch-to-completions)
+  "M-g M-c"   #'switch-to-completions
+  "M-<up>"    #'minibuffer-completion-previous
+  "M-<down>"  #'minibuffer-completion-next
+  "M-RET"     #'minibuffer-completion-choose)
 
 (defvar-keymap minibuffer-local-must-match-map
   :doc "Local keymap for minibuffer input with completion, for exact match."
@@ -4271,6 +4359,39 @@ minibuffer-scroll-other-window-down
   (with-minibuffer-selected-window
     (scroll-other-window-down arg)))
 
+(defmacro with-minibuffer-scroll-window (&rest body)
+  "Execute the forms in BODY from the minibuffer in its scrolling window.
+When used in a minibuffer window, select the window where scrolling command
+should scroll, and execute the forms."
+  (declare (indent 0) (debug t))
+  `(let ((window (or (get-buffer-window "*Completions*" 0) ; remove?
+		     ;; Make sure we have a completions window.
+                     (progn (minibuffer-completion-help)
+                            (get-buffer-window "*Completions*" 0)))))
+     (when window
+       (with-selected-window window
+         ,@body))))
+
+(defun minibuffer-completion-previous (&optional arg)
+  "Run `previous-completion' from the minibuffer in its scrolling window."
+  (interactive "P")
+  (with-minibuffer-scroll-window
+    (previous-completion (or arg 1))
+    (choose-completion nil t t)))
+
+(defun minibuffer-completion-next (&optional arg)
+  "Run `next-completion' from the minibuffer in its scrolling window."
+  (interactive "P")
+  (with-minibuffer-scroll-window
+    (next-completion (or arg 1))
+    (choose-completion nil t t)))
+
+(defun minibuffer-completion-choose (&optional arg)
+  "Run `choose-completion' from the minibuffer in its scrolling window."
+  (interactive "P")
+  (with-minibuffer-scroll-window
+    (choose-completion nil arg)))
+
 (defcustom minibuffer-default-prompt-format " (default %s)"
   "Format string used to output \"default\" values.
 When prompting for input, there will often be a default value,

^ permalink raw reply related	[flat|nested] 92+ messages in thread

end of thread, other threads:[~2022-03-24  9:07 UTC | newest]

Thread overview: 92+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-10 18:58 Select completions from the minibuffer Juri Linkov
2022-03-10 19:32 ` Lars Ingebrigtsen
2022-03-10 19:51   ` Juri Linkov
2022-03-10 20:32     ` Lars Ingebrigtsen
2022-03-11  8:58       ` Juri Linkov
2022-03-12 17:08         ` Lars Ingebrigtsen
2022-03-12 18:55           ` Juri Linkov
2022-03-13 14:05             ` Lars Ingebrigtsen
2022-03-13 18:05               ` Juri Linkov
2022-03-14  9:13                 ` Lars Ingebrigtsen
2022-03-21 19:28                   ` Juri Linkov
2022-03-21 19:30                     ` Lars Ingebrigtsen
2022-03-22  8:24                       ` Juri Linkov
2022-03-22 13:38                         ` Eli Zaretskii
2022-03-22 13:44                           ` Eric S Fraga
2022-03-22 14:18                           ` Ergus
2022-03-22 14:49                             ` Eli Zaretskii
2022-03-22 15:21                               ` Ergus
2022-03-22 18:38                                 ` Juri Linkov
2022-03-22 19:07                                   ` Ergus
2022-03-22 19:24                                   ` Ergus
2022-03-23  8:47                                     ` Juri Linkov
2022-03-23 12:07                                       ` Ergus
2022-03-23 18:28                                         ` Juri Linkov
2022-03-24  9:07                                           ` Ergus
2022-03-22 15:46                               ` Ergus
2022-03-22 16:59                                 ` Eli Zaretskii
2022-03-22 17:10                                   ` Ergus
2022-03-22 17:58                               ` Eli Zaretskii
2022-03-22 17:56                             ` Juri Linkov
2022-03-22 17:23                         ` Ergus
2022-03-22 17:52                           ` Juri Linkov
2022-03-22 18:31                           ` Juri Linkov
2022-03-14  8:41               ` Juri Linkov
2022-03-14  9:08                 ` Ergus
2022-03-14 18:19                   ` Juri Linkov
2022-03-14 19:46                     ` Ergus
2022-03-14 20:58                       ` Stefan Monnier
2022-03-14 22:28                         ` Ergus
2022-03-14 22:34                           ` Stefan Monnier
2022-03-15 15:22                           ` Stefan Monnier
2022-03-14 19:34                   ` Juri Linkov
2022-03-17 18:01                     ` Ergus
2022-03-17 18:47                     ` Ergus
2022-03-17 20:56                       ` Juri Linkov
2022-03-17 21:26                         ` Stefan Monnier
2022-03-17 21:33                           ` Ergus
2022-03-17 22:44                             ` Stefan Monnier
2022-03-17 22:44                         ` Ergus
2022-03-18  6:25                           ` Eli Zaretskii
2022-03-17 23:10                         ` Ergus
2022-03-18  6:28                           ` Eli Zaretskii
2022-03-18 11:16                             ` Ergus
2022-03-18 11:33                               ` Eli Zaretskii
2022-03-18 12:04                             ` Stefan Monnier
2022-03-18 12:11                               ` Eli Zaretskii
2022-03-18 12:23                                 ` Ergus
2022-03-18 12:35                                   ` Stefan Monnier
2022-03-18 12:38                                     ` Ergus
2022-03-18 12:57                                       ` Eli Zaretskii
2022-03-18  9:27                           ` Juri Linkov
2022-03-18 11:26                             ` Eli Zaretskii
2022-03-18 11:53                             ` Ergus
2022-03-18 12:06                               ` Eli Zaretskii
2022-03-18 21:31                             ` Ergus
2022-03-19 19:03                               ` Juri Linkov
2022-03-19 20:43                                 ` Ergus
2022-03-19 20:46                                 ` Ergus
2022-03-20 18:42                                   ` Juri Linkov
2022-03-20 22:00                                     ` Ergus
2022-03-21  8:32                                       ` Juri Linkov
2022-03-18 12:08                           ` Stefan Monnier
2022-03-18 12:13                             ` Eli Zaretskii
2022-03-12  0:14       ` Ergus
2022-03-12 17:04         ` Lars Ingebrigtsen
2022-03-12 17:29           ` Eli Zaretskii
2022-03-12 17:37             ` Ergus
2022-03-12 18:14               ` Eli Zaretskii
2022-03-12 19:30                 ` Ergus
2022-03-12 19:39                   ` Eli Zaretskii
2022-03-13 18:55                     ` Ergus
2022-03-13 17:47                   ` Juri Linkov
2022-03-13 18:52                     ` Ergus
2022-03-12 19:11         ` [External] : " Drew Adams
2022-03-10 19:55   ` Drew Adams
2022-03-10 19:59     ` Juri Linkov
2022-03-10 23:13       ` Drew Adams
2022-03-10 19:58 ` Eli Zaretskii
2022-03-10 20:23   ` Lars Ingebrigtsen
2022-03-10 20:38     ` Eli Zaretskii
2022-03-12 18:52       ` Juri Linkov
2022-03-12 19:16         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).