aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Steingold2001-10-27 16:07:35 +0000
committerSam Steingold2001-10-27 16:07:35 +0000
commitc77c3a7302d60b02ff6c8d3e852c3225b5b9a1e9 (patch)
treecab72753f366a1f61dae42ff58978490c0a41ec8
parent9ac553b9528f8cd59a4d0b29bd2a935026b3f4e0 (diff)
downloademacs-c77c3a7302d60b02ff6c8d3e852c3225b5b9a1e9.tar.gz
emacs-c77c3a7302d60b02ff6c8d3e852c3225b5b9a1e9.zip
renamed `html-xhtml' to `sgml-xml' and generalized accordingly
-rw-r--r--lisp/ChangeLog12
-rw-r--r--lisp/textmodes/sgml-mode.el173
2 files changed, 101 insertions, 84 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 77334afe7f8..c1fece77c0c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12001-10-27 Sam Steingold <sds@gnu.org>
2
3 * textmodes/sgml-mode.el (sgml-xml): Renamed from `html-xhtml'.
4 (sgml-xml-guess): Extracted from `html-mode' and generalized.
5 (sgml-mode-common): Call it.
6 (sgml-mode, html-mode): Set `mode-name' based on `sgml-xml'.
7 (sgml-tag, sgml-skip-close-p, html-tag-alist, html-line)
8 (html-horizontal-rule, html-image, html-ordered-list):
9 (html-unordered-list, html-list-item, html-paragraph):
10 (html-checkboxes, html-radio-buttons): Use `sgml-xml' instead of
11 `html-xhtml'.
12
12001-10-26 Masayuki Ataka <ataka@milk.freemail.ne.jp> 132001-10-26 Masayuki Ataka <ataka@milk.freemail.ne.jp>
2 14
3 * textmodes/texinfmt.el (texinfo-format-ifnotinfo): New function. 15 * textmodes/texinfmt.el (texinfo-format-ifnotinfo): New function.
diff --git a/lisp/textmodes/sgml-mode.el b/lisp/textmodes/sgml-mode.el
index e864327a13f..9cddc78988c 100644
--- a/lisp/textmodes/sgml-mode.el
+++ b/lisp/textmodes/sgml-mode.el
@@ -316,51 +316,77 @@ an optional alist of possible values."
316 (string :tag "Description"))) 316 (string :tag "Description")))
317 :group 'sgml) 317 :group 'sgml)
318 318
319(defcustom sgml-xml nil
320 "*When non-nil, tag insertion functions will be XML-compliant.
321If this variable is customized, the custom value is used always.
322Otherwise, it is set to be buffer-local when the file has
323 a DOCTYPE or an XML declaration."
324 :type 'boolean
325 :version "21.2"
326 :group 'sgml)
327
328(defun sgml-xml-guess ()
329 "Guess whether the current buffer is XML."
330 (save-excursion
331 (goto-char (point-min))
332 (cond ((or (string= "xml" (file-name-extension (or buffer-file-name "")))
333 (looking-at "\\s-*<\\?xml"))
334 (set (make-local-variable 'sgml-xml) t))
335 ((re-search-forward
336 (eval-when-compile
337 (mapconcat 'identity
338 '("<!DOCTYPE" "\\(\\w+\\)" "\\(\\w+\\)"
339 "\"\\([^\"]+\\)+\"" "\"\\([^\"]+\\)+\"")
340 "\\s-+"))
341 nil t)
342 (let ((name (match-string 1))
343 (pub (match-string 2))
344 (id (match-string 3))
345 (url (match-string 4)))
346 (cond ((string= name "html")
347 (set (make-local-variable 'sgml-xml)
348 (not (null (string-match "XHTML" id)))))
349 ((string-match "XML" id)
350 (set (make-local-variable 'sgml-xml) t))))))))
351
319(defvar v2) ; free for skeleton 352(defvar v2) ; free for skeleton
320 353
321(defun sgml-mode-common () 354(defun sgml-mode-common ()
322 "Common code for setting up `sgml-mode' and derived modes." 355 "Common code for setting up `sgml-mode' and derived modes."
323 (make-local-variable 'indent-line-function)
324 (make-local-variable 'paragraph-start)
325 (make-local-variable 'paragraph-separate)
326 (make-local-variable 'adaptive-fill-regexp)
327 (make-local-variable 'sgml-saved-validate-command) 356 (make-local-variable 'sgml-saved-validate-command)
328 (make-local-variable 'comment-start)
329 (make-local-variable 'comment-end)
330 (make-local-variable 'comment-indent-function)
331 (make-local-variable 'skeleton-transformation)
332 (make-local-variable 'skeleton-further-elements)
333 (make-local-variable 'skeleton-end-hook)
334 (make-local-variable 'font-lock-defaults)
335 (make-local-variable 'facemenu-add-face-function)
336 (make-local-variable 'facemenu-end-add-face) 357 (make-local-variable 'facemenu-end-add-face)
337 ;;(make-local-variable 'facemenu-remove-face-function) 358 ;;(make-local-variable 'facemenu-remove-face-function)
338 (setq indent-line-function 'indent-relative-maybe 359 (set (make-local-variable 'indent-line-function) 'indent-relative-maybe)
339 ;; A start or end tag by itself on a line separates a paragraph. 360 ;; A start or end tag by itself on a line separates a paragraph.
340 ;; This is desirable because SGML discards a newline that appears 361 ;; This is desirable because SGML discards a newline that appears
341 ;; immediately after a start tag or immediately before an end tag. 362 ;; immediately after a start tag or immediately before an end tag.
342 paragraph-separate "[ \t]*$\\|\ 363 (set (make-local-variable 'paragraph-separate) "[ \t]*$\\|\
343\[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$" 364\[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$")
344 paragraph-start "[ \t]*$\\|\ 365 (set (make-local-variable 'paragraph-start) "[ \t]*$\\|\
345\[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>" 366\[ \t]*</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>")
346 adaptive-fill-regexp "[ \t]*" 367 (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*")
347 comment-start "<!-- " 368 (set (make-local-variable 'comment-start) "<!-- ")
348 comment-end " -->" 369 (set (make-local-variable 'comment-end) " -->")
349 comment-indent-function 'sgml-comment-indent 370 (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent)
350 skeleton-transformation sgml-transformation 371 (set (make-local-variable 'skeleton-transformation) sgml-transformation)
351 skeleton-further-elements '((completion-ignore-case t)) 372 (set (make-local-variable 'skeleton-further-elements)
352 skeleton-end-hook (lambda () 373 '((completion-ignore-case t)))
353 (or (eolp) 374 (set (make-local-variable 'skeleton-end-hook)
354 (not (or (eq v2 '\n) 375 (lambda ()
355 (eq (car-safe v2) '\n))) 376 (or (eolp)
356 (newline-and-indent))) 377 (not (or (eq v2 '\n) (eq (car-safe v2) '\n)))
357 font-lock-defaults '((sgml-font-lock-keywords 378 (newline-and-indent))))
358 sgml-font-lock-keywords-1 379 (set (make-local-variable 'font-lock-defaults)
359 sgml-font-lock-keywords-2) 380 '((sgml-font-lock-keywords
360 nil t nil nil 381 sgml-font-lock-keywords-1
361 (font-lock-syntactic-keywords 382 sgml-font-lock-keywords-2)
362 . sgml-font-lock-syntactic-keywords)) 383 nil t nil nil
363 facemenu-add-face-function 'sgml-mode-facemenu-add-face-function) 384 (font-lock-syntactic-keywords
385 . sgml-font-lock-syntactic-keywords)))
386 (set (make-local-variable 'facemenu-add-face-function)
387 'sgml-mode-facemenu-add-face-function)
388 ;; `sgml-xml' not customized -- guess
389 (unless (get 'sgml-xml 'saved-value) (sgml-xml-guess))
364 ;; This will allow existing comments within declarations to be 390 ;; This will allow existing comments within declarations to be
365 ;; recognized. 391 ;; recognized.
366 (set (make-local-variable 'comment-start-skip) "\\(?:<!\\)?--[ \t]*") 392 (set (make-local-variable 'comment-start-skip) "\\(?:<!\\)?--[ \t]*")
@@ -396,11 +422,11 @@ Do \\[describe-variable] sgml- SPC to see available variables.
396Do \\[describe-key] on the following bindings to discover what they do. 422Do \\[describe-key] on the following bindings to discover what they do.
397\\{sgml-mode-map}" 423\\{sgml-mode-map}"
398 (sgml-mode-common) 424 (sgml-mode-common)
399 ;; Set imenu-generic-expression here, rather than in sgml-mode-common, 425 (when sgml-xml (setq mode-name "XML"))
426 ;; Set `imenu-generic-expression' here, rather than in `sgml-mode-common',
400 ;; because this definition probably is not useful in HTML mode. 427 ;; because this definition probably is not useful in HTML mode.
401 (make-local-variable 'imenu-generic-expression) 428 (set (make-local-variable 'imenu-generic-expression)
402 (setq imenu-generic-expression 429 "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\([A-Za-z][-A-Za-z.0-9]*\\)"))
403 "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\([A-Za-z][-A-Za-z.0-9]*\\)"))
404 430
405 431
406(defun sgml-comment-indent () 432(defun sgml-comment-indent ()
@@ -500,7 +526,6 @@ encoded keyboard operation."
500 (message "sgml name entity mode is now %s" 526 (message "sgml name entity mode is now %s"
501 (if sgml-name-8bit-mode "ON" "OFF"))) 527 (if sgml-name-8bit-mode "ON" "OFF")))
502 528
503
504;; When an element of a skeleton is a string "str", it is passed 529;; When an element of a skeleton is a string "str", it is passed
505;; through skeleton-transformation and inserted. If "str" is to be 530;; through skeleton-transformation and inserted. If "str" is to be
506;; inserted literally, one should obtain it as the return value of a 531;; inserted literally, one should obtain it as the return value of a
@@ -517,7 +542,7 @@ skeleton-transformation RET upcase RET, or put this in your `.emacs':
517 ?< str | 542 ?< str |
518 (("") -1 '(undo-boundary) (identity "&lt;")) | ; see comment above 543 (("") -1 '(undo-boundary) (identity "&lt;")) | ; see comment above
519 `(("") '(setq v2 (sgml-attributes ,str t)) 544 `(("") '(setq v2 (sgml-attributes ,str t))
520 (if (and (eq major-mode html-mode) html-xhtml (eq v2 t)) "/>" ">") 545 (if (and sgml-xml (eq v2 t)) "/>" ">")
521 (if (string= "![" ,str) 546 (if (string= "![" ,str)
522 (prog1 '(("") " [ " _ " ]]") 547 (prog1 '(("") " [ " _ " ]]")
523 (backward-char)) 548 (backward-char))
@@ -820,8 +845,7 @@ If this can't be done, return t."
820 (match-end 0)) 845 (match-end 0))
821 t))) 846 t)))
822 847
823(defun sgml-skip-close-p (obj) 848(defun sgml-skip-close-p (obj) (and (eq obj t) (not sgml-xml)))
824 (and (eq obj t) (not html-xhtml)))
825 849
826(defun sgml-value (alist) 850(defun sgml-value (alist)
827 "Interactively insert value taken from attributerule ALIST. 851 "Interactively insert value taken from attributerule ALIST.
@@ -970,15 +994,6 @@ This takes effect when first loading the library.")
970 "Value of `sgml-display-text' for HTML mode.") 994 "Value of `sgml-display-text' for HTML mode.")
971 995
972 996
973(defcustom html-xhtml nil
974 "*When non-nil, tag insertion functions will be XHTML-compliant.
975If this variable is customized, the custom value is used always.
976Otherwise, it is set to be buffer-local when the file has
977 a DOCTYPE declaration."
978 :type 'boolean
979 :version "21.2"
980 :group 'sgml)
981
982;; should code exactly HTML 3 here when that is finished 997;; should code exactly HTML 3 here when that is finished
983(defvar html-tag-alist 998(defvar html-tag-alist
984 (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7"))) 999 (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
@@ -995,7 +1010,7 @@ Otherwise, it is set to be buffer-local when the file has
995 ("rev" ,@rel) 1010 ("rev" ,@rel)
996 ("title"))) 1011 ("title")))
997 (list '((nil \n ("List item: " "<li>" str 1012 (list '((nil \n ("List item: " "<li>" str
998 (if html-xhtml "</li>") \n)))) 1013 (if sgml-xml "</li>") \n))))
999 (cell `(t 1014 (cell `(t
1000 ,@align 1015 ,@align
1001 ("valign" ,@valign) 1016 ("valign" ,@valign)
@@ -1063,16 +1078,16 @@ Otherwise, it is set to be buffer-local when the file has
1063 ("center" \n) 1078 ("center" \n)
1064 ("cite") 1079 ("cite")
1065 ("code" \n) 1080 ("code" \n)
1066 ("dd" ,(not html-xhtml)) 1081 ("dd" ,(not sgml-xml))
1067 ("del") 1082 ("del")
1068 ("dfn") 1083 ("dfn")
1069 ("div") 1084 ("div")
1070 ("dl" (nil \n 1085 ("dl" (nil \n
1071 ( "Term: " 1086 ( "Term: "
1072 "<dt>" str (if html-xhtml "</dt>") 1087 "<dt>" str (if sgml-xml "</dt>")
1073 "<dd>" _ (if html-xhtml "</dd>") \n))) 1088 "<dd>" _ (if sgml-xml "</dd>") \n)))
1074 ("dt" (t _ (if html-xhtml "</dt>") 1089 ("dt" (t _ (if sgml-xml "</dt>")
1075 "<dd>" (if html-xhtml "</dd>") \n)) 1090 "<dd>" (if sgml-xml "</dd>") \n))
1076 ("em") 1091 ("em")
1077 ;("fn" "id" "fn") ; ??? 1092 ;("fn" "id" "fn") ; ???
1078 ("head" \n) 1093 ("head" \n)
@@ -1091,7 +1106,7 @@ Otherwise, it is set to be buffer-local when the file has
1091 ("isindex" t ("action") ("prompt")) 1106 ("isindex" t ("action") ("prompt"))
1092 ("kbd") 1107 ("kbd")
1093 ("lang") 1108 ("lang")
1094 ("li" ,(not html-xhtml)) 1109 ("li" ,(not sgml-xml))
1095 ("math" \n) 1110 ("math" \n)
1096 ("nobr") 1111 ("nobr")
1097 ("option" t ("value") ("label") ("selected" t)) 1112 ("option" t ("value") ("label") ("selected" t))
@@ -1274,17 +1289,7 @@ To work around that, do:
1274 outline-level (lambda () 1289 outline-level (lambda ()
1275 (char-after (1- (match-end 0))))) 1290 (char-after (1- (match-end 0)))))
1276 (setq imenu-create-index-function 'html-imenu-index) 1291 (setq imenu-create-index-function 'html-imenu-index)
1277 (unless (get 'html-xhtml 'saved-value) 1292 (when sgml-xml (setq mode-name "XHTML"))
1278 ;; not customized -- set from the DocType
1279 (save-excursion
1280 (goto-char (point-min))
1281 (when (re-search-forward
1282 "<!DOCTYPE\\s-+html\\s-+PUBLIC\\s-+\"-//W3C//DTD \\(X?\\)HTML"
1283 nil t)
1284 (set (make-local-variable 'html-xhtml)
1285 (string= "X" (match-string 1))))))
1286 (when html-xhtml
1287 (setq mode-name "XHTML"))
1288 ;; It's for the user to decide if it defeats it or not -stef 1293 ;; It's for the user to decide if it defeats it or not -stef
1289 ;; (make-local-variable 'imenu-sort-function) 1294 ;; (make-local-variable 'imenu-sort-function)
1290 ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose 1295 ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
@@ -1370,44 +1375,44 @@ Can be used as a value for `html-mode-hook'."
1370(define-skeleton html-horizontal-rule 1375(define-skeleton html-horizontal-rule
1371 "HTML horizontal rule tag." 1376 "HTML horizontal rule tag."
1372 nil 1377 nil
1373 (if html-xhtml "<hr/>" "<hr>") \n) 1378 (if sgml-xml "<hr/>" "<hr>") \n)
1374 1379
1375(define-skeleton html-image 1380(define-skeleton html-image
1376 "HTML image tag." 1381 "HTML image tag."
1377 nil 1382 nil
1378 "<img src=\"" _ "\"" 1383 "<img src=\"" _ "\""
1379 (if html-xhtml "/>" ">")) 1384 (if sgml-xml "/>" ">"))
1380 1385
1381(define-skeleton html-line 1386(define-skeleton html-line
1382 "HTML line break tag." 1387 "HTML line break tag."
1383 nil 1388 nil
1384 (if html-xhtml "<br/>" "<br>") \n) 1389 (if sgml-xml "<br/>" "<br>") \n)
1385 1390
1386(define-skeleton html-ordered-list 1391(define-skeleton html-ordered-list
1387 "HTML ordered list tags." 1392 "HTML ordered list tags."
1388 nil 1393 nil
1389 "<ol>" \n 1394 "<ol>" \n
1390 "<li>" _ (if html-xhtml "</li>") \n 1395 "<li>" _ (if sgml-xml "</li>") \n
1391 "</ol>") 1396 "</ol>")
1392 1397
1393(define-skeleton html-unordered-list 1398(define-skeleton html-unordered-list
1394 "HTML unordered list tags." 1399 "HTML unordered list tags."
1395 nil 1400 nil
1396 "<ul>" \n 1401 "<ul>" \n
1397 "<li>" _ (if html-xhtml "</li>") \n 1402 "<li>" _ (if sgml-xml "</li>") \n
1398 "</ul>") 1403 "</ul>")
1399 1404
1400(define-skeleton html-list-item 1405(define-skeleton html-list-item
1401 "HTML list item tag." 1406 "HTML list item tag."
1402 nil 1407 nil
1403 (if (bolp) nil '\n) 1408 (if (bolp) nil '\n)
1404 "<li>" _ (if html-xhtml "</li>")) 1409 "<li>" _ (if sgml-xml "</li>"))
1405 1410
1406(define-skeleton html-paragraph 1411(define-skeleton html-paragraph
1407 "HTML paragraph tag." 1412 "HTML paragraph tag."
1408 nil 1413 nil
1409 (if (bolp) nil ?\n) 1414 (if (bolp) nil ?\n)
1410 \n "<p>" _ (if html-xhtml "</p>")) 1415 \n "<p>" _ (if sgml-xml "</p>"))
1411 1416
1412(define-skeleton html-checkboxes 1417(define-skeleton html-checkboxes
1413 "Group of connected checkbox inputs." 1418 "Group of connected checkbox inputs."
@@ -1420,11 +1425,11 @@ Can be used as a value for `html-mode-hook'."
1420 "\" value=\"" str ?\" 1425 "\" value=\"" str ?\"
1421 (when (y-or-n-p "Set \"checked\" attribute? ") 1426 (when (y-or-n-p "Set \"checked\" attribute? ")
1422 (funcall skeleton-transformation " checked")) 1427 (funcall skeleton-transformation " checked"))
1423 (if html-xhtml "/>" ">") 1428 (if sgml-xml "/>" ">")
1424 (skeleton-read "Text: " (capitalize str)) 1429 (skeleton-read "Text: " (capitalize str))
1425 (or v2 (setq v2 (if (y-or-n-p "Newline after text? ") 1430 (or v2 (setq v2 (if (y-or-n-p "Newline after text? ")
1426 (funcall skeleton-transformation 1431 (funcall skeleton-transformation
1427 (if html-xhtml "<br/>" "<br>")) 1432 (if sgml-xml "<br/>" "<br>"))
1428 ""))) 1433 "")))
1429 \n)) 1434 \n))
1430 1435
@@ -1439,11 +1444,11 @@ Can be used as a value for `html-mode-hook'."
1439 "\" value=\"" str ?\" 1444 "\" value=\"" str ?\"
1440 (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? "))) 1445 (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? ")))
1441 (funcall skeleton-transformation " checked")) 1446 (funcall skeleton-transformation " checked"))
1442 (if html-xhtml "/>" ">") 1447 (if sgml-xml "/>" ">")
1443 (skeleton-read "Text: " (capitalize str)) 1448 (skeleton-read "Text: " (capitalize str))
1444 (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ") 1449 (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ")
1445 (funcall skeleton-transformation 1450 (funcall skeleton-transformation
1446 (if html-xhtml "<br/>" "<br>")) 1451 (if sgml-xml "<br/>" "<br>"))
1447 ""))) 1452 "")))
1448 \n)) 1453 \n))
1449 1454