all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: help-gnu-emacs@gnu.org
Subject: Re: search across linebreaks
Date: Sun, 17 Feb 2013 18:05:32 +0100	[thread overview]
Message-ID: <51210DDC.5070505@easy-emacs.de> (raw)
In-Reply-To: <878v6nbd1i.fsf@ericabrahamsen.net>

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)))



  parent reply	other threads:[~2013-02-17 17:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-17  7:43 search across linebreaks Eric Abrahamsen
2013-02-17 13:13 ` Jude DaShiell
     [not found] ` <mailman.20189.1361106838.855.help-gnu-emacs@gnu.org>
2013-02-17 14:43   ` J G Miller
2013-02-17 15:52 ` Drew Adams
2013-02-18  3:52   ` Eric Abrahamsen
2013-02-18  4:01     ` Jambunathan K
2013-02-18  6:09       ` Eric Abrahamsen
2013-02-17 17:05 ` Andreas Röhler [this message]
2013-02-18 13:09 ` Nicolas Richard
2013-02-19  1:22   ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51210DDC.5070505@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.