* Why 10 lines?
@ 2006-05-31 23:59 Juri Linkov
0 siblings, 0 replies; only message in thread
From: Juri Linkov @ 2006-05-31 23:59 UTC (permalink / raw)
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/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-05-31 23:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-31 23:59 Why 10 lines? Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.