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

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

Re: replace regex takes long


From: Peter Dyballa
Subject: Re: replace regex takes long
Date: Sun, 16 Apr 2006 12:17:26 +0200


Am 16.04.2006 um 01:35 schrieb Gary Wessle:

with M-x regex-replace it shows (replaced 304172 occurrences) and it
is taking more than 5 minutes now and still have not finished the
task.

When the message appears in the mini-buffer the task is completed.

Could be your operating system is recovering from the task. 4 MB of data are a lot, 304,172 replacements (four in every line) are "buffered" for undo's *and* 304,172 times marks where set in the buffer *and* areas highlighted and in the end de-highlighted. GNU Emacs itself is clearing its programme stack to be prepared for the next command.

replace.el explains:

        This function is usually the wrong thing to use in a Lisp program.
        What you probably want is a loop like this:
          (while (re-search-forward REGEXP nil t)
            (replace-match TO-STRING nil nil))
        which will run faster and will not set the mark or print anything."

--
Greetings

  Pete     === -Q
             ==<__/% >>
_____________(_)____@_____________________________






reply via email to

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