]> git.eshelyaron.com Git - emacs.git/commitdiff
(bs--mark-unmark): New function.
authorJuanma Barranquero <lekktu@gmail.com>
Thu, 11 Oct 2007 16:10:26 +0000 (16:10 +0000)
committerJuanma Barranquero <lekktu@gmail.com>
Thu, 11 Oct 2007 16:10:26 +0000 (16:10 +0000)
(bs-mark-current, bs-unmark-current): Use it.

lisp/ChangeLog
lisp/bs.el

index f6e3dd0bdf2dd4915ead22807dc5bdd99d97d28e..b8be970a74c9dc22a8b3e7dad071a8a58df6deea 100644 (file)
@@ -1,6 +1,11 @@
+2007-10-11  Juanma Barranquero  <lekktu@gmail.com>
+
+       * bs.el (bs--mark-unmark): New function.
+       (bs-mark-current, bs-unmark-current): Use it.
+
 2007-10-11  Eric S. Raymond  <esr@snark.thyrsus.com>
 
-       * vc.el (vc-diff): 
+       * vc.el (vc-diff):
        (vc-diff-internal): Bug fixes by Juanma Barranquero.  Temporarily
        disable the check for his edge case, it's calling some brittle
        code.
@@ -13,7 +18,7 @@
 
 2007-10-11  Eric S. Raymond  <esr@snark.thyrsus.com>
 
-       * vc.el: Address an edge case in vc-diff pointed out by  
+       * vc.el: Address an edge case in vc-diff pointed out by
        Juanma Barranquero.  This is an experimental fix and may change.
 
        * vc-hooks.el (vc-registered): Robustify this function a bit
index 4d13c97c2fd64547702e9766435b8e3bc8307d92..6390bd2dd81271a49189c6a61e450c499d0cbeda 100644 (file)
@@ -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.