# HG changeset patch # User Sam Steingold # Date 1004198855 0 # Node ID ea7ef845ccf3dddb7598dc026e15cf75bebf796c # Parent 4139a35c785ce689ef9957a926f04f5c4f9e2d1d renamed `html-xhtml' to `sgml-xml' and generalized accordingly diff -r 4139a35c785c -r ea7ef845ccf3 lisp/ChangeLog --- a/lisp/ChangeLog Sat Oct 27 15:08:48 2001 +0000 +++ b/lisp/ChangeLog Sat Oct 27 16:07:35 2001 +0000 @@ -1,3 +1,15 @@ +2001-10-27 Sam Steingold + + * textmodes/sgml-mode.el (sgml-xml): Renamed from `html-xhtml'. + (sgml-xml-guess): Extracted from `html-mode' and generalized. + (sgml-mode-common): Call it. + (sgml-mode, html-mode): Set `mode-name' based on `sgml-xml'. + (sgml-tag, sgml-skip-close-p, html-tag-alist, html-line) + (html-horizontal-rule, html-image, html-ordered-list): + (html-unordered-list, html-list-item, html-paragraph): + (html-checkboxes, html-radio-buttons): Use `sgml-xml' instead of + `html-xhtml'. + 2001-10-26 Masayuki Ataka * textmodes/texinfmt.el (texinfo-format-ifnotinfo): New function. diff -r 4139a35c785c -r ea7ef845ccf3 lisp/textmodes/sgml-mode.el --- a/lisp/textmodes/sgml-mode.el Sat Oct 27 15:08:48 2001 +0000 +++ b/lisp/textmodes/sgml-mode.el Sat Oct 27 16:07:35 2001 +0000 @@ -316,51 +316,77 @@ (string :tag "Description"))) :group 'sgml) +(defcustom sgml-xml nil + "*When non-nil, tag insertion functions will be XML-compliant. +If this variable is customized, the custom value is used always. +Otherwise, it is set to be buffer-local when the file has + a DOCTYPE or an XML declaration." + :type 'boolean + :version "21.2" + :group 'sgml) + +(defun sgml-xml-guess () + "Guess whether the current buffer is XML." + (save-excursion + (goto-char (point-min)) + (cond ((or (string= "xml" (file-name-extension (or buffer-file-name ""))) + (looking-at "\\s-*<\\?xml")) + (set (make-local-variable 'sgml-xml) t)) + ((re-search-forward + (eval-when-compile + (mapconcat 'identity + '("$" - paragraph-start "[ \t]*$\\|\ -\[ \t]*" - adaptive-fill-regexp "[ \t]*" - comment-start "" - comment-indent-function 'sgml-comment-indent - skeleton-transformation sgml-transformation - skeleton-further-elements '((completion-ignore-case t)) - skeleton-end-hook (lambda () - (or (eolp) - (not (or (eq v2 '\n) - (eq (car-safe v2) '\n))) - (newline-and-indent))) - font-lock-defaults '((sgml-font-lock-keywords - sgml-font-lock-keywords-1 - sgml-font-lock-keywords-2) - nil t nil nil - (font-lock-syntactic-keywords - . sgml-font-lock-syntactic-keywords)) - facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) + (set (make-local-variable 'indent-line-function) 'indent-relative-maybe) + ;; A start or end tag by itself on a line separates a paragraph. + ;; This is desirable because SGML discards a newline that appears + ;; immediately after a start tag or immediately before an end tag. + (set (make-local-variable 'paragraph-separate) "[ \t]*$\\|\ +\[ \t]*$") + (set (make-local-variable 'paragraph-start) "[ \t]*$\\|\ +\[ \t]*") + (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*") + (set (make-local-variable 'comment-start) "") + (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent) + (set (make-local-variable 'skeleton-transformation) sgml-transformation) + (set (make-local-variable 'skeleton-further-elements) + '((completion-ignore-case t))) + (set (make-local-variable 'skeleton-end-hook) + (lambda () + (or (eolp) + (not (or (eq v2 '\n) (eq (car-safe v2) '\n))) + (newline-and-indent)))) + (set (make-local-variable 'font-lock-defaults) + '((sgml-font-lock-keywords + sgml-font-lock-keywords-1 + sgml-font-lock-keywords-2) + nil t nil nil + (font-lock-syntactic-keywords + . sgml-font-lock-syntactic-keywords))) + (set (make-local-variable 'facemenu-add-face-function) + 'sgml-mode-facemenu-add-face-function) + ;; `sgml-xml' not customized -- guess + (unless (get 'sgml-xml 'saved-value) (sgml-xml-guess)) ;; This will allow existing comments within declarations to be ;; recognized. (set (make-local-variable 'comment-start-skip) "\\(?:" ">") + (if (and sgml-xml (eq v2 t)) "/>" ">") (if (string= "![" ,str) (prog1 '(("") " [ " _ " ]]") (backward-char)) @@ -820,8 +845,7 @@ (match-end 0)) t))) -(defun sgml-skip-close-p (obj) - (and (eq obj t) (not html-xhtml))) +(defun sgml-skip-close-p (obj) (and (eq obj t) (not sgml-xml))) (defun sgml-value (alist) "Interactively insert value taken from attributerule ALIST. @@ -970,15 +994,6 @@ "Value of `sgml-display-text' for HTML mode.") -(defcustom html-xhtml nil - "*When non-nil, tag insertion functions will be XHTML-compliant. -If this variable is customized, the custom value is used always. -Otherwise, it is set to be buffer-local when the file has - a DOCTYPE declaration." - :type 'boolean - :version "21.2" - :group 'sgml) - ;; should code exactly HTML 3 here when that is finished (defvar html-tag-alist (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7"))) @@ -995,7 +1010,7 @@ ("rev" ,@rel) ("title"))) (list '((nil \n ("List item: " "
  • " str - (if html-xhtml "
  • ") \n)))) + (if sgml-xml "") \n)))) (cell `(t ,@align ("valign" ,@valign) @@ -1063,16 +1078,16 @@ ("center" \n) ("cite") ("code" \n) - ("dd" ,(not html-xhtml)) + ("dd" ,(not sgml-xml)) ("del") ("dfn") ("div") ("dl" (nil \n ( "Term: " - "
    " str (if html-xhtml "
    ") - "
    " _ (if html-xhtml "
    ") \n))) - ("dt" (t _ (if html-xhtml "") - "
    " (if html-xhtml "
    ") \n)) + "
    " str (if sgml-xml "
    ") + "
    " _ (if sgml-xml "
    ") \n))) + ("dt" (t _ (if sgml-xml "") + "
    " (if sgml-xml "
    ") \n)) ("em") ;("fn" "id" "fn") ; ??? ("head" \n) @@ -1091,7 +1106,7 @@ ("isindex" t ("action") ("prompt")) ("kbd") ("lang") - ("li" ,(not html-xhtml)) + ("li" ,(not sgml-xml)) ("math" \n) ("nobr") ("option" t ("value") ("label") ("selected" t)) @@ -1274,17 +1289,7 @@ outline-level (lambda () (char-after (1- (match-end 0))))) (setq imenu-create-index-function 'html-imenu-index) - (unless (get 'html-xhtml 'saved-value) - ;; not customized -- set from the DocType - (save-excursion - (goto-char (point-min)) - (when (re-search-forward - "" "
    ") \n) + (if sgml-xml "
    " "
    ") \n) (define-skeleton html-image "HTML image tag." nil "" ">")) + (if sgml-xml "/>" ">")) (define-skeleton html-line "HTML line break tag." nil - (if html-xhtml "
    " "
    ") \n) + (if sgml-xml "
    " "
    ") \n) (define-skeleton html-ordered-list "HTML ordered list tags." nil "
      " \n - "
    1. " _ (if html-xhtml "
    2. ") \n + "
    3. " _ (if sgml-xml "
    4. ") \n "
    ") (define-skeleton html-unordered-list "HTML unordered list tags." nil "
      " \n - "
    • " _ (if html-xhtml "
    • ") \n + "
    • " _ (if sgml-xml "
    • ") \n "
    ") (define-skeleton html-list-item "HTML list item tag." nil (if (bolp) nil '\n) - "
  • " _ (if html-xhtml "
  • ")) + "
  • " _ (if sgml-xml "
  • ")) (define-skeleton html-paragraph "HTML paragraph tag." nil (if (bolp) nil ?\n) - \n "

    " _ (if html-xhtml "

    ")) + \n "

    " _ (if sgml-xml "

    ")) (define-skeleton html-checkboxes "Group of connected checkbox inputs." @@ -1420,11 +1425,11 @@ "\" value=\"" str ?\" (when (y-or-n-p "Set \"checked\" attribute? ") (funcall skeleton-transformation " checked")) - (if html-xhtml "/>" ">") + (if sgml-xml "/>" ">") (skeleton-read "Text: " (capitalize str)) (or v2 (setq v2 (if (y-or-n-p "Newline after text? ") (funcall skeleton-transformation - (if html-xhtml "
    " "
    ")) + (if sgml-xml "
    " "
    ")) ""))) \n)) @@ -1439,11 +1444,11 @@ "\" value=\"" str ?\" (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? "))) (funcall skeleton-transformation " checked")) - (if html-xhtml "/>" ">") + (if sgml-xml "/>" ">") (skeleton-read "Text: " (capitalize str)) (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ") (funcall skeleton-transformation - (if html-xhtml "
    " "
    ")) + (if sgml-xml "
    " "
    ")) ""))) \n))