From: Romain Francoise <romain@orebokech.com>
Subject: Re: Should `auto-coding-functions' be mode-specific?
Date: Sun, 07 Jan 2007 14:47:26 +0100 [thread overview]
Message-ID: <87k5zzq781.fsf@pacem.orebokech.com> (raw)
In-Reply-To: <8764bkeydx.fsf@jurta.org> (Juri Linkov's message of "Sun\, 07 Jan 2007 01\:33\:55 +0200")
Juri Linkov <juri@jurta.org> writes:
> The reported bug can occur even without my change because "<html"
> was not anchored at the beginning of the buffer and can match
> "<html" in the presented HTML snippet near the top.
Right.
> But then why not to go further and use the same regexp as used for
> detecting HTML files in `magic-mode-alist'? It seems reasonable
> to detect the HTML encoding exactly in the same files that later
> recognized as HTML according to the file contents.
I think it's a good idea, and it is easy to do (see below).
But it would reopen your original issue: that encoding detection
doesn't work in Mozilla bookmark files.
Index: lisp/international/mule.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/international/mule.el,v
retrieving revision 1.250
diff -c -r1.250 mule.el
*** lisp/international/mule.el 5 Jan 2007 17:58:02 -0000 1.250
--- lisp/international/mule.el 7 Jan 2007 13:43:29 -0000
***************
*** 2292,2309 ****
;; In case of no header, search only 10 lines.
(forward-line 10))
(point))))
! ;; Make sure that the buffer really contains an HTML document, by
! ;; checking that it starts with a doctype or a <HTML> start tag
! ;; (allowing for whitespace at bob). Note: 'DOCTYPE NETSCAPE' is
! ;; useful for Mozilla bookmark files.
! (when (and (re-search-forward "\\`[[:space:]\n]*\\(<!doctype[[:space:]\n]+\\(html\\|netscape\\)\\|<html\\)" size t)
! (re-search-forward "<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*charset=\\(.+?\\)[\"']" size t))
! (let* ((match (match-string 1))
! (sym (intern (downcase match))))
! (if (coding-system-p sym)
! sym
! (message "Warning: unknown coding system \"%s\"" match)
! nil))))
;;;
(provide 'mule)
--- 2292,2311 ----
;; In case of no header, search only 10 lines.
(forward-line 10))
(point))))
! ;; Make sure that the buffer really contains an HTML document. We
! ;; assume that the first entry that associates itself to html-mode in
! ;; `magic-mode-alist' is good enough to detect HTML documents
! ;; reliably.
! (let ((html-re (car (rassoc 'html-mode magic-mode-alist))))
! (when (and html-re
! (re-search-forward (concat "\\`" html-re) size t)
! (re-search-forward "<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*charset=\\(.+?\\)[\"']" size t))
! (let* ((match (match-string 1))
! (sym (intern (downcase match))))
! (if (coding-system-p sym)
! sym
! (message "Warning: unknown coding system \"%s\"" match)
! nil)))))
;;;
(provide 'mule)
--
Romain Francoise <romain@orebokech.com> | The sea! the sea! the open
it's a miracle -- http://orebokech.com/ | sea! The blue, the fresh, the
| ever free! --Bryan W. Procter
next prev parent reply other threads:[~2007-01-07 13:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-02 20:43 Should `auto-coding-functions' be mode-specific? Romain Francoise
2007-01-02 22:14 ` Lennart Borgman (gmail)
2007-01-03 0:54 ` Kevin Ryde
2007-01-03 3:34 ` Richard Stallman
2007-01-03 12:09 ` Vincent Lefevre
2007-01-04 2:31 ` Richard Stallman
2007-01-04 4:14 ` Kenichi Handa
2007-01-04 19:02 ` Romain Francoise
2007-01-04 22:33 ` Richard Stallman
2007-01-05 18:04 ` Romain Francoise
2007-01-03 5:26 ` Kevin Rodgers
2007-01-03 14:18 ` Ralf Mattes
2007-01-04 8:44 ` Romain Francoise
2007-01-06 23:33 ` Juri Linkov
2007-01-07 13:47 ` Romain Francoise [this message]
2007-01-07 16:22 ` Juri Linkov
2007-01-08 19:46 ` Romain Francoise
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k5zzq781.fsf@pacem.orebokech.com \
--to=romain@orebokech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).