emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/vertico 27070bb 27/48: truncate long candidate strings


From: Stefan Monnier
Subject: [elpa] externals/vertico 27070bb 27/48: truncate long candidate strings
Date: Mon, 5 Apr 2021 10:54:44 -0400 (EDT)

branch: externals/vertico
commit 27070bba78d5f736944ac5fc0ccd071dbe90e074
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    truncate long candidate strings
---
 minicomp.el | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/minicomp.el b/minicomp.el
index b1da4f4..cda90ce 100644
--- a/minicomp.el
+++ b/minicomp.el
@@ -287,7 +287,8 @@
                                                    
minibuffer-completion-predicate "")))
             metadata
             candidates)))
-         (title nil)
+         (max-width (- (* 2 (window-width)) 5))
+         (title)
          (formatted (propertize " " 'cursor t))
          (group (completion-metadata-get metadata 'x-group-function)))
     (dolist (ann-cand ann-candidates formatted)
@@ -309,8 +310,9 @@
                      (replace-regexp-in-string "\n+" "⤶")
                      (string-trim)
                      (minicomp--replace-prop 'display (lambda (x) (if (stringp 
x) x "")))
-                     (minicomp--replace-prop 'invisible (lambda (_) ""))))
-        (setq cand (concat prefix cand
+                     (minicomp--replace-prop 'invisible (lambda (_) "")))
+              cand (truncate-string-to-width cand max-width 0 nil "…")
+              cand (concat prefix cand
                            (if (text-property-not-all 0 (length suffix) 'face 
nil suffix)
                                suffix
                              (propertize suffix 'face 
'completions-annotations))))



reply via email to

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