emacs-devel
[Top][All Lists]
Advanced

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

Re: latexenc-find-file-coding-system is slow.


From: Lute Kamstra
Subject: Re: latexenc-find-file-coding-system is slow.
Date: Fri, 29 Apr 2005 17:48:26 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Arne Jørgensen <address@hidden> writes:

> Lute Kamstra <address@hidden> writes:

[...]

>> Since this change, opening a 117k .texi file takes seconds. 
>
> 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-system)
>
> 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.




reply via email to

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