unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* tabulated-list: extend truncation into next align-right col
@ 2016-10-31 17:41 Tino Calancha
  2016-10-31 18:40 ` Stefan Monnier
  2016-10-31 20:15 ` Drew Adams
  0 siblings, 2 replies; 19+ messages in thread
From: Tino Calancha @ 2016-10-31 17:41 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Tino Calancha, Emacs developers


Hi Stefan,

i am trying to address following TODO in tabulated-list.el
(commit f0809a9):
+  ;; TODO: don't truncate to `width' if the next column is align-right
+  ;; and has some space left.

Following example compares the patch below with the current behaviour:

emacs -r -Q -eval '(switch-to-buffer "*abcdefghijklmnopqrstuvwxyz*")'
M-x list-buffers RET
;; List this buffer as:
;; Before patch: *abcdefghijklmno...
;; After patch:  *abcdefghijklmnopqrs...

Please, take a look on it when you have time.
Regards,
Tino

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From e150d919e59ca339115a1657cf04b0b32385d1a1 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Tue, 1 Nov 2016 02:15:09 +0900
Subject: [PATCH] tabulated-list: extend truncation into next align-right
  column

* lisp/emacs-lisp/tabulated-list.el (tabulated-list--col-max-widths):
New variable.
(tabulated-list--col-max-widths): New defun.
(tabulated-list-print, tabulated-list-set-col): Use it.
(tabulated-list-print-col): If the next column is align-right,
and has some space left then don't truncate to width, use
some of the available space from the next column.
---
  lisp/emacs-lisp/tabulated-list.el | 59 ++++++++++++++++++++++++++++++++-------
  1 file changed, 49 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 00b029d..6ad0707 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -36,6 +36,7 @@

  ;;; Code:

+(eval-when-compile (require 'cl-lib))
  ;; The reason `tabulated-list-format' and other variables are
  ;; permanent-local is to make it convenient to switch to a different
  ;; major mode, switch back, and have the original Tabulated List data
@@ -86,6 +87,10 @@ tabulated-list-entries
  arguments and must return a list of the above form.")
  (put 'tabulated-list-entries 'permanent-local t)

+(defvar-local tabulated-list--col-max-widths nil
+  "List of maximum entry widths per each column.")
+(put 'tabulated-list--col-max-widths 'permanent-local t)
+
  (defvar-local tabulated-list-padding 0
    "Number of characters preceding each Tabulated List mode entry.
  By default, lines are padded with spaces, but you can use the
@@ -298,6 +303,22 @@ tabulated-list--get-sorter
            (lambda (a b) (not (funcall sorter a b)))
          sorter))))

+(defun tabulated-list--col-max-widths ()
+  "Update `tabulated-list--col-max-widths'."
+  (let ((entries (if (functionp tabulated-list-entries)
+                     (funcall tabulated-list-entries)
+                   tabulated-list-entries)))
+    (setq tabulated-list--col-max-widths
+          (cl-loop for n from 0 to (1- (length tabulated-list-format))
+                   collect
+                   (apply #'max (mapcar (lambda (x)
+                                          (let ((desc (elt (cadr x) n)))
+                                            (string-width
+                                             (if (stringp desc)
+                                                 desc
+                                               (car desc)))))
+                                        entries))))))
+
  (defun tabulated-list-print (&optional remember-pos update)
    "Populate the current Tabulated List mode buffer.
  This sorts the `tabulated-list-entries' list if sorting is
@@ -339,6 +360,8 @@ tabulated-list-print
        (erase-buffer)
        (unless tabulated-list-use-header-line
          (tabulated-list-print-fake-header)))
+    ;; Update columns max element widths list.
+    (tabulated-list--col-max-widths)
      ;; Finally, print the resulting list.
      (dolist (elt entries)
        (let ((id (car elt)))
@@ -402,8 +425,6 @@ tabulated-list-print-col
  N is the column number, COL-DESC is a column descriptor (see
  `tabulated-list-entries'), and X is the column number at point.
  Return the column number after insertion."
-  ;; TODO: don't truncate to `width' if the next column is align-right
-  ;; and has some space left.
    (let* ((format    (aref tabulated-list-format n))
  	 (name      (nth 0 format))
  	 (width     (nth 1 format))
@@ -414,12 +435,29 @@ tabulated-list-print-col
           (label-width (string-width label))
  	 (help-echo (concat (car format) ": " label))
  	 (opoint (point))
-	 (not-last-col (< (1+ n) (length tabulated-list-format))))
+	 (not-last-col (< (1+ n) (length tabulated-list-format)))
+	  available-space)
+    (when not-last-col
+      (let* ((next-col-format (aref tabulated-list-format (1+ n)))
+             (next-col-right-align (plist-get (nthcdr 3 next-col-format)
+                                              :right-align))
+             (next-col-width (nth 1 next-col-format)))
+        (setq available-space
+              (if (and (not right-align)
+                       next-col-right-align)
+                  (-
+                   (+ width next-col-width)
+                   (min next-col-width
+                        (nth (1+ n) tabulated-list--col-max-widths)))
+                width))))
      ;; Truncate labels if necessary (except last column).
-    (and not-last-col
-	 (> label-width width)
-	 (setq label (truncate-string-to-width label width nil nil t)
-               label-width width))
+    ;; Don't truncate to `width' if the next column is align-right
+    ;; and has some space left, truncate to `available-space' instead.
+    (when (and not-last-col
+               (> label-width available-space)
+               (setq label (truncate-string-to-width
+                            label available-space nil nil t)
+                     label-width available-space)))
      (setq label (bidi-string-mark-left-to-right label))
      (when (and right-align (> width label-width))
        (let ((shift (- width label-width)))
@@ -437,7 +475,7 @@ tabulated-list-print-col
        (when not-last-col
          (when (> pad-right 0) (insert (make-string pad-right ?\s)))
          (insert (propertize
-                 (make-string (- next-x x label-width pad-right) ?\s)
+                 (make-string (- width (min width label-width)) ?\s)
                   'display `(space :align-to ,next-x))))
        (put-text-property opoint (point) 'tabulated-list-column-name name)
        next-x)))
