]> code.delx.au - gnu-emacs/blobdiff - lisp/textmodes/sgml-mode.el
Merge from origin/emacs-24
[gnu-emacs] / lisp / textmodes / sgml-mode.el
index 9d1cb0373fa1e0838bc76c601e2156d647da2620..12d98c8238a0ae09abf8b001041c411b0e06cd90 100644 (file)
@@ -1,6 +1,6 @@
 ;;; sgml-mode.el --- SGML- and HTML-editing modes -*- coding: utf-8 -*-
 
-;; Copyright (C) 1992, 1995-1996, 1998, 2001-2014 Free Software
+;; Copyright (C) 1992, 1995-1996, 1998, 2001-2015 Free Software
 ;; Foundation, Inc.
 
 ;; Author: James Clark <jjc@jclark.com>
@@ -245,7 +245,7 @@ Currently, only Latin-1 characters are supported.")
   ;; which makes it next to useless
   (cond ((executable-find "tidy")
          ;; tidy is available from http://tidy.sourceforge.net/
-         "tidy --gnu-emacs yes -e -q")
+         "tidy --gnu-emacs yes -utf8 -e -q")
         ((executable-find "nsgmls")
          ;; nsgmls is a free SGML parser in the SP suite available from
          ;; ftp.jclark.com, replaced old `sgmls'.
@@ -457,6 +457,7 @@ This function is designed for use in `fill-nobreak-predicate'.
         (eq (char-before) ?<))))
 
 (defvar tildify-space-string)
+(defvar tildify-foreach-region-function)
 
 ;;;###autoload
 (define-derived-mode sgml-mode text-mode '(sgml-xml-mode "XML" "SGML")
@@ -486,6 +487,20 @@ Do \\[describe-key] on the following bindings to discover what they do.
                           (encode-coding-string " " buffer-file-coding-system)
                           buffer-file-coding-system) " ")
                   " " "&#160;"))
+  ;; FIXME: Use the fact that we're parsing the document already
+  ;; rather than using regex-based filtering.
+  (setq-local tildify-foreach-region-function
+              (apply-partially
+               'tildify-foreach-ignore-environments
+               `((,(eval-when-compile
+                     (concat
+                      "<\\("
+                      (regexp-opt '("pre" "dfn" "code" "samp" "kbd" "var"
+                                    "PRE" "DFN" "CODE" "SAMP" "KBD" "VAR"))
+                      "\\)\\>[^>]*>"))
+                  . ("</" 1 ">"))
+                 ("<! *--" . "-- *>")
+                 ("<" . ">"))))
   ;;(make-local-variable 'facemenu-remove-face-function)
   ;; A start or end tag by itself on a line separates a paragraph.
   ;; This is desirable because SGML discards a newline that appears