unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Ergus <spacibba@aol.com>
To: Juri Linkov <juri@linkov.net>
Cc: Eli Zaretskii <eliz@gnu.org>, larsi@gnus.org, emacs-devel@gnu.org
Subject: Re: Select completions from the minibuffer
Date: Tue, 22 Mar 2022 20:24:14 +0100	[thread overview]
Message-ID: <20220322192414.imcbntimg7d35cdn@Ergus> (raw)
In-Reply-To: <864k3p6cxe.fsf@mail.linkov.net>

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

On Tue, Mar 22, 2022 at 08:38:45PM +0200, Juri Linkov wrote:
>> First tab: attempts to complete common and shows completions
>> Second tab: go to completions and select first candidate.
>> Following tabs: move to next candidate
>
>This is exactly what happens when completion-auto-select is t.
>

Look at the attached patch that produces this behavior... I am
not sure is we want to add it, but it is useful in my case to mix

completion-auto-help 'always/'visible
completion-auto-select 'second-tab

If you think this is useful I may add it to a branch and add some
documentation.

Best,
Ergus

[-- Attachment #2: second-tab.patch --]
[-- Type: text/plain, Size: 3484 bytes --]

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 00d4560865..f38db6d278 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1407,18 +1407,26 @@ completion--in-region-1
    ;; and this command is repeated, scroll that window.
    ((and (window-live-p minibuffer-scroll-window)
          (eq t (frame-visible-p (window-frame minibuffer-scroll-window))))
-    (let ((window minibuffer-scroll-window)
-          (reverse (equal (this-command-keys) [backtab])))
+    (let ((window minibuffer-scroll-window))
       (with-current-buffer (window-buffer window)
-        (if (pos-visible-in-window-p (if reverse (point-min) (point-max)) window)
-            ;; If end or beginning is in view, scroll up to the
-            ;; beginning or end respectively.
-            (if reverse
-                (set-window-point window (point-max))
-              (set-window-start window (point-min) nil))
-          ;; Else scroll down one screen.
-          (with-selected-window window
-            (if reverse (scroll-down) (scroll-up))))
+        (cond
+         ;; here this is possible only when second-tab, so jump now.
+         (completion-auto-select
+          (switch-to-completions))
+         ;; reverse tab
+         ((equal (this-command-keys) [backtab])
+          (if (pos-visible-in-window-p (point-min) window)
+              ;; If beginning is in view, scroll up to the end
+              (set-window-point window (point-max))
+            ;; Else scroll down one screen.
+            (with-selected-window window (scroll-down))))
+         ;; normal tab
+         (t
+          (if (pos-visible-in-window-p (point-max) window)
+              ;; If end is in view, scroll up to the end
+              (set-window-start window (point-min) nil)
+            ;; Else scroll down one screen.
+            (with-selected-window window (scroll-up)))))
         nil)))
    ;; If we're cycling, keep on cycling.
    ((and completion-cycling completion-all-sorted-completions)
diff --git a/lisp/simple.el b/lisp/simple.el
index 9a8ed0bb75..f229608690 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9144,6 +9144,14 @@ completion-wrap-movement
   :version "29.1"
   :group 'completion)
 
+(defcustom completion-auto-select nil
+  "Non-nil means to automatically select the *Completions* buffer."
+  :type '(choice (const :tag "Select window" t)
+                 (const :tag "Disabled" nil)
+                 (const :tag "Select window on second-tab" second-tab))
+  :version "29.1"
+  :group 'completion)
+
 (defun previous-completion (n)
   "Move to the previous item in the completion list.
 With prefix argument N, move back N items (negative N means move
@@ -9365,12 +9373,6 @@ completion-show-help
   :version "22.1"
   :group 'completion)
 
-(defcustom completion-auto-select nil
-  "Non-nil means to automatically select the *Completions* buffer."
-  :type 'boolean
-  :version "29.1"
-  :group 'completion)
-
 ;; This function goes in completion-setup-hook, so that it is called
 ;; after the text of the completion list buffer is written.
 (defun completion-setup-function ()
@@ -9411,8 +9413,8 @@ completion-setup-function
 	(insert (substitute-command-keys
 		 "In this buffer, type \\[choose-completion] to \
 select the completion near point.\n\n")))))
-  (when completion-auto-select
-    (switch-to-completions)))
+  (if (eq completion-auto-select t)
+      (switch-to-completions)))
 
 (add-hook 'completion-setup-hook #'completion-setup-function)
 

  parent reply	other threads:[~2022-03-22 19:24 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220322192414.imcbntimg7d35cdn@Ergus \
    --to=spacibba@aol.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=juri@linkov.net \
    --cc=larsi@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).