@@ -495,8 +533,9 @@ tabulated-list-set-col
        (delete-region pos (next-single-property-change pos prop nil eol))
        (goto-char pos)
        (tabulated-list-print-col col desc (current-column))
-      (if change-entry-data
-	  (aset entry col desc))
+      (when change-entry-data
+        (aset entry col desc)
+        (tabulated-list--col-max-widths))
        (put-text-property pos (point) 'tabulated-list-id id)
        (put-text-property pos (point) 'tabulated-list-entry entry)
        (goto-char opoint))))
-- 
2.10.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.9 (x86_64-pc-linux-gnu, GTK+ Version 3.22.1)
  of 2016-11-01
Repository revision: 8e7b1af1d708dcf41695cf3fbeff9d35cdb8e5b6



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-10-31 17:41 tabulated-list: extend truncation into next align-right col Tino Calancha
@ 2016-10-31 18:40 ` Stefan Monnier
  2016-11-01  3:31   ` Tino Calancha
  2016-10-31 20:15 ` Drew Adams
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2016-10-31 18:40 UTC (permalink / raw)
  To: Tino Calancha; +Cc: Emacs developers

> +  ;; TODO: don't truncate to `width' if the next column is align-right
> +  ;; and has some space left.
[...]
> +(defvar-local tabulated-list--col-max-widths nil

By "some space left" I meant "in the current line", so there shouldn't be
any need to compute the maximum width.


        Stefan



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

* RE: tabulated-list: extend truncation into next align-right col
  2016-10-31 17:41 tabulated-list: extend truncation into next align-right col Tino Calancha
  2016-10-31 18:40 ` Stefan Monnier
@ 2016-10-31 20:15 ` Drew Adams
  2016-10-31 20:47   ` Mark Oteiza
  1 sibling, 1 reply; 19+ messages in thread
From: Drew Adams @ 2016-10-31 20:15 UTC (permalink / raw)
  To: Tino Calancha; +Cc: Emacs developers

> +(eval-when-compile (require 'cl-lib))

Why?  Did I miss something, or is `cl-loop' all you need/want?

If it is, then `cl-macs.el' should be all you need at compile time.
Requiring only what you need makes the dependencies clearer (IMO).




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

* Re: tabulated-list: extend truncation into next align-right col
  2016-10-31 20:15 ` Drew Adams
@ 2016-10-31 20:47   ` Mark Oteiza
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Oteiza @ 2016-10-31 20:47 UTC (permalink / raw)
  To: Drew Adams; +Cc: Emacs developers, Tino Calancha


Drew Adams <drew.adams@oracle.com> writes:
>> +(eval-when-compile (require 'cl-lib))
>
> Why?  Did I miss something, or is `cl-loop' all you need/want?
>
> If it is, then `cl-macs.el' should be all you need at compile time.

What's there is fine: cl-macs requires cl-lib anyways.



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-10-31 18:40 ` Stefan Monnier
@ 2016-11-01  3:31   ` Tino Calancha
  2016-11-01 12:41     ` Stefan Monnier
  0 siblings, 1 reply; 19+ messages in thread
From: Tino Calancha @ 2016-11-01  3:31 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers, Tino Calancha



On Mon, 31 Oct 2016, Stefan Monnier wrote:

>> +  ;; TODO: don't truncate to `width' if the next column is align-right
>> +  ;; and has some space left.
> [...]
>> +(defvar-local tabulated-list--col-max-widths nil
>
> By "some space left" I meant "in the current line", so there shouldn't be
> any need to compute the maximum width.
Yeah, but we must preserve the legibility of the table.

If we calculate the maximum widths and we restrict the
truncation until one well-defined limit, then the table
looks nicer.

For instance, compare following two tables:

;; Without computing maximum widths:
C1  C2                                       Numbers
abc **************************************... 123456
abc *******************************************... 1
abc ************************************         123

;; With `tabulated-list--col-max-widths':
C1  C2                                       Numbers
abc **************************************... 123456
abc **************************************...      1
abc ************************************         123

With many rows this effect might have an impact on table
readability.



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-01  3:31   ` Tino Calancha
@ 2016-11-01 12:41     ` Stefan Monnier
  2016-11-01 13:25       ` Tino Calancha
  2016-11-01 18:25       ` Tino Calancha
  0 siblings, 2 replies; 19+ messages in thread
From: Stefan Monnier @ 2016-11-01 12:41 UTC (permalink / raw)
  To: Tino Calancha; +Cc: Emacs developers

> ;; Without computing maximum widths:
> C1  C2                                       Numbers
> abc **************************************... 123456
> abc *******************************************... 1
> abc ************************************         123

That's exactly what used to happen in *Buffer List* (and the source for
this TODO item).  It wasn't that bad (I can't remember any user
complaints about it).  Admittedly, we could do better: compute the max
width not of the whole column but of the current line, and the two
surrounding ones.  This way we'd avoid

    abc **************************************... 123456
    abc *****************************************... 123
    abc ************************************         456

yet we'd allow

    abc **************************************... 123456
    abc **************************************...    123
    abc *****************************************...   1


-- Stefan



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-01 12:41     ` Stefan Monnier
@ 2016-11-01 13:25       ` Tino Calancha
  2016-11-01 18:25       ` Tino Calancha
  1 sibling, 0 replies; 19+ messages in thread
From: Tino Calancha @ 2016-11-01 13:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers, Tino Calancha



On Tue, 1 Nov 2016, Stefan Monnier wrote:

>> ;; Without computing maximum widths:
>> C1  C2                                       Numbers
>> abc **************************************... 123456
>> abc *******************************************... 1
>> abc ************************************         123
>
> That's exactly what used to happen in *Buffer List* (and the source for
> this TODO item).  It wasn't that bad (I can't remember any user
> complaints about it).
For *Buffer List* maybe was OK that old way.  My concern is that
`tabulated-list' is still a young lib (2011) in an Emacs scale and
a general tool;  that funny truncations might look uglier in future
applications using this lib.

> Admittedly, we could do better: compute the max
> width not of the whole column but of the current line, and the two
> surrounding ones.  This way we'd avoid
>
>    abc **************************************... 123456
>    abc *****************************************... 123
>    abc ************************************         456
>
> yet we'd allow
>
>    abc **************************************... 123456
>    abc **************************************...    123
>    abc *****************************************...   1

Thanks for this suggestion.
This might be good: we get generally longer truncations.  I am
not sure how it looks in big tables, but i can test it.

I will prepare a patch for this alternative truncation.

Tino



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-01 12:41     ` Stefan Monnier
  2016-11-01 13:25       ` Tino Calancha
@ 2016-11-01 18:25       ` Tino Calancha
  2016-11-02  0:38         ` Stefan Monnier
  2016-11-02 12:27         ` Stefan Monnier
  1 sibling, 2 replies; 19+ messages in thread
