unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Boruch Baum <boruch_baum@gmx.com>
To: Emacs-Devel List <emacs-devel@gnu.org>
Subject: Tab advance for tabulated-list-mode [CODE ATTACHED]
Date: Sun, 17 Jan 2021 02:17:59 -0500	[thread overview]
Message-ID: <20210117071759.ge3gqdnucoc7jrm2@E15-2016.optimum.net> (raw)

Tabulated-list-mode provides for sorting by column at POINT, but not for
navigating by column to quickly get to the column one wishes to sort.
The following code provides that feature.


(defun tabulated-list-tab-backward (&optional n)
  "Navigated N column entries backward in tabulated listing.
Default is to advance one column."
  (interactive "p")
  (crossword-summary-tab-forward (- n)))

(defun tabulated-list-tab-forward (&optional n)
  "Navigate N column entries forward in tabulated listing.
Default is to advance one column."
  (interactive "p")
  (let* ((direction (if (< 0 n)
                      'next-single-property-change
                     (setq n (- n))
                     'previous-single-property-change))
         (pos (point))
         N)
    (dotimes (N n)
      (if (not pos)
        (setq N n)
       (while (and (setq pos (funcall direction pos 'tabulated-list-column-name))
                   (not (get-text-property pos 'tabulated-list-entry))))))
    (goto-char (or pos (if (eq direction 'next-property-change)
                         (point-max)
                        (point-min))))))

(define-key tabulated-list-mode-map "\t"              'tabulated-list-tab-forward)
(define-key tabulated-list-mode-map (kbd "<backtab>") 'tabulated-list-tab-backward)



--
hkp://keys.gnupg.net
CA45 09B5 5351 7C11 A9D1  7286 0036 9E45 1595 8BC0



             reply	other threads:[~2021-01-17  7:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-17  7:17 Boruch Baum [this message]
2021-01-17 11:05 ` Tab advance for tabulated-list-mode [CODE ATTACHED] Daniel Martín
2021-01-17 12:00   ` Boruch Baum
2021-01-17 15:20   ` Stefan Monnier
2021-01-17 16:00     ` Daniel Martín
2021-01-17 18:58       ` Stefan Monnier

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=20210117071759.ge3gqdnucoc7jrm2@E15-2016.optimum.net \
    --to=boruch_baum@gmx.com \
    --cc=emacs-devel@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).