]> git.eshelyaron.com Git - emacs.git/commitdiff
Add completion-auto-select second-tab value.
authorJimmy Aguilar Mena <spacibba@aol.com>
Tue, 22 Mar 2022 20:24:13 +0000 (21:24 +0100)
committerJimmy Aguilar Mena <spacibba@aol.com>
Thu, 24 Mar 2022 10:18:05 +0000 (11:18 +0100)
* lisp/minibuffer.el (completion--in-region-1) : Change if with cond and
check if completion-auto-select.
* lisp/simple.el (completion-auto-select) : Move before first use.
(completion-setup-function) : Make a more precise check for when
completion-auto-select is t.

lisp/minibuffer.el
lisp/simple.el

index c4fb1c00391617de39ae3921fddd8118e6cb06a6..742d39f2d29af88eca37a02e2c8a62ed9da135e7 100644 (file)
@@ -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)
index 9a8ed0bb75707879d85022975655060b9588b2d2..f22960869082c6ac08cb52eeae31c70989c357d9 100644 (file)
@@ -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)