From: Tino Calancha @ 2016-11-01 18:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers, Tino Calancha

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



On Tue, 1 Nov 2016, Stefan Monnier wrote:

>> ;; Without computing maximum widths:
>> C1  C2                                       Numbers
>> abc **************************************... 123456
>> abc *******************************************... 1
>> abc ************************************         123
>
> That's exactly what used to happen in *Buffer List* (and the source for
> this TODO item).  It wasn't that bad (I can't remember any user
> complaints about it).  Admittedly, we could do better: compute the max
> width not of the whole column but of the current line, and the two
> surrounding ones.  This way we'd avoid
We have now also a patch for that approach.

Following is a comparison of:
I) The classical: The current behaviour in master branch.
II) The shy one: Using previous patch, i.e., computing the maximum width in the
     whole column.  Note how, for every row, he feel shy to enter in Score column :-)
III) The brother-in-law: Using new patch, i.e., computing the local maximum width in the
     column around the target row.  Note how he enter in your score column, open your
     fridge without asking perm. and collect one of your favourite beers :-S

;; I) current behaviour: truncate until column width (50 in Comment column):
M Name            Date             Comment                                                    Score ▼
   Foo Tree        2016-11-02 02:51 ******************************************line ...               5
D Bar Soup        2016-11-02 02:51 line with 23 characters                                         15
* Baz Silver      2016-11-02 02:51 ***************************line with 50 characters          210000
   Qux Spec        2016-11-02 02:51 ********************************line with 55 ch...          380000

;; II) Previous patch; compute maximum in column:
M Name            Date             Comment                                                    Score ▼
   Foo Tree        2016-11-02 02:30 ******************************************line with 65 c...      5
D Bar Soup        2016-11-02 02:30 line with 23 characters                                         15
* Baz Silver      2016-11-02 02:30 ***************************line with 50 characters          210000
   Qux Spec        2016-11-02 02:30 ********************************line with 55 characters     380000

;; III) New patch; compute local maximum in column around target row:
M Name            Date             Comment                                                    Score ▼
   Foo Tree        2016-11-02 02:30 ******************************************line with 65 chara...  5
D Bar Soup        2016-11-02 02:30 line with 23 characters                                         15
* Baz Silver      2016-11-02 02:30 ***************************line with 50 characters          210000
   Qux Spec        2016-11-02 02:30 ********************************line with 55 characters     380000

So, from previous e-mail exchange i guess you prefer III) right?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 6512184ccb8127d94410d56f147de9ecadc932c6 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Wed, 2 Nov 2016 02:20:14 +0900
Subject: [PATCH] tabulated-list: extend truncation into next align-right
  column

See discussion on:
https://lists.gnu.org/archive/html/emacs-devel/2016-10/msg01101.html
* lisp/emacs-lisp/tabulated-list.el
(tabulated-list--near-cols-max-widths): New defun.
(tabulated-list-print-col): Use it.  If the next column is
align-right, and has some space left then don't truncate to width,
use some of the available space from the next column.
---
  lisp/emacs-lisp/tabulated-list.el | 54 +++++++++++++++++++++++++++++++++------
  1 file changed, 46 insertions(+), 8 deletions(-)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 00b029d..085fe6f 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -298,6 +298,27 @@ tabulated-list--get-sorter
            (lambda (a b) (not (funcall sorter a b)))
          sorter))))

+(defun tabulated-list--near-cols-max-widths (row col)
+  (let ((entries (if (functionp tabulated-list-entries)
+                     (funcall tabulated-list-entries)
+                   tabulated-list-entries)))
+    (let* ((entry (nth row entries))
+           (entry-up (if (> row 0)
+                         (nth (1- row) entries)
+                       entry))
+           (entry-down (if (< row (1- (length entries)))
+                           (nth (1+ row) entries)
+                         entry))
+           (desc (elt (cadr entry) col))
+           (desc-up (elt (cadr entry-up) col))
+           (desc-down (elt (cadr entry-down) col)))
+      (apply #'max (mapcar (lambda (x)
+                             (string-width
+                              (if (stringp x)
+                                  x
+                                (car x))))
+                           (list desc desc-up desc-down))))))
+
  (defun tabulated-list-print (&optional remember-pos update)
    "Populate the current Tabulated List mode buffer.
  This sorts the `tabulated-list-entries' list if sorting is
@@ -402,8 +423,6 @@ tabulated-list-print-col
  N is the column number, COL-DESC is a column descriptor (see
  `tabulated-list-entries'), and X is the column number at point.
  Return the column number after insertion."
-  ;; TODO: don't truncate to `width' if the next column is align-right
-  ;; and has some space left.
    (let* ((format    (aref tabulated-list-format n))
  	 (name      (nth 0 format))
  	 (width     (nth 1 format))
@@ -414,12 +433,31 @@ tabulated-list-print-col
           (label-width (string-width label))
  	 (help-echo (concat (car format) ": " label))
  	 (opoint (point))
-	 (not-last-col (< (1+ n) (length tabulated-list-format))))
+	 (not-last-col (< (1+ n) (length tabulated-list-format)))
+	  available-space)
+    (when not-last-col
+      (let* ((next-col-format (aref tabulated-list-format (1+ n)))
+             (next-col-right-align (plist-get (nthcdr 3 next-col-format)
+                                              :right-align))
+             (next-col-width (nth 1 next-col-format)))
+        (setq available-space
+              (if (and (not right-align)
+                       next-col-right-align)
+                  (-
+                   (+ width next-col-width)
+                   (min next-col-width
+                        (tabulated-list--near-cols-max-widths
+                         (1- (line-number-at-pos))
+                         (1+ n))))
+                width))))
      ;; Truncate labels if necessary (except last column).
-    (and not-last-col
-	 (> label-width width)
-	 (setq label (truncate-string-to-width label width nil nil t)
-               label-width width))
+    ;; Don't truncate to `width' if the next column is align-right
+    ;; and has some space left, truncate to `available-space' instead.
+    (when (and not-last-col
+               (> label-width available-space)
+               (setq label (truncate-string-to-width
+                            label available-space nil nil t)
+                     label-width available-space)))
      (setq label (bidi-string-mark-left-to-right label))
      (when (and right-align (> width label-width))
        (let ((shift (- width label-width)))
@@ -437,7 +475,7 @@ tabulated-list-print-col
        (when not-last-col
          (when (> pad-right 0) (insert (make-string pad-right ?\s)))
          (insert (propertize
-                 (make-string (- next-x x label-width pad-right) ?\s)
+                 (make-string (- width (min width label-width)) ?\s)
                   'display `(space :align-to ,next-x))))
        (put-text-property opoint (point) 'tabulated-list-column-name name)
        next-x)))
