• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/textmodes/

Lines Matching +refs:sgml +refs:unclosed +refs:tag

0 ;;; sgml-mode.el --- SGML- and HTML-editing modes -*- coding: iso-2022-7bit -*-
42 (defgroup sgml nil
44 :link '(custom-group-link :tag "Font Lock Faces group" font-lock-faces)
47 (defcustom sgml-basic-offset 2
48 "*Specifies the basic indentation level for `sgml-indent-line'."
50 :group 'sgml)
52 (defcustom sgml-transformation-function 'identity
55 :group 'sgml)
57 (put 'sgml-transformation-function 'variable-interactive
59 (defvaralias 'sgml-transformation 'sgml-transformation-function)
61 (defcustom sgml-mode-hook nil
62 "Hook run by command `sgml-mode'.
64 :group 'sgml
70 (defvar sgml-specials '(?\")
72 This list is used when first loading the `sgml-mode' library.
81 self insert as named entities depending on `sgml-quick-keys'.
86 (defvar sgml-quick-keys nil
87 "Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil.
88 This takes effect when first loading the `sgml-mode' library.")
90 (defvar sgml-mode-map
93 (define-key map "\C-c\C-i" 'sgml-tags-invisible)
94 (define-key map "/" 'sgml-slash)
95 (define-key map "\C-c\C-n" 'sgml-name-char)
96 (define-key map "\C-c\C-t" 'sgml-tag)
97 (define-key map "\C-c\C-a" 'sgml-attributes)
98 (define-key map "\C-c\C-b" 'sgml-skip-tag-backward)
99 (define-key map [?\C-c left] 'sgml-skip-tag-backward)
100 (define-key map "\C-c\C-f" 'sgml-skip-tag-forward)
101 (define-key map [?\C-c right] 'sgml-skip-tag-forward)
102 (define-key map "\C-c\C-d" 'sgml-delete-tag)
103 (define-key map "\C-c\^?" 'sgml-delete-tag)
104 (define-key map "\C-c?" 'sgml-tag-help)
105 (define-key map "\C-c/" 'sgml-close-tag)
106 (define-key map "\C-c8" 'sgml-name-8bit-mode)
107 (define-key map "\C-c\C-v" 'sgml-validate)
108 (when sgml-quick-keys
109 (define-key map "&" 'sgml-name-char)
110 (define-key map "<" 'sgml-tag)
111 (define-key map " " 'sgml-auto-attributes)
112 (define-key map ">" 'sgml-maybe-end-tag)
113 (when (memq ?\" sgml-specials)
114 (define-key map "\"" 'sgml-name-self))
115 (when (memq ?' sgml-specials)
116 (define-key map "'" 'sgml-name-self)))
118 'sgml-maybe-name-self)
122 (aset map c 'sgml-maybe-name-self)))
123 (define-key map [menu-bar sgml] (cons "SGML" menu-map))
124 (define-key menu-map [sgml-validate] '("Validate" . sgml-validate))
125 (define-key menu-map [sgml-name-8bit-mode]
126 '("Toggle 8 Bit Insertion" . sgml-name-8bit-mode))
127 (define-key menu-map [sgml-tags-invisible]
128 '("Toggle Tag Visibility" . sgml-tags-invisible))
129 (define-key menu-map [sgml-tag-help]
130 '("Describe Tag" . sgml-tag-help))
131 (define-key menu-map [sgml-delete-tag]
132 '("Delete Tag" . sgml-delete-tag))
133 (define-key menu-map [sgml-skip-tag-forward]
134 '("Forward Tag" . sgml-skip-tag-forward))
135 (define-key menu-map [sgml-skip-tag-backward]
136 '("Backward Tag" . sgml-skip-tag-backward))
137 (define-key menu-map [sgml-attributes]
138 '("Insert Attributes" . sgml-attributes))
139 (define-key menu-map [sgml-tag] '("Insert Tag" . sgml-tag))
141 "Keymap for SGML mode. See also `sgml-specials'.")
143 (defun sgml-make-syntax-table (specials)
158 (defvar sgml-mode-syntax-table (sgml-make-syntax-table sgml-specials)
159 "Syntax table used in SGML mode. See also `sgml-specials'.")
161 (defconst sgml-tag-syntax-table
162 (let ((table (sgml-make-syntax-table '(?- ?\" ?\'))))
168 (defcustom sgml-name-8bit-mode nil
171 :group 'sgml)
173 (defvar sgml-char-names
208 (put 'sgml-table 'char-table-extra-slots 0)
210 (defvar sgml-char-names-table
211 (let ((table (make-char-table 'sgml-table))
215 (setq elt (aref sgml-char-names i))
227 (defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls'
233 :group 'sgml)
235 (defvar sgml-saved-validate-command nil
240 (defcustom sgml-slash-distance 1000
243 :group 'sgml)
245 (defconst sgml-namespace-re "[_[:alpha:]][-_.[:alnum:]]*")
246 (defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*")
247 (defconst sgml-tag-name-re (concat "<\\([!/?]?" sgml-name-re "\\)"))
248 (defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*")
249 (defconst sgml-start-tag-regex (concat "<" sgml-name-re sgml-attrs-re)
250 "Regular expression that matches a non-empty start tag.
253 (defface sgml-namespace
255 "`sgml-mode' face used to highlight the namespace part of identifiers."
256 :group 'sgml)
257 (defvar sgml-namespace-face 'sgml-namespace)
260 (defconst sgml-font-lock-keywords-1
261 `((,(concat "<\\([!?]" sgml-name-re "\\)") 1 font-lock-keyword-face)
262 ;; We could use the simpler "\\(" sgml-namespace-re ":\\)?" instead,
264 (,(concat "</?\\(" sgml-namespace-re "\\)\\(?::\\(" sgml-name-re "\\)\\)?")
265 (1 (if (match-end 2) sgml-namespace-face font-lock-function-name-face))
271 (,(concat "\\(?:^\\|[ \t]\\)\\(" sgml-namespace-re "\\)\\(?::\\("
272 sgml-name-re "\\)\\)?=[\"']")
273 (1 (if (match-end 2) sgml-namespace-face font-lock-variable-name-face))
275 (,(concat "[&%]" sgml-name-re ";?") . font-lock-variable-name-face)))
277 (defconst sgml-font-lock-keywords-2
279 sgml-font-lock-keywords-1
282 (regexp-opt (mapcar 'car sgml-tag-face-alist) t)
285 sgml-tag-face-alist)) prepend))))))
288 ;; sgml-font-lock-keywords-1 and sgml-font-lock-keywords-2 above
289 (defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
290 "*Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
292 (defvar sgml-font-lock-syntactic-keywords
294 ;; comments recognized when `sgml-specials' includes ?-.
298 "Syntactic keywords for `sgml-mode'.")
301 (defvar sgml-face-tag-alist ()
302 "Alist of face and tag name for facemenu.")
304 (defvar sgml-tag-face-alist ()
307 When more these are fontified together with `sgml-font-lock-keywords'.")
309 (defvar sgml-display-text ()
313 (defvar sgml-tags-invisible nil)
315 (defcustom sgml-tag-alist
321 "*Alist of tag names for completing read and insertion rules.
324 ((\"tag\" . TAGRULE)
339 :type '(repeat (cons (string :tag "Tag Name")
340 (repeat :tag "Tag Rule" sexp)))
341 :group 'sgml)
342 (put 'sgml-tag-alist 'risky-local-variable t)
344 (defcustom sgml-tag-help
351 "*Alist of tag name and short description."
352 :type '(repeat (cons (string :tag "Tag Name")
353 (string :tag "Description")))
354 :group 'sgml)
356 (defcustom sgml-xml-mode nil
357 "*When non-nil, tag insertion functions will be XML-compliant.
363 :group 'sgml)
365 (defvar sgml-empty-tags nil
368 (defvar sgml-unclosed-tags nil
369 "List of tags whose !ELEMENT definition says the end-tag is optional.")
371 (defun sgml-xml-guess ()
385 (set (make-local-variable 'sgml-xml-mode) t))))
389 (defun sgml-comment-indent-new-line (&optional soft)
396 (defun sgml-mode-facemenu-add-face-function (face end)
397 (if (setq face (cdr (assq face sgml-face-tag-alist)))
404 (defun sgml-fill-nobreak ()
405 ;; Don't break between a tag name and its first argument.
413 (define-derived-mode sgml-mode text-mode "SGML"
417 `sgml-quick-keys'.
419 An argument of N to a tag-inserting command means to wrap it around
423 If you like upcased tags, put (setq sgml-transformation-function 'upcase)
426 Use \\[sgml-validate] to validate your document with an SGML parser.
428 Do \\[describe-variable] sgml- SPC to see available variables.
430 \\{sgml-mode-map}"
431 (make-local-variable 'sgml-saved-validate-command)
434 ;; A start or end tag by itself on a line separates a paragraph.
436 ;; immediately after a start tag or immediately before an end tag.
438 \[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>"))
442 (add-hook 'fill-nobreak-predicate 'sgml-fill-nobreak nil t)
443 (set (make-local-variable 'indent-line-function) 'sgml-indent-line)
446 (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent)
448 'sgml-comment-indent-new-line)
457 '((sgml-font-lock-keywords
458 sgml-font-lock-keywords-1
459 sgml-font-lock-keywords-2)
462 . sgml-font-lock-syntactic-keywords)))
464 'sgml-mode-facemenu-add-face-function)
465 (sgml-xml-guess)
466 (if sgml-xml-mode
469 sgml-transformation-function))
478 sgml-name-re "\\)")
482 (if sgml-xml-mode "" "?")
483 "\\)\\(" sgml-name-re "\\)\\1")
487 (if sgml-xml-mode "" "?")
488 "\\)\\(" sgml-name-re "\\)\\1")
494 (defalias 'xml-mode 'sgml-mode)
496 (defun sgml-comment-indent ()
499 (defun sgml-slash (arg)
501 Behaves electrically if `sgml-quick-keys' is non-nil."
505 (sgml-slash-matching arg))
506 ((eq sgml-quick-keys 'indent)
509 ((eq sgml-quick-keys 'close)
511 (sgml-close-tag))
513 (sgml-slash-matching arg))))
515 (defun sgml-slash-matching (arg)
518 start tag, and the second `/' is the corresponding null end tag."
527 (if sgml-slash-distance
529 (- (point) sgml-slash-distance))
531 (if (and (re-search-backward sgml-start-tag-regex (point-min) t)
538 (if (re-search-backward sgml-start-tag-regex
558 (defun sgml-name-char (&optional char)
559 "Insert a symbolic character name according to `sgml-char-names'.
570 (sgml-namify-char))
572 (defun sgml-namify-char ()
574 Uses `sgml-char-names'."
580 ((< char 256) (or (aref sgml-char-names char) char))
581 ((aref sgml-char-names-table char))
588 (defun sgml-name-self ()
589 "Insert a symbolic character name according to `sgml-char-names'."
591 (sgml-name-char last-command-char))
593 (defun sgml-maybe-name-self ()
594 "Insert a symbolic character name according to `sgml-char-names'."
596 (if sgml-name-8bit-mode
601 (sgml-name-char mc))
604 (defun sgml-name-8bit-mode ()
608 (setq sgml-name-8bit-mode (not sgml-name-8bit-mode))
609 (message "sgml name entity mode is now %s"
610 (if sgml-name-8bit-mode "ON" "OFF")))
617 (defvar sgml-tag-last nil)
618 (defvar sgml-tag-history nil)
619 (define-skeleton sgml-tag
620 "Prompt for a tag and insert it, optionally with attributes.
621 Completion and configuration are done according to `sgml-tag-alist'.
625 (setq sgml-transformation-function 'upcase)"
627 (setq sgml-tag-last
629 (if (> (length sgml-tag-last) 0)
630 (format "Tag (default %s): " sgml-tag-last)
632 sgml-tag-alist nil nil nil 'sgml-tag-history sgml-tag-last)))
635 `(("") '(setq v2 (sgml-attributes ,str t)) ?>
640 ((and (eq v2 t) sgml-xml-mode (member ,str sgml-empty-tags))
642 ((or (and (eq v2 t) (not sgml-xml-mode)) (string-match "^[/!?]" ,str))
646 ;; For xhtml's `tr' tag, we should maybe use \n instead.
660 (defun sgml-attributes (tag &optional quiet)
661 "When at top level of a tag, interactively insert attributes.
663 Completion and configuration of TAG are done according to `sgml-tag-alist'.
665 (interactive (list (save-excursion (sgml-beginning-of-tag t))))
666 (or (stringp tag) (error "Wrong context for adding attribute"))
667 (if tag
669 (alist (cdr (assoc (downcase tag) sgml-tag-alist)))
681 (sgml-value alist))
692 (sgml-value (assoc (downcase attribute) alist))
698 (defun sgml-auto-attributes (arg)
699 "Self insert the character typed; at top level of tag, prompt for attributes.
703 tag)
705 (not sgml-tag-alist) ; no message when nothing configured
706 (symbolp (setq tag (save-excursion (sgml-beginning-of-tag t))))
707 (eq (aref tag 0) ?/))
709 (sgml-attributes tag)
714 (defun sgml-tag-help (&optional tag)
715 "Display description of tag TAG. If TAG is omitted, use the tag at point."
717 (or tag
721 (setq tag (sgml-beginning-of-tag))))
722 (or (stringp tag)
723 (error "No tag selected"))
724 (setq tag (downcase tag))
726 (or (cdr (assoc (downcase tag) sgml-tag-help))
727 (and (eq (aref tag 0) ?/)
728 (cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))
731 (defun sgml-maybe-end-tag (&optional arg)
732 "Name self unless in position to end a tag or a prefix ARG is given."
734 (if (or arg (eq (car (sgml-lexical-context)) 'tag))
736 (sgml-name-self)))
738 (defun sgml-skip-tag-backward (arg)
739 "Skip to beginning of tag or matching opening tag if present.
742 ;; FIXME: use sgml-get-context or something similar.
746 ;; end tag, skip any nested pairs
754 (sgml-skip-tag-backward 1))))
757 (defun sgml-skip-tag-forward (arg)
758 "Skip to end of tag or matching closing tag if present.
760 Return t iff after a closing tag."
762 ;; FIXME: Use sgml-get-context or something similar.
766 (with-syntax-table sgml-tag-syntax-table
772 ;; start tag, skip any nested same pairs _and_ closing tag
781 ;; tag-like text inside attributes.
786 (sgml-skip-tag-forward 1))
795 (defun sgml-delete-tag (arg)
796 ;; FIXME: Should be called sgml-kill-tag or should not touch the kill-ring.
797 "Delete tag on or after cursor, and matching closing or opening tag.
804 ;; just before tag
806 ;; closing tag
810 ;; on tag?
811 (or (save-excursion (setq close (sgml-beginning-of-tag)
815 ;; not on closing tag
817 (sgml-skip-tag-backward 1)
822 (error "Not on or before tag")))))
825 (sgml-skip-tag-backward 1)
830 (when (and (sgml-skip-tag-forward 1)
834 ;; this *should* do nothing, because we're right after the tag.
846 (or (get 'sgml-tag 'invisible)
847 (setplist 'sgml-tag
849 point-entered sgml-point-entered
852 (symbol-plist 'sgml-tag))))
854 (defun sgml-tags-invisible (arg)
863 ;; since it moves point and might call sgml-point-entered.
870 (if (set (make-local-variable 'sgml-tags-invisible)
873 (not sgml-tags-invisible)))
874 (while (re-search-forward sgml-tag-name-re nil t)
877 sgml-display-text)))
883 (overlay-put ol 'sgml-tag t)))
886 'category 'sgml-tag))
890 (if (overlay-get ol 'sgml-tag)
894 (run-hooks 'sgml-tags-invisible-hook)
897 (defun sgml-point-entered (x y)
898 ;; Show preceding or following hidden tag, depending of cursor direction.
902 (message "Invisible tag: %s"
917 (defun sgml-validate (command)
925 (or sgml-saved-validate-command
926 (concat sgml-validate-command
932 (setq sgml-saved-validate-command command)
936 (defsubst sgml-at-indentation-p ()
942 (defun sgml-lexical-context (&optional limit)
945 TYPE is one of `string', `comment', `tag', `cdata', or `text'.
948 If nil, start from a preceding tag at indentation."
955 (while (and (ignore-errors (sgml-parse-tag-backward))
956 (not (sgml-at-indentation-p)))))
957 (with-syntax-table sgml-tag-syntax-table
965 ;; We got to the end without seeing a tag.
973 ;; We've reached a tag. Parse it.
980 ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state)))
983 (defun sgml-beginning-of-tag (&optional top-level)
984 "Skip to beginning of tag and return its name.
986 (let ((context (sgml-lexical-context)))
987 (if (eq (car context) 'tag)
990 (when (looking-at sgml-tag-name-re)
995 (sgml-beginning-of-tag t))))))
997 (defun sgml-value (alist)
999 See `sgml-tag-alist' for info about attribute rules."
1003 (if (and (eq (car alist) t) (not sgml-xml-mode))
1015 (defun sgml-quote (start end &optional unquotep)
1036 (defun sgml-pretty-print (beg end)
1041 ;; - insert newline between some start-tag and text.
1052 (with-syntax-table sgml-tag-syntax-table
1066 (defstruct (sgml-tag
1067 (:constructor sgml-make-tag (type start end name)))
1070 (defsubst sgml-parse-tag-name ()
1071 "Skip past a tag-name, and return the name."
1075 (defsubst sgml-looking-back-at (str)
1081 (defun sgml-tag-text-p (start end)
1082 "Return non-nil if text between START and END is a tag.
1083 Checks among other things that the tag does not contain spurious
1085 really isn't a tag after all."
1087 (with-syntax-table sgml-tag-syntax-table
1091 (defun sgml-parse-tag-backward (&optional limit)
1092 "Parse an SGML tag backward, and return information about the tag.
1094 Leave point at the beginning of the tag."
1096 (let (tag-type tag-start tag-end name)
1098 (error "No tag found"))
1102 (with-syntax-table sgml-tag-syntax-table
1109 (throw 'found (sgml-parse-tag-backward limit))))
1110 ;; Check it is really a tag, without any extra < or > inside.
1111 (unless (sgml-tag-text-p pos (point))
1113 (throw 'found (sgml-parse-tag-backward limit)))
1115 (setq tag-end (1+ (point)))
1117 ((sgml-looking-back-at "--") ; comment
1118 (setq tag-type 'comment
1119 tag-start (search-backward "<!--" nil t)))
1120 ((sgml-looking-back-at "]]") ; cdata
1121 (setq tag-type 'cdata
1122 tag-start (re-search-backward "<!\\[[A-Z]+\\[" nil t)))
1124 (setq tag-start
1125 (with-syntax-table sgml-tag-syntax-table
1126 (goto-char tag-end)
1130 ;; This > isn't really the end of a tag. Skip it.
1131 (goto-char (1- tag-end))
1132 (throw 'found (sgml-parse-tag-backward limit))))
1134 (goto-char (1+ tag-start))
1137 (setq tag-type 'decl))
1139 (setq tag-type 'pi))
1140 (?/ ; close-tag
1142 (setq tag-type 'close
1143 name (sgml-parse-tag-name)))
1145 (setq tag-type 'jsp))
1146 (t ; open or empty tag
1147 (setq tag-type 'open
1148 name (sgml-parse-tag-name))
1149 (if (or (eq ?/ (char-before (- tag-end 1)))
1150 (sgml-empty-tag-p name))
1151 (setq tag-type 'empty))))))
1152 (goto-char tag-start)
1153 (sgml-make-tag tag-type tag-start tag-end name))))
1155 (defun sgml-get-context (&optional until)
1157 By default, parse until we find a start-tag as the first thing on a line.
1161 The context is a list of tag-info structures. The last one is the tag
1164 Point is assumed to be outside of any tag. If we discover that it's
1165 not the case, the first tag returned is the one inside which we are."
1170 tag-info)
1171 ;; CONTEXT keeps track of the tag-stack
1181 (not (sgml-at-indentation-p))
1183 (/= (point) (sgml-tag-start (car context)))
1184 (sgml-unclosed-tag-p (sgml-tag-name (car context)))))
1185 (setq tag-info (ignore-errors (sgml-parse-tag-backward))))
1187 ;; This tag may enclose things we thought were tags. If so,
1190 (> (sgml-tag-end tag-info)
1191 (sgml-tag-end (car context))))
1195 ((> (sgml-tag-end tag-info) here)
1196 ;; Oops!! Looks like we were not outside of any tag, after all.
1197 (push tag-info context)
1200 ;; start-tag
1201 ((eq (sgml-tag-type tag-info) 'open)
1204 (if (member-ignore-case (sgml-tag-name tag-info) ignore)
1205 ;; There was an implicit end-tag.
1207 (push tag-info context)
1213 ((eq t (compare-strings (sgml-tag-name tag-info) nil nil
1218 (if (not sgml-xml-mode)
1219 (unless (sgml-unclosed-tag-p (sgml-tag-name tag-info))
1220 (message "Unclosed tag <%s>" (sgml-tag-name tag-info))
1222 ;; We could just assume that the tag is simply not closed
1227 (sgml-tag-name tag-info) nil nil
1232 (sgml-tag-name tag-info) (pop stack)))))
1234 (if (and (null stack) (sgml-unclosed-tag-p (sgml-tag-name tag-info)))
1235 ;; This is a top-level open of an implicitly closed tag, so any
1236 ;; occurrence of such an open tag at the same level can be ignored
1238 (push (sgml-tag-name tag-info) ignore)))
1240 ;; end-tag
1241 ((eq (sgml-tag-type tag-info) 'close)
1242 (if (sgml-empty-tag-p (sgml-tag-name tag-info))
1243 (message "Spurious </%s>: empty tag" (sgml-tag-name tag-info))
1244 (push (sgml-tag-name tag-info) stack)))
1250 (defun sgml-show-context (&optional full)
1256 (let ((context (sgml-get-context)))
1259 (while (setq more (sgml-get-context))
1267 (defun sgml-close-tag ()
1269 Depending on context, inserts a matching close-tag, or closes
1270 the current start-tag or the current comment or the current cdata, ..."
1272 (case (car (sgml-lexical-context))
1277 (tag (insert " />"))
1279 (let ((context (save-excursion (sgml-get-context))))
1282 (insert "</" (sgml-tag-name (car (last context))) ">")
1287 (defun sgml-empty-tag-p (tag-name)
1288 "Return non-nil if TAG-NAME is an implicitly empty tag."
1289 (and (not sgml-xml-mode)
1290 (member-ignore-case tag-name sgml-empty-tags)))
1292 (defun sgml-unclosed-tag-p (tag-name)
1293 "Return non-nil if TAG-NAME is a tag for which an end-tag is optional."
1294 (and (not sgml-xml-mode)
1295 (member-ignore-case tag-name sgml-unclosed-tags)))
1297 (defun sgml-calculate-indent (&optional lcon)
1300 (unless lcon (setq lcon (sgml-lexical-context)))
1303 (if (and (eq (car lcon) 'tag)
1342 (tag
1344 (skip-chars-forward "^ \t\n") ;Skip tag name.
1350 (+ (current-column) sgml-basic-offset)))
1357 (unclosed (and ;; (not sgml-xml-mode)
1358 (looking-at sgml-tag-name-re)
1360 sgml-unclosed-tags)
1365 ;; tag(s) relative to which we should be indenting.
1366 (if (and (not unclosed) (skip-chars-backward " \t")
1372 (nreverse (sgml-get-context (if unclosed nil 'empty)))))
1374 ;; Ignore previous unclosed start-tag in context.
1375 (while (and context unclosed
1377 (sgml-tag-name (car context)) nil nil
1378 unclosed nil nil t)))
1383 ((and context (> (sgml-tag-end (car context)) here))
1385 (sgml-calculate-indent
1386 (cons (if (memq (sgml-tag-type (car context)) '(comment cdata))
1387 (sgml-tag-type (car context)) 'tag)
1388 (sgml-tag-start (car context)))))
1389 ;; Align on the first element after the nearest open-tag, if any.
1391 (goto-char (sgml-tag-end (car context)))
1393 (< (point) here) (sgml-at-indentation-p))
1398 (* sgml-basic-offset (length context)))))))
1405 (defun sgml-indent-line ()
1413 (sgml-calculate-indent))))
1420 (defun sgml-guess-indent ()
1421 "Guess an appropriate value for `sgml-basic-offset'.
1422 Base the guessed identation level on the first indented tag in the buffer.
1423 Add this to `sgml-mode-hook' for convenience."
1429 (set (make-local-variable 'sgml-basic-offset)
1431 (message "Guessed sgml-basic-offset = %d"
1432 sgml-basic-offset)
1435 (defun sgml-parse-dtd ()
1440 (unclosed nil))
1446 (push (match-string-no-properties 1) unclosed))))
1448 (setq unclosed (sort (mapcar 'downcase unclosed) 'string<))
1449 (list empty unclosed)))
1455 `text-mode-hook' and `sgml-mode-hook' are run first."
1456 :group 'sgml
1460 (defvar html-quick-keys sgml-quick-keys
1462 This defaults to `sgml-quick-keys'.
1468 (set-keymap-parent map sgml-mode-map)
1524 (defvar html-face-tag-alist
1529 "Value of `sgml-face-tag-alist' for HTML mode.")
1531 (defvar html-tag-face-alist
1552 "Value of `sgml-tag-face-alist' for HTML mode.")
1558 "Value of `sgml-display-text' for HTML mode.")
1563 (defvar html-tag-alist
1578 (if sgml-xml-mode "</li>") \n))))
1592 (if sgml-xml-mode " />" ">"))
1614 "<option>" str (if sgml-xml-mode "</option>") \n))
1620 (if sgml-xml-mode (concat "<" str "></tr>")) \n))
1627 ,@sgml-tag-alist
1633 ("Item: " "<item>" str (if sgml-xml-mode "</item>") \n))
1642 ("box" (nil _ "<over>" _ (if sgml-xml-mode "</over>")))
1648 ("dd" ,(not sgml-xml-mode))
1654 "<dt>" str (if sgml-xml-mode "</dt>")
1655 "<dd>" _ (if sgml-xml-mode "</dd>") \n)))
1656 ("dt" (t _ (if sgml-xml-mode "</dt>")
1657 "<dd>" (if sgml-xml-mode "</dd>") \n))
1676 ("li" ,(not sgml-xml-mode))
1708 "*Value of `sgml-tag-alist' for HTML mode.")
1710 (defvar html-tag-help
1711 `(,@sgml-tag-help
1799 "*Value of `sgml-tag-help' for HTML mode.")
1804 (define-derived-mode html-mode sgml-mode "HTML"
1808 \\[browse-url-of-buffer] to see how this comes out. See also `sgml-mode' on
1811 Do \\[describe-variable] html- SPC and \\[describe-variable] sgml- SPC to see available variables.
1822 <p>Paragraphs only need an opening tag. Line breaks and multiple spaces are
1834 If you mainly create your own documents, `sgml-specials' might be
1837 (eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
1840 (set (make-local-variable 'sgml-display-text) html-display-text)
1841 (set (make-local-variable 'sgml-tag-face-alist) html-tag-face-alist)
1842 (make-local-variable 'sgml-tag-alist)
1843 (make-local-variable 'sgml-face-tag-alist)
1844 (make-local-variable 'sgml-tag-help)
1850 sgml-tag-alist html-tag-alist
1851 sgml-face-tag-alist html-face-tag-alist
1852 sgml-tag-help html-tag-help
1858 (when sgml-xml-mode (setq mode-name "XHTML"))
1859 (set (make-local-variable 'sgml-empty-tags)
1860 ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd',
1864 (set (make-local-variable 'sgml-unclosed-tags)
1865 ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd'.
1900 :group 'sgml
1908 "HTML anchor tag with href attribute."
1914 "HTML anchor tag with name attribute."
1917 (if sgml-xml-mode (concat " id=\"" str "\""))
1951 "HTML horizontal rule tag."
1953 (if sgml-xml-mode "<hr />" "<hr>") \n)
1956 "HTML image tag."
1959 (if sgml-xml-mode " />" ">"))
1962 "HTML line break tag."
1964 (if sgml-xml-mode "<br />" "<br>") \n)
1970 "<li>" _ (if sgml-xml-mode "</li>") \n
1977 "<li>" _ (if sgml-xml-mode "</li>") \n
1981 "HTML list item tag."
1984 "<li>" _ (if sgml-xml-mode "</li>"))
1987 "HTML paragraph tag."
1990 "<p>" _ (if sgml-xml-mode "</p>"))
2003 (if sgml-xml-mode " checked=\"checked\"" " checked")))
2004 (if sgml-xml-mode " />" ">")
2008 (if sgml-xml-mode "<br />" "<br>"))
2023 (if sgml-xml-mode " checked=\"checked\"" " checked")))
2024 (if sgml-xml-mode " />" ">")
2028 (if sgml-xml-mode "<br />" "<br>"))
2032 (provide 'sgml-mode)
2034 ;; arch-tag: 9675da94-b7f9-4bda-ad19-73ed7b4fb401
2035 ;;; sgml-mode.el ends here