[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/completions-highlight-modifications 6ea2c5c 20/25: Fixes:
From: |
Jimmy Aguilar Mena |
Subject: |
feature/completions-highlight-modifications 6ea2c5c 20/25: Fixes: |
Date: |
Fri, 20 Nov 2020 13:28:35 -0500 (EST) |
branch: feature/completions-highlight-modifications
commit 6ea2c5c9804f4ffc911420943048ba1c18e57e15
Author: Jimmy Aguilar Mena <spacibba@aol.com>
Commit: Jimmy Aguilar Mena <spacibba@aol.com>
Fixes:
* lisp/completions-highlight.el (minibuffer-completion-set-suffix) :
Renamed as minibuffer-completion--set-suffix.
(completions-highlight--clear-suffix) : New function
(completions-highlight-minibuffer-tab-through-completions) : Renamed as
completions-highlight--minibuffer-tab-through-completions
(completions-highlight-completions-pre-command-hook) :
(completions-highlight-minibuffer-pre-command-hook) : Removed and
references substituted with completions-highlight--clear-suffix.
---
lisp/completions-highlight.el | 57 ++++++++++++++++++-------------------------
1 file changed, 24 insertions(+), 33 deletions(-)
diff --git a/lisp/completions-highlight.el b/lisp/completions-highlight.el
index 703d0d1..7e7ea2c 100644
--- a/lisp/completions-highlight.el
+++ b/lisp/completions-highlight.el
@@ -150,7 +150,7 @@ is executed in another window, but cursor stays in
minibuffer."
(with-minibuffer-scroll-window (previous-line n)))
;; General commands
-(defun minibuffer-completion-set-suffix (choice)
+(defun completions-highlight--set-suffix (choice)
"Set CHOICE suffix to current completion.
It uses `completion-base-position' to determine the cursor
position. If choice is the empty string the command removes the
@@ -161,21 +161,24 @@ suffix."
(completion-no-auto-exit t))
(with-selected-window minibuffer-window
- (let* ((prompt-end (minibuffer-prompt-end))
- (cursor-pos (if obase-position
- (cadr obase-position)
- (choose-completion-guess-base-position choice)))
- (prefix-len (- cursor-pos prompt-end))
- (suffix (if (< prefix-len (length choice))
- (substring choice prefix-len)
- ""))
- (suffix-len (string-width suffix)))
-
- (choose-completion-string suffix minibuffer-buffer
- (list cursor-pos (point-max)))
- (add-face-text-property cursor-pos (+ cursor-pos suffix-len) 'shadow)
- (goto-char cursor-pos)))))
-
+ (let* ((prompt-end (minibuffer-prompt-end))
+ (cursor-pos (if obase-position
+ (cadr obase-position)
+ (choose-completion-guess-base-position choice)))
+ (prefix-len (- cursor-pos prompt-end))
+ (suffix (if (< prefix-len (length choice))
+ (substring choice prefix-len)
+ ""))
+ (suffix-len (string-width suffix)))
+
+ (choose-completion-string suffix minibuffer-buffer
+ (list cursor-pos (point-max)))
+ (add-face-text-property cursor-pos (+ cursor-pos suffix-len) 'shadow)
+ (goto-char cursor-pos)))))
+
+(defun completions-highlight--clear-suffix()
+ "Clear completion suffix if set."
+ (completions-highlight--set-suffix ""))
(defvar completions-highlight-minibuffer-map
(let ((map (make-sparse-keymap)))
@@ -195,7 +198,7 @@ suffix."
map)
"Keymap used in *Completions* while highlighting candidates.")
-(defun completions-highlight-minibuffer-tab-through-completions ()
+(defun completions-highlight--minibuffer-tab-through-completions ()
"Default action in `minibuffer-scroll-window' WINDOW.
This is called when *Completions* window is already visible and
should be assigned to completion-in-minibuffer-scroll-window."
@@ -213,15 +216,6 @@ should be assigned to
completion-in-minibuffer-scroll-window."
;; can scroll.
(with-selected-window window (scroll-up))))))
-(defun completions-highlight-completions-pre-command-hook ()
- "Function `pre-command-hook' to use only in the *Completions."
- (minibuffer-completion-set-suffix ""))
-
-(defun completions-highlight-minibuffer-pre-command-hook ()
- "Function `pre-command-hook' to use only in the minibuffer."
- (unless (eq this-command 'minibuffer-complete-and-exit)
- (minibuffer-completion-set-suffix "")))
-
(defun completions-highlight-setup ()
"Function to call when enabling the `completion-highlight-mode' mode.
It is called when showing the *Completions* buffer."
@@ -230,10 +224,8 @@ It is called when showing the *Completions* buffer."
(with-current-buffer standard-output
(when (string= (buffer-name) "*Completions*")
- (add-hook 'pre-command-hook
- #'completions-highlight-completions-pre-command-hook nil t)
- (add-hook 'post-command-hook
- #'completions-highlight-this-completion nil t)
+ (add-hook 'pre-command-hook #'completions-highlight--clear-suffix nil t)
+ (add-hook 'post-command-hook #'completions-highlight--this-completion
nil t)
;; Add completions-highlight-completions-map to *Completions*
(use-local-map (make-composed-keymap
@@ -245,8 +237,7 @@ It is called when showing the *Completions* buffer."
(next-completion 1)
(completions-highlight-select-near)))))
- (add-hook 'pre-command-hook
- #'completions-highlight-minibuffer-pre-command-hook nil t)
+ (add-hook 'pre-command-hook #'completions-highlight--clear-suffix nil t)
;; Add completions-highlight-minibuffer-map bindings to minibuffer
(use-local-map (make-composed-keymap
@@ -266,7 +257,7 @@ It is called when showing the *Completions* buffer."
minibuffer-tab-through-completions-function)
(setq minibuffer-tab-through-completions-function
- #'completions-highlight-minibuffer-tab-through-completions)
+ #'completions-highlight--minibuffer-tab-through-completions)
(add-hook 'completion-setup-hook #'completions-highlight-setup t))
- feature/completions-highlight-modifications b1a027d 01/25: Insert some modifications to implement completions highlighting., (continued)
- feature/completions-highlight-modifications b1a027d 01/25: Insert some modifications to implement completions highlighting., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 5509afa 02/25: Document the changes in the API for Completions., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications d4d9f6a 04/25: Fix initial comment in completions-highlight file., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 3a22b70 05/25: Improve keymap handling., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 31d6ec4 12/25: Add parent maps, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications c6943d7 09/25: Simplify setting keymaps., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 11431bc 13/25: Add # to function bindings, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications f19039c 14/25: Improve completions-highlight description in file header., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications ce8b5b2 17/25: Simplify and rely more in the post-command-hook, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 3f0f13e 18/25: Add backtab commands., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 6ea2c5c 20/25: Fixes:,
Jimmy Aguilar Mena <=
- feature/completions-highlight-modifications 25f23b1 25/25: Add try to close completions more often like zsh., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 5cf9dd6 11/25: Add autoload decorator., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 6cea893 07/25: Fix corner case when going out of bounds, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications e143246 10/25: Simplify overlay handling, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications ab1e2e6 15/25: Add custom variable completions-highlight-autoselect., Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 10359ba 19/25: Fix previous commit, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications bfb8a71 21/25: Add ignore-errors when executing from minibuffer, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 3319dcc 22/25: New command minibuffer-choose-completion, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications 6369e59 23/25: Other changes:, Jimmy Aguilar Mena, 2020/11/20
- feature/completions-highlight-modifications c990a28 24/25: Simplify and add custom, Jimmy Aguilar Mena, 2020/11/20