-- 
2.10.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.3 (x86_64-pc-linux-gnu, GTK+ Version 3.22.2)
  of 2016-11-02 built on calancha-pc
Repository revision: c3640fcc96ed80368209c73d7ac9a0f0d1833d93

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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-01 18:25       ` Tino Calancha
@ 2016-11-02  0:38         ` Stefan Monnier
  2016-11-02  5:06           ` Tino Calancha
  2016-11-02 12:27         ` Stefan Monnier
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2016-11-02  0:38 UTC (permalink / raw)
  To: Tino Calancha; +Cc: Emacs developers

> So, from previous e-mail exchange i guess you prefer III) right?

Yes.  Obviously, I have the `list-buffers` case in mind.  Maybe it's not
desirable in all contexts, but it's worth a try.


        Stefan



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-02  0:38         ` Stefan Monnier
@ 2016-11-02  5:06           ` Tino Calancha
  2016-11-02  8:20             ` Tino Calancha
  0 siblings, 1 reply; 19+ messages in thread
From: Tino Calancha @ 2016-11-02  5:06 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers, Tino Calancha



On Tue, 1 Nov 2016, Stefan Monnier wrote:

>> So, from previous e-mail exchange i guess you prefer III) right?
>
> Yes.  Obviously, I have the `list-buffers` case in mind.  Maybe it's not
> desirable in all contexts, but it's worth a try.
Maybe one option to enable/disable this extended truncation?
Enable by default?

I suspect my patch naively asumes that we have
`tabulated-list-use-header-line' non-nil, so that buffer line 1
is the first column.  But we might have a fake header there...




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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-02  5:06           ` Tino Calancha
@ 2016-11-02  8:20             ` Tino Calancha
  0 siblings, 0 replies; 19+ messages in thread
From: Tino Calancha @ 2016-11-02  8:20 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Tino Calancha, Emacs developers

Tino Calancha <tino.calancha@gmail.com> writes:

> I suspect my patch naively asumes that we have
> `tabulated-list-use-header-line' non-nil, so that buffer line 1
> is the first column.  But we might have a fake header there...
In that case, assuming we add the predicate suggested in Bug#24855,
i guess we just need to change:

+                   (min next-col-width
+                        (tabulated-list--near-cols-max-widths
+                         (1- (line-number-at-pos))
+                         (1+ n))))
+                width))))

by the following:

+                   (min next-col-width
+                        (tabulated-list--near-cols-max-widths
+                         (- (line-number-at-pos)
+                            (if (tabulated-list-no-header-p) 1 2))
+                         (1+ n))))
+                width))))



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-01 18:25       ` Tino Calancha
  2016-11-02  0:38         ` Stefan Monnier
@ 2016-11-02 12:27         ` Stefan Monnier
  2016-11-02 15:08           ` Tino Calancha
  2016-11-04 14:35           ` Tino Calancha
  1 sibling, 2 replies; 19+ messages in thread
From: Stefan Monnier @ 2016-11-02 12:27 UTC (permalink / raw)
  To: emacs-devel

