[comp.emacs] searching that wrap over lines

pausch@uvacs.cs.Virginia.EDU (Randy Pausch) (01/19/89)

Does anyone have a GNUemacs lisp function handy that allows incremental
string searches to wrap over lines?  (I guess this would involve 
converting the string search to a regular expression search, so that
the newlines would match, as well as spaces).

Thanks,  

     pausch@virginia.edu

jr@bbn.com (John Robinson) (01/19/89)

In article <2922@uvacs.cs.Virginia.EDU>, pausch@uvacs (Randy Pausch) writes:
>Does anyone have a GNUemacs lisp function handy that allows incremental
>string searches to wrap over lines?  (I guess this would involve 
>converting the string search to a regular expression search, so that
>the newlines would match, as well as spaces).

Ummm, GNU emacs comes with a perfectly good one, isearch-forward.  If
you type a return at it while it is prompting for a search string, it
mathces that jsut like any other character.  What?  You say you have
search-exit-char bound to return?  Then just quote a newline with
^Q^J.

Piece o' pie.

p.s. There are also incremental regexp searches (isearch-*-regexp) in
case you were wondering.
--
/jr
jr@bbn.com or bbn!jr

bard@THEORY.LCS.MIT.EDU (01/19/89)

> In article <2922@uvacs.cs.Virginia.EDU>, pausch@uvacs (Randy Pausch) writes:
> >Does anyone have a GNUemacs lisp function handy that allows incremental
> >string searches to wrap over lines?  (I guess this would involve 
> >converting the string search to a regular expression search, so that
> >the newlines would match, as well as spaces).
> 
> Ummm, GNU emacs comes with a perfectly good one, isearch-forward.  If
> you type a return at it while it is prompting for a search string, it
> mathces that jsut like any other character.  What?  You say you have
> search-exit-char bound to return?  Then just quote a newline with
> ^Q^J.

I thought that he meant something like an interactive word search, looking
for a phrase that is broken (at some unknown word boundary) over a line --
not looking for a string containing newlines at known places.  You can do it
with re-search-forward, typing "[ \t\n]+" after each word boundary, but of
course that's a pain.  Or, you can do it with word search -- but that's not
interactive.  It ought to be a routine hack on isearch or isearch-regexp to
write.

-- Bard the (lambda (x) (gargoyle))

asp@lancelot.avalon.cs.cmu.edu (James Aspnes) (01/19/89)

In article <2922@uvacs.cs.Virginia.EDU> pausch@uvacs.cs.Virginia.EDU (Randy Pausch) writes:

   Does anyone have a GNUemacs lisp function handy that allows incremental
   string searches to wrap over lines?  (I guess this would involve 
   converting the string search to a regular expression search, so that
   the newlines would match, as well as spaces).

Isearch will do this, you just have to quote newlines using C-q.

E.g.: foo^Q^Jbar matches

fjfjfjekf foo
bar
-- 

hrp@hall.cray.com (Hal Peterson) (01/19/89)

In article <2922@uvacs.cs.Virginia.EDU>, pausch@uvacs (Randy Pausch) writes:
   Does anyone have a GNUemacs lisp function handy that allows incremental
   string searches to wrap over lines?

It already does.  To insert a newline into the search string, you must
quote it with C-q; so to look for the line in your posting that ends
with ``incremental'' and is followed by a line beginning with
``string'', you might type
	C-s t a l C-q C-j s t r
Notice that newlines in files on UNIX systems are represented by the
C-j character, so that's what you have to put in your search string.

liberte@m.cs.uiuc.edu (01/20/89)

> In article <2922@uvacs.cs.Virginia.EDU>, pausch@uvacs (Randy Pausch) writes:
> >Does anyone have a GNUemacs lisp function handy that allows incremental
> >string searches to wrap over lines?  
> 
> Ummm, GNU emacs comes with a perfectly good one, isearch-forward.
> 
> p.s. There are also incremental regexp searches (isearch-*-regexp) in
> case you were wondering.
> jr@bbn.com or bbn!jr

What he wants is a little different.  Any space in the string should also
be able to match a newline, or more generally, any whitespace.
This is just isearch-forward-regexp, except with added convenience.
A variable option could automatically replace space with [ \t\n\r\f]+
or, better, \\s-+.

Dan LaLiberte
uiucdcs!liberte
liberte@cs.uiuc.edu
liberte%a.cs.uiuc.edu@uiucvmd.bitnet

merlyn@intelob.intel.com (Randal L. Schwartz @ Stonehenge) (01/20/89)

In article <2922@uvacs.cs.Virginia.EDU>, pausch@uvacs (Randy Pausch) writes:
| Does anyone have a GNUemacs lisp function handy that allows incremental
| string searches to wrap over lines?  (I guess this would involve 
| converting the string search to a regular expression search, so that
| the newlines would match, as well as spaces).
| 
| Thanks,  
| 
|      pausch@virginia.edu

Or, you can just invoke ESC-^S (isearch-forward-regexp), and put "\W+"
where you want whitespace.  I do that all the time.
-- 
Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095
on contract to BiiN (for now :-), Hillsboro, Oregon, USA.
<merlyn@intelob.intel.com> or ...!tektronix!biin!merlyn
HEADER ADDRESS MAY BE UNREPLYABLE if it says merlyn@intelob.biin.com ...
Standard disclaimer: I *am* my employer!