From 92cdba70401663f3765571472af3623db8c7c304 Mon Sep 17 00:00:00 2001 From: Peter Feigl Date: Tue, 17 Nov 2020 18:42:03 +0100 Subject: [PATCH] Add commands to move to next/previous column in tabulated-list-mode. * lisp/emacs-lisp/tabulated-list.el (tabulated-list-mode-map): Add keybindings "b" and "f" (tabulated-list-previous-column tabulated-list-next-column): Implement commands. --- lisp/emacs-lisp/tabulated-list.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index 30577679f2..a19ab00838 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -212,6 +212,8 @@ If ADVANCE is non-nil, move forward by one line afterwards." special-mode-map)) (define-key map "n" 'next-line) (define-key map "p" 'previous-line) + (define-key map "b" 'tabulated-list-previous-column) + (define-key map "f" 'tabulated-list-next-column) (define-key map "S" 'tabulated-list-sort) (define-key map "}" 'tabulated-list-widen-current-column) (define-key map "{" 'tabulated-list-narrow-current-column) @@ -726,6 +728,24 @@ Interactively, N is the prefix numeric argument, and defaults to (setq-local tabulated-list--current-lnum-width lnum-width) (tabulated-list-init-header))))) +(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)) + (let ((next (or (next-single-property-change (point) 'tabulated-list-column-name) (point-max)))) + (unless (>= next (line-end-position)) + (goto-char next))))) + +(defun tabulated-list-previous-column (&optional arg) + "Go to the start of the column point is in on the current line. +If ARG is provided, move that many columns." + (interactive "p") + (dotimes (c (or arg 1)) + (let ((prev (or (previous-single-property-change (point) 'tabulated-list-column-name) 1))) + (unless (< prev (line-beginning-position)) + (goto-char prev))))) + ;;; The mode definition: (define-derived-mode tabulated-list-mode special-mode "Tabulated" -- 2.28.0