]> git.eshelyaron.com Git - emacs.git/commitdiff
Add new commands to widen/narrow tabulated list columns
authorLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Jun 2019 14:35:13 +0000 (16:35 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Mon, 24 Jun 2019 14:35:13 +0000 (16:35 +0200)
* 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.

doc/emacs/buffers.texi
etc/NEWS
lisp/emacs-lisp/tabulated-list.el

index 14a0a01ca8b57f0a1e9eb97aeb724fb207461945..6face1e73cbc1438672060b577906e3c141bccb5 100644 (file)
@@ -550,6 +550,18 @@ Sort the Buffer Menu entries according to their values in the column
 at point.  With a numeric prefix argument @var{n}, sort according to
 the @var{n}-th column (@code{tabulated-list-sort}).
 
+@item w
+@kindex w @r{(Buffer Menu)}
+@findex tabulated-list-widen-current-column
+Widen the current column width by @var{n} (the prefix numeric
+argument) characters.
+
+@item c
+@kindex c @r{(Buffer Menu)}
+@findex tabulated-list-narrow-current-column
+Make the current column contract its width by @var{n} (the prefix numeric
+argument) characters.
+
 @item T
 @findex Buffer-menu-toggle-files-only
 @kindex T @r{(Buffer Menu)}
index 5e134c47e4229312b6f37e3f3f7db947d21b5d25..74a8bbe8fa1e9174329ee220a5daf3e7c6b1e2d0 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1448,6 +1448,11 @@ near the current column in Tabulated Lists (see variables
 'tabulated-list-tty-sort-indicator-asc', and
 'tabulated-list-tty-sort-indicator-desc').
 
++++
+*** Two new commands and keystrokes have been added to the tabulated
+list mode: `w' (which widens the current column) and `c' which makes
+the current column contract.
+
 ** Text mode
 
 +++
index b23ce21027b73ffba36e646b10b04045dab6b75c..59a5d118ff75b497039507045c51c3f6840e02ad 100644 (file)
@@ -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