Subject: bug#73463: closed (Re: bug#73463: [PATCH] Align columns with wide characters properly)

From: [email-masked] (GNU bug Tracking System)
Date: Wed, 25 Sep 2024 11:58:02 +0000

Your bug report

#73463: [PATCH] Align columns with wide characters properly

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
73463: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73463
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#73463: [PATCH] Align columns with wide characters properly
From: Eli Zaretskii <[email-masked]>
To: "Thomas Voss" <[email-masked]>
Cc: [email-masked]
Date: Wed, 25 Sep 2024 14:57:03 +0300
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Wed, 25 Sep 2024 02:23:29 +0200
> From:  "Thomas Voss" via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> For a while I’ve been bugged by some behaviour in Which-Key.  My font of
> choice is Iosevka — a font that is quite popular — and it chooses to make
> the ellipsis character 2-columns wide.  This is typically not a problem,
> but it causes Which-Key columns to appear misaligned as it truncates long
> descriptions with the ellipsis by default when the user configures it to
> use Unicode (and I rather enjoy the ellipsis).
> 
> This happens despite the following being in my init.el:
> 
>     (set-char-table-range char-width-table ?… 2)
> 
> After further investigation, this appears to be due to a simple usage of
> ‘length’ instead of ‘string-width’.  The following trivial patch attached
> to this email seems to have solved this issue.

Thanks, installed on the emacs-30 branch, and closing the bug.

Subject: [PATCH] Align columns with wide characters properly
From: "Thomas Voss" <[email-masked]>
To: <[email-masked]>
Date: Wed, 25 Sep 2024 02:23:29 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi all,

For a while I’ve been bugged by some behaviour in Which-Key.  My font of
choice is Iosevka — a font that is quite popular — and it chooses to make
the ellipsis character 2-columns wide.  This is typically not a problem,
but it causes Which-Key columns to appear misaligned as it truncates long
descriptions with the ellipsis by default when the user configures it to
use Unicode (and I rather enjoy the ellipsis).

This happens despite the following being in my init.el:

    (set-char-table-range char-width-table ?… 2)

After further investigation, this appears to be due to a simple usage of
‘length’ instead of ‘string-width’.  The following trivial patch attached
to this email seems to have solved this issue.

-- 
— Thomas
From b87de8beb17582608afb7e9f30e67085c5d78d7a Mon Sep 17 00:00:00 2001
From: Thomas Voss <[email-masked]>
Date: Wed, 25 Sep 2024 02:17:49 +0200
Subject: [PATCH] Align columns with wide characters properly
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In the case that a character in takes up multple columns (such as `…'
when used as a truncation character) make sure that the columns are
still aligned properly.
* lisp/which-key.el (which-key--pad-column):
Use `string-width' instead of `length'.

Copyright-paperwork-exempt: yes
---
 lisp/which-key.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/which-key.el b/lisp/which-key.el
index 91eb05c..fb0685c 100644
--- a/lisp/which-key.el
+++ b/lisp/which-key.el
@@ -2037,7 +2037,7 @@ that width."
           (mapcar (pcase-lambda (`(,key ,sep ,desc ,_doc))
                     (concat
                      (format col-format key sep desc)
-                     (make-string (- col-desc-width (length desc)) ?\s)))
+                     (make-string (- col-desc-width (string-width desc)) ?\s)))
                   col-keys))))
 
 (defun which-key--partition-list (n list)
-- 
2.46.1