bug-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Bug/Patch view.el


From: Jonathan Goldblatt
Subject: Re: Bug/Patch view.el
Date: Mon, 24 Sep 2007 07:35:22 -0400

X-Mailer: VM 7.18 under Emacs 21.4.1
FCC: /server/home/jonathan/Mail/correspondance/correspondance.gz
From: address@hidden
--text follows this line--
>>>>> "GM" == Glenn Morris <address@hidden> writes:

GM> Thanks for the detailed report. 

You're welcome.

GM> Can't your version be simplified as follows?

Your code is so much cleverer and exhibits so far a greater
knowledge of elisp than mine that it doesn't seem appropriate to
describe it as a simplification; I'd describe it as a greatly
improved reimplementation of view-search-no-match-lines.
However, it doesn't seem to test bobp in the place where it tests
eobp, which would concern me, since the function searches both
forward and backward and it also doesn't seem to be concerned
with its return value which would also be a source of concern to
me, as I believe the caller uses the value.

I tested my implementation extensively enough that I'm convinced
that it works in "more, possibly all, cases," and I find it much
easier to test my own code than the code of others.  It's
possible that I will add the greater knowledge of elisp that I
have gained by reading your code into what I wrote to preserve
the investment that I have in testing, and add in comments to
make it clearer; however, it seemed straightforward to me.

Is there any real benefit to combining the loop over times with
the loop looking for a non-matching line?  I found that to be a
confusing to me.  I also found the short-circuiting of if tests by
using conditionals a bit confusing, and have the same question
about this practice.


GM> I gave up trying to understand the original.

Please forgive the obscurity of my code.  I thank you for your
comment.  

GM> (defun view-search-no-match-lines (times regexp)
GM>   (let ((fwd-one (if (< times 0) -1 1)))
GM>     (setq times (abs times))
GM>     (while (and (> times 0)
GM>                 (zerop (forward-line fwd-one)))
GM>       (if (eobp)
GM>           (setq times -1)
GM>         (or (re-search-forward regexp (line-end-position) t)
GM>             (setq times (1- times)))))
GM>     (and (zerop times)
GM>          (looking-at "^.*$"))))




reply via email to

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