changeset 44286:1d7ee8515c45

Add an explicit check for 'text syntax, to protect against future enhancements to sgml-lexical-context. Add sgml-empty-tag-p and sgml-unclosed-tag-p.
author Mike Williams <mdub@bigfoot.com>
date Mon, 01 Apr 2002 12:08:13 +0000
parents 30505fab0350
children b714fce090e7
files lisp/textmodes/sgml-mode.el
diffstat 1 files changed, 20 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/sgml-mode.el	Mon Apr 01 12:03:14 2002 +0000
+++ b/lisp/textmodes/sgml-mode.el	Mon Apr 01 12:08:13 2002 +0000
@@ -890,7 +890,7 @@
 	  (sgml-beginning-of-tag t))))))
 
 (defun sgml-value (alist)
-  "Interactively insert value taken from attributerule ALIST.
+  "Interactively insert value taken from attribute-rule ALIST.
 See `sgml-tag-alist' for info about attribute rules."
   (setq alist (cdr alist))
   (if (stringp (car alist))
@@ -924,9 +924,20 @@
 						(?> . "&gt;"))))))))
 
 
+(defun sgml-empty-tag-p (tag-name)
+  "Return non-nil if TAG-NAME is an implicitly empty tag."
+  (and (not sgml-xml-mode)
+       (member-ignore-case tag-name sgml-empty-tags)))
+
+(defun sgml-unclosed-tag-p (tag-name)
+  "Return non-nil if TAG-NAME is a tag for which an end-tag is optional."
+  (and (not sgml-xml-mode)
+       (member-ignore-case tag-name sgml-unclosed-tags)))
+
 (defun sgml-calculate-indent ()
   "Calculate the column to which this line should be indented."
   (let ((lcon (sgml-lexical-context)))
+
     ;; Indent comment-start markers inside <!-- just like comment-end markers.
     (if (and (eq (car lcon) 'tag)
 	     (looking-at "--")
@@ -934,6 +945,7 @@
 	(setq lcon (cons 'comment (+ (cdr lcon) 2))))
 
     (case (car lcon)
+
       (string
        ;; Go back to previous non-empty line.
        (while (and (> (point) (cdr lcon))
@@ -970,7 +982,7 @@
 	 (goto-char (1+ (cdr lcon)))
 	 (+ (current-column) sgml-basic-offset)))
 
-      (t ;; text
+      (text
        (while (looking-at "</")
 	 (forward-sexp 1)
 	 (skip-chars-forward " \t"))
@@ -1006,7 +1018,12 @@
 	     (current-column)
 	   (goto-char there)
 	   (+ (current-column)
-	      (* sgml-basic-offset (length context)))))))))
+	      (* sgml-basic-offset (length context))))))
+      
+      (otherwise
+       (error "Unrecognised context %s" (car lcon)))
+
+      )))
 
 (defun sgml-indent-line ()
   "Indent the current line as SGML."