From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#73032: 31.0.50; vtable header is not aligned Date: Thu, 05 Sep 2024 10:36:10 +0300 Message-ID: <86mskm4knp.fsf@gnu.org> References: <87cyljt4w5.fsf@disroot.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="329"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73032@debbugs.gnu.org To: Aleksandr Vityazev Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Sep 05 09:53:45 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 1sm7JJ-000AYt-14 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 05 Sep 2024 09:53:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sm7IZ-0001wj-NW; Thu, 05 Sep 2024 03:52: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 1sm7IY-0001wR-Dx for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 03:52:58 -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 1sm7IY-0004DZ-36 for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 03:52:58 -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:References:In-Reply-To:From:Date:To:Subject; bh=+kRW4Kd4e5zCWtdhuoF7SlhvA8yuHXs6e5+k3/w7UO4=; b=OOB2Wt7mXDr/6E+lDpgcxLSvgD2tjo10QaKOHt6+7RrrAfS0acCgzGt66XVlDW7Sm15qN+JFoWKhk7KUeVWDP70Ie0WK35021rXINqhrftv9Y/RP+VJADr2Edsvqmr6JCpcEs9zEa28XD5r0XBqSiqsjOJuSwxG2XlKtWgj1d0f98fvUhnpYGrEKGaw2+1+mnQgmEs8sZ0VgY5WsbSPT2khWXSuaOyYHj/r7c3C/7jxQMEvrDQtfnUNVuajyBZ2naAXlv4IFe5ReIY3dwv+L1zLBKvsVE/zpNjpkK2hqAcN4fqCMej2briE5ZuXIUzPIAvWHK5zHTTU+a0Nmp3rrKw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sm7Ja-0000al-Oh for bug-gnu-emacs@gnu.org; Thu, 05 Sep 2024 03:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Sep 2024 07:54:02 +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.17255228172175 (code B ref 73032); Thu, 05 Sep 2024 07:54:02 +0000 Original-Received: (at 73032) by debbugs.gnu.org; 5 Sep 2024 07:53:37 +0000 Original-Received: from localhost ([127.0.0.1]:36043 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sm7JB-0000Yz-6L for submit@debbugs.gnu.org; Thu, 05 Sep 2024 03:53:37 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:56374) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sm7J6-0000YY-RX for 73032@debbugs.gnu.org; Thu, 05 Sep 2024 03:53:35 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sm72W-0000wx-OW; Thu, 05 Sep 2024 03:36:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=+kRW4Kd4e5zCWtdhuoF7SlhvA8yuHXs6e5+k3/w7UO4=; b=JGmRt9AqqvU01PbC7JgP hAJEqdfD+Pb3sDg89ay1CcczJGZZzVLUt96yiNADiEN1qgvxcOa/HPDAo9kI/U1wr7JojVS5Ebv4B YTwcoMZhADTEXP4T+A3WOH/c+6NX+q5UiSxLzD3BHQkemiId3KDzuo4XG6omFjw4/+lk8OI9H7ZHv jg34CHauX08Ih4DApkDk3hGAjF/7PgHbwwo+OAPJpCHR4s5Ggdg6slN79qTM8sj8UeulMPnAOCcO4 m1B9H68MPz+1tIHV1h7lGs0d9IO56qmNYEgAhSeRIACGt+qFWz5UNG9jy2NKKywxxA0KbEb3XQ9Mu c6KCNRZRdPPorQ==; In-Reply-To: <87cyljt4w5.fsf@disroot.org> (bug-gnu-emacs@gnu.org) 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:291230 Archived-At: > 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" > > There is a problem in vtable.el when an emoji is specified as a delimiter; the > header and row delimiters are not aligned. > > Minimal reproducer for emacs -Q: > > (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 " 🍉 " > :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*")) > > Screenshot is attached. I cannot get them aligned even if I replace the Emoji character with an ASCII character, like 'x'. Can you? 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? diff --git a/lisp/emacs-lisp/vtable.el b/lisp/emacs-lisp/vtable.el index cb7ea39..dd26ccd 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