unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
Subject: Re: replace regex takes long
Date: Sun, 16 Apr 2006 09:27:45 +0300	[thread overview]
Message-ID: <usloeyqzi.fsf@gnu.org> (raw)
In-Reply-To: <87fykepg4b.fsf@localhost.localdomain> (message from Gary Wessle on 16 Apr 2006 09:35:00 +1000)

> From: Gary Wessle <phddas@yahoo.com>
> Date: 16 Apr 2006 09:35:00 +1000
> 
> Gary Wessle <phddas@yahoo.com> writes:
> 
> > Peter Dyballa <Peter_Dyballa@Web.DE> writes:
> > 
> > > Am 15.04.2006 um 23:29 schrieb Gary Wessle:
> > > 
> > > > M-x query-replace-regex <RET> +<RET><ONE SPACE>
> > > > the file size is 4162111 with 77000 lines on PentiumIII 500, it has
> > > > been 10 minutes so I opened another emacs processor to write and
> > > > post this.
> > > > is there a problem with my command and why it is taking that long?
> > > 
> > > Yes, because the command needs your co-operation. And if you don't
> > > press "yes" no change will be made.
> > 
> > if fact I forget to say that I did hit ! which means "replace all"
> 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.

I just tried query-replace-regex on a file with the structure you
described, and the command ran to completion in just 40 seconds,
including 3 questions whether to discard undo info.  That was on a
3-GHz Pentium 4 in a buffer that is in Fundamental mode.  So your
timing seems very unusual, to say the least.

Do you have some specialized major mode in that buffer?  If so,
perhaps it slows down the replacement; try in Fundamental mode.  I'd
also suggest to try the command in "emacs -q", perhaps something in
your customizations slows down the replacements.

In any case, your command is wasteful because it forces Emacs to
replace even a single space.  I suggest to try this instead:

    M-x query-replace-regex <RET>  +<RET> <RET>
                                 ^^
                             two spaces here

This command takes just 20 seconds on my machine.

Btw, what version of Emacs do you have, and on which OS?

  reply	other threads:[~2006-04-16  6:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-15 21:29 replace regex takes long Gary Wessle
2006-04-15 22:36 ` Peter Dyballa
     [not found] ` <mailman.456.1145140624.9609.help-gnu-emacs@gnu.org>
2006-04-15 23:09   ` Gary Wessle
2006-04-15 23:35     ` Gary Wessle
2006-04-16  6:27       ` Eli Zaretskii [this message]
2006-04-16 10:17       ` Peter Dyballa
2006-04-16 17:11         ` Eli Zaretskii
     [not found]       ` <mailman.473.1145168872.9609.help-gnu-emacs@gnu.org>
2006-04-16 11:53         ` Gary Wessle
2006-04-16 14:01       ` Stefan Monnier

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=usloeyqzi.fsf@gnu.org \
    --to=eliz@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).