From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.help Subject: Re: How to circumvent warning in batch mode Date: Fri, 09 Oct 2009 16:42:42 +0200 Message-ID: <87bpkg1vdp.fsf@fh-trier.de> References: <5ebdc222-a8b5-4eed-9481-39b813da5f1c@j28g2000vbl.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1255099439 5896 80.91.229.12 (9 Oct 2009 14:43:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Oct 2009 14:43:59 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 09 16:43:49 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1MwGh9-0001Tx-BL for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Oct 2009 16:43:47 +0200 Original-Received: from localhost ([127.0.0.1]:44786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MwGh8-0004Tz-Pl for geh-help-gnu-emacs@m.gmane.org; Fri, 09 Oct 2009 10:43:46 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MwGgg-0004SC-PG for help-gnu-emacs@gnu.org; Fri, 09 Oct 2009 10:43:18 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MwGgc-0004Mv-P3 for help-gnu-emacs@gnu.org; Fri, 09 Oct 2009 10:43:18 -0400 Original-Received: from [199.232.76.173] (port=34667 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MwGgc-0004Mh-Gd for help-gnu-emacs@gnu.org; Fri, 09 Oct 2009 10:43:14 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:60592) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MwGgb-0007ep-VG for help-gnu-emacs@gnu.org; Fri, 09 Oct 2009 10:43:14 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.50) id 1MwGgW-00017j-TW for help-gnu-emacs@gnu.org; Fri, 09 Oct 2009 16:43:08 +0200 Original-Received: from dslb-088-068-221-131.pools.arcor-ip.net ([88.68.221.131]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 09 Oct 2009 16:43:08 +0200 Original-Received: from politza by dslb-088-068-221-131.pools.arcor-ip.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Fri, 09 Oct 2009 16:43:08 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 46 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: dslb-088-068-221-131.pools.arcor-ip.net User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:C0e3/RRA+Vd2QXdPcIELDpUuMQg= X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:68796 Archived-At: Kevin Rodgers 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