diff options
| author | Richard M. Stallman | 1996-01-24 17:12:21 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1996-01-24 17:12:21 +0000 |
| commit | fcc3195eee02457d307257c8eb86be2e5fe6cd49 (patch) | |
| tree | 188e4d3ab501cf4a6811147bcfbe972ce8aa9e9d /lisp | |
| parent | 189134c3e70590e9dc4f5d5816deb0dea8ee8152 (diff) | |
| download | emacs-fcc3195eee02457d307257c8eb86be2e5fe6cd49.tar.gz emacs-fcc3195eee02457d307257c8eb86be2e5fe6cd49.zip | |
(sgml-quick-keys): New variable.
(sgml-mode-map): Use it, defined additional long keys to compensate.
(sgml-tag-alist): Added <![ ]>
(sgml-tag): Special treatment for previous construct.
(sgml-auto-attributes): Deleted variable covered by sgml-quick-keys,
changed function of same name.
(sgml-delete-tag): Newline also counts as whitespace before tag.
(html-quick-keys): Use sgml-quick-keys as default, thus changed to nil.
(html-mode-map): Added C-c C-c char combinations for when
html-quick-keys is nil.
(html-tag-alist): Added /cgi-bin/ to href completions, submit (spelling
fixed) button to form.
(html-checkboxes): New skeleton.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/textmodes/sgml-mode.el | 129 |
1 files changed, 82 insertions, 47 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index 51512092857..f146e21a4b3 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el | |||
| @@ -45,8 +45,13 @@ The supported characters and potential disadvantages are: | |||
| 45 | 45 | ||
| 46 | When only one of ?\\\" or ?' are included, \"'\" or '\"' as it can be found in | 46 | When only one of ?\\\" or ?' are included, \"'\" or '\"' as it can be found in |
| 47 | DTDs, start a string. To partially avoid this problem this also makes these | 47 | DTDs, start a string. To partially avoid this problem this also makes these |
| 48 | self insert as named entities. <!----> must contain an even multiple of two | 48 | self insert as named entities depending on `sgml-quick-keys'. <!----> must |
| 49 | (4, 8, ...) minuses, or Emacs' syntax mechanism won't recognize a comment.") | 49 | contain an even multiple of two (4, 8, ...) minuses, or Emacs' syntax |
| 50 | mechanism won't recognize a comment.") | ||
| 51 | |||
| 52 | (defvar sgml-quick-keys nil | ||
| 53 | "Use <, >, &, SPC and `sgml-specials' keys ``electrically'' when non-nil. | ||
| 54 | This takes effect when first loading the library.") | ||
| 50 | 55 | ||
| 51 | 56 | ||
| 52 | (defvar sgml-mode-map | 57 | (defvar sgml-mode-map |
| @@ -55,8 +60,8 @@ self insert as named entities. <!----> must contain an even multiple of two | |||
| 55 | (define-key map "\t" 'indent-relative-maybe) | 60 | (define-key map "\t" 'indent-relative-maybe) |
| 56 | (define-key map "\C-c\C-i" 'sgml-tags-invisible) | 61 | (define-key map "\C-c\C-i" 'sgml-tags-invisible) |
| 57 | (define-key map "/" 'sgml-slash) | 62 | (define-key map "/" 'sgml-slash) |
| 58 | (define-key map "&" 'sgml-name-char) | 63 | (define-key map "\C-c\C-n" 'sgml-name-char) |
| 59 | (define-key map "<" 'sgml-tag) | 64 | (define-key map "\C-c\C-t" 'sgml-tag) |
| 60 | (define-key map "\C-c\C-a" 'sgml-attributes) | 65 | (define-key map "\C-c\C-a" 'sgml-attributes) |
| 61 | (define-key map "\C-c\C-b" 'sgml-skip-tag-backward) | 66 | (define-key map "\C-c\C-b" 'sgml-skip-tag-backward) |
| 62 | (define-key map [?\C-c left] 'sgml-skip-tag-backward) | 67 | (define-key map [?\C-c left] 'sgml-skip-tag-backward) |
| @@ -65,14 +70,18 @@ self insert as named entities. <!----> must contain an even multiple of two | |||
| 65 | (define-key map "\C-c\C-d" 'sgml-delete-tag) | 70 | (define-key map "\C-c\C-d" 'sgml-delete-tag) |
| 66 | (define-key map "\C-c\^?" 'sgml-delete-tag) | 71 | (define-key map "\C-c\^?" 'sgml-delete-tag) |
| 67 | (define-key map "\C-c?" 'sgml-tag-help) | 72 | (define-key map "\C-c?" 'sgml-tag-help) |
| 68 | (define-key map " " 'sgml-auto-attributes) | ||
| 69 | (define-key map ">" 'sgml-maybe-end-tag) | ||
| 70 | (if (memq ?\" sgml-specials) | ||
| 71 | (define-key map "\"" 'sgml-name-self)) | ||
| 72 | (if (memq ?' sgml-specials) | ||
| 73 | (define-key map "'" 'sgml-name-self)) | ||
| 74 | (define-key map "\C-c8" 'sgml-name-8bit-mode) | 73 | (define-key map "\C-c8" 'sgml-name-8bit-mode) |
| 75 | (define-key map "\C-c\C-v" 'sgml-validate) | 74 | (define-key map "\C-c\C-v" 'sgml-validate) |
| 75 | (if sgml-quick-keys | ||
| 76 | (progn | ||
| 77 | (define-key map "&" 'sgml-name-char) | ||
| 78 | (define-key map "<" 'sgml-tag) | ||
| 79 | (define-key map " " 'sgml-auto-attributes) | ||
| 80 | (define-key map ">" 'sgml-maybe-end-tag) | ||
| 81 | (if (memq ?\" sgml-specials) | ||
| 82 | (define-key map "\"" 'sgml-name-self)) | ||
| 83 | (if (memq ?' sgml-specials) | ||
| 84 | (define-key map "'" 'sgml-name-self)))) | ||
| 76 | (let ((c 127) | 85 | (let ((c 127) |
| 77 | (map (nth 1 map))) | 86 | (map (nth 1 map))) |
| 78 | (while (< (setq c (1+ c)) 256) | 87 | (while (< (setq c (1+ c)) 256) |
| @@ -202,7 +211,8 @@ When more these are fontified together with `sgml-font-lock-keywords'.") | |||
| 202 | 211 | ||
| 203 | 212 | ||
| 204 | (defvar sgml-tag-alist | 213 | (defvar sgml-tag-alist |
| 205 | '(("!attlist") | 214 | '(("![" ("ignore" t) ("include" t)) |
| 215 | ("!attlist") | ||
| 206 | ("!doctype") | 216 | ("!doctype") |
| 207 | ("!element") | 217 | ("!element") |
| 208 | ("!entity")) | 218 | ("!entity")) |
| @@ -245,10 +255,6 @@ an optional alist of possible values.") | |||
| 245 | (symbol-plist 'sgml-tag)))) | 255 | (symbol-plist 'sgml-tag)))) |
| 246 | 256 | ||
| 247 | 257 | ||
| 248 | (defvar sgml-auto-attributes t | ||
| 249 | "*When non-`nil' SPC at top level of tag prompts for attributes.") | ||
| 250 | |||
| 251 | |||
| 252 | 258 | ||
| 253 | (defun sgml-mode-common (sgml-tag-face-alist sgml-display-text) | 259 | (defun sgml-mode-common (sgml-tag-face-alist sgml-display-text) |
| 254 | "Common code for setting up `sgml-mode' and derived modes. | 260 | "Common code for setting up `sgml-mode' and derived modes. |
| @@ -327,6 +333,8 @@ varables of same name)." | |||
| 327 | (defun sgml-mode (&optional function) | 333 | (defun sgml-mode (&optional function) |
| 328 | "Major mode for editing SGML documents. | 334 | "Major mode for editing SGML documents. |
| 329 | Makes > match <. Makes / blink matching /. | 335 | Makes > match <. Makes / blink matching /. |
| 336 | Keys <, &, SPC within <>, \" and ' can be electric depending on | ||
| 337 | `sgml-quick-keys'. | ||
| 330 | 338 | ||
| 331 | Do \\[describe-variable] sgml- SPC to see available variables. | 339 | Do \\[describe-variable] sgml- SPC to see available variables. |
| 332 | 340 | ||
| @@ -444,16 +452,19 @@ to `upcase'." | |||
| 444 | ?< (setq v1 (eval str)) | | 452 | ?< (setq v1 (eval str)) | |
| 445 | (("") -1 '(undo-boundary) "<") | | 453 | (("") -1 '(undo-boundary) "<") | |
| 446 | (("") '(setq v2 (sgml-attributes v1 t)) ?> | 454 | (("") '(setq v2 (sgml-attributes v1 t)) ?> |
| 447 | (if (or (eq v2 t) | 455 | (if (string= "![" v1) |
| 448 | (string-match "^[/!?]" v1)) | 456 | (prog1 '(("") " [ " _ " ]]") |
| 449 | () | 457 | (backward-char)) |
| 450 | (if (symbolp v2) | 458 | (if (or (eq v2 t) |
| 451 | '(("") v2 _ v2 "</" v1 ?>) | 459 | (string-match "^[/!?]" v1)) |
| 452 | (if (eq (car v2) t) | 460 | () |
| 453 | (cons '("") (cdr v2)) | 461 | (if (symbolp v2) |
| 454 | (append '(("") (car v2)) | 462 | '(("") v2 _ v2 "</" v1 ?>) |
| 455 | (cdr v2) | 463 | (if (eq (car v2) t) |
| 456 | '(resume: (car v2) _ "</" v1 ?>))))))) | 464 | (cons '("") (cdr v2)) |
| 465 | (append '(("") (car v2)) | ||
| 466 | (cdr v2) | ||
| 467 | '(resume: (car v2) _ "</" v1 ?>)))))))) | ||
| 457 | 468 | ||
| 458 | (autoload 'skeleton-read "skeleton") | 469 | (autoload 'skeleton-read "skeleton") |
| 459 | 470 | ||
| @@ -493,12 +504,11 @@ to `upcase'." | |||
| 493 | 504 | ||
| 494 | (defun sgml-auto-attributes (arg) | 505 | (defun sgml-auto-attributes (arg) |
| 495 | "Self insert, except, when at top level of tag, prompt for attributes. | 506 | "Self insert, except, when at top level of tag, prompt for attributes. |
| 496 | With prefix ARG, or if `sgml-auto-attributes' is `nil' only self insert." | 507 | With prefix ARG only self insert." |
| 497 | (interactive "*P") | 508 | (interactive "*P") |
| 498 | (let ((point (point)) | 509 | (let ((point (point)) |
| 499 | tag) | 510 | tag) |
| 500 | (if (or arg | 511 | (if (or arg |
| 501 | (not sgml-auto-attributes) | ||
| 502 | (not sgml-tag-alist) ; no message when nothing configured | 512 | (not sgml-tag-alist) ; no message when nothing configured |
| 503 | (symbolp (setq tag (save-excursion (sgml-beginning-of-tag t)))) | 513 | (symbolp (setq tag (save-excursion (sgml-beginning-of-tag t)))) |
| 504 | (eq (aref tag 0) ?/)) | 514 | (eq (aref tag 0) ?/)) |
| @@ -595,7 +605,7 @@ With prefix ARG, repeat that many times." | |||
| 595 | (while (>= arg 1) | 605 | (while (>= arg 1) |
| 596 | (save-excursion | 606 | (save-excursion |
| 597 | (let* (close open) | 607 | (let* (close open) |
| 598 | (if (looking-at "[ \t]*<") | 608 | (if (looking-at "[ \t\n]*<") |
| 599 | ;; just before tag | 609 | ;; just before tag |
| 600 | (if (eq (char-after (match-end 0)) ?/) | 610 | (if (eq (char-after (match-end 0)) ?/) |
| 601 | ;; closing tag | 611 | ;; closing tag |
| @@ -742,27 +752,38 @@ Else `t'." | |||
| 742 | 752 | ||
| 743 | (provide 'sgml-mode) | 753 | (provide 'sgml-mode) |
| 744 | 754 | ||
| 745 | (defvar html-quick-keys t | 755 | (defvar html-quick-keys sgml-quick-keys |
| 746 | "Use C-c <x> combinations for quick insertion of frequent tags when non-nil. | 756 | "Use C-c X combinations for quick insertion of frequent tags when non-nil. |
| 757 | This defaults to `sgml-quick-keys'. | ||
| 747 | This takes effect when first loading the library.") | 758 | This takes effect when first loading the library.") |
| 748 | 759 | ||
| 749 | (defvar html-mode-map | 760 | (defvar html-mode-map |
| 750 | (let ((map (nconc (make-sparse-keymap) sgml-mode-map)) | 761 | (let ((map (nconc (make-sparse-keymap) sgml-mode-map)) |
| 751 | (menu-map (make-sparse-keymap "HTML"))) | 762 | (menu-map (make-sparse-keymap "HTML"))) |
| 763 | (define-key map "\C-c6" 'html-headline) | ||
| 764 | (define-key map "\C-c5" 'html-headline) | ||
| 765 | (define-key map "\C-c4" 'html-headline) | ||
| 766 | (define-key map "\C-c3" 'html-headline) | ||
| 767 | (define-key map "\C-c2" 'html-headline) | ||
| 768 | (define-key map "\C-c1" 'html-headline) | ||
| 769 | (define-key map "\C-c\r" 'html-paragraph) | ||
| 770 | (define-key map "\C-c\n" 'html-line) | ||
| 771 | (define-key map "\C-c\C-c-" 'html-horizontal-rule) | ||
| 772 | (define-key map "\C-c\C-co" 'html-list) | ||
| 773 | (define-key map "\C-c\C-cu" 'html-list) | ||
| 774 | (define-key map "\C-c\C-cr" 'html-radio-buttons) | ||
| 775 | (define-key map "\C-c\C-cc" 'html-checkboxes) | ||
| 776 | (define-key map "\C-c\C-cl" 'html-list-item) | ||
| 777 | (define-key map "\C-c\C-ch" 'html-href-anchor) | ||
| 778 | (define-key map "\C-c\C-cn" 'html-name-anchor) | ||
| 779 | (define-key map "\C-c\C-ci" 'html-image) | ||
| 752 | (if html-quick-keys | 780 | (if html-quick-keys |
| 753 | (progn | 781 | (progn |
| 754 | (define-key map "\C-c1" 'html-headline) | ||
| 755 | (define-key map "\C-c2" 'html-headline) | ||
| 756 | (define-key map "\C-c3" 'html-headline) | ||
| 757 | (define-key map "\C-c4" 'html-headline) | ||
| 758 | (define-key map "\C-c5" 'html-headline) | ||
| 759 | (define-key map "\C-c6" 'html-headline) | ||
| 760 | (define-key map "\C-c-" 'html-horizontal-rule) | 782 | (define-key map "\C-c-" 'html-horizontal-rule) |
| 761 | (define-key map "\C-c\r" 'html-paragraph) | ||
| 762 | (define-key map "\C-c\n" 'html-line) | ||
| 763 | (define-key map "\C-co" 'html-list) | 783 | (define-key map "\C-co" 'html-list) |
| 764 | (define-key map "\C-cu" 'html-list) | 784 | (define-key map "\C-cu" 'html-list) |
| 765 | (define-key map "\C-cr" 'html-radio-buttons) | 785 | (define-key map "\C-cr" 'html-radio-buttons) |
| 786 | (define-key map "\C-cc" 'html-checkboxes) | ||
| 766 | (define-key map "\C-cl" 'html-list-item) | 787 | (define-key map "\C-cl" 'html-list-item) |
| 767 | (define-key map "\C-ch" 'html-href-anchor) | 788 | (define-key map "\C-ch" 'html-href-anchor) |
| 768 | (define-key map "\C-cn" 'html-name-anchor) | 789 | (define-key map "\C-cn" 'html-name-anchor) |
| @@ -782,10 +803,11 @@ This takes effect when first loading the library.") | |||
| 782 | (define-key menu-map "2" '("Heading 2" . html-headline)) | 803 | (define-key menu-map "2" '("Heading 2" . html-headline)) |
| 783 | (define-key menu-map "1" '("Heading 1" . html-headline)) | 804 | (define-key menu-map "1" '("Heading 1" . html-headline)) |
| 784 | (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons)) | 805 | (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons)) |
| 806 | (define-key menu-map "c" '("Checkboxes" . html-checkboxes)) | ||
| 785 | (define-key menu-map "l" '("List Item" . html-list-item)) | 807 | (define-key menu-map "l" '("List Item" . html-list-item)) |
| 786 | (define-key menu-map "u" '("Unordered List" . html-list)) | 808 | (define-key menu-map "u" '("Unordered List" . html-list)) |
| 787 | (define-key menu-map "o" '("Ordered List" . html-list)) | 809 | (define-key menu-map "o" '("Ordered List" . html-list)) |
| 788 | (define-key menu-map "-" '("Horizontal rule" . html-horizontal-rule)) | 810 | (define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule)) |
| 789 | (define-key menu-map "\n" '("Line Break" . html-line)) | 811 | (define-key menu-map "\n" '("Line Break" . html-line)) |
| 790 | (define-key menu-map "\r" '("Paragraph" . html-paragraph)) | 812 | (define-key menu-map "\r" '("Paragraph" . html-paragraph)) |
| 791 | (define-key menu-map "i" '("Image" . html-image)) | 813 | (define-key menu-map "i" '("Image" . html-image)) |
| @@ -842,7 +864,7 @@ This takes effect when first loading the library.") | |||
| 842 | (rel '(("next") ("previous") ("parent") ("subdocument") ("made"))) | 864 | (rel '(("next") ("previous") ("parent") ("subdocument") ("made"))) |
| 843 | (href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:") | 865 | (href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:") |
| 844 | ("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:") | 866 | ("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:") |
| 845 | ("wais:"))) | 867 | ("wais:") ("/cgi-bin/"))) |
| 846 | (name '("name")) | 868 | (name '("name")) |
| 847 | (link `(,href | 869 | (link `(,href |
| 848 | ("rel" ,@rel) | 870 | ("rel" ,@rel) |
| @@ -864,7 +886,8 @@ This takes effect when first loading the library.") | |||
| 864 | ("base" t ,@href) | 886 | ("base" t ,@href) |
| 865 | ("dir" ,@list) | 887 | ("dir" ,@list) |
| 866 | ("font" "size" ("-1") ("+1") ("-2") ("+2") ,@(cdr (cdr 1-9))) | 888 | ("font" "size" ("-1") ("+1") ("-2") ("+2") ,@(cdr (cdr 1-9))) |
| 867 | ("form" \n ("action" ,@(cdr href)) ("method" ("get") ("post"))) | 889 | ("form" (\n _ \n "<input type=\"submit\" value=\"\">") |
| 890 | ("action" ,@(cdr href)) ("method" ("get") ("post"))) | ||
| 868 | ("h1" ,@align) | 891 | ("h1" ,@align) |
| 869 | ("h2" ,@align) | 892 | ("h2" ,@align) |
| 870 | ("h3" ,@align) | 893 | ("h3" ,@align) |
| @@ -876,7 +899,8 @@ This takes effect when first loading the library.") | |||
| 876 | ("src") ("alt") ("width" "1") ("height" "1") | 899 | ("src") ("alt") ("width" "1") ("height" "1") |
| 877 | ("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t)) | 900 | ("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t)) |
| 878 | ("input" t ("size" ,@1-9) ("maxlength" ,@1-9) ("checked" t) ,name | 901 | ("input" t ("size" ,@1-9) ("maxlength" ,@1-9) ("checked" t) ,name |
| 879 | ("type" ("text") ("password") ("checkbox") ("radio") ("sbmit") ("reset")) | 902 | ("type" ("text") ("password") ("checkbox") ("radio") |
| 903 | ("submit") ("reset")) | ||
| 880 | ("value")) | 904 | ("value")) |
| 881 | ("link" t ,@link) | 905 | ("link" t ,@link) |
| 882 | ("menu" ,@list) | 906 | ("menu" ,@list) |
| @@ -1058,12 +1082,12 @@ This takes effect when first loading the library.") | |||
| 1058 | ;;;###autoload | 1082 | ;;;###autoload |
| 1059 | (defun html-mode () | 1083 | (defun html-mode () |
| 1060 | "Major mode based on SGML mode for editing HTML documents. | 1084 | "Major mode based on SGML mode for editing HTML documents. |
| 1061 | This allows inserting skeleton costructs used in hypertext documents via | 1085 | This allows inserting skeleton costructs used in hypertext documents with |
| 1062 | the command `<' with completion. See below for an introduction to HTML. | 1086 | completion. See below for an introduction to HTML. Use |
| 1063 | Use \\[browse-url-of-buffer] to see how this comes out. | 1087 | \\[browse-url-of-buffer] to see how this comes out. See also `sgml-mode' on |
| 1064 | See also `sgml-mode' on which this is based. | 1088 | which this is based. |
| 1065 | 1089 | ||
| 1066 | Do \\[describe-variable] html- SPC to see available variables. | 1090 | Do \\[describe-variable] html- SPC and \\[describe-variable] sgml- SPC to see available variables. |
| 1067 | 1091 | ||
| 1068 | To write fairly well formatted pages you only need to know few things. Most | 1092 | To write fairly well formatted pages you only need to know few things. Most |
| 1069 | browsers have a function to read the source code of the page being seen, so | 1093 | browsers have a function to read the source code of the page being seen, so |
| @@ -1162,6 +1186,17 @@ do: | |||
| 1162 | (if (bolp) nil ?\n) | 1186 | (if (bolp) nil ?\n) |
| 1163 | \n "<p>") | 1187 | \n "<p>") |
| 1164 | 1188 | ||
| 1189 | (define-skeleton html-checkboxes | ||
| 1190 | "Group of connected checkbox inputs." | ||
| 1191 | nil | ||
| 1192 | '(setq v1 (eval str)) ; allow passing name as argument | ||
| 1193 | ("Value & Text: " | ||
| 1194 | "<input type=\"checkbox\" name=\"" | ||
| 1195 | (or v1 (setq v1 (skeleton-read "Name: "))) | ||
| 1196 | "\" value=\"" str ?\" | ||
| 1197 | (if v2 "" " checked") ?> str | ||
| 1198 | (or v2 (setq v2 (if (y-or-n-p "Newline? ") "<br>" ""))) \n)) | ||
| 1199 | |||
| 1165 | (define-skeleton html-radio-buttons | 1200 | (define-skeleton html-radio-buttons |
| 1166 | "Group of connected radio button inputs." | 1201 | "Group of connected radio button inputs." |
| 1167 | nil | 1202 | nil |