Mercurial > emacs
comparison lisp/international/mule.el @ 78853:4e8fc43ecce3
Kevin Ryde <user42 at zip.com.au>
(sgml-html-meta-auto-coding-function): Bind `case-fold-search' to t.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Fri, 21 Sep 2007 03:18:29 +0000 |
parents | 2daf9c28b3a4 |
children | b6fdfff4ae81 |
comparison
equal
deleted
inserted
replaced
78852:61391ef40a01 | 78853:4e8fc43ecce3 |
---|---|
2300 'utf-8))))) | 2300 'utf-8))))) |
2301 | 2301 |
2302 (defun sgml-html-meta-auto-coding-function (size) | 2302 (defun sgml-html-meta-auto-coding-function (size) |
2303 "If the buffer has an HTML meta tag, use it to determine encoding. | 2303 "If the buffer has an HTML meta tag, use it to determine encoding. |
2304 This function is intended to be added to `auto-coding-functions'." | 2304 This function is intended to be added to `auto-coding-functions'." |
2305 (setq size (min (+ (point) size) | 2305 (let ((case-fold-search t)) |
2306 (save-excursion | 2306 (setq size (min (+ (point) size) |
2307 ;; Limit the search by the end of the HTML header. | 2307 (save-excursion |
2308 (or (search-forward "</head>" size t) | 2308 ;; Limit the search by the end of the HTML header. |
2309 ;; In case of no header, search only 10 lines. | 2309 (or (search-forward "</head>" size t) |
2310 (forward-line 10)) | 2310 ;; In case of no header, search only 10 lines. |
2311 (point)))) | 2311 (forward-line 10)) |
2312 ;; Make sure that the buffer really contains an HTML document, by | 2312 (point)))) |
2313 ;; checking that it starts with a doctype or a <HTML> start tag | 2313 ;; Make sure that the buffer really contains an HTML document, by |
2314 ;; (allowing for whitespace at bob). Note: 'DOCTYPE NETSCAPE' is | 2314 ;; checking that it starts with a doctype or a <HTML> start tag |
2315 ;; useful for Mozilla bookmark files. | 2315 ;; (allowing for whitespace at bob). Note: 'DOCTYPE NETSCAPE' is |
2316 (when (and (re-search-forward "\\`[[:space:]\n]*\\(<!doctype[[:space:]\n]+\\(html\\|netscape\\)\\|<html\\)" size t) | 2316 ;; useful for Mozilla bookmark files. |
2317 (re-search-forward "<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*charset=\\(.+?\\)[\"']" size t)) | 2317 (when (and (re-search-forward "\\`[[:space:]\n]*\\(<!doctype[[:space:]\n]+\\(html\\|netscape\\)\\|<html\\)" size t) |
2318 (let* ((match (match-string 1)) | 2318 (re-search-forward "<meta\\s-+http-equiv=[\"']?content-type[\"']?\\s-+content=[\"']text/\\sw+;\\s-*charset=\\(.+?\\)[\"']" size t)) |
2319 (sym (intern (downcase match)))) | 2319 (let* ((match (match-string 1)) |
2320 (if (coding-system-p sym) | 2320 (sym (intern (downcase match)))) |
2321 sym | 2321 (if (coding-system-p sym) |
2322 (message "Warning: unknown coding system \"%s\"" match) | 2322 sym |
2323 nil)))) | 2323 (message "Warning: unknown coding system \"%s\"" match) |
2324 nil))))) | |
2324 | 2325 |
2325 ;;; | 2326 ;;; |
2326 (provide 'mule) | 2327 (provide 'mule) |
2327 | 2328 |
2328 ;; arch-tag: 9aebaa6e-0e8a-40a9-b857-cb5d04a39e7c | 2329 ;; arch-tag: 9aebaa6e-0e8a-40a9-b857-cb5d04a39e7c |