diff options
| author | Lars Ingebrigtsen | 2019-06-24 16:35:13 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2019-06-24 16:35:13 +0200 |
| commit | 1ad3387600442af3030b97f219bc60ccafb356eb (patch) | |
| tree | 9fa85564dd57d6e8a9400d788522beea94d74dc6 | |
| parent | d279c45e9c8019b37e774d769e832ce86b7e4946 (diff) | |
| download | emacs-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.
| -rw-r--r-- | doc/emacs/buffers.texi | 12 | ||||
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/emacs-lisp/tabulated-list.el | 35 |
3 files changed, 52 insertions, 0 deletions
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi index 14a0a01ca8b..6face1e73cb 100644 --- a/doc/emacs/buffers.texi +++ b/doc/emacs/buffers.texi | |||
| @@ -550,6 +550,18 @@ Sort the Buffer Menu entries according to their values in the column | |||
| 550 | at point. With a numeric prefix argument @var{n}, sort according to | 550 | at point. With a numeric prefix argument @var{n}, sort according to |
| 551 | the @var{n}-th column (@code{tabulated-list-sort}). | 551 | the @var{n}-th column (@code{tabulated-list-sort}). |
| 552 | 552 | ||
| 553 | @item w | ||
| 554 | @kindex w @r{(Buffer Menu)} | ||
| 555 | @findex tabulated-list-widen-current-column | ||
| 556 | Widen the current column width by @var{n} (the prefix numeric | ||
| 557 | argument) characters. | ||
| 558 | |||
| 559 | @item c | ||
| 560 | @kindex c @r{(Buffer Menu)} | ||
| 561 | @findex tabulated-list-narrow-current-column | ||
| 562 | Make the current column contract its width by @var{n} (the prefix numeric | ||
| 563 | argument) characters. | ||
| 564 | |||
| 553 | @item T | 565 | @item T |
| 554 | @findex Buffer-menu-toggle-files-only | 566 | @findex Buffer-menu-toggle-files-only |
| 555 | @kindex T @r{(Buffer Menu)} | 567 | @kindex T @r{(Buffer Menu)} |
| @@ -1448,6 +1448,11 @@ near the current column in Tabulated Lists (see variables | |||
| 1448 | 'tabulated-list-tty-sort-indicator-asc', and | 1448 | 'tabulated-list-tty-sort-indicator-asc', and |
| 1449 | 'tabulated-list-tty-sort-indicator-desc'). | 1449 | 'tabulated-list-tty-sort-indicator-desc'). |
| 1450 | 1450 | ||
| 1451 | +++ | ||
| 1452 | *** Two new commands and keystrokes have been added to the tabulated | ||
| 1453 | list mode: `w' (which widens the current column) and `c' which makes | ||
| 1454 | the current column contract. | ||
| 1455 | |||
| 1451 | ** Text mode | 1456 | ** Text mode |
| 1452 | 1457 | ||
| 1453 | +++ | 1458 | +++ |
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. | ||
| 652 | Interactively, N is the prefix numeric argument, and defaults to | ||
| 653 | 1." | ||
| 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. | ||
| 678 | Interactively, N is the prefix numeric argument, and defaults to | ||
| 679 | 1." | ||
| 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 |