changeset 33467:09da172d93be

(lisp-mode-variables): Set font-lock-defaults. (lisp-mode-shared-map): Init inside the defvar. (emacs-lisp-mode, lisp-mode, lisp-interaction-mode): Use define-derived-mode.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 14 Nov 2000 09:52:24 +0000
parents 1683c21f6b98
children 4d15850856e4
files lisp/emacs-lisp/lisp-mode.el
diffstat 1 files changed, 17 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/emacs-lisp/lisp-mode.el	Tue Nov 14 09:02:02 2000 +0000
+++ b/lisp/emacs-lisp/lisp-mode.el	Tue Nov 14 09:52:24 2000 +0000
@@ -139,7 +139,12 @@
   (make-local-variable 'imenu-generic-expression)
   (setq imenu-generic-expression lisp-imenu-generic-expression)
   (make-local-variable 'multibyte-syntax-as-symbol)
-  (setq multibyte-syntax-as-symbol t))
+  (setq multibyte-syntax-as-symbol t)
+  (setq font-lock-defaults
+	'((lisp-font-lock-keywords
+	   lisp-font-lock-keywords-1 lisp-font-lock-keywords-2)
+	  nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun
+	  (font-lock-mark-block-function . mark-defun))))
 
 (defun lisp-outline-level ()
   "Lisp mode `outline-level' function."
@@ -149,15 +154,13 @@
     (- (match-end 0) (match-beginning 0))))
 
 
-(defvar lisp-mode-shared-map ()
+(defvar lisp-mode-shared-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "\e\C-q" 'indent-sexp)
+    (define-key map "\177" 'backward-delete-char-untabify)
+    map)
   "Keymap for commands shared by all sorts of Lisp modes.")
 
-(if lisp-mode-shared-map
-    ()
-   (setq lisp-mode-shared-map (make-sparse-keymap))
-   (define-key lisp-mode-shared-map "\e\C-q" 'indent-sexp)
-   (define-key lisp-mode-shared-map "\177" 'backward-delete-char-untabify))
-
 (defvar emacs-lisp-mode-map ()
   "Keymap for Emacs Lisp mode.
 All commands in `lisp-mode-shared-map' are inherited by this map.")
@@ -232,7 +235,7 @@
   :type 'hook
   :group 'lisp)
 
-(defun emacs-lisp-mode ()
+(define-derived-mode emacs-lisp-mode nil "Emacs-Lisp"
   "Major mode for editing Lisp code to run in Emacs.
 Commands:
 Delete converts tabs to spaces as it moves back.
@@ -240,15 +243,8 @@
 \\{emacs-lisp-mode-map}
 Entry to this mode calls the value of `emacs-lisp-mode-hook'
 if that value is non-nil."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map emacs-lisp-mode-map)
-  (set-syntax-table emacs-lisp-mode-syntax-table)
-  (setq major-mode 'emacs-lisp-mode)
-  (setq mode-name "Emacs-Lisp")
   (lisp-mode-variables nil)
-  (setq imenu-case-fold-search nil)
-  (run-hooks 'emacs-lisp-mode-hook))
+  (setq imenu-case-fold-search nil))
 
 (defvar lisp-mode-map
   (let ((map (make-sparse-keymap)))
@@ -259,7 +255,7 @@
   "Keymap for ordinary Lisp mode.
 All commands in `lisp-mode-shared-map' are inherited by this map.")
 
-(defun lisp-mode ()
+(define-derived-mode lisp-mode nil "Lisp"
   "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp.
 Commands:
 Delete converts tabs to spaces as it moves back.
@@ -270,15 +266,8 @@
 
 Entry to this mode calls the value of `lisp-mode-hook'
 if that value is non-nil."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map lisp-mode-map)
-  (setq major-mode 'lisp-mode)
-  (setq mode-name "Lisp")
   (lisp-mode-variables t)
-  (setq imenu-case-fold-search t)
-  (set-syntax-table lisp-mode-syntax-table)
-  (run-hooks 'lisp-mode-hook))
+  (setq imenu-case-fold-search t))
 
 ;; This will do unless inf-lisp.el is loaded.
 (defun lisp-eval-defun (&optional and-go)
@@ -296,7 +285,7 @@
   "Keymap for Lisp Interaction mode.
 All commands in `lisp-mode-shared-map' are inherited by this map.")
 
-(defun lisp-interaction-mode ()
+(define-derived-mode lisp-interaction-mode emacs-lisp-mode "Lisp Interaction"
   "Major mode for typing and evaluating Lisp forms.
 Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression
 before point, and prints its value into the buffer, advancing point.
@@ -307,15 +296,7 @@
 Semicolons start comments.
 \\{lisp-interaction-mode-map}
 Entry to this mode calls the value of `lisp-interaction-mode-hook'
-if that value is non-nil."
-  (interactive)
-  (kill-all-local-variables)
-  (use-local-map lisp-interaction-mode-map)
-  (setq major-mode 'lisp-interaction-mode)
-  (setq mode-name "Lisp Interaction")
-  (set-syntax-table emacs-lisp-mode-syntax-table)
-  (lisp-mode-variables nil)
-  (run-hooks 'lisp-interaction-mode-hook))
+if that value is non-nil.")
 
 (defun eval-print-last-sexp ()
   "Evaluate sexp before point; print value into current buffer."