From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Richard Stallman Newsgroups: gmane.emacs.devel Subject: Re: latexenc-find-file-coding-system is slow. (was: Your Emacs changes) Date: Sun, 01 May 2005 08:07:01 -0400 Message-ID: References: <87ekcxrbb8.fsf@arnested.dk> <87u0lpye89.fsf_-_@xs4all.nl> Reply-To: rms@gnu.org NNTP-Posting-Host: main.gmane.org X-Trace: sea.gmane.org 1114949684 4274 80.91.229.2 (1 May 2005 12:14:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 1 May 2005 12:14:44 +0000 (UTC) Cc: ttn@gnu.org, arne@arnested.dk, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun May 01 14:14:42 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DSDL9-0004tk-C0 for ged-emacs-devel@m.gmane.org; Sun, 01 May 2005 14:14:27 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DSDRq-0007YX-G5 for ged-emacs-devel@m.gmane.org; Sun, 01 May 2005 08:21:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DSDQv-0007Bc-C1 for emacs-devel@gnu.org; Sun, 01 May 2005 08:20:25 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DSDQu-0007Aq-EG for emacs-devel@gnu.org; Sun, 01 May 2005 08:20:24 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DSDQt-00068U-LI for emacs-devel@gnu.org; Sun, 01 May 2005 08:20:23 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1DSDIN-0008SQ-VT for emacs-devel@gnu.org; Sun, 01 May 2005 08:11:36 -0400 Original-Received: from rms by fencepost.gnu.org with local (Exim 4.34) id 1DSDDx-0007FA-9r; Sun, 01 May 2005 08:07:01 -0400 Original-To: Lute Kamstra In-reply-to: <87u0lpye89.fsf_-_@xs4all.nl> (message from Lute Kamstra on Fri, 29 Apr 2005 14:11:34 +0200) 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:36518 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:36518 I guess the re-searching in latexenc-find-file-coding-system needs to be improved. It would be faster to search for the strings "\\inputencoding{" and "\\usepackage\\[" using search-forward, and each time it finds an occurrence, do string-match at the beginning of the line to see if the line is a real match. It would need to do this loop once for each string. Such a loop could easily be 100 times faster than the call to re-search-forward. (while (and (not found) (search-forward string nil t)) (save-excursion (beginning-of-line) (if (looking-at entire-regexp) (setq found (point)))) (forward-line 1)) There's another way to speed this up, if there is some rule about where in the file those constructs should occur. For instance, if the rule is that they should occur before the first \foo, and \foo is commonly found in LaTeX files, it could be faster to search first for \foo, then use the position of the first \foo as a bound in the other searches.