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. _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel