[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Why 10 lines?
From: |
Juri Linkov |
Subject: |
Why 10 lines? |
Date: |
Thu, 01 Jun 2006 02:59:59 +0300 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
sgml-html-meta-auto-coding-function has the hard-coded limit of 10 lines
to search for the HTML meta tag. But HTML files can have the HTML meta tag
outside the 10-line limit. For example, HTML files generated by livejournal
contain this tag on 11-th line, and Emacs fails to recognize the coding
of such HTML files.
I propose to limit the search for the HTML meta tag by the end of the
existing HTML header (by looking for </head>). The limit of 10 lines
(or perhaps any slightly increased number) could be still applied only
for the case if there are no HTML header.
Index: lisp/international/mule.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/international/mule.el,v
retrieving revision 1.236
diff -c -r1.236 mule.el
*** lisp/international/mule.el 24 May 2006 13:22:12 -0000 1.236
--- lisp/international/mule.el 1 Jun 2006 00:55:47 -0000
***************
*** 2253,2261 ****
"If the buffer has an HTML meta tag, use it to determine encoding.
This function is intended to be added to `auto-coding-functions'."
(setq size (min (+ (point) size)
- ;; Only search forward 10 lines
(save-excursion
! (forward-line 10)
(point))))
(when (and (search-forward "<html" size t)
(re-search-forward
"<meta\\s-+http-equiv=\"content-type\"\\s-+content=\"text/\\sw+;\\s-*charset=\\(.+?\\)\""
size t))
--- 2257,2267 ----
"If the buffer has an HTML meta tag, use it to determine encoding.
This function is intended to be added to `auto-coding-functions'."
(setq size (min (+ (point) size)
(save-excursion
! ;; Limit the search by the end of the HTML header
! (or (search-forward "</head>" size t)
! ;; In case of no header, search only 10 lines
! (forward-line 10))
(point))))
(when (and (search-forward "<html" size t)
(re-search-forward
"<meta\\s-+http-equiv=\"content-type\"\\s-+content=\"text/\\sw+;\\s-*charset=\\(.+?\\)\""
size t))
--
Juri Linkov
http://www.jurta.org/emacs/
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Why 10 lines?,
Juri Linkov <=