Article View: gnu.emacs.help
Article #189838Re: Aborting a search nicely
From: Piet van Oostrum
Date: Tue, 06 Nov 1990 12:58
Date: Tue, 06 Nov 1990 12:58
29 lines
2228 bytes
2228 bytes
>>>>> In message <815@inews.intel.com>, jsweedle@mipos2.intel.com (Jonathan Sweedler) (JS) writes: JS> (re-search-forward "String") JS> (some-commands-follow) JS> If "String" does not exist in my buffer then the search-forward command JS> bombs out. There must be a way to stop the search-forward from bombing JS> out and to do something if the string is not found. For instance, if JS> the string is found I want to execute certain commands and if it is JS> not found then I want to do something else. Well, use ^H f (describe-function 're-search-forward) to find out what re-search-forward does and what its parameters are. re-search-forward: Search forward from point for regular expression REGEXP. Set point to the end of the occurrence found, and return t. An optional second argument bounds the search; it is a buffer position. The match found must not extend after that position. Optional third argument, if t, means if fail just return nil (no error). ======================================================================== If not nil and not t, move to limit of search and return nil. Optional fourth argument is repeat count--search for successive occurrences. See also the functions match-beginning and match-end and replace-match. -- Piet* van Oostrum, Dept of Computer Science, Utrecht University, Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands. Telephone: +31 30 531806 Uucp: uunet!mcsun!ruuinf!piet Telefax: +31 30 513791 Internet: piet@cs.ruu.nl (*`Pete')
Technical Details
Message-ID:
<4201@ruuinf.cs.ruu.nl>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!hp4nl!ruuinf!pietReferences:
<815@inews.intel.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,6f8b507ca4d29177 X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1990-11-06 04:58:23 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!hp4nl!ruuinf!piet From: piet@cs.ruu.nl (Piet van Oostrum) Newsgroups: gnu.emacs.help Subject: Re: Aborting a search nicely Message-ID: <4201@ruuinf.cs.ruu.nl> Date: 6 Nov 90 12:58:23 GMT References: <815@inews.intel.com> Sender: news@ruuinf.cs.ruu.nl Reply-To: piet@cs.ruu.nl (Piet van Oostrum) Organization: Dept of Computer Science, Utrecht University, The Netherlands Lines: 29 Posted: Tue Nov 6 13:58:23 1990 In-reply-to: jsweedle@mipos2.intel.com (Jonathan Sweedler)