unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings
@ 2022-01-24 10:55 Thuna
  2022-01-24 14:32 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Thuna @ 2022-01-24 10:55 UTC (permalink / raw)
  To: 53498

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]


Previously tabulted-list-widen-current-column failed to work when point
was at or ahead of a button or an image.  It now checks for image width
and button width.  Button width calculation doesn't account for the
properties of the button, however, so that is left there as a FIXME.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-tabulated-list-widen-current-column-not-working-.patch --]
[-- Type: text/x-diff, Size: 1757 bytes --]

From c5d6b80867f7f02b8ecbc5ed7dc8009c570831ac Mon Sep 17 00:00:00 2001
From: Thuna <thuna.cing@gmail.com>
Date: Mon, 24 Jan 2022 12:40:13 +0300
Subject: [PATCH] Fix tabulated-list-widen-current-column not working for
 non-strings

* tabulated-list.el (tabulated-list-widen-current-column): Consider
buttons and images when calculating the width of the contents of a
cell.
---
 lisp/emacs-lisp/tabulated-list.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 7ad4f7f863..2ace7ebb35 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -734,7 +734,16 @@ tabulated-list-widen-current-column
                        (max (setq col-width
                                   (cadr (aref tabulated-list-format
                                               col-nb)))
-                            (string-width (aref entry col-nb)))
+                            (let ((desc (aref entry col-nb)))
+                              (cond
+                               ((stringp desc)
+                                (string-width desc))
+                               ((eq (car desc) 'image)
+                                (car (image-size desc)))
+                               (t (string-width (car desc))
+                                  ;; FIXME: Take into consideration the properties
+                                  ;;        of the button when calculating width
+                                  ))))
                        (or (plist-get (nthcdr 3 (aref tabulated-list-format
                                                       col-nb))
                                       :pad-right)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-01-25 12:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 10:55 bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings Thuna
2022-01-24 14:32 ` Lars Ingebrigtsen
2022-01-24 15:14   ` Thuna
2022-01-24 17:31     ` Lars Ingebrigtsen
2022-01-24 17:43       ` Thuna
2022-01-25 11:59         ` Lars Ingebrigtsen
2022-01-25 12:16           ` Thuna

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).