> +                   (min next-col-width
> +                        (tabulated-list--near-cols-max-widths
> +                         (1- (line-number-at-pos))

Hmm... this (line-number-at-pos) and the inverse `nth` inside
tabulated-list--near-cols-max-widths are both O(N), and since we go
through this loop N times, this gives us an O(N^2) complexity.

Can't we just get "the next row" and "the previous row" more directly?


        Stefan




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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-02 12:27         ` Stefan Monnier
@ 2016-11-02 15:08           ` Tino Calancha
  2016-11-02 15:16             ` Tino Calancha
  2016-11-04 14:35           ` Tino Calancha
  1 sibling, 1 reply; 19+ messages in thread
From: Tino Calancha @ 2016-11-02 15:08 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: tino.calancha, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> +                   (min next-col-width
>> +                        (tabulated-list--near-cols-max-widths
>> +                         (1- (line-number-at-pos))
>
> Hmm... this (line-number-at-pos) and the inverse `nth` inside
> tabulated-list--near-cols-max-widths are both O(N), and since we go
> through this loop N times, this gives us an O(N^2) complexity.
>
> Can't we just get "the next row" and "the previous row" more directly?

We might introduce one variable `tabulated-list--current-row'.
Please, let me know if there is a cleaner way.

It might be convenient to define the predicate mentioned in Bug#24855.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From fdd805264d19b46c81a2abc42d47e0e403395a5e Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Thu, 3 Nov 2016 00:01:11 +0900
Subject: [PATCH] tabulated-list: extend truncation into next align-right
 column

See discussion on:
https://lists.gnu.org/archive/html/emacs-devel/2016-10/msg01101.html
* lisp/emacs-lisp/tabulated-list.el
(tabulated-list--current-row): New variable.
(tabulated-list-print, tabulated-list-set-col): Use it.
(tabulated-list--next-col-local-max-widths): New defun.
(tabulated-list-print-col): Use it.  If the next column is
align-right, and has some space left then don't truncate to width,
use some of the available space from the next column.
---
 lisp/emacs-lisp/tabulated-list.el | 63 +++++++++++++++++++++++++++++++++------
 1 file changed, 54 insertions(+), 9 deletions(-)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 00b029d..cc91ae0 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -102,6 +102,8 @@ tabulated-list-printer
 object identifying the entry, and COLS is a vector of column
 descriptors, as documented in `tabulated-list-entries'.")
 
+(defvar tabulated-list--current-row)
+
 (defvar-local tabulated-list-sort-key nil
   "Sort key for the current Tabulated List mode buffer.
 If nil, no additional sorting is performed.
@@ -298,6 +300,28 @@ tabulated-list--get-sorter
           (lambda (a b) (not (funcall sorter a b)))
         sorter))))
 
+(defun tabulated-list--next-col-local-max-widths (col)
+  (let ((entries (if (functionp tabulated-list-entries)
+                     (funcall tabulated-list-entries)
+                   tabulated-list-entries)))
+    (let* ((row tabulated-list--current-row)
+           (entry (nth row entries))
+           (entry-up (if (> row 0)
+                         (nth (1- row) entries)
+                       entry))
+           (entry-down (if (< row (1- (length entries)))
+                           (nth (1+ row) entries)
+                         entry))
+           (desc (elt (cadr entry) col))
+           (desc-up (elt (cadr entry-up) col))
+           (desc-down (elt (cadr entry-down) col)))
+      (apply #'max (mapcar (lambda (x)
+                             (string-width
+                              (if (stringp x)
+                                  x
+                                (car x))))
+                           (list desc desc-up desc-down))))))
+
 (defun tabulated-list-print (&optional remember-pos update)
   "Populate the current Tabulated List mode buffer.
 This sorts the `tabulated-list-entries' list if sorting is
@@ -319,6 +343,7 @@ tabulated-list-print
 		     (funcall tabulated-list-entries)
 		   tabulated-list-entries))
         (sorter (tabulated-list--get-sorter))
+        (tabulated-list--current-row -1)
 	entry-id saved-pt saved-col window-line)
     (and remember-pos
 	 (setq entry-id (tabulated-list-get-id))
@@ -341,6 +366,8 @@ tabulated-list-print
         (tabulated-list-print-fake-header)))
     ;; Finally, print the resulting list.
     (dolist (elt entries)
+      (setq tabulated-list--current-row
+            (1+ tabulated-list--current-row))
       (let ((id (car elt)))
         (and entry-id
              (equal entry-id id)
@@ -402,8 +429,6 @@ tabulated-list-print-col
 N is the column number, COL-DESC is a column descriptor (see
 `tabulated-list-entries'), and X is the column number at point.
 Return the column number after insertion."
-  ;; TODO: don't truncate to `width' if the next column is align-right
-  ;; and has some space left.
   (let* ((format    (aref tabulated-list-format n))
 	 (name      (nth 0 format))
 	 (width     (nth 1 format))
@@ -414,12 +439,29 @@ tabulated-list-print-col
          (label-width (string-width label))
 	 (help-echo (concat (car format) ": " label))
 	 (opoint (point))
-	 (not-last-col (< (1+ n) (length tabulated-list-format))))
+	 (not-last-col (< (1+ n) (length tabulated-list-format)))
+	  available-space)
+    (when not-last-col
+      (let* ((next-col-format (aref tabulated-list-format (1+ n)))
+             (next-col-right-align (plist-get (nthcdr 3 next-col-format)
+                                              :right-align))
+             (next-col-width (nth 1 next-col-format)))
+        (setq available-space
+              (if (and (not right-align)
+                       next-col-right-align)
+                  (-
+                   (+ width next-col-width)
+                   (min next-col-width
+                        (tabulated-list--next-col-local-max-widths (1+ n))))
+                width))))
     ;; Truncate labels if necessary (except last column).
-    (and not-last-col
-	 (> label-width width)
-	 (setq label (truncate-string-to-width label width nil nil t)
-               label-width width))
+    ;; Don't truncate to `width' if the next column is align-right
+    ;; and has some space left, truncate to `available-space' instead.
+    (when (and not-last-col
+               (> label-width available-space)
+               (setq label (truncate-string-to-width
+                            label available-space nil nil t)
+                     label-width available-space)))
     (setq label (bidi-string-mark-left-to-right label))
     (when (and right-align (> width label-width))
       (let ((shift (- width label-width)))
@@ -437,7 +479,7 @@ tabulated-list-print-col
       (when not-last-col
         (when (> pad-right 0) (insert (make-string pad-right ?\s)))
         (insert (propertize
-                 (make-string (- next-x x label-width pad-right) ?\s)
+                 (make-string (- width (min width label-width)) ?\s)
                  'display `(space :align-to ,next-x))))
       (put-text-property opoint (point) 'tabulated-list-column-name name)
       next-x)))
