X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/10471ae36190f741829cdc490f410b68226a1bb9..996ad1b846a0865245df008bdb551093278b3c30:/lisp/textmodes/sgml-mode.el diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 39ac062173..fbcc0ede7a 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el @@ -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'. @@ -456,6 +456,9 @@ This function is designed for use in `fill-nobreak-predicate'. (skip-chars-backward "/?!") (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") "Major mode for editing SGML documents. @@ -477,6 +480,27 @@ Do \\[describe-key] on the following bindings to discover what they do. \\{sgml-mode-map}" (make-local-variable 'sgml-saved-validate-command) (make-local-variable 'facemenu-end-add-face) + ;; If encoding does not allow non-break space character, use reference. + ;; FIXME: Perhaps use   if possible (e.g. when we know its HTML)? + (setq-local tildify-space-string + (if (equal (decode-coding-string + (encode-coding-string " " buffer-file-coding-system) + buffer-file-coding-system) " ") + " " " ")) + ;; 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")) + "\\)\\>[^>]*>")) + . ("")) + ("") + ("<" . ">")))) ;;(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