From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lute Kamstra Newsgroups: gmane.emacs.devel Subject: Re: latexenc-find-file-coding-system is slow. Date: Fri, 29 Apr 2005 17:48:26 +0200 Message-ID: <87is254m9h.fsf@xs4all.nl> References: <87ekcxrbb8.fsf@arnested.dk> <87u0lpye89.fsf_-_@xs4all.nl> <874qdpaavu.fsf@arnested.dk> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1114973893 12475 80.91.229.2 (1 May 2005 18:58:13 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 1 May 2005 18:58:13 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 01 20:58:10 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DSJdN-0004Qs-E5 for ged-emacs-devel@m.gmane.org; Sun, 01 May 2005 20:57:41 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DSJk7-0004zr-Vg for ged-emacs-devel@m.gmane.org; Sun, 01 May 2005 15:04:39 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DSIZo-0007sS-Vv for emacs-devel@gnu.org; Sun, 01 May 2005 13:49:57 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DSITR-0004nz-Sn for emacs-devel@gnu.org; Sun, 01 May 2005 13:43:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DSISE-00045i-HH for emacs-devel@gnu.org; Sun, 01 May 2005 13:42:06 -0400 Original-Received: from [199.232.41.67] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtp (TLS-1.0:RSA_ARCFOUR_SHA:16) (Exim 4.34) id 1DSIUn-0004yI-5M for emacs-devel@gnu.org; Sun, 01 May 2005 13:44:45 -0400 Original-Received: from [194.109.24.29] (helo=smtp-vbr9.xs4all.nl) by mx20.gnu.org with esmtp (Exim 4.34) id 1DRXkh-0007zY-TA for emacs-devel@gnu.org; Fri, 29 Apr 2005 11:50:04 -0400 Original-Received: from pijl (a80-127-67-124.adsl.xs4all.nl [80.127.67.124]) by smtp-vbr9.xs4all.nl (8.12.11/8.12.11) with ESMTP id j3TFmRuf034416; Fri, 29 Apr 2005 17:48:27 +0200 (CEST) (envelope-from Lute.Kamstra@xs4all.nl) Original-Received: from lute by pijl with local (Exim 3.36 #1 (Debian)) id 1DRXj8-0005ma-00; Fri, 29 Apr 2005 17:48:26 +0200 Original-To: Arne =?iso-8859-1?Q?J=F8rgensen?= In-Reply-To: <874qdpaavu.fsf@arnested.dk> (Arne =?iso-8859-1?Q?J=F8rgensen?= =?iso-8859-1?Q?'s?= message of "Fri, 29 Apr 2005 16:57:41 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Original-Lines: 64 X-Virus-Scanned: by XS4ALL Virus Scanner X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:36550 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36550 Arne J=F8rgensen writes: > Lute Kamstra writes: [...] >> Since this change, opening a 117k .texi file takes seconds.=20 > > First of all latexenc-find-file-coding-system shouldn't search .texi > files. I just tested it and in my emacs it is not called on .texi > files, but there could be something wrong with the entry in > file-coding-system-alist: > > ("\\.tex\\|\\.ltx\\|\\.dtx\\|\\.drv\\'" . latexenc-find-file-coding-syst= em) > > Does that entry match .texi files? Yup, you probably mean "\\.\\(tex\\|ltx\\|dtx\\|drv\\)\\'". I'll fix that. > Secondly the problem will of course still be there on large .tex files > etc. which latexenc-find-file-coding-system is supposed search. See > below. > > But my guess is .tex files normally doesn't grow as large as .texi > files. YMMV. My LaTeX files are typically 100k, sometimes even 200k. >> It used to take a fraction of a second. I did a debug-on-quit >> during the wait a couple of times and that consistently gave me one >> of these two backtraces: > > [...] > >> I guess the re-searching in latexenc-find-file-coding-system needs to >> be improved. > > latexenc-find-file-coding-system re-searches all of the files for an > \inputencoding{...} command and if none is found it re-searches all of > the file for an \usepackage[...]{inputenc} command. > > The two re-search-forward's could of course be limited to only search > the first n positions of the buffer. The problem is though to find > decent defaults for these limits. > > It would be possible to introduce some variables for these limits and > let people customize them for their individual needs/tastes. That seems like a good approach. There is no need to search beyond a \begin{document}, is it? Maybe that can be used as well: first search the first N characters for \begin{document} and then search backward for \inputencoding{...} and \usepackage[...]{inputenc}. You probably have to test this on a number of files to see if it really helps. Would you like to work on this? Another idea is to change the regexps and search only for \inputencoding{...} and \usepackage[...]{inputenc} at the start of a line. That's where they typically are. This will speed up the search dramatically. If you agree with it, I'll apply this fix for now. Lute.