summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2019-11-08 00:11:34 +0000
committerJoão Távora <joaotavora@gmail.com>2019-11-08 10:18:33 +0000
commit5761a1a3939e23d8e8c725241dd9398a12f191b0 (patch)
tree1bd844f950062ad71827fbc6cb39a8befd39d0f5
parentd558d9fa1e0daf7e8f511cac4595c1eeeeeeb177 (diff)
downloademacs-5761a1a3939e23d8e8c725241dd9398a12f191b0.tar.gz
Nudge icomplete-mode a little closer to fido-mode
* lisp/icomplete.el (icomplete-completions): Don't use ellipsis when truncating determ in fido-mode. Highlight the center part of determ with icomplete-first-match.
-rw-r--r--lisp/icomplete.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/lisp/icomplete.el b/lisp/icomplete.el
index 40f4f0bc688..a7f9086d828 100644
--- a/lisp/icomplete.el
+++ b/lisp/icomplete.el
@@ -572,6 +572,13 @@ matches exist."
(compare (compare-strings name nil nil
most nil nil completion-ignore-case))
(ellipsis (if (char-displayable-p ?…) "…" "..."))
+ ;; `determ' is what we "determined" to be the thing that
+ ;; TAB will complete to. Also, if we're working with a
+ ;; large prefix (like when finding files), we want to
+ ;; truncate the common prefix away. `determ-ellipsis'
+ ;; says if we should do it with an `ellipsis'. Icomplete
+ ;; uses one, Ido doesn't.
+ (determ-ellipsis (if fido-mode "" ellipsis))
(determ (unless (or (eq t compare) (eq t most-try)
(= (setq compare (1- (abs compare)))
(length most)))
@@ -582,8 +589,10 @@ matches exist."
(substring most compare))
;; Don't bother truncating if it doesn't gain
;; us at least 2 columns.
- ((< compare (+ 2 (string-width ellipsis))) most)
- (t (concat ellipsis (substring most compare))))
+ ((< compare (+ 2 (string-width determ-ellipsis)))
+ most)
+ (t (concat determ-ellipsis
+ (substring most compare))))
close-bracket)))
;;"-prospects" - more than one candidate
(prospects-len (+ (string-width
@@ -664,6 +673,8 @@ matches exist."
(mapconcat 'identity prospects icomplete-separator)
(and limit (concat icomplete-separator ellipsis))
"}")
+ (put-text-property 1 (1- (length determ))
+ 'face 'icomplete-first-match determ)
(concat determ " [Matched]"))))))
;;; Iswitchb compatibility