[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/completions-highlight-modifications f3ad5c1 09/18: Simplify sett
From: |
Jimmy Aguilar Mena |
Subject: |
feature/completions-highlight-modifications f3ad5c1 09/18: Simplify setting keymaps. |
Date: |
Wed, 18 Nov 2020 22:30:35 -0500 (EST) |
branch: feature/completions-highlight-modifications
commit f3ad5c19f114660e3554e23a2a55bd5470542baf
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>
Simplify setting keymaps.
*
lisp/completions-highlight.el (completions-highlight-minibuffer-map-save)
(completions-highlight-completions-map-save)
(completions-highlight-minibuffer-bindings) :
(completions-highlight-completions-bindings) : Removed functions and
variables.
(completions-highlight-mode) : Remove extra
minibuffer-hide-completions-hook insertion and remove.
---
lisp/completions-highlight.el | 59 +++++--------------------------------------
1 file changed, 7 insertions(+), 52 deletions(-)
diff --git a/lisp/completions-highlight.el b/lisp/completions-highlight.el
index 440ee3b..31442da 100644
--- a/lisp/completions-highlight.el
+++ b/lisp/completions-highlight.el
@@ -43,12 +43,6 @@
(defvar minibuffer-tab-through-completions-function-save nil
"Saves the the original value of completion-in-minibuffer-scroll-window.")
-(defvar completions-highlight-minibuffer-map-save nil
- "Saves the minibuffer current-localmap to restore it disabling the mode.")
-
-(defvar completions-highlight-completions-map-save nil
- "Saves the Completions current-localmap to restore it disabling the mode.")
-
;; *Completions* side commands
(defun completions-highlight-this-completion (&optional n)
"Highlight the completion under point or near.
@@ -209,38 +203,6 @@ suffix."
"Keymap used in *Completions* while highlighting candidates.")
-(defun completions-highlight-minibuffer-bindings (set)
- "Add extra/remove keybindings to `minibuffer-local-must-match-map'.
-When SET is nil the bindings are removed."
- (if set
- (let ((local-map (current-local-map)))
- (unless (eq local-map completions-highlight-minibuffer-map)
- (setq completions-highlight-minibuffer-map-save local-map)
- (unless (eq local-map
- (keymap-parent completions-highlight-minibuffer-map))
- (set-keymap-parent completions-highlight-minibuffer-map local-map))
- (use-local-map completions-highlight-minibuffer-map)))
-
- (use-local-map completions-highlight-minibuffer-map-save)))
-
-
-(defun completions-highlight-completions-bindings (set)
- "Add extra keybindings to `completion-list-mode-map'.
-When SET is nil the bindings are removed."
- (if set
- (let ((local-map (current-local-map)))
- (unless (eq local-map completions-highlight-completions-map)
- (setq completions-highlight-completions-map-save local-map)
- (set-keymap-parent completions-highlight-completions-map local-map)
- (use-local-map completions-highlight-completions-map)))
-
- ;; Set is called already inside *Completions* but unset not
- (when-let ((parent (keymap-parent completions-highlight-completions-map))
- (buffer (get-buffer "*Completions*")))
- (with-current-buffer buffer
- (use-local-map completions-highlight-completions-map-save)))))
-
-
(defun completions-highlight-minibuffer-tab-through-completions ()
"Default action in `minibuffer-scroll-window' WINDOW.
This is called when *Completions* window is already visible and
@@ -284,17 +246,15 @@ It is called when showing the *Completions* buffer."
(add-hook 'isearch-mode-end-hook
#'completions-highlight-this-completion nil t)
- (completions-highlight-completions-bindings t)))
+ (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)
- (completions-highlight-minibuffer-bindings t))
-
-(defun completions-highlight-exit ()
- "Function to call when disabling the `completion-highlight-mode' mode.
-It is called when hiding the *Completions* buffer."
- (completions-highlight-minibuffer-bindings nil))
+ ;; Add completions-highlight-minibuffer-map bindings to minibuffer map
+ (use-local-map (make-composed-keymap
+ completions-highlight-minibuffer-map (current-local-map))))
(define-minor-mode completions-highlight-mode
"Completion highlight mode to enable candidates highlight in the minibuffer."
@@ -309,18 +269,13 @@ It is called when hiding the *Completions* buffer."
(setq minibuffer-tab-through-completions-function
#'completions-highlight-minibuffer-tab-through-completions)
- (add-hook 'completion-setup-hook #'completions-highlight-setup t)
- (add-hook 'minibuffer-hide-completions-hook
#'completions-highlight-exit)
- )
+ (add-hook 'completion-setup-hook #'completions-highlight-setup t))
;; Restore the default completion-in-minibuffer-scroll-window
(setq minibuffer-tab-through-completions-function
minibuffer-tab-through-completions-function-save)
- (remove-hook 'completion-setup-hook #'completions-highlight-setup)
- (remove-hook 'minibuffer-hide-completions-hook
#'completions-highlight-exit)
-
- (completions-highlight-completions-bindings nil)))
+ (remove-hook 'completion-setup-hook #'completions-highlight-setup)))
(provide 'completions-highlight)
;;; completions-highlight.el ends here
- feature/completions-highlight-modifications a686211 10/18: Simplify overlay handling, (continued)
- feature/completions-highlight-modifications a686211 10/18: Simplify overlay handling, Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications 34570e1 14/18: Improve completions-highlight description in file header., Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications bfe4747 12/18: Add parent maps, Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications 6db2c4a 17/18: Simplify and rely more in the post-command-hook, Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications d397d2b 13/18: Add # to function bindings, Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications cb02cb6 11/18: Add autoload decorator., Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications 9fe2441 15/18: Add custom variable completions-highlight-autoselect., Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications ff46a8f 18/18: Add backtab commands., Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications 71f60b6 07/18: Fix corner case when going out of bounds, Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications ac93fdb 16/18: Define completions-highlight face and group, Jimmy Aguilar Mena, 2020/11/18
- feature/completions-highlight-modifications f3ad5c1 09/18: Simplify setting keymaps.,
Jimmy Aguilar Mena <=