# HG changeset patch # User Juanma Barranquero # Date 1192118974 0 # Node ID 000327e80fc2bc9a694b05eb35ad9df48cd8471d # Parent 708abc311fa629998b6b01504ec0027047d89f9e (bs--mark-unmark): New function. (bs-mark-current, bs-unmark-current): Use it. diff -r 708abc311fa6 -r 000327e80fc2 lisp/bs.el --- a/lisp/bs.el Thu Oct 11 16:02:53 2007 +0000 +++ b/lisp/bs.el Thu Oct 11 16:09:34 2007 +0000 @@ -864,35 +864,32 @@ (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.