bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#24880: 26.0.50; buff-menu: Command to unmark all buffers


From: Tino Calancha
Subject: bug#24880: 26.0.50; buff-menu: Command to unmark all buffers
Date: Sat, 05 Nov 2016 19:04:15 +0900

I miss in this package a command to unmark all buffers bound to 'U'.
How about the following?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>From 1b7ff2820bd9e342a9f27c645fe961c06afaefc8 Mon Sep 17 00:00:00 2001
From: Tino Calancha <tino.calancha@gmail.com>
Date: Sat, 5 Nov 2016 18:58:33 +0900
Subject: [PATCH] buff-menu: Command to unmark all buffers

* 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):
New command; cancel all requested operations on buffers.  Bind it
to 'U'.
---
 lisp/buff-menu.el                 | 13 +++++++++++++
 lisp/emacs-lisp/tabulated-list.el |  6 ++++++
 2 files changed, 19 insertions(+)

diff --git a/lisp/buff-menu.el b/lisp/buff-menu.el
index 4742628..e920382 100644
--- a/lisp/buff-menu.el
+++ b/lisp/buff-menu.el
@@ -121,6 +121,7 @@ Buffer-menu-mode-map
     (define-key map "\177" 'Buffer-menu-backup-unmark)
     (define-key map "~" 'Buffer-menu-not-modified)
     (define-key map "u" 'Buffer-menu-unmark)
+    (define-key map "U" 'Buffer-menu-unmark-all)
     (define-key map "m" 'Buffer-menu-mark)
     (define-key map "t" 'Buffer-menu-visit-tags-table)
     (define-key map "%" 'Buffer-menu-toggle-read-only)
@@ -356,6 +357,18 @@ Buffer-menu-unmark
   (Buffer-menu--unmark)
   (forward-line (if backup -1 1)))
 
+(defun Buffer-menu-unmark-all ()
+  "Cancel all requested operations on buffers."
+  (interactive)
+  (save-excursion
+    (goto-char (point-min))
+    (when (tabulated-list-header-overlay-p)
+      (forward-line))
+    (while (not (eobp))
+      (unless (string= "." (aref (tabulated-list-get-entry) 0))
+        (tabulated-list-set-col 0 " " t))
+      (forward-line))))
+
 (defun Buffer-menu-backup-unmark ()
   "Move up and cancel all requested operations on buffer on line above."
   (interactive)
diff --git a/lisp/emacs-lisp/tabulated-list.el 
b/lisp/emacs-lisp/tabulated-list.el
index 00b029d..2757feb 100644
--- a/lisp/emacs-lisp/tabulated-list.el
+++ b/lisp/emacs-lisp/tabulated-list.el
@@ -257,6 +257,12 @@ tabulated-list-print-fake-header
                     (make-overlay (point-min) (point))))
       (overlay-put tabulated-list--header-overlay 'face 'underline))))
 
+(defsubst tabulated-list-header-overlay-p (&optional pos)
+  "Return non-nil if there is a fake header.
+Optional arg POS is a buffer position where to look for a fake header;
+defaults to `point-min'."
+  (overlays-at (or pos (point-min))))
+
 (defun tabulated-list-revert (&rest ignored)
   "The `revert-buffer-function' for `tabulated-list-mode'.
 It runs `tabulated-list-revert-hook', then calls `tabulated-list-print'."
-- 
2.10.1

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
In GNU Emacs 26.0.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.22.2)
 of 2016-11-05 built on calancha-pc
Repository revision: f95bf3cd1f55cf8f99b88c7318c21c967b11dfd1





reply via email to

[Prev in Thread] Current Thread [Next in Thread]