From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Decebal Newsgroups: gmane.emacs.help Subject: Re: How to circumvent warning in batch mode Date: Sat, 10 Oct 2009 01:50:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <5ebdc222-a8b5-4eed-9481-39b813da5f1c@j28g2000vbl.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1255167713 16543 80.91.229.12 (10 Oct 2009 09:41:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 10 Oct 2009 09:41:53 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Oct 10 11:41:44 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 1MwYSO-00071r-4L for geh-help-gnu-emacs@m.gmane.org; Sat, 10 Oct 2009 11:41:44 +0200 Original-Received: from localhost ([127.0.0.1]:51843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MwYSM-0001Su-R5 for geh-help-gnu-emacs@m.gmane.org; Sat, 10 Oct 2009 05:41:42 -0400 Original-Path: news.stanford.edu!usenet.stanford.edu!postnews.google.com!y21g2000yqn.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 74 Original-NNTP-Posting-Host: 84.53.123.169 Original-X-Trace: posting.google.com 1255164647 11082 127.0.0.1 (10 Oct 2009 08:50:47 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sat, 10 Oct 2009 08:50:47 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: y21g2000yqn.googlegroups.com; posting-host=84.53.123.169; posting-account=K-cdeAoAAAD_0d505kUtHXJaT5LFIu-3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; nl; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3,gzip(gfe),gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:173716 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:68807 Archived-At: On Oct 9, 3:43=A0pm, Kevin Rodgers wrote: > > The input file is quite big and I get: > > =A0 =A0 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= . I allready use: (switch-to-buffer (find-file-noselect input-file t t)) > > 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. =A0Then instead = of > =A0 =A0 --eval 'CODE' on the command line, use --load FILE.elc It is part of a script. So I think the compilation would be faster as a load from disc. Also: how can I give parameters to an .elc file? > 2. It looks like you are doing a lot of unnecessary string allocation wit= h > =A0 =A0 concat and substring: > > =A0 =A0 For every character after the first character in the match, you d= ouble the > =A0 =A0 length of the replacement string until it is at least as long as = the length > =A0 =A0 of the match string, then you only use the number of characters t= hat were in > =A0 =A0 the match string anyway. =A0Change the loop to: > > =A0 =A0 =A0(while (re-search-forward "^ +" nil t) > =A0 =A0 =A0 =A0(setq match-length (- (point) (match-beginning 0))) > =A0 =A0 =A0 =A0(if (> match-length 1) > =A0 =A0 =A0 =A0 =A0 (replace-match (make-string match-length ?@)) > =A0 =A0 =A0 =A0 (replace-match "@"))) Will not work in my case. In the example the replace string is only a character long, but it could also be for example '1234567890'. > =A0 =A0 That could be improved further by caching each replacement string= of length > =A0 =A0 > 1, so it is only allocated once... But now, I can see that my v= ersion > =A0 =A0 using make-string does the same amount of string allocation as yo= urs using > =A0 =A0 substring, and that your use of concat is infrequent (only needed= when the > =A0 =A0 match string jumps to a larger length than has been seen so far).= =A0So caching > =A0 =A0 the replacement string (in an array, indexed by its length) is th= e way to go. Making the replacement string longer takes only about a second. The real work is in the replace-match. Only the coders of Emacs can change that. > > Instead of the '@' or chr$(64) I would like to use a nbsp or chr > > $(160). But then the script needs almost 3 minutes. Also every space > > is replaced by two characters chr$(194) + chr$(160). > > What is going wrong here? > > In UTF-8, NBSP is 2 bytes: decimal 194 160 aka hex 00C2 00A0. That explains the two characters, but why does it akes so long? Because I now use (switch-to-buffer (find-file-noselect input-file t t)) I do not have this problem anymore.