bongo-patches
[Top][All Lists]
Advanced

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

[bongo-patches] Add BEG and END parameters to `bongo-count-lines-satisfy


From: Daniel Brockman
Subject: [bongo-patches] Add BEG and END parameters to `bongo-count-lines-satisfying'
Date: Tue, 10 Apr 2007 16:09:22 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.92 (gnu/linux)

2007-04-10  Daniel Brockman  <address@hidden>

        Add BEG and END parameters to `bongo-count-lines-satisfying'.

diff -rN -u old-bongo/bongo.el new-bongo/bongo.el
--- old-bongo/bongo.el  2007-04-10 16:09:21.000000000 +0200
+++ new-bongo/bongo.el  2007-04-10 16:09:21.000000000 +0200
@@ -3131,12 +3131,15 @@
         (forward-line))
       result)))
 
-(defun bongo-count-lines-satisfying (predicate)
-  "Return the total number of lines that satisfy PREDICATE."
+(defun bongo-count-lines-satisfying (predicate &optional beg end)
+  "Return the total number of lines that satisfy PREDICATE.
+If BEG and END are non-nil, only count lines in that region."
+  (or beg (setq beg (point-min)))
+  (or end (setq end (point-max)))
   (let ((result 0))
     (save-excursion
-      (goto-char (point-min))
-      (while (not (eobp))
+      (goto-char beg)
+      (while (< (point) end)
         (when (funcall predicate)
           (setq result (+ result 1)))
         (forward-line 1)))
-- 
Daniel Brockman <address@hidden>

reply via email to

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