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

* bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-24 14:32 UTC (permalink / raw)
  To: Thuna; +Cc: 53498

Thuna <thuna.cing@gmail.com> writes:

> 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.

I didn't know that tabulated-list-mode worked with images at all -- I'd
have thought you'd needed pixel calculations for that to work nicely?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings
  2022-01-24 14:32 ` Lars Ingebrigtsen
@ 2022-01-24 15:14   ` Thuna
  2022-01-24 17:31     ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Thuna @ 2022-01-24 15:14 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53498


> I didn't know that tabulated-list-mode worked with images at all -- I'd
> have thought you'd needed pixel calculations for that to work nicely?

It really depends on :align-to display property and that seems to handle
non-integer values properly.  It seems to work so long as the image
isn't wider than the column itself so the next thing to do is to patch
in image collapsing into print-col.





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

* bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings
  2022-01-24 15:14   ` Thuna
@ 2022-01-24 17:31     ` Lars Ingebrigtsen
  2022-01-24 17:43       ` Thuna
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-24 17:31 UTC (permalink / raw)
  To: Thuna; +Cc: 53498

Thuna <thuna.cing@gmail.com> writes:

> It really depends on :align-to display property and that seems to handle
> non-integer values properly.  It seems to work so long as the image
> isn't wider than the column itself so the next thing to do is to patch
> in image collapsing into print-col.

I think trying to expand tabulated-list-mode into elements that don't
have the same size isn't going to work well.  We're planning to add a
new library for columnar display of variable pitch stuff instead (so
that you can use images, mix fonts and variable pitch fonts).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings
  2022-01-24 17:31     ` Lars Ingebrigtsen
@ 2022-01-24 17:43       ` Thuna
  2022-01-25 11:59         ` Lars Ingebrigtsen
  0 siblings, 1 reply; 7+ messages in thread
From: Thuna @ 2022-01-24 17:43 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53498


> I think trying to expand tabulated-list-mode into elements that don't
> have the same size isn't going to work well.  We're planning to add a
> new library for columnar display of variable pitch stuff instead (so
> that you can use images, mix fonts and variable pitch fonts).

I don't know if a different library is necessary for columnar display.
I believe tabulated-list-mode has the necessary foundations for such a
purpose.  I imagine with additions to the tabulated-list-format's
accepted props such as :content-type, desired features can be
implemented without the need to rewrite all the code.


PS: I have recently attempted to mail emacs-devel@gnu.org (to
help-gnu-emacs@gnu.org as well) regarding the wanted behavior of images
as I believe that is where this conversation belongs to however my mails
seem to not be getting through.  I am unsure why this the case as my
mails are seen as sent on my end.





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

* bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings
  2022-01-24 17:43       ` Thuna
@ 2022-01-25 11:59         ` Lars Ingebrigtsen
  2022-01-25 12:16           ` Thuna
  0 siblings, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-25 11:59 UTC (permalink / raw)
  To: Thuna; +Cc: 53498

Thuna <thuna.cing@gmail.com> writes:

> I don't know if a different library is necessary for columnar display.
> I believe tabulated-list-mode has the necessary foundations for such a
> purpose.

I don't -- it would require a pretty full rewrite to handle these
things.  (And tabulated-list-mode has many other problems, like not
being able to have other text in the buffer, etc.)

So adding things like this, in my opinion, just makes
tabulated-list-mode more convoluted, but won't work properly for most
people, so I don't think we'll try to take tabulated-list-mode in this
direction, and I'm therefore closing this bug report.

> PS: I have recently attempted to mail emacs-devel@gnu.org (to
> help-gnu-emacs@gnu.org as well) regarding the wanted behavior of images
> as I believe that is where this conversation belongs to however my mails
> seem to not be getting through.  I am unsure why this the case as my
> mails are seen as sent on my end.

Seems like they're getting through OK to me?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#53498: [PATCH] Fix tabulated-list-widen-current-column not working for non-strings
  2022-01-25 11:59         ` Lars Ingebrigtsen
@ 2022-01-25 12:16           ` Thuna
  0 siblings, 0 replies; 7+ messages in thread
From: Thuna @ 2022-01-25 12:16 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 53498


> So adding things like this, in my opinion, just makes
> tabulated-list-mode more convoluted, but won't work properly for most
> people, so I don't think we'll try to take tabulated-list-mode in this
> direction, and I'm therefore closing this bug report.

I understand the reasoning for not supporting images however this patch
fixes the bug for buttons as well, which I assume will be supported.





^ permalink raw reply	[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).