diff options
| author | Richard M. Stallman | 1997-04-23 18:58:33 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1997-04-23 18:58:33 +0000 |
| commit | d10447bad90b647a987779afd7fde51a19632875 (patch) | |
| tree | 2cd0c5c2b235469753205548722c846c5e0efa28 /lisp | |
| parent | 53d393c96beb8df9f68e246e5aa7a54d60892c9c (diff) | |
| download | emacs-d10447bad90b647a987779afd7fde51a19632875.tar.gz emacs-d10447bad90b647a987779afd7fde51a19632875.zip | |
(sgml-value): Use 'identity as default value.
(sgml-mode): Doc fix.
(sgml-name-8bit-mode): Tell the user if set or reset.
(sgml-tag): Doc fix.
(sgml-tag): Protect "<" from skeleton-transformation.
(sgml-attributes): Doc fix.
(sgml-attributes): Square brackets removed from prompt.
(sgml-attributes): Arg ALIST renamed to TAG.
(sgml-attributes): Apply skeleton-transformation when necessary.
(sgml-value): Doc added.
(sgml-value): Square brackets removed from prompt.
(html-tag-alist): New variable 1-7, variable `list' changed.
(html-tag-alist)<dir>, <menu>: Use new value of `list'.
(html-tag-alist)<font>: Fixed (doc of sgml-tag-alist needs fixing).
(html-tag-alist)<ol>, <ul>: Fixed.
(html-tag-alist)<fn>: Commented out.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/textmodes/sgml-mode.el | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el index ca86fee221d..c3f7c585a96 100644 --- a/lisp/textmodes/sgml-mode.el +++ b/lisp/textmodes/sgml-mode.el | |||
| @@ -36,7 +36,7 @@ | |||
| 36 | "SGML editing mode" | 36 | "SGML editing mode" |
| 37 | :group 'languages) | 37 | :group 'languages) |
| 38 | 38 | ||
| 39 | (defcustom sgml-transformation nil | 39 | (defcustom sgml-transformation 'identity |
| 40 | "*Default value for `skeleton-transformation' (which see) in SGML mode." | 40 | "*Default value for `skeleton-transformation' (which see) in SGML mode." |
| 41 | :type 'function | 41 | :type 'function |
| 42 | :group 'sgml) | 42 | :group 'sgml) |
| @@ -358,8 +358,8 @@ An argument of N to a tag-inserting command means that the next N | |||
| 358 | words should be wrapped. When the region is highlighted, N defaults | 358 | words should be wrapped. When the region is highlighted, N defaults |
| 359 | to -1, which means the current region. | 359 | to -1, which means the current region. |
| 360 | 360 | ||
| 361 | If you like upcased tags, put (setq skeleton-transformation 'upcase) in | 361 | If you like upcased tags, put (setq sgml-transformation 'upcase) in |
| 362 | sgml-mode-hook. | 362 | your .emacs file. |
| 363 | 363 | ||
| 364 | Use \\[sgml-validate] to validate your document with an SGML parser. | 364 | Use \\[sgml-validate] to validate your document with an SGML parser. |
| 365 | 365 | ||
| @@ -464,19 +464,26 @@ or M-- for a soft hyphen." | |||
| 464 | (defun sgml-name-8bit-mode () | 464 | (defun sgml-name-8bit-mode () |
| 465 | "Toggle insertion of 8 bit characters." | 465 | "Toggle insertion of 8 bit characters." |
| 466 | (interactive) | 466 | (interactive) |
| 467 | (setq sgml-name-8bit-mode (not sgml-name-8bit-mode))) | 467 | (setq sgml-name-8bit-mode (not sgml-name-8bit-mode)) |
| 468 | (message "sgml name 8 bit mode is now %" | ||
| 469 | (if sgml-name-8bit-mode "ON" "OFF"))) | ||
| 468 | 470 | ||
| 469 | 471 | ||
| 472 | ; When an element of a skeleton is a string "str", it is passed | ||
| 473 | ; through skeleton-transformation and inserted. If "str" is to be | ||
| 474 | ; inserted literally, one should obtain it as the return value of a | ||
| 475 | ; function, e.g. (identity "str"). | ||
| 470 | 476 | ||
| 471 | (define-skeleton sgml-tag | 477 | (define-skeleton sgml-tag |
| 472 | "Insert a tag you are prompted for, optionally with attributes. | 478 | "Insert a tag you are prompted for, optionally with attributes. |
| 473 | Completion and configuration is according to `sgml-tag-alist'. | 479 | Completion and configuration is done according to `sgml-tag-alist'. |
| 474 | If you like tags and attributes in uppercase set `skeleton-transformation' | 480 | If you like tags and attributes in uppercase do \\[set-variable] |
| 475 | to `upcase'." | 481 | skeleton-transformation RET upcase RET, or put this in your .emacs |
| 482 | (setq sgml-transformation 'upcase)." | ||
| 476 | (funcall skeleton-transformation | 483 | (funcall skeleton-transformation |
| 477 | (completing-read "Tag: " sgml-tag-alist)) | 484 | (completing-read "Tag: " sgml-tag-alist)) |
| 478 | ?< (setq v1 (eval str)) | | 485 | ?< (setq v1 (eval str)) | |
| 479 | (("") -1 '(undo-boundary) "<") | | 486 | (("") -1 '(undo-boundary) (identity "<")) | ; see comment above |
| 480 | (("") '(setq v2 (sgml-attributes v1 t)) ?> | 487 | (("") '(setq v2 (sgml-attributes v1 t)) ?> |
| 481 | (if (string= "![" v1) | 488 | (if (string= "![" v1) |
| 482 | (prog1 '(("") " [ " _ " ]]") | 489 | (prog1 '(("") " [ " _ " ]]") |
| @@ -494,14 +501,17 @@ to `upcase'." | |||
| 494 | 501 | ||
| 495 | (autoload 'skeleton-read "skeleton") | 502 | (autoload 'skeleton-read "skeleton") |
| 496 | 503 | ||
| 497 | (defun sgml-attributes (alist &optional quiet) | 504 | (defun sgml-attributes (tag &optional quiet) |
| 498 | "When at toplevel of a tag, interactively insert attributes." | 505 | "When at toplevel of a tag, interactively insert attributes. |
| 506 | |||
| 507 | Completion and configuration of TAG is done according to `sgml-tag-alist'. | ||
| 508 | If QUIET, does not print a message when there are no attributes for TAG." | ||
| 499 | (interactive (list (save-excursion (sgml-beginning-of-tag t)))) | 509 | (interactive (list (save-excursion (sgml-beginning-of-tag t)))) |
| 500 | (or (stringp alist) (error "Wrong context for adding attribute")) | 510 | (or (stringp tag) (error "Wrong context for adding attribute")) |
| 501 | (if alist | 511 | (if tag |
| 502 | (let ((completion-ignore-case t) | 512 | (let ((completion-ignore-case t) |
| 513 | (alist (cdr (assoc (downcase tag) sgml-tag-alist))) | ||
| 503 | car attribute i) | 514 | car attribute i) |
| 504 | (setq alist (cdr (assoc (downcase alist) sgml-tag-alist))) | ||
| 505 | (if (or (symbolp (car alist)) | 515 | (if (or (symbolp (car alist)) |
| 506 | (symbolp (car (car alist)))) | 516 | (symbolp (car (car alist)))) |
| 507 | (setq car (car alist) | 517 | (setq car (car alist) |
| @@ -510,7 +520,8 @@ to `upcase'." | |||
| 510 | (message "No attributes configured.")) | 520 | (message "No attributes configured.")) |
| 511 | (if (stringp (car alist)) | 521 | (if (stringp (car alist)) |
| 512 | (progn | 522 | (progn |
| 513 | (insert (if (eq (preceding-char) ? ) "" ? ) (car alist)) | 523 | (insert (if (eq (preceding-char) ? ) "" ? ) |
| 524 | (funcall skeleton-transformation (car alist))) | ||
| 514 | (sgml-value alist)) | 525 | (sgml-value alist)) |
| 515 | (setq i (length alist)) | 526 | (setq i (length alist)) |
| 516 | (while (> i 0) | 527 | (while (> i 0) |
| @@ -518,7 +529,7 @@ to `upcase'." | |||
| 518 | (insert (funcall skeleton-transformation | 529 | (insert (funcall skeleton-transformation |
| 519 | (setq attribute | 530 | (setq attribute |
| 520 | (skeleton-read '(completing-read | 531 | (skeleton-read '(completing-read |
| 521 | "[Attribute]: " | 532 | "Attribute: " |
| 522 | alist))))) | 533 | alist))))) |
| 523 | (if (string= "" attribute) | 534 | (if (string= "" attribute) |
| 524 | (setq i 0) | 535 | (setq i 0) |
| @@ -771,6 +782,8 @@ Else `t'." | |||
| 771 | t))) | 782 | t))) |
| 772 | 783 | ||
| 773 | (defun sgml-value (alist) | 784 | (defun sgml-value (alist) |
| 785 | "Interactively insert value taken from ALIST, which is an | ||
| 786 | `attributerule' as described in sgml-tag-alist." | ||
| 774 | (setq alist (cdr alist)) | 787 | (setq alist (cdr alist)) |
| 775 | (if (stringp (car alist)) | 788 | (if (stringp (car alist)) |
| 776 | (insert "=\"" (car alist) ?\") | 789 | (insert "=\"" (car alist) ?\") |
| @@ -779,7 +792,7 @@ Else `t'." | |||
| 779 | (progn | 792 | (progn |
| 780 | (insert "=\"") | 793 | (insert "=\"") |
| 781 | (setq alist (skeleton-read '(completing-read | 794 | (setq alist (skeleton-read '(completing-read |
| 782 | "[Value]: " (cdr alist)))) | 795 | "Value: " (cdr alist)))) |
| 783 | (if (string< "" alist) | 796 | (if (string< "" alist) |
| 784 | (insert alist ?\") | 797 | (insert alist ?\") |
| 785 | (delete-backward-char 2)))) | 798 | (delete-backward-char 2)))) |
| @@ -895,8 +908,8 @@ This takes effect when first loading the library.") | |||
| 895 | 908 | ||
| 896 | ; should code exactly HTML 3 here when that is finished | 909 | ; should code exactly HTML 3 here when that is finished |
| 897 | (defvar html-tag-alist | 910 | (defvar html-tag-alist |
| 898 | (let* ((1-9 '(("8") ("9") | 911 | (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7"))) |
| 899 | ("1") ("2") ("3") ("4") ("5") ("6") ("7"))) | 912 | (1-9 '(,@1-7 ("8") ("9"))) |
| 900 | (align '(("align" ("left") ("center") ("right")))) | 913 | (align '(("align" ("left") ("center") ("right")))) |
| 901 | (valign '(("top") ("middle") ("bottom") ("baseline"))) | 914 | (valign '(("top") ("middle") ("bottom") ("baseline"))) |
| 902 | (rel '(("next") ("previous") ("parent") ("subdocument") ("made"))) | 915 | (rel '(("next") ("previous") ("parent") ("subdocument") ("made"))) |
| @@ -908,10 +921,8 @@ This takes effect when first loading the library.") | |||
| 908 | ("rel" ,@rel) | 921 | ("rel" ,@rel) |
| 909 | ("rev" ,@rel) | 922 | ("rev" ,@rel) |
| 910 | ("title"))) | 923 | ("title"))) |
| 911 | (list '((nil \n | 924 | (list '((nil \n ( "List item: " |
| 912 | ( "List item: " | 925 | "<li>" str \n)))) |
| 913 | "<li>" str \n)) | ||
| 914 | ("type" ("A") ("a") ("I") ("i") ("1")))) | ||
| 915 | (cell `(t | 926 | (cell `(t |
| 916 | ,align | 927 | ,align |
| 917 | ("valign" ,@valign) | 928 | ("valign" ,@valign) |
| @@ -923,7 +934,7 @@ This takes effect when first loading the library.") | |||
| 923 | `(("a" ,name ,@link) | 934 | `(("a" ,name ,@link) |
| 924 | ("base" t ,@href) | 935 | ("base" t ,@href) |
| 925 | ("dir" ,@list) | 936 | ("dir" ,@list) |
| 926 | ("font" ("size" ("-1") ("+1") ("-2") ("+2") ,@(cdr (cdr 1-9)))) | 937 | ("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7) |
| 927 | ("form" (\n _ \n "<input type=\"submit\" value=\"\">") | 938 | ("form" (\n _ \n "<input type=\"submit\" value=\"\">") |
| 928 | ("action" ,@(cdr href)) ("method" ("get") ("post"))) | 939 | ("action" ,@(cdr href)) ("method" ("get") ("post"))) |
| 929 | ("h1" ,@align) | 940 | ("h1" ,@align) |
| @@ -942,7 +953,7 @@ This takes effect when first loading the library.") | |||
| 942 | ("value")) | 953 | ("value")) |
| 943 | ("link" t ,@link) | 954 | ("link" t ,@link) |
| 944 | ("menu" ,@list) | 955 | ("menu" ,@list) |
| 945 | ("ol" ,@list) | 956 | ("ol" ,@list ("type" ("A") ("a") ("I") ("i") ("1"))) |
| 946 | ("p" t ,@align) | 957 | ("p" t ,@align) |
| 947 | ("select" (nil \n | 958 | ("select" (nil \n |
| 948 | ("Text: " | 959 | ("Text: " |
| @@ -956,7 +967,7 @@ This takes effect when first loading the library.") | |||
| 956 | ("td" ,@cell) | 967 | ("td" ,@cell) |
| 957 | ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9)) | 968 | ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9)) |
| 958 | ("th" ,@cell) | 969 | ("th" ,@cell) |
| 959 | ("ul" ,@list) | 970 | ("ul" ,@list ("type" ("disc") ("circle") ("square"))) |
| 960 | 971 | ||
| 961 | ,@sgml-tag-alist | 972 | ,@sgml-tag-alist |
| 962 | 973 | ||
| @@ -987,7 +998,7 @@ This takes effect when first loading the library.") | |||
| 987 | "<dt>" str "<dd>" _ \n))) | 998 | "<dt>" str "<dd>" _ \n))) |
| 988 | ("dt" (t _ "<dd>")) | 999 | ("dt" (t _ "<dd>")) |
| 989 | ("em") | 1000 | ("em") |
| 990 | ("fn" "id" "fn") | 1001 | ;("fn" "id" "fn") ; ??? |
| 991 | ("head" \n) | 1002 | ("head" \n) |
| 992 | ("html" (\n | 1003 | ("html" (\n |
| 993 | "<head>\n" | 1004 | "<head>\n" |
| @@ -1057,7 +1068,7 @@ This takes effect when first loading the library.") | |||
| 1057 | ("figa" . "Figure anchor") | 1068 | ("figa" . "Figure anchor") |
| 1058 | ("figd" . "Figure description") | 1069 | ("figd" . "Figure description") |
| 1059 | ("figt" . "Figure text") | 1070 | ("figt" . "Figure text") |
| 1060 | ("fn" . "?") | 1071 | ;("fn" . "?") ; ??? |
| 1061 | ("font" . "Font size") | 1072 | ("font" . "Font size") |
| 1062 | ("form" . "Form with input fields") | 1073 | ("form" . "Form with input fields") |
| 1063 | ("group" . "Document grouping") | 1074 | ("group" . "Document grouping") |
| @@ -1266,7 +1277,7 @@ do: | |||
| 1266 | '(setq v1 nil | 1277 | '(setq v1 nil |
| 1267 | v2 nil) | 1278 | v2 nil) |
| 1268 | ("Value: " | 1279 | ("Value: " |
| 1269 | "<input type=\"" (identity "checkbox") | 1280 | "<input type=\"" (identity "checkbox") ; see comment above about identity |
| 1270 | "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: "))) | 1281 | "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: "))) |
| 1271 | "\" value=\"" str ?\" | 1282 | "\" value=\"" str ?\" |
| 1272 | (if (y-or-n-p "Set \"checked\" attribute? ") | 1283 | (if (y-or-n-p "Set \"checked\" attribute? ") |
| @@ -1283,7 +1294,7 @@ do: | |||
| 1283 | '(setq v1 nil | 1294 | '(setq v1 nil |
| 1284 | v2 (cons nil nil)) | 1295 | v2 (cons nil nil)) |
| 1285 | ("Value: " | 1296 | ("Value: " |
| 1286 | "<input type=\"" (identity "radio") | 1297 | "<input type=\"" (identity "radio") ; see comment above about identity |
| 1287 | "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: "))) | 1298 | "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: "))) |
| 1288 | "\" value=\"" str ?\" | 1299 | "\" value=\"" str ?\" |
| 1289 | (if (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? "))) | 1300 | (if (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? "))) |