[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug/Patch view.el
From: |
Glenn Morris |
Subject: |
Re: Bug/Patch view.el |
Date: |
Mon, 24 Sep 2007 22:30:39 -0400 |
User-agent: |
Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) |
Eventually I settled on this version, which reduces the number of
operations in the loop.
(defun view-search-no-match-lines (times regexp)
"Search for the TIMESth occurrence of a line with no match for REGEXP.
If such a line is found, return non-nil and set the match-data to that line.
If TIMES is negative, search backwards."
(let ((step 1)
(noerror 'move))
(when (< times 0)
(setq times (- times)
step -1
noerror t))
;; Note that we do not check the current line.
(while (and (> times 0)
(zerop (forward-line step)))
;; Move only to handle eob in the forward case: on last line,
;; (forward-line 1) returns 0 before the end of line.
(or (re-search-forward regexp (line-end-position) noerror)
(setq times (1- times)))))
(when (zerop times)
(forward-line 0)
(looking-at ".*")))