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

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

Re: search across linebreaks


From: Andreas Röhler
Subject: Re: search across linebreaks
Date: Sun, 17 Feb 2013 18:05:32 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130105 Thunderbird/17.0.2

Am 17.02.2013 08:43, schrieb Eric Abrahamsen:
I'm going to need to do a large scale search-and-replace on a series of
text files, using a sort of dictionary or hash-table of search terms and
their replacement. The text files are filled to the usual fill column.
The search terms may be broken across linebreaks, and I'm not sure of
the best way to handle this. If it was regular English words I could
probably manage a programmatic version of `isearch-toggle-word', but in
this case these are solid strings, and might be broken anywhere.

The two solutions I can think of are: 1) break up the characters in the
search string and insert "\n?" between each one to create regexps to
search on, and 2) unfill the whole file at the start of the procedure
and then refill it afterwards. Neither of these seems like a great
idea -- does anyone have any brighter ideas?

Thanks,
Eric




IMO Emacs Lisp is much better suited for that kind of tasks than sed, awk, Perl 
etc.
That's because you can cascade matching conditions nearly to infinite, while 
jumping around in buffer,
that way break complex regexps up, avoid them.

Write a function which first takes your files list

than

(while files-list

(while (re-search-forward 1nd-condition)
(while (re-search-forward 2nd-condition)

...

do-what-its-needed)))



reply via email to

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