From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.bugs Subject: bug#37179: 27.0.50; tabulated-list-mode creates obsolete empty line on the end Date: Mon, 19 Oct 2020 09:41:00 +0300 Message-ID: <20201019064100.GC5209@protected.rcdrun.com> References: <86a7bxy52a.fsf@protected.rcdrun.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33168"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.10.1 (2018-07-13) Cc: 37179@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 19 08:43:47 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUOtV-0008V1-Ro for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Oct 2020 08:43:45 +0200 Original-Received: from localhost ([::1]:60468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUOtU-0006eA-FO for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Oct 2020 02:43:44 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUOt2-0006dm-B4 for bug-gnu-emacs@gnu.org; Mon, 19 Oct 2020 02:43:16 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:56395) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUOt2-0000Sg-1f for bug-gnu-emacs@gnu.org; Mon, 19 Oct 2020 02:43:16 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kUOt1-0000aS-8L for bug-gnu-emacs@gnu.org; Mon, 19 Oct 2020 02:43:15 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jean Louis Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Oct 2020 06:43:14 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37179 X-GNU-PR-Package: emacs Original-Received: via spool by 37179-submit@debbugs.gnu.org id=B37179.16030897362170 (code B ref 37179); Mon, 19 Oct 2020 06:43:14 +0000 Original-Received: (at 37179) by debbugs.gnu.org; 19 Oct 2020 06:42:16 +0000 Original-Received: from localhost ([127.0.0.1]:39708 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUOrr-0000Yc-5b for submit@debbugs.gnu.org; Mon, 19 Oct 2020 02:42:13 -0400 Original-Received: from static.rcdrun.com ([95.85.24.50]:54039) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kUOqv-0000TW-4O for 37179@debbugs.gnu.org; Mon, 19 Oct 2020 02:41:53 -0400 Original-Received: from localhost ([::ffff:41.202.241.51]) (AUTH: PLAIN admin, TLS: TLS1.2,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by static.rcdrun.com with ESMTPSA id 00000000002A0B3E.000000005F8D34FF.000026E2; Mon, 19 Oct 2020 06:41:02 +0000 Content-Disposition: inline In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:190947 Archived-At: I have tried that, and I like previous behavior so much more, as in tabulated mode, the cursor then escapes on the end of line, which is really not intended so. In my opinion it is better to leave it as it is, and that I improve my personal program that stops reacting on the end of line. Jean * Stefan Kangas [2020-10-19 02:56]: > Jean Louis writes: > > > Here is sample demonstration: > > > > (define-derived-mode my-mode tabulated-list-mode "My Mode" "My mode" > > (setq tabulated-list-format [("ID" 5 t . (:right-align t)) > > ("Hyperlink" 30 t) > > ("Type" 10 t)]) > > (setq tabulated-list-padding 1) > > (setq tabulated-list-sort-key (cons "ID" nil)) > > (tabulated-list-init-header)) > > > > (defun my-set-list (&optional parent) > > (interactive) > > (let ((buffer "*Hyperspace*")) > > (pop-to-buffer buffer nil) > > (read-only-mode 0) > > (erase-buffer) > > (read-only-mode 1) > > (my-mode) > > (hl-line-mode) > > (setq tabulated-list-entries (list > > (list "1" ["1" "Link 1" "Type"]) > > (list "2" ["2" "Link 2" "Type"]))) > > (tabulated-list-print t))) > > > > When it is defined the M-x my-set-list allows me to go after the last > > line. Yet that is not logical, and empty line shall not be displayed, as > > it does not exist in the tabulated-list-entries variable. > > > > Video demonstration 1MB: > > https://gnu.support/images/2019/08/2019-08-25/2019-08-25-11:15:46.ogv > > I tend to agree; there doesn't seem to be any point to go to a line > after the last entry. > > But this issue is not unique to tabulated-list-mode, and in fact crops > up in all kinds of places in Emacs. IME, the usual solution is to just > leave the final newline, and maybe there are good reasons for that. See > Dired for example, or Gnus. > > As an experiment, I came up with the attached patch that removes the > final newline in `tabulated-list-mode'. As expected, it is not without > issues: `end-of-buffer' leaves point at the end of last line. If that > line is very long, we can end up scrolled far to the right, which is > rather unsettling. Another thing that may or may not be problematic (I > didn't test it) is if we have commands that operate on regions of lines. > > So I'm not exactly sure what to do here. Perhaps we should just leave > it alone... Or maybe there is some smart solution just waiting to be > discovered. > > Does anyone else have any comments? > diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el > index 2f7899ec51..7079eaad03 100644 > --- a/lisp/emacs-lisp/tabulated-list.el > +++ b/lisp/emacs-lisp/tabulated-list.el > @@ -480,6 +480,11 @@ tabulated-list-print > (forward-line 1) > (delete-region old (point)))))) > (setq entries (cdr entries))) > + ;; Remove empty last line. > + (save-excursion > + (let ((inhibit-read-only t)) > + (goto-char (point-max)) > + (delete-char -1))) > (set-buffer-modified-p nil) > ;; If REMEMBER-POS was specified, move to the "old" location. > (if saved-pt