changeset 38068:e3bd229672c1

Move `provide' to the end. Update copyright. (sgml-mode-map): Use `make-keymap' rather than make the keymap by hand. Bind the latin-1 charset-char to sgml-maybe-name-self rather than incorrectly binding chars between 128 and 256 to it. (sgml-maybe-name-self): Handle latin-1 chars properly. (sgml-tags-invisible): Bind buffer-file-name to nil. Use unwind-protect and restore-buffer-modified-p. (sgml-point-entered): Use buffer-substring-no-properties. (html-tag-alist): Add `div' and `span' and fix backquote/unquote typos. (html-mode): Don't force `imenu-sort-function'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 17 Jun 2001 09:01:23 +0000
parents c1e43c8d51d2
children 8e47deabedf6
files lisp/textmodes/sgml-mode.el
diffstat 1 files changed, 51 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/textmodes/sgml-mode.el	Sat Jun 16 08:04:27 2001 +0000
+++ b/lisp/textmodes/sgml-mode.el	Sun Jun 17 09:01:23 2001 +0000
@@ -1,6 +1,6 @@
 ;;; sgml-mode.el --- SGML- and HTML-editing modes
 
-;; Copyright (C) 1992, 1995, 1996, 1998 Free Software Foundation, Inc.
+;; Copyright (C) 1992,95,96,98,2001  Free Software Foundation, Inc.
 
 ;; Author: James Clark <jjc@jclark.com>
 ;; Adapted-By: ESR, Daniel Pfeiffer <occitan@esperanto.org>,
