branch: externals/taxy-magit-section commit 0dc1c2a4af2957248e15d99d1868fc9eeea6d844 Author: Adam Porter <a...@alphapapa.net> Commit: Adam Porter <a...@alphapapa.net>
Fix: (taxy-magit-section-define-column-definer) Don't pass ellipsis Don't pass string as ELLIPSIS argument to TRUNCATE-STRING-TO-WIDTH; instead pass t, which defaults to value of variable TRUNCATE-STRING-ELLIPSIS. The width of the string passed before, the U+2026 HORIZONTAL ELLIPSIS character, varies by font, and fonts which display it with a width different than that of a single space cause misalignment of columns. Now users may specify the ellipsis string according to their needs. --- README.org | 3 ++- taxy-magit-section.el | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.org b/README.org index 24416d7bce..c11baaf67e 100644 --- a/README.org +++ b/README.org @@ -34,7 +34,8 @@ This library renders [[https://github.com/alphapapa/taxy.el][Taxy]] structs with ** 0.14.1-pre -Nothing new yet. +*Fixes* ++ Don't pass string as ~ELLIPSIS~ argument to ~truncate-string-to-width~; pass t, which defaults to value of variable ~truncate-string-ellipsis~. (The width of the string passed before, the U+2026 HORIZONTAL ELLIPSIS character, varies by font, and fonts which display it with a width different than that of a single space cause misalignment of columns. Now users may specify the ellipsis string according to their needs.) ** 0.14 diff --git a/taxy-magit-section.el b/taxy-magit-section.el index 59944d8081..8fd7fcfb85 100644 --- a/taxy-magit-section.el +++ b/taxy-magit-section.el @@ -322,8 +322,13 @@ PLIST may be a plist setting the following options: ;; calculates widths, I don't see much alternative. It would ;; be nice if it returned nil when no change was made. (let ((old-string string) - (new-string (truncate-string-to-width - string ,max-width-variable nil nil "…"))) + ;; NOTE: We do not specify an ELLIPSIS argument to + ;; `truncate-string-to-width', because some fonts display + ;; e.g. U+2026 "HORIZONTAL ELLIPSIS" with a width greater + ;; than that of the space character, which breaks + ;; alignment. The ellipsis used can be controlled with + ;; the variable `truncate-string-ellipsis', which see. + (new-string (truncate-string-to-width string ,max-width-variable nil nil t))) (unless (equal old-string new-string) ;; String was elided: add help-echo. (put-text-property 0 (length new-string) 'help-echo old-string new-string)