84 |
"Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil. |
"Use <, >, &, /, SPC and `sgml-specials' keys \"electrically\" when non-nil. |
85 |
This takes effect when first loading the `sgml-mode' library.") |
This takes effect when first loading the `sgml-mode' library.") |
86 |
|
|
|
|
|
87 |
(defvar sgml-mode-map |
(defvar sgml-mode-map |
88 |
(let ((map (make-keymap)) ;`sparse' doesn't allow binding to charsets. |
(let ((map (make-keymap)) ;`sparse' doesn't allow binding to charsets. |
89 |
(menu-map (make-sparse-keymap "SGML"))) |
(menu-map (make-sparse-keymap "SGML"))) |
137 |
map) |
map) |
138 |
"Keymap for SGML mode. See also `sgml-specials'.") |
"Keymap for SGML mode. See also `sgml-specials'.") |
139 |
|
|
|
|
|
140 |
(defun sgml-make-syntax-table (specials) |
(defun sgml-make-syntax-table (specials) |
141 |
(let ((table (make-syntax-table text-mode-syntax-table))) |
(let ((table (make-syntax-table text-mode-syntax-table))) |
142 |
(modify-syntax-entry ?< "(>" table) |
(modify-syntax-entry ?< "(>" table) |
162 |
table) |
table) |
163 |
"Syntax table used to parse SGML tags.") |
"Syntax table used to parse SGML tags.") |
164 |
|
|
|
|
|
165 |
(defcustom sgml-name-8bit-mode nil |
(defcustom sgml-name-8bit-mode nil |
166 |
"*When non-nil, insert non-ASCII characters as named entities." |
"*When non-nil, insert non-ASCII characters as named entities." |
167 |
:type 'boolean |
:type 'boolean |
216 |
"A table for mapping non-ASCII characters into SGML entity names. |
"A table for mapping non-ASCII characters into SGML entity names. |
217 |
Currently, only Latin-1 characters are supported.") |
Currently, only Latin-1 characters are supported.") |
218 |
|
|
|
|
|
219 |
;; nsgmls is a free SGML parser in the SP suite available from |
;; nsgmls is a free SGML parser in the SP suite available from |
220 |
;; ftp.jclark.com and otherwise packaged for GNU systems. |
;; ftp.jclark.com and otherwise packaged for GNU systems. |
221 |
;; Its error messages can be parsed by next-error. |
;; Its error messages can be parsed by next-error. |
232 |
(defvar sgml-saved-validate-command nil |
(defvar sgml-saved-validate-command nil |
233 |
"The command last used to validate in this buffer.") |
"The command last used to validate in this buffer.") |
234 |
|
|
|
|
|
235 |
;; I doubt that null end tags are used much for large elements, |
;; I doubt that null end tags are used much for large elements, |
236 |
;; so use a small distance here. |
;; so use a small distance here. |
237 |
(defcustom sgml-slash-distance 1000 |
(defcustom sgml-slash-distance 1000 |
287 |
When `font-lock-maximum-decoration' is 1 this is always used for fontifying. |
When `font-lock-maximum-decoration' is 1 this is always used for fontifying. |
288 |
When more these are fontified together with `sgml-font-lock-keywords'.") |
When more these are fontified together with `sgml-font-lock-keywords'.") |
289 |
|
|
|
|
|
290 |
(defvar sgml-display-text () |
(defvar sgml-display-text () |
291 |
"Tag names as lowercase symbols, and display string when invisible.") |
"Tag names as lowercase symbols, and display string when invisible.") |
292 |
|
|
293 |
;; internal |
;; internal |
294 |
(defvar sgml-tags-invisible nil) |
(defvar sgml-tags-invisible nil) |
295 |
|
|
|
|
|
296 |
(defcustom sgml-tag-alist |
(defcustom sgml-tag-alist |
297 |
'(("![" ("ignore" t) ("include" t)) |
'(("![" ("ignore" t) ("include" t)) |
298 |
("!attlist") |
("!attlist") |
305 |
((\"tag\" . TAGRULE) |
((\"tag\" . TAGRULE) |
306 |
...) |
...) |
307 |
|
|
308 |
TAGRULE is a list of optionally `t' (no endtag) or `\\n' (separate endtag by |
TAGRULE is a list of optionally t (no endtag) or `\\n' (separate endtag by |
309 |
newlines) or a skeleton with `nil', `t' or `\\n' in place of the interactor |
newlines) or a skeleton with nil, t or `\\n' in place of the interactor |
310 |
followed by an ATTRIBUTERULE (for an always present attribute) or an |
followed by an ATTRIBUTERULE (for an always present attribute) or an |
311 |
attribute alist. |
attribute alist. |
312 |
|
|
315 |
((\"attribute\" . ATTRIBUTERULE) |
((\"attribute\" . ATTRIBUTERULE) |
316 |
...) |
...) |
317 |
|
|
318 |
ATTRIBUTERULE is a list of optionally `t' (no value when no input) followed by |
ATTRIBUTERULE is a list of optionally t (no value when no input) followed by |
319 |
an optional alist of possible values." |
an optional alist of possible values." |
320 |
:type '(repeat (cons (string :tag "Tag Name") |
:type '(repeat (cons (string :tag "Tag Name") |
321 |
(repeat :tag "Tag Rule" sexp))) |
(repeat :tag "Tag Rule" sexp))) |
381 |
(concat "<" face ">")) |
(concat "<" face ">")) |
382 |
(error "Face not configured for %s mode" mode-name))) |
(error "Face not configured for %s mode" mode-name))) |
383 |
|
|
|
|
|
384 |
;;;###autoload |
;;;###autoload |
385 |
(define-derived-mode sgml-mode text-mode "SGML" |
(define-derived-mode sgml-mode text-mode "SGML" |
386 |
"Major mode for editing SGML documents. |
"Major mode for editing SGML documents. |
446 |
(concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\(" |
(concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\(" |
447 |
sgml-name-re "\\)"))) |
sgml-name-re "\\)"))) |
448 |
|
|
|
|
|
449 |
(defun sgml-comment-indent () |
(defun sgml-comment-indent () |
450 |
(if (looking-at "--") comment-column 0)) |
(if (looking-at "--") comment-column 0)) |
451 |
|
|
|
|
|
|
|
|
452 |
(defun sgml-slash (arg) |
(defun sgml-slash (arg) |
453 |
"Insert ARG slash characters. |
"Insert ARG slash characters. |
454 |
Behaves electrically if `sgml-quick-keys' is non-nil." |
Behaves electrically if `sgml-quick-keys' is non-nil." |
505 |
(buffer-substring (line-beginning-position) |
(buffer-substring (line-beginning-position) |
506 |
(1+ blinkpos))))))))) |
(1+ blinkpos))))))))) |
507 |
|
|
|
|
|
508 |
;; Why doesn't this use the iso-cvt table or, preferably, generate the |
;; Why doesn't this use the iso-cvt table or, preferably, generate the |
509 |
;; inverse of the extensive table in the SGML Quail input method? -- fx |
;; inverse of the extensive table in the SGML Quail input method? -- fx |
510 |
;; I guess that's moot since it only works with Latin-1 anyhow. |
;; I guess that's moot since it only works with Latin-1 anyhow. |
654 |
(or (> (point) point) |
(or (> (point) point) |
655 |
(self-insert-command 1))))) |
(self-insert-command 1))))) |
656 |
|
|
|
|
|
657 |
(defun sgml-tag-help (&optional tag) |
(defun sgml-tag-help (&optional tag) |
658 |
"Display description of tag TAG. If TAG is omitted, use the tag at point." |
"Display description of tag TAG. If TAG is omitted, use the tag at point." |
659 |
(interactive) |
(interactive) |
671 |
(cdr (assoc (downcase (substring tag 1)) sgml-tag-help))) |
(cdr (assoc (downcase (substring tag 1)) sgml-tag-help))) |
672 |
"No description available"))) |
"No description available"))) |
673 |
|
|
|
|
|
674 |
(defun sgml-maybe-end-tag (&optional arg) |
(defun sgml-maybe-end-tag (&optional arg) |
675 |
"Name self unless in position to end a tag or a prefix ARG is given." |
"Name self unless in position to end a tag or a prefix ARG is given." |
676 |
(interactive "P") |
(interactive "P") |
767 |
(goto-char open) |
(goto-char open) |
768 |
(kill-sexp 1))) |
(kill-sexp 1))) |
769 |
(setq arg (1- arg)))) |
(setq arg (1- arg)))) |
770 |
|
|
771 |
|
|
772 |
;; Put read-only last to enable setting this even when read-only enabled. |
;; Put read-only last to enable setting this even when read-only enabled. |
773 |
(or (get 'sgml-tag 'invisible) |
(or (get 'sgml-tag 'invisible) |
836 |
(eq (preceding-char) ?>))) |
(eq (preceding-char) ?>))) |
837 |
(backward-list) |
(backward-list) |
838 |
(forward-list))))))) |
(forward-list))))))) |
839 |
|
|
840 |
|
|
841 |
(autoload 'compile-internal "compile") |
(autoload 'compile-internal "compile") |
842 |
|
|
858 |
(save-some-buffers (not compilation-ask-about-save) nil) |
(save-some-buffers (not compilation-ask-about-save) nil) |
859 |
(compile-internal command "No more errors")) |
(compile-internal command "No more errors")) |
860 |
|
|
|
|
|
861 |
(defun sgml-lexical-context (&optional limit) |
(defun sgml-lexical-context (&optional limit) |
862 |
"Return the lexical context at point as (TYPE . START). |
"Return the lexical context at point as (TYPE . START). |
863 |
START is the location of the start of the lexical element. |
START is the location of the start of the lexical element. |
947 |
(replace-match (cdr (assq (char-before) '((?& . "&") |
(replace-match (cdr (assq (char-before) '((?& . "&") |
948 |
(?< . "<") |
(?< . "<") |
949 |
(?> . ">")))))))) |
(?> . ">")))))))) |
|
|
|
950 |
|
|
951 |
(defsubst sgml-at-indentation-p () |
(defsubst sgml-at-indentation-p () |
952 |
"Return true if point is at the first non-whitespace character on the line." |
"Return true if point is at the first non-whitespace character on the line." |
1316 |
map) |
map) |
1317 |
"Keymap for commands for use in HTML mode.") |
"Keymap for commands for use in HTML mode.") |
1318 |
|
|
|
|
|
1319 |
(defvar html-face-tag-alist |
(defvar html-face-tag-alist |
1320 |
'((bold . "b") |
'((bold . "b") |
1321 |
(italic . "i") |
(italic . "i") |
1346 |
("var" . italic)) |
("var" . italic)) |
1347 |
"Value of `sgml-tag-face-alist' for HTML mode.") |
"Value of `sgml-tag-face-alist' for HTML mode.") |
1348 |
|
|
|
|
|
1349 |
(defvar html-display-text |
(defvar html-display-text |
1350 |
'((img . "[/]") |
'((img . "[/]") |
1351 |
(hr . "----------") |
(hr . "----------") |
1352 |
(li . "o ")) |
(li . "o ")) |
1353 |
"Value of `sgml-display-text' for HTML mode.") |
"Value of `sgml-display-text' for HTML mode.") |
|
|
|
1354 |
|
|
1355 |
|
|
1356 |
;; should code exactly HTML 3 here when that is finished |
;; should code exactly HTML 3 here when that is finished |
1357 |
(defvar html-tag-alist |
(defvar html-tag-alist |
1358 |
(let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7"))) |
(let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7"))) |
1591 |
("var" . "Math variable face") |
("var" . "Math variable face") |
1592 |
("wbr" . "Enable <br> within <nobr>")) |
("wbr" . "Enable <br> within <nobr>")) |
1593 |
"*Value of `sgml-tag-help' for HTML mode.") |
"*Value of `sgml-tag-help' for HTML mode.") |
1594 |
|
|
1595 |
|
|
1596 |
;;;###autoload |
;;;###autoload |
1597 |
(define-derived-mode html-mode sgml-mode "HTML" |
(define-derived-mode html-mode sgml-mode "HTML" |
1665 |
;; (make-local-variable 'imenu-sort-function) |
;; (make-local-variable 'imenu-sort-function) |
1666 |
;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose |
;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose |
1667 |
) |
) |
1668 |
|
|
1669 |
(defvar html-imenu-regexp |
(defvar html-imenu-regexp |
1670 |
"\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)" |
"\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)" |
1671 |
"*A regular expression matching a head line to be added to the menu. |
"*A regular expression matching a head line to be added to the menu. |
1701 |
(add-hook 'after-save-hook 'browse-url-of-buffer nil t)) |
(add-hook 'after-save-hook 'browse-url-of-buffer nil t)) |
1702 |
(message "Autoviewing turned %s." |
(message "Autoviewing turned %s." |
1703 |
(if arg "off" "on"))) |
(if arg "off" "on"))) |
1704 |
|
|
1705 |
|
|
1706 |
(define-skeleton html-href-anchor |
(define-skeleton html-href-anchor |
1707 |
"HTML anchor tag with href attribute." |
"HTML anchor tag with href attribute." |