changeset 41225:74219f3013c6

(reb-mode): Use define-derived-mode. (font-lock-defaults-alist): Don't change it any more. (reb-subexp-mode-map): Cleanup.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 18 Nov 2001 01:44:08 +0000
parents fc0e6d3f905d
children 170c7bb7fc74
files lisp/emacs-lisp/re-builder.el
diffstat 1 files changed, 13 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/re-builder.el	Sun Nov 18 01:35:12 2001 +0000
+++ b/lisp/emacs-lisp/re-builder.el	Sun Nov 18 01:44:08 2001 +0000
@@ -226,21 +226,13 @@
       (define-key reb-mode-map "\C-c\C-e" 'reb-enter-subexp-mode)
       (define-key reb-mode-map "\C-c\C-u" 'reb-force-update)))
 
-(defun reb-mode ()
-  "Major mode for interactively building Regular Expressions.
-\\{reb-mode-map}"
-  (interactive)
-
-  (setq major-mode       'reb-mode
-        mode-name        "RE Builder")
-  (use-local-map reb-mode-map)
-  (reb-mode-common)
-  (run-hooks 'reb-mode-hook))
+(define-derived-mode reb-mode nil "RE Builder"
+  "Major mode for interactively building Regular Expressions."
+  (reb-mode-common))
 
 (define-derived-mode reb-lisp-mode
   emacs-lisp-mode "RE Builder Lisp"
-  "Major mode for interactively building symbolic Regular Expressions.
-\\{reb-lisp-mode-map}"
+  "Major mode for interactively building symbolic Regular Expressions."
   (cond ((eq reb-re-syntax 'lisp-re)	; Pull in packages
 	 (require 'lisp-re))		; as needed
 	((eq reb-re-syntax 'sregex)	; sregex is not autoloaded
@@ -252,29 +244,17 @@
 (define-key reb-lisp-mode-map "\C-c"
   (lookup-key reb-mode-map "\C-c"))
 
-(if (boundp 'font-lock-defaults-alist)
-    (setq font-lock-defaults-alist
-	  (cons (cons 'reb-lisp-mode
-		      (cdr (assoc 'emacs-lisp-mode
-				  font-lock-defaults-alist)))
-		font-lock-defaults-alist)))
-
-(defvar reb-subexp-mode-map nil
+(defvar reb-subexp-mode-map 
+  (let ((m (make-keymap)))
+    (suppress-keymap m)
+    ;; Again share the "\C-c" keymap for the commands
+    (define-key m "\C-c" (lookup-key reb-mode-map "\C-c"))
+    (define-key m "q" 'reb-quit-subexp-mode)
+    (dotimes (digit 10)
+      (define-key m (int-to-string digit) 'reb-display-subexp))
+    m)
   "Keymap used by the RE Builder for the subexpression mode.")
 
-(if (not reb-subexp-mode-map)
-    (progn
-      (setq reb-subexp-mode-map (make-sparse-keymap))
-      (suppress-keymap reb-subexp-mode-map)
-      ;; Again share the "\C-c" keymap for the commands
-      (define-key reb-subexp-mode-map "\C-c"
-	(lookup-key reb-mode-map "\C-c"))
-      (define-key reb-subexp-mode-map "q" 'reb-quit-subexp-mode)
-      (mapcar (lambda (digit)
-		(define-key reb-subexp-mode-map (int-to-string digit)
-		  'reb-display-subexp))
-	      '(0 1 2 3 4 5 6 7 8 9))))
-
 (defun reb-mode-common ()
   "Setup functions common to functions `reb-mode' and `reb-mode-lisp'."
 
@@ -411,7 +391,6 @@
 (defun reb-enter-subexp-mode ()
   "Enter the subexpression mode in the RE Builder."
   (interactive)
-
   (setq reb-subexp-mode t)
   (reb-update-modestring)
   (use-local-map reb-subexp-mode-map)
@@ -434,7 +413,6 @@
 (defun reb-quit-subexp-mode ()
   "Quit the subexpression mode in the RE Builder."
   (interactive)
-
   (setq reb-subexp-mode nil
 	reb-subexp-displayed nil)
   (reb-update-modestring)