Article View: gnu.emacs.bug
Article #897zero repeat count in search-forward
From: Eirik Fuller
Date: Sun, 13 Dec 1992 07:05
Date: Sun, 13 Dec 1992 07:05
21 lines
1633 bytes
1633 bytes
The documentation for search-forward makes no explicit mention of what happens if the repeat count is zero. Whether or not the documentation is changed to mention this case, I think it would be useful to change the behavior. The present behavior is mysterious; it seems like an unforeseen consequence of the way more usual cases are implemented. What seems to be happening is this: if the cursor is near enough the beginning of the buffer, it stays put and search-forward returns nil. Otherwise, it moves backward some distance which seems to have nothing to do with the contents of the buffer, and search-forward returns t. What I think should happen with a zero repeat count is that search-forward should leave the cursor where it is and return t, whether or not the search pattern occurs anywhere in the buffer. It seems a conditional early return in search.c:search_command is a suitable way of doing this. I don't have diffs for that, but I'm willing to make some, test them, and send them in if there's any need for that. This is more than a philosophical question to me; I was forced by this mysterious behavior to complicate some elisp code I was writing.
Technical Details
Message-ID:
<199212131705.AA11970@DUMPSTER.TC.CORNELL.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!elf.tn.cornell.edu!eirikShow Full Headers
Complete Article Headers
Newsgroups: gnu.emacs.bug Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!elf.tn.cornell.edu!eirik From: eirik@elf.tn.cornell.edu (Eirik Fuller) Subject: zero repeat count in search-forward Message-ID: <199212131705.AA11970@DUMPSTER.TC.CORNELL.EDU> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Sun, 13 Dec 1992 07:05:51 GMT Approved: bug-gnu-emacs@prep.ai.mit.edu Lines: 22