unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: "Peter Feigl" <peter.feigl@nexoid.at>
Cc: 44711@debbugs.gnu.org
Subject: bug#44711: [PATCH] Add movement commands `tabulated-list-next-column' and `tabulated-list-previous-column'
Date: Tue, 17 Nov 2020 18:35:52 +0000	[thread overview]
Message-ID: <873617al13.fsf@tcd.ie> (raw)
In-Reply-To: <87wnyj6fc8.fsf@nexoid.at> (Peter Feigl's message of "Tue, 17 Nov 2020 18:52:23 +0100")

"Peter Feigl" <peter.feigl@nexoid.at> writes:

> The attached patch adds two movement commands,

Thanks, just some minor comments from me.

> +(defun tabulated-list-next-column (&optional arg)
> +  "Go to the start of the next column after point on the current line.
> +If ARG is provided, move that many columns."
> +  (interactive "p")
> +  (dotimes (c (or arg 1))
               ^
The names of unused lexical variables should start with (or consist only
of) an underscore, e.g. '_' or '_c'.  (The byte-compiler should
otherwise complain.)

> +    (let ((next (or (next-single-property-change (point) 'tabulated-list-column-name) (point-max))))

This line is a bit long; suggest breaking the function call across two
lines.  More importantly, why scan all the way to the end of the buffer
if we're only interested in the current line?

> +      (unless (>= next (line-end-position))
> +        (goto-char next)))))

Given my suggestion to limit the search to the current line, this could
be modified along the following lines:

  (dotimes (_ (or arg 1))
    (let* ((eol (line-end-position))
           (next (next-single-property-change
                  (point) 'tabulated-list-column-name nil (1+ eol))))
      (when (< next eol)
        (goto-char next))))

But there's a subtle issue here: some tabulated lists
(e.g. list-buffers) can have an empty final column (e.g. with
non-file-visiting buffers such as *scratch*), but the (< next eol) guard
will not allow point to reach this final empty column, because that
position is at the end of the line.

So I suggest either augmenting the guard to check whether the current
(last) column is empty, or unconditionally allowing point to reach the
end of the line, even if point was already originally in the final
column.

> +(defun tabulated-list-previous-column (&optional arg)

Ditto.

-- 
Basil





  reply	other threads:[~2020-11-17 18:35 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-17 17:52 bug#44711: [PATCH] Add movement commands `tabulated-list-next-column' and `tabulated-list-previous-column' Peter Feigl
2020-11-17 18:35 ` Basil L. Contovounesios [this message]
2020-11-17 19:48 ` Juri Linkov
2020-11-24  8:08 ` Lars Ingebrigtsen
2021-05-13 11:36   ` Lars Ingebrigtsen
2021-05-13 18:08     ` Peter Feigl
2021-06-12 12:12       ` Lars Ingebrigtsen
2021-06-13  3:19         ` Richard Stallman
2021-07-21 12:08         ` Lars Ingebrigtsen
2021-07-21 19:46           ` Peter Feigl
2021-07-25  7:18             ` 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=873617al13.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=44711@debbugs.gnu.org \
    --cc=peter.feigl@nexoid.at \
    /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).