unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Shitikanth <shitikanth1@gmail.com>
To: 50194@debbugs.gnu.org
Subject: bug#50194: 28.0.50; tabulated-list-print (with non-nil UPDATE argument) doesn't clean up excess entries
Date: Wed, 25 Aug 2021 00:43:11 +0530	[thread overview]
Message-ID: <CALjXJSRs-2v+xhLQmMGs2HZD=efmFtX1GBmSpz1E4BGpMkEMHw@mail.gmail.com> (raw)
In-Reply-To: <CALjXJSTnjJeoNLzLDT_ePEqNQPT_sXMhsAT71BtzYWdDrDCWMA@mail.gmail.com>

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


  reply	other threads:[~2021-08-24 19:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-08-25 11:35   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALjXJSRs-2v+xhLQmMGs2HZD=efmFtX1GBmSpz1E4BGpMkEMHw@mail.gmail.com' \
    --to=shitikanth1@gmail.com \
    --cc=50194@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).