unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Tab advance for tabulated-list-mode [CODE ATTACHED]
@ 2021-01-17  7:17 Boruch Baum
  2021-01-17 11:05 ` Daniel Martín
  0 siblings, 1 reply; 6+ messages in thread
From: Boruch Baum @ 2021-01-17  7:17 UTC (permalink / raw)
  To: Emacs-Devel List

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



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

end of thread, other threads:[~2021-01-17 18:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-17  7:17 Tab advance for tabulated-list-mode [CODE ATTACHED] Boruch Baum
2021-01-17 11:05 ` 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

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