emacs-diffs
[Top][All Lists]
Advanced

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

feature/completions-highlight-modifications ab1e2e6 15/25: Add custom va


From: Jimmy Aguilar Mena
Subject: feature/completions-highlight-modifications ab1e2e6 15/25: Add custom variable completions-highlight-autoselect.
Date: Fri, 20 Nov 2020 13:28:34 -0500 (EST)

branch: feature/completions-highlight-modifications
commit ab1e2e6b202eb0e9c8055f972998e4ccf321c7de
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>

    Add custom variable completions-highlight-autoselect.
    
    * lisp/completions-highlight.el (completions-highlight-autoselect) : New
    custom.
    (completions-highlight-setup) : Auto selects the first candidate when
    completions-highlight-autoselect is non nil.
---
 lisp/completions-highlight.el | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/lisp/completions-highlight.el b/lisp/completions-highlight.el
index e675a72..78017f9 100644
--- a/lisp/completions-highlight.el
+++ b/lisp/completions-highlight.el
@@ -58,6 +58,17 @@
 (require 'simple)
 (require 'minibuffer)
 
+(defcustom completions-highlight-autoselect nil
+  "Select first candidate without extra tab.
+
+When this variable is nil an extra tab is required to select and
+highlight the first candidate in the *Completions* buffer.  When
+the value is non-nil the candidate is selected every time the
+buffer is shown and updated."
+  :type 'boolean
+  :group 'completion
+  :version "28.1")
+
 (defvar completions-highlight-overlay (make-overlay 0 0)
   "Overlay to use when `completion-highlight-mode' is enabled.")
 
@@ -267,7 +278,12 @@ It is called when showing the *Completions* buffer."
 
       ;; Add completions-highlight-completions-map to *Completions*
       (use-local-map (make-composed-keymap
-                      completions-highlight-completions-map 
(current-local-map)))))
+                      completions-highlight-completions-map 
(current-local-map)))
+
+      ;; Autoselect candidate if enabled
+      (when completions-highlight-autoselect
+        (with-selected-window (get-buffer-window (current-buffer) 0)
+          (completions-highlight-next-completion 1)))))
 
   (add-hook 'pre-command-hook
            #'completions-highlight-minibuffer-pre-command-hook nil t)



reply via email to

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