aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTino Calancha2016-11-22 15:23:50 +0900
committerTino Calancha2016-11-22 15:23:50 +0900
commit27b754cb4432ece3efe3fc9d8e52a869ae061b7f (patch)
treea0b2c5c7a1747c07c41187723b629280a9e6f05c
parent3c194dafe080c45528063a20075f8cd53a3760b3 (diff)
downloademacs-27b754cb4432ece3efe3fc9d8e52a869ae061b7f.tar.gz
emacs-27b754cb4432ece3efe3fc9d8e52a869ae061b7f.zip
buff-menu: Add command to unmark all buffers
Bind 'U' in buff-menu, bs and electric-buff-menu to commands to unmark all buffers (Bug#24880). * lisp/emacs-lisp/tabulated-list.el (tabulated-list-header-overlay-p): New predicate; return non-nil if tabulated-list has a fake header. * lisp/buff-menu.el (Buffer-menu-unmark-all-buffers): New command; remove all flags that use a particular mark from all the lines. Bind it to 'M-DEL'. (Buffer-menu-unmark-all): New command; remove all flags from all the lines. Bind it to 'U'. (Buffer-menu-marker-char, Buffer-menu-del-char): New variables. (Buffer-menu-delete, Buffer-menu-mark): Use them. (Buffer-menu-mode-map): Update menus. (Buffer-menu-mode): Update mode doc. * lisp/bs.el (bs-unmark-all, bs-unmark-previous): New commands. (bs-mode-map): Bind them to 'U' and '<backspace>' respectively. (bs-mode): Update mode doc. * lisp/ebuff-menu.el (electric-buffer-menu-mode-map): Bind Buffer-menu-unmark-all to 'U' and Buffer-menu-unmark-all-buffers to 'M-DEL'. (bs--down, bs-down, bs--up, bs-up, bs-unmark-current, bs-mark-current): Use point instead of cursor in doc string. (electric-buffer-list): Update mode doc. * doc/emacs/buffers.texi (Several Buffers): Mention Buffer-menu-unmark-all and Buffer-menu-unmark-all-buffers. ; * etc/NEWS: Add an entry per each new feature.
-rw-r--r--doc/emacs/buffers.texi12
-rw-r--r--etc/NEWS18
-rw-r--r--lisp/bs.el43
-rw-r--r--lisp/buff-menu.el44
-rw-r--r--lisp/ebuff-menu.el3
-rw-r--r--lisp/emacs-lisp/tabulated-list.el6
6 files changed, 117 insertions, 9 deletions
diff --git a/doc/emacs/buffers.texi b/doc/emacs/buffers.texi
index 2eb837f1510..c70e583b9ed 100644
--- a/doc/emacs/buffers.texi
+++ b/doc/emacs/buffers.texi
@@ -411,6 +411,18 @@ Remove all flags from the current line, and move down
411@kindex DEL @r{(Buffer Menu)} 411@kindex DEL @r{(Buffer Menu)}
412Move to the previous line and remove all flags on that line 412Move to the previous line and remove all flags on that line
413(@code{Buffer-menu-backup-unmark}). 413(@code{Buffer-menu-backup-unmark}).
414
415@item M-@key{DEL}
416@findex Buffer-menu-unmark-all-buffers
417@kindex M-DEL @r{(Buffer Menu)}
418Remove a particular flag from all lines
419(@code{Buffer-menu-unmark-all-buffers}).
420
421@item U
422@findex Buffer-menu-unmark-all
423@kindex U @r{(Buffer Menu)}
424Remove all flags from all the lines
425(@code{Buffer-menu-unmark-all}).
414@end table 426@end table
415 427
416@noindent 428@noindent
diff --git a/etc/NEWS b/etc/NEWS
index 619d56ba7b7..02e93e4f9fb 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -283,6 +283,24 @@ the file's actual content before prompting the user.
283 283
284* Changes in Specialized Modes and Packages in Emacs 26.1 284* Changes in Specialized Modes and Packages in Emacs 26.1
285 285
286** Electric-Buffer-menu
287
288+++
289*** Key 'U' is bound to 'Buffer-menu-unmark-all' and key 'M-DEL' is
290bound to 'Buffer-menu-unmark-all-buffers'.
291
292** bs
293
294---
295*** Two new commands 'bs-unmark-all', bound to 'U', and
296'bs-unmark-previous', bound to <backspace>.
297
298** Buffer-menu
299
300+++
301*** Two new commands 'Buffer-menu-unmark-all', bound to 'U' and
302'Buffer-menu-unmark-all-buffers', bound to 'M-DEL'.
303
286** Ibuffer 304** Ibuffer
287 305
288--- 306---
diff --git a/lisp/bs.el b/lisp/bs.el
index 835116912d4..d05a568197c 100644
--- a/lisp/bs.el
+++ b/lisp/bs.el
@@ -491,6 +491,8 @@ Used internally, only.")
491 (define-key map "t" 'bs-visit-tags-table) 491 (define-key map "t" 'bs-visit-tags-table)
492 (define-key map "m" 'bs-mark-current) 492 (define-key map "m" 'bs-mark-current)
493 (define-key map "u" 'bs-unmark-current) 493 (define-key map "u" 'bs-unmark-current)
494 (define-key map "U" 'bs-unmark-all)
495 (define-key map "\177" 'bs-unmark-previous)
494 (define-key map ">" 'scroll-right) 496 (define-key map ">" 'scroll-right)
495 (define-key map "<" 'scroll-left) 497 (define-key map "<" 'scroll-left)
496 (define-key map "?" 'bs-help) 498 (define-key map "?" 'bs-help)
@@ -635,6 +637,8 @@ For faster navigation each digit key is a digit argument.
635\\[bs-clear-modified] -- clear modified-flag on that buffer. 637\\[bs-clear-modified] -- clear modified-flag on that buffer.
636\\[bs-mark-current] -- mark current line's buffer to be displayed. 638\\[bs-mark-current] -- mark current line's buffer to be displayed.
637\\[bs-unmark-current] -- unmark current line's buffer to be displayed. 639\\[bs-unmark-current] -- unmark current line's buffer to be displayed.
640\\[bs-unmark-all] -- unmark all buffer lines.
641\\[bs-unmark-previous] -- unmark previous line's buffer to be displayed.
638\\[bs-show-sorted] -- display buffer list sorted by next sort aspect. 642\\[bs-show-sorted] -- display buffer list sorted by next sort aspect.
639\\[bs-set-configuration-and-refresh] -- ask user for a configuration and \ 643\\[bs-set-configuration-and-refresh] -- ask user for a configuration and \
640apply selected configuration. 644apply selected configuration.
@@ -867,7 +871,7 @@ the status of buffer on current line."
867(defun bs-mark-current (count) 871(defun bs-mark-current (count)
868 "Mark buffers. 872 "Mark buffers.
869COUNT is the number of buffers to mark. 873COUNT is the number of buffers to mark.
870Move cursor vertically down COUNT lines." 874Move point vertically down COUNT lines."
871 (interactive "p") 875 (interactive "p")
872 (bs--mark-unmark count 876 (bs--mark-unmark count
873 (lambda (buf) 877 (lambda (buf)
@@ -876,12 +880,39 @@ Move cursor vertically down COUNT lines."
876(defun bs-unmark-current (count) 880(defun bs-unmark-current (count)
877 "Unmark buffers. 881 "Unmark buffers.
878COUNT is the number of buffers to unmark. 882COUNT is the number of buffers to unmark.
879Move cursor vertically down COUNT lines." 883Move point vertically down COUNT lines."
880 (interactive "p") 884 (interactive "p")
881 (bs--mark-unmark count 885 (bs--mark-unmark count
882 (lambda (buf) 886 (lambda (buf)
883 (setq bs--marked-buffers (delq buf bs--marked-buffers))))) 887 (setq bs--marked-buffers (delq buf bs--marked-buffers)))))
884 888
889(defun bs-unmark-previous (count)
890 "Unmark previous COUNT buffers.
891Move point vertically up COUNT lines.
892When called interactively a numeric prefix argument sets COUNT."
893 (interactive "p")
894 (forward-line (- count))
895 (save-excursion (bs-unmark-current count)))
896
897(defun bs-unmark-all ()
898 "Unmark all buffers."
899 (interactive)
900 (let ((marked (string-to-char bs-string-marked))
901 (current (string-to-char bs-string-current))
902 (marked-cur (string-to-char bs-string-current-marked))
903 (unmarked (string-to-char bs-string-show-normally))
904 (inhibit-read-only t))
905 (save-excursion
906 (goto-char (point-min))
907 (forward-line 2)
908 (while (not (eobp))
909 (if (eq (char-after) marked)
910 (subst-char-in-region (point) (1+ (point)) marked unmarked)
911 (when (eq (char-after) marked-cur)
912 (subst-char-in-region (point) (1+ (point)) marked-cur current)))
913 (forward-line 1))
914 (setq bs--marked-buffers nil))))
915
885(defun bs--show-config-message (what) 916(defun bs--show-config-message (what)
886 "Show message indicating the new showing status WHAT. 917 "Show message indicating the new showing status WHAT.
887WHAT is a value of nil, `never', or `always'." 918WHAT is a value of nil, `never', or `always'."
@@ -973,14 +1004,14 @@ Uses function `read-only-mode'."
973 (apply fun args))) 1004 (apply fun args)))
974 1005
975(defun bs-up (arg) 1006(defun bs-up (arg)
976 "Move cursor vertically up ARG lines in Buffer Selection Menu." 1007 "Move point vertically up ARG lines in Buffer Selection Menu."
977 (interactive "p") 1008 (interactive "p")
978 (if (and arg (numberp arg) (< arg 0)) 1009 (if (and arg (numberp arg) (< arg 0))
979 (bs--nth-wrapper (- arg) 'bs--down) 1010 (bs--nth-wrapper (- arg) 'bs--down)
980 (bs--nth-wrapper arg 'bs--up))) 1011 (bs--nth-wrapper arg 'bs--up)))
981 1012
982(defun bs--up () 1013(defun bs--up ()
983 "Move cursor vertically up one line. 1014 "Move point vertically up one line.
984If on top of buffer list go to last line." 1015If on top of buffer list go to last line."
985 (if (> (count-lines 1 (point)) bs-header-lines-length) 1016 (if (> (count-lines 1 (point)) bs-header-lines-length)
986 (forward-line -1) 1017 (forward-line -1)
@@ -989,14 +1020,14 @@ If on top of buffer list go to last line."
989 (recenter -1))) 1020 (recenter -1)))
990 1021
991(defun bs-down (arg) 1022(defun bs-down (arg)
992 "Move cursor vertically down ARG lines in Buffer Selection Menu." 1023 "Move point vertically down ARG lines in Buffer Selection Menu."
993 (interactive "p") 1024 (interactive "p")
994 (if (and arg (numberp arg) (< arg 0)) 1025 (if (and arg (numberp arg) (< arg 0))
995 (bs--nth-wrapper (- arg) 'bs--up) 1026 (bs--nth-wrapper (- arg) 'bs--up)
996 (bs--nth-wrapper arg 'bs--down))) 1027 (bs--nth-wrapper arg 'bs--down)))
997 1028
998(defun bs--down () 1029(defun bs--down ()
999 "Move cursor vertically down one line. 1030 "Move point vertically down one line.
1000If at end of buffer list go to first line." 1031If at end of buffer list go to first line."
1001 (if (eq (line-end-position) (point-max)) 1032 (if (eq (line-end-position) (point-max))
1002 (progn 1033 (progn
diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 47426285c80..f34c814feab 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -37,6 +37,12 @@
37 :group 'tools 37 :group 'tools
38 :group 'convenience) 38 :group 'convenience)
39 39
40(defvar Buffer-menu-marker-char ?>
41 "The mark character for marked buffers.")
42
43(defvar Buffer-menu-del-char ?D
44 "Character used to flag buffers for deletion.")
45
40(defcustom Buffer-menu-use-header-line t 46(defcustom Buffer-menu-use-header-line t
41 "If non-nil, use the header line to display Buffer Menu column titles." 47 "If non-nil, use the header line to display Buffer Menu column titles."
42 :type 'boolean 48 :type 'boolean
@@ -121,6 +127,8 @@ commands.")
121 (define-key map "\177" 'Buffer-menu-backup-unmark) 127 (define-key map "\177" 'Buffer-menu-backup-unmark)
122 (define-key map "~" 'Buffer-menu-not-modified) 128 (define-key map "~" 'Buffer-menu-not-modified)
123 (define-key map "u" 'Buffer-menu-unmark) 129 (define-key map "u" 'Buffer-menu-unmark)
130 (define-key map "\M-\177" 'Buffer-menu-unmark-all-buffers)
131 (define-key map "U" 'Buffer-menu-unmark-all)
124 (define-key map "m" 'Buffer-menu-mark) 132 (define-key map "m" 'Buffer-menu-mark)
125 (define-key map "t" 'Buffer-menu-visit-tags-table) 133 (define-key map "t" 'Buffer-menu-visit-tags-table)
126 (define-key map "%" 'Buffer-menu-toggle-read-only) 134 (define-key map "%" 'Buffer-menu-toggle-read-only)
@@ -197,6 +205,12 @@ commands.")
197 (bindings--define-key menu-map [umk] 205 (bindings--define-key menu-map [umk]
198 '(menu-item "Unmark" Buffer-menu-unmark 206 '(menu-item "Unmark" Buffer-menu-unmark
199 :help "Cancel all requested operations on buffer on this line and move down")) 207 :help "Cancel all requested operations on buffer on this line and move down"))
208 (bindings--define-key menu-map [umkab]
209 '(menu-item "Remove marks..." Buffer-menu-unmark-all-buffers
210 :help "Cancel a requested operation on all buffers"))
211 (bindings--define-key menu-map [umka]
212 '(menu-item "Unmark all" Buffer-menu-unmark-all
213 :help "Cancel all requested operations on buffers"))
200 (bindings--define-key menu-map [mk] 214 (bindings--define-key menu-map [mk]
201 '(menu-item "Mark" Buffer-menu-mark 215 '(menu-item "Mark" Buffer-menu-mark
202 :help "Mark buffer on this line for being displayed by v command")) 216 :help "Mark buffer on this line for being displayed by v command"))
@@ -239,6 +253,8 @@ In Buffer Menu mode, the following commands are defined:
239\\[Buffer-menu-execute] Delete or save marked buffers. 253\\[Buffer-menu-execute] Delete or save marked buffers.
240\\[Buffer-menu-unmark] Remove all marks from current line. 254\\[Buffer-menu-unmark] Remove all marks from current line.
241 With prefix argument, also move up one line. 255 With prefix argument, also move up one line.
256\\[Buffer-menu-unmark-all-buffers] Remove a particular mark from all lines.
257\\[Buffer-menu-unmark-all] Remove all marks from all lines.
242\\[Buffer-menu-backup-unmark] Back up a line and remove marks. 258\\[Buffer-menu-backup-unmark] Back up a line and remove marks.
243\\[Buffer-menu-toggle-read-only] Toggle read-only status of buffer on this line. 259\\[Buffer-menu-toggle-read-only] Toggle read-only status of buffer on this line.
244\\[revert-buffer] Update the list of buffers. 260\\[revert-buffer] Update the list of buffers.
@@ -346,7 +362,7 @@ is nil or omitted, and signal an error otherwise."
346 "Mark the Buffer menu entry at point for later display. 362 "Mark the Buffer menu entry at point for later display.
347It will be displayed by the \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command." 363It will be displayed by the \\<Buffer-menu-mode-map>\\[Buffer-menu-select] command."
348 (interactive) 364 (interactive)
349 (tabulated-list-set-col 0 ">" t) 365 (tabulated-list-set-col 0 (char-to-string Buffer-menu-marker-char) t)
350 (forward-line)) 366 (forward-line))
351 367
352(defun Buffer-menu-unmark (&optional backup) 368(defun Buffer-menu-unmark (&optional backup)
@@ -356,6 +372,28 @@ Optional prefix arg means move up."
356 (Buffer-menu--unmark) 372 (Buffer-menu--unmark)
357 (forward-line (if backup -1 1))) 373 (forward-line (if backup -1 1)))
358 374
375(defun Buffer-menu-unmark-all-buffers (mark)
376 "Cancel a requested operation on all buffers.
377MARK is the character to flag the operation on the buffers.
378When called interactively prompt for MARK; RET remove all marks."
379 (interactive "cRemove marks (RET means all):")
380 (save-excursion
381 (goto-char (point-min))
382 (when (tabulated-list-header-overlay-p)
383 (forward-line))
384 (while (not (eobp))
385 (let ((xmarks (list (aref (tabulated-list-get-entry) 0)
386 (aref (tabulated-list-get-entry) 2))))
387 (when (or (char-equal mark ?\r)
388 (member (char-to-string mark) xmarks))
389 (Buffer-menu--unmark)))
390 (forward-line))))
391
392(defun Buffer-menu-unmark-all ()
393 "Cancel all requested operations on buffers."
394 (interactive)
395 (Buffer-menu-unmark-all-buffers ?\r))
396
359(defun Buffer-menu-backup-unmark () 397(defun Buffer-menu-backup-unmark ()
360 "Move up and cancel all requested operations on buffer on line above." 398 "Move up and cancel all requested operations on buffer on line above."
361 (interactive) 399 (interactive)
@@ -382,12 +420,12 @@ buffers to delete; a negative ARG means to delete backwards."
382 (setq arg 1)) 420 (setq arg 1))
383 (while (> arg 0) 421 (while (> arg 0)
384 (when (Buffer-menu-buffer) 422 (when (Buffer-menu-buffer)
385 (tabulated-list-set-col 0 "D" t)) 423 (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t))
386 (forward-line 1) 424 (forward-line 1)
387 (setq arg (1- arg))) 425 (setq arg (1- arg)))
388 (while (< arg 0) 426 (while (< arg 0)
389 (when (Buffer-menu-buffer) 427 (when (Buffer-menu-buffer)
390 (tabulated-list-set-col 0 "D" t)) 428 (tabulated-list-set-col 0 (char-to-string Buffer-menu-del-char) t))
391 (forward-line -1) 429 (forward-line -1)
392 (setq arg (1+ arg)))) 430 (setq arg (1+ arg))))
393 431
diff --git a/lisp/ebuff-menu.el b/lisp/ebuff-menu.el
index 5536f946dc3..74a9dd542d1 100644
--- a/lisp/ebuff-menu.el
+++ b/lisp/ebuff-menu.el
@@ -55,6 +55,8 @@
55 (define-key map "\177" 'Buffer-menu-backup-unmark) 55 (define-key map "\177" 'Buffer-menu-backup-unmark)
56 (define-key map "~" 'Buffer-menu-not-modified) 56 (define-key map "~" 'Buffer-menu-not-modified)
57 (define-key map "u" 'Buffer-menu-unmark) 57 (define-key map "u" 'Buffer-menu-unmark)
58 (define-key map "\M-\177" 'Buffer-menu-unmark-all-buffers)
59 (define-key map "U" 'Buffer-menu-unmark-all)
58 (let ((i ?0)) 60 (let ((i ?0))
59 (while (<= i ?9) 61 (while (<= i ?9)
60 (define-key map (char-to-string i) 'digit-argument) 62 (define-key map (char-to-string i) 'digit-argument)
@@ -114,6 +116,7 @@ Run hooks in `electric-buffer-menu-mode-hook' on entry.
114\\[Buffer-menu-save] -- mark that buffer to be saved. 116\\[Buffer-menu-save] -- mark that buffer to be saved.
115\\[Buffer-menu-delete] or \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted. 117\\[Buffer-menu-delete] or \\[Buffer-menu-delete-backwards] -- mark that buffer to be deleted.
116\\[Buffer-menu-unmark] -- remove all kinds of marks from current line. 118\\[Buffer-menu-unmark] -- remove all kinds of marks from current line.
119\\[Buffer-menu-unmark-all] -- remove all kinds of marks from all lines.
117\\[Electric-buffer-menu-mode-view-buffer] -- view buffer, returning when done. 120\\[Electric-buffer-menu-mode-view-buffer] -- view buffer, returning when done.
118\\[Buffer-menu-backup-unmark] -- back up a line and remove marks." 121\\[Buffer-menu-backup-unmark] -- back up a line and remove marks."
119 (interactive "P") 122 (interactive "P")
diff --git a/lisp/emacs-lisp/tabulated-list.el b/lisp/emacs-lisp/tabulated-list.el
index cf297f1ef4a..9523d5e89e3 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -259,6 +259,12 @@ Do nothing if `tabulated-list--header-string' is nil."
259 (make-overlay (point-min) (point)))) 259 (make-overlay (point-min) (point))))
260 (overlay-put tabulated-list--header-overlay 'face 'underline)))) 260 (overlay-put tabulated-list--header-overlay 'face 'underline))))
261 261
262(defsubst tabulated-list-header-overlay-p (&optional pos)
263 "Return non-nil if there is a fake header.
264Optional arg POS is a buffer position where to look for a fake header;
265defaults to `point-min'."
266 (overlays-at (or pos (point-min))))
267
262(defun tabulated-list-revert (&rest ignored) 268(defun tabulated-list-revert (&rest ignored)
263 "The `revert-buffer-function' for `tabulated-list-mode'. 269 "The `revert-buffer-function' for `tabulated-list-mode'.
264It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'." 270It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'."