@@ -494,7 +536,10 @@ tabulated-list-set-col
     (when (< pos eol)
       (delete-region pos (next-single-property-change pos prop nil eol))
       (goto-char pos)
-      (tabulated-list-print-col col desc (current-column))
+      (let ((tabulated-list--current-row
+             (- (line-number-at-pos)
+                (if (overlays-at (point-min)) 2 1))))
+        (tabulated-list-print-col col desc (current-column)))
       (if change-entry-data
 	  (aset entry col desc))
       (put-text-property pos (point) 'tabulated-list-id id)
-- 
2.10.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.5 (x86_64-pc-linux-gnu, GTK+ Version 3.22.2)
 of 2016-11-02 built on calancha-pc
Repository revision: 126c879df42f741fe486236aea538290a8c2ed64



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-02 15:08           ` Tino Calancha
@ 2016-11-02 15:16             ` Tino Calancha
  0 siblings, 0 replies; 19+ messages in thread
From: Tino Calancha @ 2016-11-02 15:16 UTC (permalink / raw)
  To: Tino Calancha; +Cc: Stefan Monnier, emacs-devel



On Thu, 3 Nov 2016, Tino Calancha wrote:

> It might be convenient to define the predicate mentioned in Bug#24855.
Or just checking the value of `tabulated-list--header-overlay'; but
this is an internal variable... maybe better to add a predicate in
`tabulated-list.el' checking its value.
Then Buffer-menu and other derivated modes could use it.



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-02 12:27         ` Stefan Monnier
  2016-11-02 15:08           ` Tino Calancha
@ 2016-11-04 14:35           ` Tino Calancha
  2016-11-04 16:53             ` Tino Calancha
  2016-11-04 17:29             ` Stefan Monnier
  1 sibling, 2 replies; 19+ messages in thread
From: Tino Calancha @ 2016-11-04 14:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: tino.calancha, emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> +                   (min next-col-width
>> +                        (tabulated-list--near-cols-max-widths
>> +                         (1- (line-number-at-pos))
>
> Hmm... this (line-number-at-pos) and the inverse `nth` inside
> tabulated-list--near-cols-max-widths are both O(N), and since we go
> through this loop N times, this gives us an O(N^2) complexity.
>
> Can't we just get "the next row" and "the previous row" more directly?

I have tested the new patch (see below) with:

(benchmark-run-compiled 1
  (with-current-buffer "*Packages*"
    (let ((inhibit-read-only t)) (erase-buffer))
    (tabulated-list-print)))


I) When `package-archives' equals '(("gnu" . "http://elpa.gnu.org/packages/")),
i get 262 entries and the form above returns: (VALUE 0 0.0).
VALUE fluctuates around (0.012, 0.017).

II) After adding to `package-archives' `melpa' and `marmalade' repositories,
i get 4758 entries and the same form returns:  (VALUE 3 0.3869728290000012).
VALUE fluctuates around (0.71, 0.75).

The ratio on number of entries is N2/N1 = 4758/262 ~ 18.
The ratio of elapsed times is T2/T1 ~ 0.73/0.015 ~ 50 ~ 3 N2/N1.

Quite reasonable, right?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 84c7690717e8b59b62cce79f37d89a8acf526b58 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Fri, 4 Nov 2016 23:17:41 +0900
Subject: [PATCH] tabulated-list: extend truncation into next align-right
 column

See discussion on:
https://lists.gnu.org/archive/html/emacs-devel/2016-10/msg01101.html
* lisp/emacs-lisp/tabulated-list.el
(tabulated-list--near-rows): New variable.
(tabulated-list-print, tabulated-list-set-col): Use it.
(tabulated-list--col-local-max-widths): New defsubst.
(tabulated-list-print-col): Use it.  If the next column is
align-right, and has some space left then don't truncate to width,
use some of the available space from the next column.
---
 lisp/emacs-lisp/tabulated-list.el | 55 ++++++++++++++++++++++++++++++++-------
 1 file changed, 45 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 00b029d..7f05b34 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -102,6 +102,8 @@ tabulated-list-printer
 object identifying the entry, and COLS is a vector of column
 descriptors, as documented in `tabulated-list-entries'.")
 
+(defvar tabulated-list--near-rows)
+
 (defvar-local tabulated-list-sort-key nil
   "Sort key for the current Tabulated List mode buffer.
 If nil, no additional sorting is performed.
@@ -298,6 +300,14 @@ tabulated-list--get-sorter
           (lambda (a b) (not (funcall sorter a b)))
         sorter))))
 
+(defsubst tabulated-list--col-local-max-widths (col)
+   "Return maximum entry widths at column COL around current row.
+Check the current row, the previous one and the next row."
+  (apply #'max (mapcar (lambda (x)
+                         (let ((nt (elt x col)))
+                           (string-width (if (stringp nt) nt (car nt)))))
+                       tabulated-list--near-rows)))
+
 (defun tabulated-list-print (&optional remember-pos update)
   "Populate the current Tabulated List mode buffer.
 This sorts the `tabulated-list-entries' list if sorting is
@@ -341,7 +351,12 @@ tabulated-list-print
         (tabulated-list-print-fake-header)))
     ;; Finally, print the resulting list.
     (dolist (elt entries)
-      (let ((id (car elt)))
+      (let ((tabulated-list--near-rows
+             (list
+              (or (tabulated-list-get-entry (point-at-bol 0)) (cadr elt))
+              (cadr elt)
+              (or (cadr (cadr entries)) (cadr elt))))
+            (id (car elt)))
         (and entry-id
              (equal entry-id id)
              (setq entry-id nil
@@ -402,8 +417,6 @@ tabulated-list-print-col
 N is the column number, COL-DESC is a column descriptor (see
 `tabulated-list-entries'), and X is the column number at point.
 Return the column number after insertion."
-  ;; TODO: don't truncate to `width' if the next column is align-right
-  ;; and has some space left.
   (let* ((format    (aref tabulated-list-format n))
 	 (name      (nth 0 format))
 	 (width     (nth 1 format))
@@ -414,12 +427,29 @@ tabulated-list-print-col
          (label-width (string-width label))
 	 (help-echo (concat (car format) ": " label))
 	 (opoint (point))
-	 (not-last-col (< (1+ n) (length tabulated-list-format))))
+	 (not-last-col (< (1+ n) (length tabulated-list-format)))
+	  available-space)
+    (when not-last-col
+      (let* ((next-col-format (aref tabulated-list-format (1+ n)))
+             (next-col-right-align (plist-get (nthcdr 3 next-col-format)
+                                              :right-align))
+             (next-col-width (nth 1 next-col-format)))
+        (setq available-space
+              (if (and (not right-align)
+                       next-col-right-align)
+                  (-
+                   (+ width next-col-width)
+                   (min next-col-width
+                        (tabulated-list--col-local-max-widths (1+ n))))
+                width))))
     ;; Truncate labels if necessary (except last column).
-    (and not-last-col
-	 (> label-width width)
-	 (setq label (truncate-string-to-width label width nil nil t)
-               label-width width))
+    ;; Don't truncate to `width' if the next column is align-right
+    ;; and has some space left, truncate to `available-space' instead.
+    (when (and not-last-col
+               (> label-width available-space)
+               (setq label (truncate-string-to-width
+                            label available-space nil nil t)
+                     label-width available-space)))
     (setq label (bidi-string-mark-left-to-right label))
     (when (and right-align (> width label-width))
       (let ((shift (- width label-width)))
@@ -437,7 +467,7 @@ tabulated-list-print-col
       (when not-last-col
         (when (> pad-right 0) (insert (make-string pad-right ?\s)))
         (insert (propertize
-                 (make-string (- next-x x label-width pad-right) ?\s)
+                 (make-string (- width (min width label-width)) ?\s)
                  'display `(space :align-to ,next-x))))
       (put-text-property opoint (point) 'tabulated-list-column-name name)
       next-x)))
@@ -494,7 +524,12 @@ tabulated-list-set-col
     (when (< pos eol)
       (delete-region pos (next-single-property-change pos prop nil eol))
       (goto-char pos)
-      (tabulated-list-print-col col desc (current-column))
+      (let ((tabulated-list--near-rows
+             (list
+              (tabulated-list-get-entry (point-at-bol 0))
+              entry
+              (or (tabulated-list-get-entry (point-at-bol 2)) entry))))
+        (tabulated-list-print-col col desc (current-column)))
       (if change-entry-data
 	  (aset entry col desc))
       (put-text-property pos (point) 'tabulated-list-id id)
-- 
2.10.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.2)
 of 2016-11-03 built on calancha-pc
Repository revision: 86bec41906c17f3b96288bd34ac0f835cde88a27



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-04 14:35           ` Tino Calancha
@ 2016-11-04 16:53             ` Tino Calancha
  2016-11-04 17:29             ` Stefan Monnier
  1 sibling, 0 replies; 19+ messages in thread
From: Tino Calancha @ 2016-11-04 16:53 UTC (permalink / raw)
  To: Tino Calancha; +Cc: tino.calancha, emacs-devel

Tino Calancha <tino.calancha@gmail.com> writes:

> I have tested the new patch (see below) with:
>
> (benchmark-run-compiled 1
>   (with-current-buffer "*Packages*"
>     (let ((inhibit-read-only t)) (erase-buffer))
>     (tabulated-list-print)))

Well, in previous patch i need to change
(dolist (elt entries)
  by
(while entries  
because i refer sometimes to the variable `entries'.
This change doesn't affect previous benchmark numbers.


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
From 366cbd3db74890cfb3cab006d6403b75027d55f0 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Sat, 5 Nov 2016 01:45:34 +0900
Subject: [PATCH] tabulated-list: extend truncation into next align-right
 column

See discussion on:
https://lists.gnu.org/archive/html/emacs-devel/2016-10/msg01101.html
* lisp/emacs-lisp/tabulated-list.el
(tabulated-list--near-rows): New variable.
(tabulated-list-print, tabulated-list-set-col): Use it.
(tabulated-list--col-local-max-widths): New defsubst.
(tabulated-list-print-col): Use it.  If the next column is
align-right, and has some space left then don't truncate to width,
use some of the available space from the next column.
---
 lisp/emacs-lisp/tabulated-list.el | 61 +++++++++++++++++++++++++++++++--------
 1 file changed, 49 insertions(+), 12 deletions(-)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index 00b029d..cf297f1 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -102,6 +102,8 @@ tabulated-list-printer
 object identifying the entry, and COLS is a vector of column
 descriptors, as documented in `tabulated-list-entries'.")
 
+(defvar tabulated-list--near-rows)
+
 (defvar-local tabulated-list-sort-key nil
   "Sort key for the current Tabulated List mode buffer.
 If nil, no additional sorting is performed.
@@ -298,6 +300,14 @@ tabulated-list--get-sorter
           (lambda (a b) (not (funcall sorter a b)))
         sorter))))
 
+(defsubst tabulated-list--col-local-max-widths (col)
+   "Return maximum entry widths at column COL around current row.
+Check the current row, the previous one and the next row."
+  (apply #'max (mapcar (lambda (x)
+                         (let ((nt (elt x col)))
+                           (string-width (if (stringp nt) nt (car nt)))))
+                       tabulated-list--near-rows)))
+
 (defun tabulated-list-print (&optional remember-pos update)
   "Populate the current Tabulated List mode buffer.
 This sorts the `tabulated-list-entries' list if sorting is
@@ -340,8 +350,14 @@ tabulated-list-print
       (unless tabulated-list-use-header-line
         (tabulated-list-print-fake-header)))
     ;; Finally, print the resulting list.
-    (dolist (elt entries)
-      (let ((id (car elt)))
+    (while entries
+      (let* ((elt (car entries))
+             (tabulated-list--near-rows
+              (list
+               (or (tabulated-list-get-entry (point-at-bol 0)) (cadr elt))
+               (cadr elt)
+               (or (cadr (cadr entries)) (cadr elt))))
+             (id (car elt)))
         (and entry-id
              (equal entry-id id)
              (setq entry-id nil
@@ -368,7 +384,8 @@ tabulated-list-print
                          (t t)))
             (let ((old (point)))
               (forward-line 1)
-              (delete-region old (point)))))))
+              (delete-region old (point))))))
+      (setq entries (cdr entries)))
     (set-buffer-modified-p nil)
     ;; If REMEMBER-POS was specified, move to the "old" location.
     (if saved-pt
@@ -402,8 +419,6 @@ tabulated-list-print-col
 N is the column number, COL-DESC is a column descriptor (see
 `tabulated-list-entries'), and X is the column number at point.
 Return the column number after insertion."
-  ;; TODO: don't truncate to `width' if the next column is align-right
-  ;; and has some space left.
   (let* ((format    (aref tabulated-list-format n))
 	 (name      (nth 0 format))
 	 (width     (nth 1 format))
@@ -414,12 +429,29 @@ tabulated-list-print-col
          (label-width (string-width label))
 	 (help-echo (concat (car format) ": " label))
 	 (opoint (point))
-	 (not-last-col (< (1+ n) (length tabulated-list-format))))
+	 (not-last-col (< (1+ n) (length tabulated-list-format)))
+	  available-space)
+    (when not-last-col
+      (let* ((next-col-format (aref tabulated-list-format (1+ n)))
+             (next-col-right-align (plist-get (nthcdr 3 next-col-format)
+                                              :right-align))
+             (next-col-width (nth 1 next-col-format)))
+        (setq available-space
+              (if (and (not right-align)
+                       next-col-right-align)
+                  (-
+                   (+ width next-col-width)
+                   (min next-col-width
+                        (tabulated-list--col-local-max-widths (1+ n))))
+                width))))
     ;; Truncate labels if necessary (except last column).
-    (and not-last-col
-	 (> label-width width)
-	 (setq label (truncate-string-to-width label width nil nil t)
-               label-width width))
+    ;; Don't truncate to `width' if the next column is align-right
+    ;; and has some space left, truncate to `available-space' instead.
+    (when (and not-last-col
+               (> label-width available-space)
+               (setq label (truncate-string-to-width
+                            label available-space nil nil t)
+                     label-width available-space)))
     (setq label (bidi-string-mark-left-to-right label))
     (when (and right-align (> width label-width))
       (let ((shift (- width label-width)))
@@ -437,7 +469,7 @@ tabulated-list-print-col
       (when not-last-col
         (when (> pad-right 0) (insert (make-string pad-right ?\s)))
         (insert (propertize
-                 (make-string (- next-x x label-width pad-right) ?\s)
+                 (make-string (- width (min width label-width)) ?\s)
                  'display `(space :align-to ,next-x))))
       (put-text-property opoint (point) 'tabulated-list-column-name name)
       next-x)))
