[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/marginalia d1deaea 1/5: Call `truncate-string-to-width`
From: |
ELPA Syncer |
Subject: |
[elpa] externals/marginalia d1deaea 1/5: Call `truncate-string-to-width` only on short strings (Fix #85) |
Date: |
Sat, 5 Jun 2021 06:57:12 -0400 (EDT) |
branch: externals/marginalia
commit d1deaea44778b0a62bf25b48a6fdd443914e48ca
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Call `truncate-string-to-width` only on short strings (Fix #85)
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.
---
marginalia.el | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/marginalia.el b/marginalia.el
index 755b10c..29e5ea5 100644
--- a/marginalia.el
+++ b/marginalia.el
@@ -267,6 +267,11 @@ determine it."
(defun marginalia--truncate (str width)
"Truncate string STR to WIDTH."
+ ;; 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)