emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Tab advance for tabulated-list-mode [CODE ATTACHED]


From: Boruch Baum
Subject: Tab advance for tabulated-list-mode [CODE ATTACHED]
Date: Sun, 17 Jan 2021 02:17:59 -0500
User-agent: NeoMutt/20180716

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 via email to

[Prev in Thread] Current Thread [Next in Thread]