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: Wed, 11 May 2005 13:48:18 +0200 Message-ID: <87psvykmpp.fsf@xs4all.nl> References: <87ekcxrbb8.fsf@arnested.dk> <87u0lpye89.fsf_-_@xs4all.nl> <871x8m96p6.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 1115813442 649 80.91.229.2 (11 May 2005 12:10:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 11 May 2005 12:10:42 +0000 (UTC) Cc: Thien-Thi Nguyen , Stefan Monnier , Richard Stallman , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 11 14:10:37 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DVq1x-0004cP-4Z for ged-emacs-devel@m.gmane.org; Wed, 11 May 2005 14:09:37 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DVqAf-00077e-Qc for ged-emacs-devel@m.gmane.org; Wed, 11 May 2005 08:18:37 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DVq6g-0005gZ-2C for emacs-devel@gnu.org; Wed, 11 May 2005 08:14:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DVpwQ-0002FJ-9G for emacs-devel@gnu.org; Wed, 11 May 2005 08:03:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DVpvG-0001ha-7X for emacs-devel@gnu.org; Wed, 11 May 2005 08:02:42 -0400 Original-Received: from [194.109.24.26] (helo=smtp-vbr6.xs4all.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DVpnp-0005lC-Jh; Wed, 11 May 2005 07:55:01 -0400 Original-Received: from pijl (a80-127-67-124.adsl.xs4all.nl [80.127.67.124]) by smtp-vbr6.xs4all.nl (8.12.11/8.12.11) with ESMTP id j4BBmJF6042807; Wed, 11 May 2005 13:48:19 +0200 (CEST) (envelope-from Lute.Kamstra@xs4all.nl) Original-Received: from lute by pijl with local (Exim 3.36 #1 (Debian)) id 1DVphK-0002SB-00; Wed, 11 May 2005 13:48:18 +0200 Original-To: Arne =?iso-8859-1?Q?J=F8rgensen?= In-Reply-To: <871x8m96p6.fsf@arnested.dk> (Arne =?iso-8859-1?Q?J=F8rgensen?= =?iso-8859-1?Q?'s?= message of "Wed, 04 May 2005 20:39:17 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Original-Lines: 107 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:36970 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36970 [For some reason, I didn't see your message on emacs-devel.] Arne J=F8rgensen writes: > Lute Kamstra writes: > >> I guess the re-searching in latexenc-find-file-coding-system needs to >> be improved. > > I have made a try at speeding up the search for input encoding. Thanks. > What is does now is search for "inputenc" with `search-forward' until > the first match also matches (with `looking-at') an > \inputencoding{...} or \usepackage[...]{inputenc} (that is not inside > a comment). That should speed things up. > For now I have not added a limit for how far to search for this > because I still see no way to decide this for all common cases. And > then I would like to hear if the change has any effect on the speed as > it is. It's probably fast enough now. > I limitied the search for a TeX-master/tex-main-file in the local > variables section though. The limit is borrowed from > `hack-local-variables'. That should work. [...] I think there a some minor problems with the details of the implementation: > Index: lisp/international/latexenc.el > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvsroot/emacs/emacs/lisp/international/latexenc.el,v > retrieving revision 1.3 > diff -u -p -r1.3 latexenc.el > --- lisp/international/latexenc.el 1 May 2005 11:01:49 -0000 1.3 > +++ lisp/international/latexenc.el 4 May 2005 18:12:23 -0000 > @@ -120,24 +120,33 @@ coding system names is determined from ` > (save-excursion > ;; try to find the coding system in this file > (goto-char (point-min)) > - (if (or > - (re-search-forward "^[^%\n]*\\\\inputencoding{\\(.*\\)}" ni= l t) > - (re-search-forward "^[^%\n]*\\\\usepackage\\[\\(.*\\)\\]{in= putenc}" nil t)) > - (let* ((match (match-string 1)) > - (sym (intern match))) > - (when (latexenc-inputenc-to-coding-system match) > - (setq sym (latexenc-inputenc-to-coding-system match)) > - (when (coding-system-p sym) > - sym > - (if (and (require 'code-pages nil t) (coding-system-p = sym)) > - sym > - 'undecided)))) > + (if (catch 'cs > + (let ((case-fold-search nil)) > + (while (search-forward "inputenc" nil t) > + (goto-char (match-beginning 0)) > + (beginning-of-line) > + (if (or (looking-at "[^%\n]*\\\\usepackage\\[\\(.*\\)\\]{\\(.*,\\)?i= nputenc\\(,.*\\)?}") That also matches something like: \usepackage[opt]{package} % don't use {package,inputenc} > + (looking-at "[^%\n]*\\\\inputencoding{\\(.*\\)}")) > + (throw 'cs (match-string 1)) Why throw (match-string 1) instead of t? > + (goto-char (match-end 0)))))) > + (let* ((match (match-string 1)) > + (sym (intern match))) > + (when (latexenc-inputenc-to-coding-system match) > + (setq sym (latexenc-inputenc-to-coding-system match))) > + (when (coding-system-p sym) > + sym > + (if (and (require 'code-pages nil t) (coding-system-p sym)) > + sym > + 'undecided))) > ;; else try to find it in the master/main file > - (let (latexenc-main-file) > + (let (latexenc-main-file > + bound) > ;; is there a TeX-master or tex-main-file in the local varia= ble section > (unless latexenc-dont-use-TeX-master-flag > (goto-char (point-max)) > - (when (re-search-backward "^%+ *\\(TeX-master\\|tex-main-f= ile\\): *\"\\(.+\\)\"" nil t) > + (search-backward "\n\^L" (max (- (point-max) 3000) (point-min)) '= move) > + (setq bound (search-forward "Local Variables:" nil t)) > + (when (re-search-forward "^%+ *\\(TeX-master\\|tex-main-fi= le\\): *\"\\(.+\\)\"" nil t) > (let ((file (concat (file-name-directory (nth 1 arg-list= )) (match-string 2)))) > (if (file-exists-p file) > (setq latexenc-main-file file) You don't seem to use the variable bound. Could you also write a ChangeLog entry for your patch? Lute.