[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: latexenc-find-file-coding-system is slow. (was: Your Emacs changes)

From: Richard Stallman
Subject: Re: latexenc-find-file-coding-system is slow. (was: Your Emacs changes)
Date: Sun, 01 May 2005 08:07:01 -0400

    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

   (while (and (not found) (search-forward string nil t))
       (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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]