From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Aleksandr Vityazev via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#73032: 31.0.50; vtable header is not aligned Date: Thu, 05 Sep 2024 19:39:37 +0300 Message-ID: <878qw6t5py.fsf@disroot.org> References: <87cyljt4w5.fsf@disroot.org> <86mskm4knp.fsf@gnu.org> Reply-To: Aleksandr Vityazev Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28213"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73032@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 05 18:40:05 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1smFWe-0007BL-Uq for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Sep 2024 18:40:05 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smFWZ-0000zw-69; Thu, 05 Sep 2024 12:39:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1smFWX-0000zB-1V for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 12:39:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1smFWW-0002L5-OD for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 12:39:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=IRMHRx4LrCNtbNvGJswvoLEpJvAkp0Jmj7kmyeM7Cu4=; b=KlVTFVhkthvzNTOGlEcIe7uXAowSC/53OAa10gAZ2YHSdGoMiJyG9LzokBJpUBS0oO9nxN/WG4uf7DbBPyFLF0bYYSAIksq/xtmkVo5JMggZjn70Dd1h9OIdmRAIUtwJ/5o2vrqAT2S6XbNUSxIih9cQZLS8zjgdv5HFm4WdotxdT14V9MXCW5ReOvuVC9gm5xHeQlA6QEJVjWWo2F6xlFpbRIvi8oqMVObfVfXgFGYbybHKiFF1QuQS5Hcujz1mrVALy1I/jieWddND0lzts7DHzMP1IDGv8hZxrua2dMzegeGD05AdDs3rZaos7q/2PybgQtr1Ql/YSVeuBFX1VQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1smFXZ-0007U1-Uq for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 12:41:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Aleksandr Vityazev Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Sep 2024 16:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73032 X-GNU-PR-Package: emacs Original-Received: via spool by 73032-submit@debbugs.gnu.org id=B73032.172555445428713 (code B ref 73032); Thu, 05 Sep 2024 16:41:01 +0000 Original-Received: (at 73032) by debbugs.gnu.org; 5 Sep 2024 16:40:54 +0000 Original-Received: from localhost ([127.0.0.1]:38024 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smFXS-0007T2-5u for submit@debbugs.gnu.org; Thu, 05 Sep 2024 12:40:54 -0400 Original-Received: from layka.disroot.org ([178.21.23.139]:50226) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1smFXP-0007St-9U for 73032@debbugs.gnu.org; Thu, 05 Sep 2024 12:40:52 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id E1B444176D; Thu, 5 Sep 2024 18:39:44 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Original-Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZIbizNr_SaQb; Thu, 5 Sep 2024 18:39:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1725554380; bh=qICZ2yA5frFb6vf1nse/Bq7YS9PIFcuhpgx438ldi3w=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=jNnoN505BUU/MA73YEKPoF5WinfH4/o0POtzCNC0ngoz3u3sxrEU0mCtKMhbv/eP1 deYH1upiGX2MmZrXV78C8Vkax0LiT0qyPP1Pxko8ycRBTIaI91y+2S2GPSHJBzqW7c i5qONSdl4wzRHhCKrd6DzPqBJDbRY9S070tXCr5qkQUbhLTg7yLT8+G0HayFgmpf0g ZNV4t1xvtFAz1bTYCDj2HElUzzAxRCkNuGiBZxlcFS/i2z55XZ99TWTwaq8mHz5nGE p2E0FJzWKmuIRHW/f0BA1Qr640jXrx2BoSO0QR94PICOy5mOGO9Nw3/6e/ideQzZw6 r3G6YYq/mLCXg== In-Reply-To: <86mskm4knp.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 05 Sep 2024 10:36:10 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:291274 Archived-At: On 2024-09-05 10:36, Eli Zaretskii wrote: >> Date: Thu, 05 Sep 2024 01:45:14 +0300 >> From: Aleksandr Vityazev via "Bug reports for GNU Emacs, >> the Swiss army knife of text editors" >>=20 >> There is a problem in vtable.el when an emoji is specified as a delimite= r; the >> header and row delimiters are not aligned. >>=20 >> Minimal reproducer for emacs -Q: >>=20 >> (require 'vtable) >> (with-current-buffer (get-buffer-create "*test*") >> (make-vtable >> :columns '((:name "Name" :width 20) "Size" "File") >> :objects (buffer-list) >> :actions '("k" kill-buffer >> "RET" display-buffer) >> :divider " =F0=9F=8D=89 " >> :getter (lambda (object column vtable) >> (pcase (vtable-column vtable column) >> ("Name" (buffer-name object)) >> ("Size" (buffer-size object)) >> ("File" (or (buffer-file-name object) ""))))) >> (switch-to-buffer "*test*")) >>=20 >> Screenshot is attached. > > I cannot get them aligned even if I replace the Emoji character with > an ASCII character, like 'x'. Can you? No, I can't. > AFAICT, there's inconsistency in whitespace calculation between the > header line and the body of the table, due to the desire to display > the sorting indicator not quite right-aligned. The patch below > attempts to fix that; does it give good results? The patch helped, but there are still some issues. I was able to achieve alignment with the following settings: (set-face-attribute 'default nil :family "monospace" :height 210) With: (set-face-attribute 'default nil :family "monospace" :height 220) the header separators are also misaligned. My patch is based on the one that was sent; I just commented out the insertion of an extra space after the column name. diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el index cb7ea397314..e5bcb54f28e 100644 --- a/lisp/emacs-lisp/vtable.el +++ b/lisp/emacs-lisp/vtable.el @@ -722,15 +722,17 @@ vtable--insert-header-line (vtable--limit-string name (- (elt widths index) indicator-width)) name)) - (let ((fill-width - (+ (- (elt widths index) - (string-pixel-width displayed) - indicator-width - (vtable-separator-width table) - ;; We want the indicator to not be quite flush - ;; right. - (/ (vtable--char-width table) 2.0)) - (if last 0 spacer)))) + (let* ((indicator-lead-width + ;; We want the indicator to not be quite flush right. + (/ (vtable--char-width table) 2.0)) + (indicator-pad-width (- (vtable--char-width table) + indicator-lead-width)) + (fill-width + (+ (- (elt widths index) + (string-pixel-width displayed) + indicator-width + indicator-lead-width) + (if last 0 spacer)))) (if (or (not last) (zerop indicator-width) (< (seq-reduce #'+ widths 0) (window-width nil t))) @@ -739,7 +741,9 @@ vtable--insert-header-line displayed (propertize " " 'display (list 'space :width (list fill-width))) - indicator) + indicator + (propertize " " 'display + (list 'space :width (list indicator-pad-width)= ))) ;; This is the final column, and we have a sorting ;; indicator, and the table is too wide for the window. (let* ((pre-indicator (string-pixel-width @@ -758,10 +762,10 @@ vtable--insert-header-line (list (- fill-width pre-fill)))))))) (when (and divider (not last)) (insert (propertize divider 'keymap dmap))) - (insert (propertize - " " 'display - (list 'space :width (list - (/ (vtable--char-width table) 2.0))= ))) + ;; (insert (propertize + ;; " " 'display + ;; (list 'space :width (list + ;; (/ (vtable--char-width table) 2.= 0))))) (put-text-property start (point) 'vtable-column index))) (vtable-columns table)) (insert "\n") --=20 Best regards, Aleksandr Vityazev