@@ -80,7 +80,7 @@
 
 
 (defvar sgml-mode-map
-  (let ((map (list 'keymap (make-vector 256 nil)))
+  (let ((map (make-keymap))	;`sparse' doesn't allow binding to charsets.
 	(menu-map (make-sparse-keymap "SGML")))
     (define-key map "\C-c\C-i" 'sgml-tags-invisible)
     (define-key map "/" 'sgml-slash)
@@ -106,10 +106,7 @@
 	      (define-key map "\"" 'sgml-name-self))
 	  (if (memq ?' sgml-specials)
 	      (define-key map "'" 'sgml-name-self))))
-    (let ((c 127)
-	  (map (nth 1 map)))
-      (while (< (setq c (1+ c)) 256)
-	(aset map c 'sgml-maybe-name-self)))
+    (define-key map (make-char 'latin-iso8859-1) 'sgml-maybe-name-self)
     (define-key map [menu-bar sgml] (cons "SGML" menu-map))
     (define-key menu-map [sgml-validate] '("Validate" . sgml-validate))
     (define-key menu-map [sgml-name-8bit-mode]
@@ -203,8 +200,8 @@
   "The command last used to validate in this buffer.")
 
 
-;;; I doubt that null end tags are used much for large elements,
-;;; so use a small distance here.
+;; I doubt that null end tags are used much for large elements,
+;; so use a small distance here.
 (defcustom sgml-slash-distance 1000
   "*If non-nil, is the maximum distance to search for matching `/'."
   :type '(choice (const nil) integer)
@@ -478,7 +475,10 @@
   "Insert a symbolic character name according to `sgml-char-names'."
   (interactive "*")
   (if sgml-name-8bit-mode
-      (sgml-name-char last-command-char)
+      (sgml-name-char
+       (if (eq (char-charset last-command-char) 'latin-iso8859-1)
+	   (+ 128 (- last-command-char (make-char 'latin-iso8859-1)))
+	 last-command-char))
     (self-insert-command 1)))
 
 
@@ -717,34 +717,38 @@
   (interactive "P")
   (let ((modified (buffer-modified-p))
 	(inhibit-read-only t)
+	(inhibit-modification-hooks t)
+	;; Avoid spurious the `file-locked' checks.
+	(buffer-file-name nil)
 	;; This is needed in case font lock gets called,
 	;; since it moves point and might call sgml-point-entered.
 	(inhibit-point-motion-hooks t)
 	symbol)
-    (save-excursion
-      (goto-char (point-min))
-      (if (setq sgml-tags-invisible
-		(if arg
-		    (>= (prefix-numeric-value arg) 0)
-		  (not sgml-tags-invisible)))
-	  (while (re-search-forward "<\\([!/?A-Za-z][-A-Za-z0-9]*\\)"
-				    nil t)
-	    (setq symbol (intern-soft (downcase (match-string 1))))
-	    (goto-char (match-beginning 0))
-	    (and (get symbol 'before-string)
-		 (not (overlays-at (point)))
-		 (overlay-put (make-overlay (point)
-					    (match-beginning 1))
-			      'category symbol))
-	    (put-text-property (point)
-			       (progn (forward-list) (point))
-			       'category 'sgml-tag))
-	(let ((pos (point)))
-	  (while (< (setq pos (next-overlay-change pos)) (point-max))
-	    (delete-overlay (car (overlays-at pos)))))
-	(remove-text-properties (point-min) (point-max)
-				'(category sgml-tag intangible t))))
-    (set-buffer-modified-p modified)
+    (unwind-protect
+	(save-excursion
+	  (goto-char (point-min))
+	  (if (setq sgml-tags-invisible
+		    (if arg
+			(>= (prefix-numeric-value arg) 0)
+		      (not sgml-tags-invisible)))
+	      (while (re-search-forward "<\\([!/?A-Za-z][-A-Za-z0-9]*\\)"
+					nil t)
+		(setq symbol (intern-soft (downcase (match-string 1))))
+		(goto-char (match-beginning 0))
+		(and (get symbol 'before-string)
+		     (not (overlays-at (point)))
+		     (overlay-put (make-overlay (point)
+						(match-beginning 1))
+				  'category symbol))
+		(put-text-property (point)
+				   (progn (forward-list) (point))
+				   'category 'sgml-tag))
+	    (let ((pos (point)))
+	      (while (< (setq pos (next-overlay-change pos)) (point-max))
+		(delete-overlay (car (overlays-at pos)))))
+	    (remove-text-properties (point-min) (point-max)
+				    '(category sgml-tag intangible t))))
+      (restore-buffer-modified-p modified))
     (run-hooks 'sgml-tags-invisible-hook)
     (message "")))
 
@@ -753,7 +757,8 @@
   (let ((inhibit-point-motion-hooks t))
     (save-excursion
       (message "Invisible tag: %s"
-	       (buffer-substring
+	       ;; Strip properties, otherwise, the text is invisible.
+	       (buffer-substring-no-properties
 		(point)
 		(if (or (and (> x y)
 			     (not (eq (following-char) ?<)))
@@ -821,9 +826,10 @@
       (if alist
 	  (insert (skeleton-read '(completing-read "Value: " alist))))
       (insert ?\"))))
+
 
-(provide 'sgml-mode)
-
+;;; HTML mode
+
 (defcustom html-mode-hook nil
   "Hook run by command `html-mode'.
 `text-mode-hook' and `sgml-mode-hook' are run first."
@@ -937,7 +943,7 @@
 ;; should code exactly HTML 3 here when that is finished
 (defvar html-tag-alist
   (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
-	 (1-9 '(,@1-7 ("8") ("9")))
+	 (1-9 `(,@1-7 ("8") ("9")))
 	 (align '(("align" ("left") ("center") ("right"))))
 	 (valign '(("top") ("middle") ("bottom") ("baseline")))
 	 (rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
@@ -949,10 +955,9 @@
 		 ("rel" ,@rel)
 		 ("rev" ,@rel)
 		 ("title")))
-	 (list '((nil \n ( "List item: "
-			   "<li>" str \n))))
+	 (list '((nil \n ("List item: " "<li>" str \n))))
 	 (cell `(t
-		 ,align
+		 ,@align
 		 ("valign" ,@valign)
 		 ("colspan" ,@1-9)
 		 ("rowspan" ,@1-9)
@@ -1021,6 +1026,7 @@
       ("dd" t)
       ("del")
       ("dfn")
+      ("div")
       ("dl" (nil \n
 		 ( "Term: "
 		   "<dt>" str "<dd>" _ \n)))
@@ -1055,6 +1061,7 @@
       ("s")
       ("samp")
       ("small")
+      ("span")
       ("strong")
       ("sub")
       ("sup")
@@ -1220,8 +1227,9 @@
 	outline-level (lambda ()
 			(char-after (1- (match-end 0)))))
   (setq imenu-create-index-function 'html-imenu-index)
-  (make-local-variable 'imenu-sort-function)
-  (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
+  ;; It's for the user to decide if it defeats it or not  -stef
+  ;; (make-local-variable 'imenu-sort-function)
+  ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
   (run-hooks 'text-mode-hook 'sgml-mode-hook 'html-mode-hook))
 
 (defvar html-imenu-regexp
@@ -1376,4 +1384,5 @@
 			     "")))
    \n))
 
+(provide 'sgml-mode)
 ;;; sgml-mode.el ends here