aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-04-16 21:43:01 +0000
committerRichard M. Stallman1997-04-16 21:43:01 +0000
commita391b17964a73f14443ab8da300ac59cfef81750 (patch)
tree79e441c61b9893080a3992db0c68ea8ceeab656b
parent93c36a6dc791865b6ece2a628cb5328327484317 (diff)
downloademacs-a391b17964a73f14443ab8da300ac59cfef81750.tar.gz
emacs-a391b17964a73f14443ab8da300ac59cfef81750.zip
(sgml-value): Don't perform the skeleton-transformation
on the value. (sgml-transformation): New variable. (sgml-mode-common): Use it. (html-href-anchor): Ask for address, wrap around text. (html-name-anchor): Same as above, without initial input. (html-image): No initial input for address. (html-ordered-list): Incorporate char into string. (html-unordered-list): Same as above. (html-checkboxes, html-radio-buttons): Rewritten. (sgml-char-names): Change ensp to nbsp. (sgml-tag): Use intangible here. (sgml-tags-invisible): Don't add intangible property separately here. Just the category property is enough. Eliminate local variable `point'. Bind inhibit-point-motion-hooks.
-rw-r--r--lisp/textmodes/sgml-mode.el122
1 files changed, 74 insertions, 48 deletions
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index 6d52f835ca5..c9734c2a6c7 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -4,6 +4,7 @@
4 4
5;; Author: James Clark <jjc@jclark.com> 5;; Author: James Clark <jjc@jclark.com>
6;; Adapted-By: ESR; Daniel.Pfeiffer@Informatik.START.dbp.de 6;; Adapted-By: ESR; Daniel.Pfeiffer@Informatik.START.dbp.de
7;; F.Potorti@cnuce.cnr.it
7;; Keywords: wp, hypermedia, comm, languages 8;; Keywords: wp, hypermedia, comm, languages
8 9
9;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
@@ -35,6 +36,14 @@
35 "SGML editing mode" 36 "SGML editing mode"
36 :group 'languages) 37 :group 'languages)
37 38
39(defcustom sgml-transformation nil
40 "*Default value for `skeleton-transformation' (which see) in SGML mode."
41 :type 'function
42 :group sgml)
43
44(put 'sgml-transformation 'variable-interactive
45 "aTransformation function: ")
46
38;; As long as Emacs' syntax can't be complemented with predicates to context 47;; As long as Emacs' syntax can't be complemented with predicates to context
39;; sensitively confirm the syntax of characters, we have to live with this 48;; sensitively confirm the syntax of characters, we have to live with this
40;; kludgy kind of tradeoff. 49;; kludgy kind of tradeoff.
@@ -136,7 +145,7 @@ This takes effect when first loading the library.")
136 nil nil nil nil nil nil nil nil 145 nil nil nil nil nil nil nil nil
137 nil nil nil nil nil nil nil nil 146 nil nil nil nil nil nil nil nil
138 nil nil nil nil nil nil nil nil 147 nil nil nil nil nil nil nil nil
139 "ensp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos" 148 "nbsp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
140 "lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol" 149 "lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol"
141 nil nil nil nil nil nil nil nil 150 nil nil nil nil nil nil nil nil
142 nil nil "colon" "semi" "lt" "eq" "gt" "quest" 151 nil nil "colon" "semi" "lt" "eq" "gt" "quest"
@@ -262,18 +271,6 @@ an optional alist of possible values."
262 (string :tag "Description"))) 271 (string :tag "Description")))
263 :group 'sgml) 272 :group 'sgml)
264 273
265
266;; put read-only last to enable setting this even when read-only enabled
267(or (get 'sgml-tag 'invisible)
268 (setplist 'sgml-tag
269 (append '(invisible t
270 rear-nonsticky t
271 point-entered sgml-point-entered
272 read-only t)
273 (symbol-plist 'sgml-tag))))
274
275
276
277(defun sgml-mode-common (sgml-tag-face-alist sgml-display-text) 274(defun sgml-mode-common (sgml-tag-face-alist sgml-display-text)
278 "Common code for setting up `sgml-mode' and derived modes. 275 "Common code for setting up `sgml-mode' and derived modes.
279SGML-TAG-FACE-ALIST is used for calculating `sgml-font-lock-keywords-1'. 276SGML-TAG-FACE-ALIST is used for calculating `sgml-font-lock-keywords-1'.
@@ -321,7 +318,7 @@ varables of same name)."
321 ;; This will allow existing comments within declarations to be 318 ;; This will allow existing comments within declarations to be
322 ;; recognized. 319 ;; recognized.
323 comment-start-skip "--[ \t]*" 320 comment-start-skip "--[ \t]*"
324 skeleton-transformation 'identity 321 skeleton-transformation sgml-transformation
325 skeleton-further-elements '((completion-ignore-case t)) 322 skeleton-further-elements '((completion-ignore-case t))
326 skeleton-end-hook (lambda () 323 skeleton-end-hook (lambda ()
327 (or (eolp) 324 (or (eolp)
@@ -357,9 +354,17 @@ Makes > match <. Makes / blink matching /.
357Keys <, &, SPC within <>, \" and ' can be electric depending on 354Keys <, &, SPC within <>, \" and ' can be electric depending on
358`sgml-quick-keys'. 355`sgml-quick-keys'.
359 356
360Do \\[describe-variable] sgml- SPC to see available variables. 357An argument of N to a tag-inserting command means that the next N
358words should be wrapped. When the region is highlighted, N defaults
359to -1, which means the current region.
360
361If you like upcased tags, put (setq skeleton-transformation 'upcase) in
362sgml-mode-hook.
361 363
362Use \\[sgml-validate] to validate your document with an SGML parser. 364Use \\[sgml-validate] to validate your document with an SGML parser.
365
366Do \\[describe-variable] sgml- SPC to see available variables.
367Do \\[describe-key] on the following bindings to discover what they do.
363\\{sgml-mode-map}" 368\\{sgml-mode-map}"
364 (interactive) 369 (interactive)
365 (sgml-mode-common sgml-tag-face-alist sgml-display-text) 370 (sgml-mode-common sgml-tag-face-alist sgml-display-text)
@@ -662,18 +667,28 @@ With prefix ARG, repeat that many times."
662 (goto-char open) 667 (goto-char open)
663 (kill-sexp 1))) 668 (kill-sexp 1)))
664 (setq arg (1- arg)))) 669 (setq arg (1- arg))))
665 670
666 671;; Put read-only last to enable setting this even when read-only enabled.
672(or (get 'sgml-tag 'invisible)
673 (setplist 'sgml-tag
674 (append '(invisible t
675 intangible t
676 point-entered sgml-point-entered
677 rear-nonsticky t
678 read-only t)
679 (symbol-plist 'sgml-tag))))
667 680
668(defun sgml-tags-invisible (arg) 681(defun sgml-tags-invisible (arg)
669 "Toggle visibility of existing tags." 682 "Toggle visibility of existing tags."
670 (interactive "P") 683 (interactive "P")
671 (let ((modified (buffer-modified-p)) 684 (let ((modified (buffer-modified-p))
672 (inhibit-read-only t) 685 (inhibit-read-only t)
673 (point (point-min)) 686 ;; This is needed in case font lock gets called,
687 ;; since it moves point and might call sgml-point-entered.
688 (inhibit-point-motion-hooks t)
674 symbol) 689 symbol)
675 (save-excursion 690 (save-excursion
676 (goto-char point) 691 (goto-char (point-min))
677 (if (setq sgml-tags-invisible 692 (if (setq sgml-tags-invisible
678 (if arg 693 (if arg
679 (>= (prefix-numeric-value arg) 0) 694 (>= (prefix-numeric-value arg) 0)
@@ -687,12 +702,12 @@ With prefix ARG, repeat that many times."
687 (overlay-put (make-overlay (point) 702 (overlay-put (make-overlay (point)
688 (match-beginning 1)) 703 (match-beginning 1))
689 'category symbol)) 704 'category symbol))
690 (put-text-property (setq point (point)) (forward-list) 705 (put-text-property (point)
691 'intangible (point)) 706 (progn (forward-list) (point))
692 (put-text-property point (point)
693 'category 'sgml-tag)) 707 'category 'sgml-tag))
694 (while (< (setq point (next-overlay-change point)) (point-max)) 708 (let ((pos (point)))
695 (delete-overlay (car (overlays-at point)))) 709 (while (< (setq pos (next-overlay-change pos)) (point-max))
710 (delete-overlay (car (overlays-at pos)))))
696 (remove-text-properties (point-min) (point-max) 711 (remove-text-properties (point-min) (point-max)
697 '(category sgml-tag intangible t)))) 712 '(category sgml-tag intangible t))))
698 (set-buffer-modified-p modified) 713 (set-buffer-modified-p modified)
@@ -712,8 +727,7 @@ With prefix ARG, repeat that many times."
712 (eq (preceding-char) ?>))) 727 (eq (preceding-char) ?>)))
713 (backward-list) 728 (backward-list)
714 (forward-list))))))) 729 (forward-list)))))))
715 730
716
717(autoload 'compile-internal "compile") 731(autoload 'compile-internal "compile")
718 732
719(defun sgml-validate (command) 733(defun sgml-validate (command)
@@ -767,12 +781,11 @@ Else `t'."
767 (setq alist (skeleton-read '(completing-read 781 (setq alist (skeleton-read '(completing-read
768 "[Value]: " (cdr alist)))) 782 "[Value]: " (cdr alist))))
769 (if (string< "" alist) 783 (if (string< "" alist)
770 (insert (funcall skeleton-transformation alist) ?\") 784 (insert alist ?\")
771 (delete-backward-char 2)))) 785 (delete-backward-char 2))))
772 (insert "=\"") 786 (insert "=\"")
773 (if alist 787 (if alist
774 (insert (funcall skeleton-transformation 788 (insert (skeleton-read '(completing-read "Value: " alist))))
775 (skeleton-read '(completing-read "Value: " alist)))))
776 (insert ?\")))) 789 (insert ?\"))))
777 790
778(provide 'sgml-mode) 791(provide 'sgml-mode)
@@ -1167,13 +1180,14 @@ do:
1167 1180
1168(define-skeleton html-href-anchor 1181(define-skeleton html-href-anchor
1169 "HTML anchor tag with href attribute." 1182 "HTML anchor tag with href attribute."
1170 nil 1183 "URL: "
1171 "<a href=\"http:" _ "\"></a>") 1184 '(setq input "http:")
1185 "<a href=\"" str "\">" _ "</a>")
1172 1186
1173(define-skeleton html-name-anchor 1187(define-skeleton html-name-anchor
1174 "HTML anchor tag with name attribute." 1188 "HTML anchor tag with name attribute."
1175 nil 1189 "Name: "
1176 "<a name=\"" _ "\"></a>") 1190 "<a name=\"" str "\">" _ "</a>")
1177 1191
1178(define-skeleton html-headline-1 1192(define-skeleton html-headline-1
1179 "HTML level 1 headline tags." 1193 "HTML level 1 headline tags."
@@ -1213,7 +1227,7 @@ do:
1213(define-skeleton html-image 1227(define-skeleton html-image
1214 "HTML image tag." 1228 "HTML image tag."
1215 nil 1229 nil
1216 "<img src=\"http:" _ "\">") 1230 "<img src=\"" _ "\">")
1217 1231
1218(define-skeleton html-line 1232(define-skeleton html-line
1219 "HTML line break tag." 1233 "HTML line break tag."
@@ -1223,14 +1237,14 @@ do:
1223(define-skeleton html-ordered-list 1237(define-skeleton html-ordered-list
1224 "HTML ordered list tags." 1238 "HTML ordered list tags."
1225 nil 1239 nil
1226 ?< "ol>" \n 1240 "<ol>" \n
1227 "<li>" _ \n 1241 "<li>" _ \n
1228 "</ol>") 1242 "</ol>")
1229 1243
1230(define-skeleton html-unordered-list 1244(define-skeleton html-unordered-list
1231 "HTML unordered list tags." 1245 "HTML unordered list tags."
1232 nil 1246 nil
1233 ?< "ul>" \n 1247 "<ul>" \n
1234 "<li>" _ \n 1248 "<li>" _ \n
1235 "</ul>") 1249 "</ul>")
1236 1250
@@ -1249,24 +1263,36 @@ do:
1249(define-skeleton html-checkboxes 1263(define-skeleton html-checkboxes
1250 "Group of connected checkbox inputs." 1264 "Group of connected checkbox inputs."
1251 nil 1265 nil
1252 '(setq v1 (eval str)) ; allow passing name as argument 1266 '(setq v1 nil
1253 ("Value & Text: " 1267 v2 nil)
1254 "<input type=\"checkbox\" name=\"" 1268 ("Value: "
1255 (or v1 (setq v1 (skeleton-read "Name: "))) 1269 "<input type=\"" (identity "checkbox")
1270 "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: ")))
1256 "\" value=\"" str ?\" 1271 "\" value=\"" str ?\"
1257 (if v2 "" " checked") ?> str 1272 (if (y-or-n-p "Set \"checked\" attribute? ")
1258 (or v2 (setq v2 (if (y-or-n-p "Newline? ") "<br>" ""))) \n)) 1273 (funcall skeleton-transformation " checked")) ">"
1274 (skeleton-read "Text: " (capitalize str))
1275 (or v2 (setq v2 (if (y-or-n-p "Newline after text? ")
1276 (funcall skeleton-transformation "<br>")
1277 "")))
1278 \n))
1259 1279
1260(define-skeleton html-radio-buttons 1280(define-skeleton html-radio-buttons
1261 "Group of connected radio button inputs." 1281 "Group of connected radio button inputs."
1262 nil 1282 nil
1263 '(setq v1 (eval str)) ; allow passing name as argument 1283 '(setq v1 nil
1264 ("Value & Text: " 1284 v2 (cons nil nil))
1265 "<input type=\"radio\" name=\"" 1285 ("Value: "
1266 (or v1 (setq v1 (skeleton-read "Name: "))) 1286 "<input type=\"" (identity "radio")
1287 "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: ")))
1267 "\" value=\"" str ?\" 1288 "\" value=\"" str ?\"
1268 (if v2 "" " checked") ?> str 1289 (if (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? ")))
1269 (or v2 (setq v2 (if (y-or-n-p "Newline? ") "<br>" ""))) \n)) 1290 (funcall skeleton-transformation " checked") ">")
1291 (skeleton-read "Text: " (capitalize str))
1292 (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ")
1293 (funcall skeleton-transformation "<br>")
1294 "")))
1295 \n))
1270 1296
1271 1297
1272(defun html-autoview-mode (&optional arg) 1298(defun html-autoview-mode (&optional arg)