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

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

[elpa] externals/marginalia cce40a1 2/5: marginalia--truncate: Take firs


From: ELPA Syncer
Subject: [elpa] externals/marginalia cce40a1 2/5: marginalia--truncate: Take first line before the length check
Date: Sat, 5 Jun 2021 06:57:12 -0400 (EDT)

branch: externals/marginalia
commit cce40a184109479a3e5f1032f52395c1d1fc8ca9
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    marginalia--truncate: Take first line before the length check
---
 marginalia.el | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/marginalia.el b/marginalia.el
index 29e5ea5..d617b15 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -267,16 +267,14 @@ determine it."
 
 (defun marginalia--truncate (str width)
   "Truncate string STR to WIDTH."
+  (when-let (pos (string-match-p "\n" str))
+    (setq str (substring str 0 pos)))
   ;; Work around Emacs bug#48839 where `string-width' takes infinititely long
   ;; for very long one-line strings as the prin1-ed value of variables like
   ;; `load-history'. So trim the string to a short-enough length beforehand.
   (when (> (length str) (* 2 width))
     (setq str (substring str 0 (* 2 width))))
-  (truncate-string-to-width
-   (if-let (pos (string-match-p "\n" str))
-       (substring str 0 pos)
-     str)
-   width 0 32 "…"))
+  (truncate-string-to-width str width 0 32 "…"))
 
 (defun marginalia--align (str)
   "Align STR at the right margin."



reply via email to

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