summaryrefslogtreecommitdiff
path: root/lisp/bs.el
diff options
context:
space:
mode:
authorTino Calancha <tino.calancha@gmail.com>2016-11-22 15:23:50 +0900
committerTino Calancha <tino.calancha@gmail.com>2016-11-22 15:23:50 +0900
commit27b754cb4432ece3efe3fc9d8e52a869ae061b7f (patch)
treea0b2c5c7a1747c07c41187723b629280a9e6f05c /lisp/bs.el
parent3c194dafe080c45528063a20075f8cd53a3760b3 (diff)
downloademacs-27b754cb4432ece3efe3fc9d8e52a869ae061b7f.tar.gz
emacs-27b754cb4432ece3efe3fc9d8e52a869ae061b7f.tar.bz2
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.
Diffstat (limited to 'lisp/bs.el')
-rw-r--r--lisp/bs.el43
1 files changed, 37 insertions, 6 deletions
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.")
(define-key map "t" 'bs-visit-tags-table)
(define-key map "m" 'bs-mark-current)
(define-key map "u" 'bs-unmark-current)
+ (define-key map "U" 'bs-unmark-all)
+ (define-key map "\177" 'bs-unmark-previous)
(define-key map ">" 'scroll-right)
(define-key map "<" 'scroll-left)
(define-key map "?" 'bs-help)
@@ -635,6 +637,8 @@ For faster navigation each digit key is a digit argument.
\\[bs-clear-modified] -- clear modified-flag on that buffer.
\\[bs-mark-current] -- mark current line's buffer to be displayed.
\\[bs-unmark-current] -- unmark current line's buffer to be displayed.
+\\[bs-unmark-all] -- unmark all buffer lines.
+\\[bs-unmark-previous] -- unmark previous line's buffer to be displayed.
\\[bs-show-sorted] -- display buffer list sorted by next sort aspect.
\\[bs-set-configuration-and-refresh] -- ask user for a configuration and \
apply selected configuration.
@@ -867,7 +871,7 @@ the status of buffer on current line."
(defun bs-mark-current (count)
"Mark buffers.
COUNT is the number of buffers to mark.
-Move cursor vertically down COUNT lines."
+Move point vertically down COUNT lines."
(interactive "p")
(bs--mark-unmark count
(lambda (buf)
@@ -876,12 +880,39 @@ Move cursor vertically down COUNT lines."
(defun bs-unmark-current (count)
"Unmark buffers.
COUNT is the number of buffers to unmark.
-Move cursor vertically down COUNT lines."
+Move point vertically down COUNT lines."
(interactive "p")
(bs--mark-unmark count
(lambda (buf)
(setq bs--marked-buffers (delq buf bs--marked-buffers)))))
+(defun bs-unmark-previous (count)
+ "Unmark previous COUNT buffers.
+Move point vertically up COUNT lines.
+When called interactively a numeric prefix argument sets COUNT."
+ (interactive "p")
+ (forward-line (- count))
+ (save-excursion (bs-unmark-current count)))
+
+(defun bs-unmark-all ()
+ "Unmark all buffers."
+ (interactive)
+ (let ((marked (string-to-char bs-string-marked))
+ (current (string-to-char bs-string-current))
+ (marked-cur (string-to-char bs-string-current-marked))
+ (unmarked (string-to-char bs-string-show-normally))
+ (inhibit-read-only t))
+ (save-excursion
+ (goto-char (point-min))
+ (forward-line 2)
+ (while (not (eobp))
+ (if (eq (char-after) marked)
+ (subst-char-in-region (point) (1+ (point)) marked unmarked)
+ (when (eq (char-after) marked-cur)
+ (subst-char-in-region (point) (1+ (point)) marked-cur current)))
+ (forward-line 1))
+ (setq bs--marked-buffers nil))))
+
(defun bs--show-config-message (what)
"Show message indicating the new showing status WHAT.
WHAT is a value of nil, `never', or `always'."
@@ -973,14 +1004,14 @@ Uses function `read-only-mode'."
(apply fun args)))
(defun bs-up (arg)
- "Move cursor vertically up ARG lines in Buffer Selection Menu."
+ "Move point vertically up ARG lines in Buffer Selection Menu."
(interactive "p")
(if (and arg (numberp arg) (< arg 0))
(bs--nth-wrapper (- arg) 'bs--down)
(bs--nth-wrapper arg 'bs--up)))
(defun bs--up ()
- "Move cursor vertically up one line.
+ "Move point vertically up one line.
If on top of buffer list go to last line."
(if (> (count-lines 1 (point)) bs-header-lines-length)
(forward-line -1)
@@ -989,14 +1020,14 @@ If on top of buffer list go to last line."
(recenter -1)))
(defun bs-down (arg)
- "Move cursor vertically down ARG lines in Buffer Selection Menu."
+ "Move point vertically down ARG lines in Buffer Selection Menu."
(interactive "p")
(if (and arg (numberp arg) (< arg 0))
(bs--nth-wrapper (- arg) 'bs--up)
(bs--nth-wrapper arg 'bs--down)))
(defun bs--down ()
- "Move cursor vertically down one line.
+ "Move point vertically down one line.
If at end of buffer list go to first line."
(if (eq (line-end-position) (point-max))
(progn