]> git.eshelyaron.com Git - emacs.git/commitdiff
Simplify overlay handling
authorJimmy Aguilar Mena <spacibba@aol.com>
Sun, 15 Nov 2020 07:01:47 +0000 (08:01 +0100)
committerJimmy Aguilar Mena <spacibba@aol.com>
Fri, 20 Nov 2020 18:03:23 +0000 (19:03 +0100)
* lisp/completions-highlight.el (completions-highlight-overlay) :
created on load.
(completions-highlight-completions-pre-command-hook) : Don't move
overlay here.
(completions-highlight-minibuffer-pre-command-hook) : Use delete overlay
instead of conditional
(completions-highlight-mode) : Use overlay-put here instead of the setup.

lisp/completions-highlight.el

index 31442dadc9c3e9bd9356a076120464fd4873879b..f9d85bdf28fdd6d02d306961577c0c65fb3d0f1c 100644 (file)
@@ -37,7 +37,7 @@
 (require 'simple)
 (require 'minibuffer)
 
-(defvar completions-highlight-overlay nil
+(defvar completions-highlight-overlay (make-overlay 0 0)
   "Overlay to use when `completion-highlight-mode' is enabled.")
 
 (defvar minibuffer-tab-through-completions-function-save nil
@@ -223,7 +223,6 @@ should be assigned to completion-in-minibuffer-scroll-window."
 
 (defun completions-highlight-completions-pre-command-hook ()
   "Function `pre-command-hook' to use only in the *Completions."
-  (move-overlay completions-highlight-overlay 0 0)
   (minibuffer-completion-set-suffix ""))
 
 (defun completions-highlight-minibuffer-pre-command-hook ()
@@ -234,25 +233,24 @@ should be assigned to completion-in-minibuffer-scroll-window."
 (defun completions-highlight-setup ()
   "Function to call when enabling the `completion-highlight-mode' mode.
 It is called when showing the *Completions* buffer."
+  (delete-overlay completions-highlight-overlay)
 
   (with-current-buffer standard-output
     (when (string= (buffer-name) "*Completions*")
-      (unless (overlayp completions-highlight-overlay)
-         (setq completions-highlight-overlay (make-overlay 0 0))
-         (overlay-put completions-highlight-overlay 'face 'highlight))
 
       (add-hook 'pre-command-hook
                #'completions-highlight-completions-pre-command-hook nil t)
       (add-hook 'isearch-mode-end-hook
                #'completions-highlight-this-completion nil t)
 
+      ;; Add completions-highlight-completions-map to *Completions*
       (use-local-map (make-composed-keymap
                       completions-highlight-completions-map (current-local-map)))))
 
   (add-hook 'pre-command-hook
            #'completions-highlight-minibuffer-pre-command-hook nil t)
 
-  ;; Add completions-highlight-minibuffer-map bindings to minibuffer map
+  ;; Add completions-highlight-minibuffer-map bindings to minibuffer
   (use-local-map (make-composed-keymap
                   completions-highlight-minibuffer-map (current-local-map))))
 
@@ -263,7 +261,9 @@ It is called when showing the *Completions* buffer."
 
   (if completions-highlight-mode
       (progn
-       (setq minibuffer-tab-through-completions-function-save
+       (overlay-put completions-highlight-overlay 'face 'highlight)
+
+        (setq minibuffer-tab-through-completions-function-save
              minibuffer-tab-through-completions-function)
 
        (setq minibuffer-tab-through-completions-function