emacs-pretest-bug
[Top][All Lists]
Advanced

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

Re: Emacs hangs on long words in .html files


From: Chris Moore
Subject: Re: Emacs hangs on long words in .html files
Date: Sun, 03 Dec 2006 12:35:24 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.91 (gnu/linux)

Chris Moore <address@hidden> writes:

> I tried cutting the bookmarks.html file down to make a minimal test
> case, and found that this does the trick:
>
>   bash$ i=0; while ((i<2000)); do printf abcdefghij; ((i++)); done >| 
> /tmp/file.html; echo >> /tmp/file.html
>   bash$ /usr/local/bin/emacs -Q -nw /tmp/file.html

Limiting the length of names and namespaces in sgml-mode.el to 64
characters fixes the problem for me:

------------------------------------------------------------------------
--- lisp/textmodes/sgml-mode.el 2006-05-29 23:54:47.000000000 +0200
+++ /tmp/sgml-mode.el   2006-12-03 12:12:52.000000000 +0100
@@ -242,8 +242,8 @@
   :type '(choice (const nil) integer)
   :group 'sgml)

-(defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*")
-(defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*")
+(defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]\\{,64\\}")
+(defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]\\{,64\\}")
 (defconst sgml-tag-name-re (concat "<\\([!/?]?" sgml-name-re "\\)"))
 (defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*")
 (defconst sgml-start-tag-regex (concat "<" sgml-name-re sgml-attrs-re)
------------------------------------------------------------------------

Whereas before it was taking 67 seconds to open a file containing a
16,000 character 'word', I can now open the same file in about a tenth
of a second.  And as the length of the file grows, the time taken
to open it grows linearly, taking only 13 seconds to open a file
containing a million-letter 'word'.

Note that this doesn't result in my bookmarks.html file being
highlighted incorrectly, since the long strings are neither names nor
namespaces, but "quoted strings".  I don't know enough about SGML to
know whether it's reasonable to limit the length of names and
namespaces to 64 characters.




reply via email to

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