summaryrefslogtreecommitdiff
path: root/lisp/bs.el
diff options
context:
space:
mode:
authorJuanma Barranquero <lekktu@gmail.com>2007-10-11 16:10:26 +0000
committerJuanma Barranquero <lekktu@gmail.com>2007-10-11 16:10:26 +0000
commit3d5aef76947d9f329fd39be39c2f871dc28dd651 (patch)
treea2a963fe6fc566f8ad6946a988b8f777b3b8fe9b /lisp/bs.el
parent0a0ca7f11fe17ee09259e07bed63e5c193997463 (diff)
(bs--mark-unmark): New function.
(bs-mark-current, bs-unmark-current): Use it.
Diffstat (limited to 'lisp/bs.el')
-rw-r--r--lisp/bs.el33
1 files changed, 15 insertions, 18 deletions
diff --git a/lisp/bs.el b/lisp/bs.el
index 4d13c97c2fd..6390bd2dd81 100644
--- a/lisp/bs.el
+++ b/lisp/bs.el
@@ -864,35 +864,32 @@ the status of buffer on current line."
(bs--set-window-height)
(bs--show-config-message what))
+(defun bs--mark-unmark (count fun)
+ "Call FUN on COUNT consecutive buffers of *buffer-selection*."
+ (let ((dir (if (> count 0) 1 -1)))
+ (dotimes (i (abs count))
+ (let ((buffer (bs--current-buffer)))
+ (when buffer (funcall fun buffer))
+ (bs--update-current-line)
+ (bs-down dir)))))
+
(defun bs-mark-current (count)
"Mark buffers.
COUNT is the number of buffers to mark.
Move cursor vertically down COUNT lines."
(interactive "p")
- (let ((dir (if (> count 0) 1 -1))
- (count (abs count)))
- (while (> count 0)
- (let ((buffer (bs--current-buffer)))
- (if buffer
- (setq bs--marked-buffers (cons buffer bs--marked-buffers)))
- (bs--update-current-line)
- (bs-down dir))
- (setq count (1- count)))))
+ (bs--mark-unmark count
+ (lambda (buf)
+ (add-to-list 'bs--marked-buffers buf))))
(defun bs-unmark-current (count)
"Unmark buffers.
COUNT is the number of buffers to unmark.
Move cursor vertically down COUNT lines."
(interactive "p")
- (let ((dir (if (> count 0) 1 -1))
- (count (abs count)))
- (while (> count 0)
- (let ((buffer (bs--current-buffer)))
- (if buffer
- (setq bs--marked-buffers (delq buffer bs--marked-buffers)))
- (bs--update-current-line)
- (bs-down dir))
- (setq count (1- count)))))
+ (bs--mark-unmark count
+ (lambda (buf)
+ (setq bs--marked-buffers (delq buf bs--marked-buffers)))))
(defun bs--show-config-message (what)
"Show message indicating the new showing status WHAT.