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

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

[elpa] master 5493d22 05/39: Fix description truncation when showing doc


From: Justin Burkett
Subject: [elpa] master 5493d22 05/39: Fix description truncation when showing docstrings
Date: Thu, 21 Jun 2018 15:48:12 -0400 (EDT)

branch: master
commit 5493d22489d159a758cb3f5e5f34f191c35c58de
Author: Justin Burkett <address@hidden>
Commit: Justin Burkett <address@hidden>

    Fix description truncation when showing docstrings
---
 which-key.el | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/which-key.el b/which-key.el
index 1f4bfa1..ae69371 100644
--- a/which-key.el
+++ b/which-key.el
@@ -1515,10 +1515,12 @@ If KEY contains any \"special keys\" defined in
 
 (defsubst which-key--truncate-description (desc)
   "Truncate DESC description to `which-key-max-description-length'."
-  (if (and which-key-max-description-length
-           (> (length desc) which-key-max-description-length))
-      (concat (substring desc 0 which-key-max-description-length) "..")
-    desc))
+  (let* ((last-face (get-text-property (1- (length desc)) 'face desc))
+         (dots (propertize ".." 'face last-face)))
+    (if (and which-key-max-description-length
+             (> (length desc) which-key-max-description-length))
+        (concat (substring desc 0 which-key-max-description-length) dots)
+      desc)))
 
 (defun which-key--highlight-face (description)
   "Return the highlight face for DESCRIPTION if it has one."
@@ -1549,8 +1551,7 @@ ORIGINAL-DESCRIPTION is the description given by
   (let* ((desc description)
          (desc (if (string-match-p "^group:" desc)
                    (substring desc 6) desc))
-         (desc (if group (concat which-key-prefix-prefix desc) desc))
-         (desc (which-key--truncate-description desc)))
+         (desc (if group (concat which-key-prefix-prefix desc) desc)))
     (make-text-button desc nil
       'face (cond (hl-face hl-face)
                   (group 'which-key-group-description-face)
@@ -1623,8 +1624,9 @@ alists. Returns a list (key separator description)."
              (hl-face (which-key--highlight-face orig-desc))
              (key-binding (which-key--maybe-replace (cons keys orig-desc)))
              (final-desc (which-key--propertize-description
-                          (cdr key-binding) group local hl-face orig-desc)))
-        (setq final-desc (which-key--maybe-add-docstring final-desc orig-desc))
+                          (cdr key-binding) group local hl-face orig-desc))
+             (final-desc (which-key--maybe-add-docstring final-desc orig-desc))
+             (final-desc (which-key--truncate-description final-desc)))
         (when (consp key-binding)
           (push
            (list (which-key--propertize-key



reply via email to

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