From: Aleksandr Vityazev via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 73032@debbugs.gnu.org
Subject: bug#73032: 31.0.50; vtable header is not aligned
Date: Thu, 05 Sep 2024 19:39:37 +0300 [thread overview]
Message-ID: <878qw6t5py.fsf@disroot.org> (raw)
In-Reply-To: <86mskm4knp.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 05 Sep 2024 10:36:10 +0300")
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" <bug-gnu-emacs@gnu.org>
>>
>> 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?
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")
--
Best regards,
Aleksandr Vityazev
next prev parent reply other threads:[~2024-09-05 16:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 22:45 bug#73032: 31.0.50; vtable header is not aligned Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-09-05 7:36 ` Eli Zaretskii
2024-09-05 16:39 ` Aleksandr Vityazev via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-09-07 8:28 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878qw6t5py.fsf@disroot.org \
--to=bug-gnu-emacs@gnu.org \
--cc=73032@debbugs.gnu.org \
--cc=avityazev@disroot.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.