[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to circumvent warning in batch mode
From: |
Andreas Politz |
Subject: |
Re: How to circumvent warning in batch mode |
Date: |
Fri, 09 Oct 2009 16:42:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
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