diff options
author | Lars Ingebrigtsen <larsi@gnus.org> | 2019-06-24 16:35:13 +0200 |
---|---|---|
committer | Lars Ingebrigtsen <larsi@gnus.org> | 2019-06-24 16:35:13 +0200 |
commit | 1ad3387600442af3030b97f219bc60ccafb356eb (patch) | |
tree | 9fa85564dd57d6e8a9400d788522beea94d74dc6 /lisp/emacs-lisp/tabulated-list.el | |
parent | d279c45e9c8019b37e774d769e832ce86b7e4946 (diff) | |
download | emacs-1ad3387600442af3030b97f219bc60ccafb356eb.tar.gz emacs-1ad3387600442af3030b97f219bc60ccafb356eb.tar.bz2 emacs-1ad3387600442af3030b97f219bc60ccafb356eb.zip |
Add new commands to widen/narrow tabulated list columns
* doc/emacs/buffers.texi: Document widen/contracting commands in
tabulated list mode.
* lisp/emacs-lisp/tabulated-list.el (tabulated-list-mode-map): Add
keystrokes.
(tabulated-list-widen-current-column): New command.
(tabulated-list-narrow-current-column): Ditto. The code was
written by Boruch Baum and then tweaked by Drew Adams (bug#32106)
before some white-space changes before the commit.
Diffstat (limited to 'lisp/emacs-lisp/tabulated-list.el')
-rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el index b23ce21027b..59a5d118ff7 100644 --- a/lisp/emacs-lisp/tabulated-list.el +++ b/lisp/emacs-lisp/tabulated-list.el @@ -195,6 +195,8 @@ If ADVANCE is non-nil, move forward by one line afterwards." (define-key map "n" 'next-line) (define-key map "p" 'previous-line) (define-key map "S" 'tabulated-list-sort) + (define-key map "e" 'tabulated-list-widen-current-column) + (define-key map "s" 'tabulated-list-narrow-current-column) (define-key map [follow-link] 'mouse-face) (define-key map [mouse-2] 'mouse-select-window) map) @@ -645,6 +647,39 @@ With a numeric prefix argument N, sort the Nth column." (tabulated-list-init-header) (tabulated-list-print t))) +(defun tabulated-list-widen-current-column (&optional n) + "Widen the current tabulated-list column by N chars. +Interactively, N is the prefix numeric argument, and defaults to +1." + (interactive "p") + (let ((start (current-column)) + (nb-cols (length tabulated-list-format)) + (col-nb 0) + (total-width 0) + (found nil) + col-width) + (while (and (not found) + (< col-nb nb-cols)) + (if (> start + (setq total-width + (+ total-width + (setq col-width + (cadr (aref tabulated-list-format + col-nb)))))) + (setq col-nb (1+ col-nb)) + (setq found t) + (setf (cadr (aref tabulated-list-format col-nb)) + (max 1 (+ col-width n))) + (tabulated-list-print t) + (tabulated-list-init-header))))) + +(defun tabulated-list-narrow-current-column (&optional n) + "Narrow the current tabulated list column by N chars. +Interactively, N is the prefix numeric argument, and defaults to +1." + (interactive "p") + (tabulated-list-widen-current-column (- n))) + (defvar tabulated-list--current-lnum-width nil) (defun tabulated-list-watch-line-number-width (_window) (if display-line-numbers |