From c5d6b80867f7f02b8ecbc5ed7dc8009c570831ac Mon Sep 17 00:00:00 2001 From: Thuna 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