unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50194: 28.0.50; tabulated-list-print (with non-nil UPDATE argument) doesn't clean up excess entries
@ 2021-08-24 18:55 Shitikanth
  2021-08-24 19:13 ` Shitikanth
  0 siblings, 1 reply; 3+ messages in thread
From: Shitikanth @ 2021-08-24 18:55 UTC (permalink / raw)
  To: 50194

(tabulated-list-print nil t) does not seem to clean up excess remaining
entries/lines if the number of tabulated-list-entries has decreased.

Demo:
    (defun demo-generate-entries (n)
        (mapcar (lambda (i)
                  (list i (vector (format "title %s" i))))
                (number-sequence 1 n)))

    (let ((buf (get-buffer-create "*demo*")))
      (with-current-buffer buf
        (tabulated-list-mode)
        (setq tabulated-list-format '[("title" 70 t)])
        (setq tabulated-list-sort-key '("title"))
        (setq tabulated-list-entries (demo-generate-entries 8))
        (tabulated-list-print)
        (pop-to-buffer buf)
        (setq tabulated-list-entries (demo-generate-entries 4))
        (tabulated-list-print nil t)
        ))

Expected behaviour:
At the end, *demo* buffer should show only 4 entries.

Observed behaviour:
*demo* buffer still holds 8 entries, still showing 4 entries that are
now removed from tabulated-list-entries.





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

* bug#50194: 28.0.50; tabulated-list-print (with non-nil UPDATE argument) doesn't clean up excess entries
  2021-08-24 18:55 bug#50194: 28.0.50; tabulated-list-print (with non-nil UPDATE argument) doesn't clean up excess entries Shitikanth
@ 2021-08-24 19:13 ` Shitikanth
  2021-08-25 11:35   ` Lars Ingebrigtsen
  0 siblings, 1 reply; 3+ messages in thread
From: Shitikanth @ 2021-08-24 19:13 UTC (permalink / raw)
  To: 50194

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

Proposed fix.

On Wed, 25 Aug 2021 at 00:26, Shitikanth <shitikanth1@gmail.com> wrote:
>
> (tabulated-list-print nil t) does not seem to clean up excess remaining
> entries/lines if the number of tabulated-list-entries has decreased.
>
> Demo:
>     (defun demo-generate-entries (n)
>         (mapcar (lambda (i)
>                   (list i (vector (format "title %s" i))))
>                 (number-sequence 1 n)))
>
>     (let ((buf (get-buffer-create "*demo*")))
>       (with-current-buffer buf
>         (tabulated-list-mode)
>         (setq tabulated-list-format '[("title" 70 t)])
>         (setq tabulated-list-sort-key '("title"))
>         (setq tabulated-list-entries (demo-generate-entries 8))
>         (tabulated-list-print)
>         (pop-to-buffer buf)
>         (setq tabulated-list-entries (demo-generate-entries 4))
>         (tabulated-list-print nil t)
>         ))
>
> Expected behaviour:
> At the end, *demo* buffer should show only 4 entries.
>
> Observed behaviour:
> *demo* buffer still holds 8 entries, still showing 4 entries that are
> now removed from tabulated-list-entries.
>
>
>

[-- Attachment #2: 0001-tabulated-list-print-delete-excess-lines-bug-50194.patch --]
[-- Type: application/octet-stream, Size: 857 bytes --]

From 3a910de8512c125810f8681b1bcae41fa3135318 Mon Sep 17 00:00:00 2001
From: Shitikanth Kashyap <shitikanth1@gmail.com>
Date: Wed, 25 Aug 2021 00:33:55 +0530
Subject: [PATCH] tabulated-list-print delete excess lines (bug#50194)

---
 lisp/emacs-lisp/tabulated-list.el | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index f0ee78745a..fecfa91147 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -481,6 +481,8 @@ tabulated-list-print
               (forward-line 1)
               (delete-region old (point))))))
       (setq entries (cdr entries)))
+    (when update
+      (delete-region (point) (point-max)))
     (set-buffer-modified-p nil)
     ;; If REMEMBER-POS was specified, move to the "old" location.
     (if saved-pt
-- 
2.25.1


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

* bug#50194: 28.0.50; tabulated-list-print (with non-nil UPDATE argument) doesn't clean up excess entries
  2021-08-24 19:13 ` Shitikanth
@ 2021-08-25 11:35   ` Lars Ingebrigtsen
  0 siblings, 0 replies; 3+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-25 11:35 UTC (permalink / raw)
  To: Shitikanth; +Cc: 50194

Shitikanth <shitikanth1@gmail.com> writes:

> Proposed fix.

Makes sense to me; applied to Emacs 28.

This change was small enough to apply without assigning copyright to the
FSF, but for future patches you want to submit, it might make sense to
get the paperwork started now, so that subsequent patches can be applied
speedily. Would you be willing to sign such paperwork?

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





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

end of thread, other threads:[~2021-08-25 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-24 18:55 bug#50194: 28.0.50; tabulated-list-print (with non-nil UPDATE argument) doesn't clean up excess entries Shitikanth
2021-08-24 19:13 ` Shitikanth
2021-08-25 11:35   ` Lars Ingebrigtsen

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