@@ -494,7 +526,12 @@ tabulated-list-set-col
     (when (< pos eol)
       (delete-region pos (next-single-property-change pos prop nil eol))
       (goto-char pos)
-      (tabulated-list-print-col col desc (current-column))
+      (let ((tabulated-list--near-rows
+             (list
+              (tabulated-list-get-entry (point-at-bol 0))
+              entry
+              (or (tabulated-list-get-entry (point-at-bol 2)) entry))))
+        (tabulated-list-print-col col desc (current-column)))
       (if change-entry-data
 	  (aset entry col desc))
       (put-text-property pos (point) 'tabulated-list-id id)
-- 
2.10.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.2)
 of 2016-11-03 built on calancha-pc
Repository revision: abe594c0990a4e6bc72b20b7ff06b4b0c01a682c



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-04 14:35           ` Tino Calancha
  2016-11-04 16:53             ` Tino Calancha
@ 2016-11-04 17:29             ` Stefan Monnier
  2016-11-07  1:59               ` Tino Calancha
  1 sibling, 1 reply; 19+ messages in thread
From: Stefan Monnier @ 2016-11-04 17:29 UTC (permalink / raw)
  To: Tino Calancha; +Cc: emacs-devel

> The ratio on number of entries is N2/N1 = 4758/262 ~ 18.
> The ratio of elapsed times is T2/T1 ~ 0.73/0.015 ~ 50 ~ 3 N2/N1.

> Quite reasonable, right?

Good enough for now, I guess.


        Stefan



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-04 17:29             ` Stefan Monnier
@ 2016-11-07  1:59               ` Tino Calancha
  2016-11-14  8:43                 ` Tino Calancha
  0 siblings, 1 reply; 19+ messages in thread
From: Tino Calancha @ 2016-11-07  1:59 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers, Tino Calancha



On Fri, 4 Nov 2016, Stefan Monnier wrote:

>> The ratio on number of entries is N2/N1 = 4758/262 ~ 18.
>> The ratio of elapsed times is T2/T1 ~ 0.73/0.015 ~ 50 ~ 3 N2/N1.
>
>> Quite reasonable, right?
>
> Good enough for now, I guess.
>
>
>        Stefan
OK.  Thank you very much.
Then, I will push it to master if there is no further comments in 1 week 
from now.



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

* Re: tabulated-list: extend truncation into next align-right col
  2016-11-07  1:59               ` Tino Calancha
@ 2016-11-14  8:43                 ` Tino Calancha
  0 siblings, 0 replies; 19+ messages in thread
From: Tino Calancha @ 2016-11-14  8:43 UTC (permalink / raw)
  To: Emacs developers; +Cc: Tino Calancha



On Mon, 7 Nov 2016, Tino Calancha wrote:

>
>
> On Fri, 4 Nov 2016, Stefan Monnier wrote:
>
>>> The ratio on number of entries is N2/N1 = 4758/262 ~ 18.
>>> The ratio of elapsed times is T2/T1 ~ 0.73/0.015 ~ 50 ~ 3 N2/N1.
>> 
>>> Quite reasonable, right?
>> 
>> Good enough for now, I guess.
>> 
>>
>>        Stefan
> OK.  Thank you very much.
> Then, I will push it to master if there is no further comments in 1 week from 
> now.
Pushed to master as commit: db43613



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

end of thread, other threads:[~2016-11-14  8:43 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-31 17:41 tabulated-list: extend truncation into next align-right col Tino Calancha
2016-10-31 18:40 ` Stefan Monnier
2016-11-01  3:31   ` Tino Calancha
2016-11-01 12:41     ` Stefan Monnier
2016-11-01 13:25       ` Tino Calancha
2016-11-01 18:25       ` Tino Calancha
2016-11-02  0:38         ` Stefan Monnier
2016-11-02  5:06           ` Tino Calancha
2016-11-02  8:20             ` Tino Calancha
2016-11-02 12:27         ` Stefan Monnier
2016-11-02 15:08           ` Tino Calancha
2016-11-02 15:16             ` Tino Calancha
2016-11-04 14:35           ` Tino Calancha
2016-11-04 16:53             ` Tino Calancha
2016-11-04 17:29             ` Stefan Monnier
2016-11-07  1:59               ` Tino Calancha
2016-11-14  8:43                 ` Tino Calancha
2016-10-31 20:15 ` Drew Adams
2016-10-31 20:47   ` Mark Oteiza

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