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

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

[elpa] externals/which-key e993113868 09/11: Allow truncating without us


From: ELPA Syncer
Subject: [elpa] externals/which-key e993113868 09/11: Allow truncating without using any ellipsis
Date: Thu, 11 Aug 2022 12:58:12 -0400 (EDT)

branch: externals/which-key
commit e993113868305221db8dff8b37be81cca2bfa139
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    Allow truncating without using any ellipsis
    
    Depending on how bindings are displayed showing docstrings can result
    in most lines being too long and adding ellipses to most lines can be
    quite ugly and distracting.
---
 which-key.el | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/which-key.el b/which-key.el
index 2062a737ab..552b6a749a 100644
--- a/which-key.el
+++ b/which-key.el
@@ -142,13 +142,13 @@ the default is \" : \"."
 
 (defcustom which-key-ellipsis
   (if which-key-dont-use-unicode ".." "…")
-  "Ellipsis to use when truncating. Default is \"…\", unless
-`which-key-dont-use-unicode' is non nil, in which case
-the default is \"..\"."
+  "Ellipsis to use when truncating.
+Default is \"…\", unless `which-key-dont-use-unicode' is non nil,
+in which case the default is \"..\".  This can also be the empty
+string to truncate without using any ellipsis."
   :group 'which-key
   :type 'string)
 
-
 (defcustom which-key-prefix-prefix "+"
   "String to insert in front of prefix commands (i.e., commands
 that represent a sub-map). Default is \"+\"."
@@ -1604,10 +1604,13 @@ If KEY contains any \"special keys\" defined in
                (function (let ((val (funcall max avl-width)))
                            (if (floatp val) (truncate val) val))))))
     (if (and max (> (length desc) max))
-       (let* ((last-face (get-text-property (1- (length desc)) 'face desc))
-               (dots (which-key--propertize which-key-ellipsis
-                                           'face last-face)))
-          (concat (substring desc 0 (- max (length dots))) dots))
+        (let ((dots (and (not (equal which-key-ellipsis ""))
+                        (which-key--propertize
+                         which-key-ellipsis 'face
+                         (get-text-property (1- (length desc)) 'face desc)))))
+         (if dots
+              (concat (substring desc 0 (- max (length dots))) dots)
+           (substring desc 0 max)))
       desc)))
 
 (defun which-key--highlight-face (description)



reply via email to

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