From: Andreas Politz <politza@fh-trier.de>
To: help-gnu-emacs@gnu.org
Subject: Re: How to circumvent warning in batch mode
Date: Fri, 09 Oct 2009 16:42:42 +0200 [thread overview]
Message-ID: <87bpkg1vdp.fsf@fh-trier.de> (raw)
In-Reply-To: hanem4$on7$1@ger.gmane.org
Kevin Rodgers <kevin.d.rodgers@gmail.com> writes:
> Decebal wrote:
>> I have the following code:
>> emacs -batch -nw --eval='
>> (let (
>> (match-length)
>> (reg-exp "^ +")
>> (substitute-str "@")
>> )
>> (find-file "input")
>> (goto-char (point-min))
>> (while (re-search-forward "^ +" nil t)
>> (setq match-length (- (point) (match-beginning 0)))
>> (while (> match-length (length substitute-str))
>> (setq substitute-str (concat substitute-str substitute-str)))
>> (replace-match (substring substitute-str 0 match-length))
>> )
>> (write-file "outputEmacs")
>> )
>> '
>> I have severall questions about it.
>> The input file is quite big and I get:
>> File input is large (31MB), really open? (y or n)
>> Is there a way to circumvent this?
>
> let-bind large-file-warning-threshold to nil around the call to find-file.
>
>> Is there a way to do this more efficient? This script needs about 20
>> seconds. When doing it with a Perl script, it takes about 6 seconds.
>
> 1. Put the code in a file (FILE.el) and byte-compile it. Then instead of
> --eval 'CODE' on the command line, use --load FILE.elc
>
> 2. It looks like you are doing a lot of unnecessary string allocation with
> concat and substring:
>
I would suggest removing the body of the while-loop, in order to see if
there is actually a significant amount of time spend there.
Depending on the file, a great deal goes probably into the
initialization of the major-mode. Maybe you can use
`find-file-literally' or some other means, I don't know.
-ap
next prev parent reply other threads:[~2009-10-09 14:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-08 23:44 How to circumvent warning in batch mode Decebal
2009-10-09 13:43 ` Kevin Rodgers
2009-10-09 14:42 ` Andreas Politz [this message]
[not found] ` <mailman.8415.1255099400.2239.help-gnu-emacs@gnu.org>
2009-10-10 8:23 ` Decebal
[not found] ` <mailman.8407.1255095844.2239.help-gnu-emacs@gnu.org>
2009-10-10 8:50 ` Decebal
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=87bpkg1vdp.fsf@fh-trier.de \
--to=politza@fh-trier.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.
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).