emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 410675ce0e 3/3: Merge 'completion-auto-select new value secont-ta


From: Jimmy Aguilar Mena
Subject: master 410675ce0e 3/3: Merge 'completion-auto-select new value secont-tab'
Date: Thu, 24 Mar 2022 06:26:39 -0400 (EDT)

branch: master
commit 410675ce0e926dbf5a9f92a0d3de7eb2741daca7
Merge: 288ecdf90c acde5252d3
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>

    Merge 'completion-auto-select new value secont-tab'
    
    This includes the second-tab value for completion-auto-select and
    documentation related.
---
 doc/emacs/mini.texi |  8 ++++++++
 etc/NEWS            |  6 ++++--
 lisp/minibuffer.el  | 30 +++++++++++++++++++-----------
 lisp/simple.el      | 18 ++++++++++--------
 4 files changed, 41 insertions(+), 21 deletions(-)

diff --git a/doc/emacs/mini.texi b/doc/emacs/mini.texi
index ff0fa505a8..181cade80b 100644
--- a/doc/emacs/mini.texi
+++ b/doc/emacs/mini.texi
@@ -642,6 +642,14 @@ the completion.  The value @code{visible} is a hybrid: it 
behaves like
 completion list buffer, and like @code{always} when it decides whether
 to pop it down.
 
+@vindex completion-auto-select
+The completions window can be automatically selected.  To enable this
+behavior, customize the user option @code{completion-auto-select} to
+@code{t} and pressing @key{TAB} will switch to the completion list
+buffer when it pops up that buffer.  If the value is
+@code{second-tab}, then the first @key{TAB} will pops up the
+completions list buffer and the second one will switch to it.
+
 @vindex completion-cycle-threshold
   If @code{completion-cycle-threshold} is non-@code{nil}, completion
 commands can cycle through completion alternatives.  Normally, if
diff --git a/etc/NEWS b/etc/NEWS
index d979c625fd..68eeee69cc 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -584,8 +584,10 @@ value.
 
 *** The "*Completions*" buffer can now be automatically selected.
 To enable this behavior, customize the user option
-'completion-auto-select' to t.  Then pressing 'TAB' will switch to the
-"*Completions*" buffer when it pops up that buffer.
+'completion-auto-select' to t and pressing 'TAB' will switch to the
+"*Completions*" buffer when it pops up that buffer. If the value is
+'second-tab', then the first tab will display "*Completions*" and the
+second one will switch to the "*Completions*" buffer.
 
 *** New user option 'completion-wrap-movement'.
 When non-nil, the commands 'next-completion' and 'previous-completion'
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index c4fb1c0039..742d39f2d2 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1410,18 +1410,26 @@ scroll the window of possible completions."
    ;; 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 @@ This affects the commands `next-completion' and
   :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 @@ Called from `temp-buffer-show-hook'."
   :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 @@ Called from `temp-buffer-show-hook'."
        (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)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]