aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-06-24 16:35:13 +0200
committerLars Ingebrigtsen2019-06-24 16:35:13 +0200
commit1ad3387600442af3030b97f219bc60ccafb356eb (patch)
tree9fa85564dd57d6e8a9400d788522beea94d74dc6 /lisp
parentd279c45e9c8019b37e774d769e832ce86b7e4946 (diff)
downloademacs-1ad3387600442af3030b97f219bc60ccafb356eb.tar.gz
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')
-rw-r--r--lisp/emacs-lisp/tabulated-list.el35
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."
195 (define-key map "n" 'next-line) 195 (define-key map "n" 'next-line)
196 (define-key map "p" 'previous-line) 196 (define-key map "p" 'previous-line)
197 (define-key map "S" 'tabulated-list-sort) 197 (define-key map "S" 'tabulated-list-sort)
198 (define-key map "e" 'tabulated-list-widen-current-column)
199 (define-key map "s" 'tabulated-list-narrow-current-column)
198 (define-key map [follow-link] 'mouse-face) 200 (define-key map [follow-link] 'mouse-face)
199 (define-key map [mouse-2] 'mouse-select-window) 201 (define-key map [mouse-2] 'mouse-select-window)
200 map) 202 map)
@@ -645,6 +647,39 @@ With a numeric prefix argument N, sort the Nth column."
645 (tabulated-list-init-header) 647 (tabulated-list-init-header)
646 (tabulated-list-print t))) 648 (tabulated-list-print t)))
647 649
650(defun tabulated-list-widen-current-column (&optional n)
651 "Widen the current tabulated-list column by N chars.
652Interactively, N is the prefix numeric argument, and defaults to
6531."
654 (interactive "p")
655 (let ((start (current-column))
656 (nb-cols (length tabulated-list-format))
657 (col-nb 0)
658 (total-width 0)
659 (found nil)
660 col-width)
661 (while (and (not found)
662 (< col-nb nb-cols))
663 (if (> start
664 (setq total-width
665 (+ total-width
666 (setq col-width
667 (cadr (aref tabulated-list-format
668 col-nb))))))
669 (setq col-nb (1+ col-nb))
670 (setq found t)
671 (setf (cadr (aref tabulated-list-format col-nb))
672 (max 1 (+ col-width n)))
673 (tabulated-list-print t)
674 (tabulated-list-init-header)))))
675
676(defun tabulated-list-narrow-current-column (&optional n)
677 "Narrow the current tabulated list column by N chars.
678Interactively, N is the prefix numeric argument, and defaults to
6791."
680 (interactive "p")
681 (tabulated-list-widen-current-column (- n)))
682
648(defvar tabulated-list--current-lnum-width nil) 683(defvar tabulated-list--current-lnum-width nil)
649(defun tabulated-list-watch-line-number-width (_window) 684(defun tabulated-list-watch-line-number-width (_window)
650 (if display-line-numbers 685 (if display-line-numbers