Mercurial > emacs
comparison lisp/emacs-lisp/lisp-mode.el @ 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 | b5c06c30c15f |
children | bf44a3e27334 |
comparison
equal
deleted
inserted
replaced
33466:1683c21f6b98 | 33467:09da172d93be |
---|---|
137 (make-local-variable 'comment-indent-function) | 137 (make-local-variable 'comment-indent-function) |
138 (setq comment-indent-function 'lisp-comment-indent) | 138 (setq comment-indent-function 'lisp-comment-indent) |
139 (make-local-variable 'imenu-generic-expression) | 139 (make-local-variable 'imenu-generic-expression) |
140 (setq imenu-generic-expression lisp-imenu-generic-expression) | 140 (setq imenu-generic-expression lisp-imenu-generic-expression) |
141 (make-local-variable 'multibyte-syntax-as-symbol) | 141 (make-local-variable 'multibyte-syntax-as-symbol) |
142 (setq multibyte-syntax-as-symbol t)) | 142 (setq multibyte-syntax-as-symbol t) |
143 (setq font-lock-defaults | |
144 '((lisp-font-lock-keywords | |
145 lisp-font-lock-keywords-1 lisp-font-lock-keywords-2) | |
146 nil nil (("+-*/.<>=!?$%_&~^:" . "w")) beginning-of-defun | |
147 (font-lock-mark-block-function . mark-defun)))) | |
143 | 148 |
144 (defun lisp-outline-level () | 149 (defun lisp-outline-level () |
145 "Lisp mode `outline-level' function." | 150 "Lisp mode `outline-level' function." |
146 (if (looking-at "(") | 151 (if (looking-at "(") |
147 1000 | 152 1000 |
148 (looking-at outline-regexp) | 153 (looking-at outline-regexp) |
149 (- (match-end 0) (match-beginning 0)))) | 154 (- (match-end 0) (match-beginning 0)))) |
150 | 155 |
151 | 156 |
152 (defvar lisp-mode-shared-map () | 157 (defvar lisp-mode-shared-map |
158 (let ((map (make-sparse-keymap))) | |
159 (define-key map "\e\C-q" 'indent-sexp) | |
160 (define-key map "\177" 'backward-delete-char-untabify) | |
161 map) | |
153 "Keymap for commands shared by all sorts of Lisp modes.") | 162 "Keymap for commands shared by all sorts of Lisp modes.") |
154 | |
155 (if lisp-mode-shared-map | |
156 () | |
157 (setq lisp-mode-shared-map (make-sparse-keymap)) | |
158 (define-key lisp-mode-shared-map "\e\C-q" 'indent-sexp) | |
159 (define-key lisp-mode-shared-map "\177" 'backward-delete-char-untabify)) | |
160 | 163 |
161 (defvar emacs-lisp-mode-map () | 164 (defvar emacs-lisp-mode-map () |
162 "Keymap for Emacs Lisp mode. | 165 "Keymap for Emacs Lisp mode. |
163 All commands in `lisp-mode-shared-map' are inherited by this map.") | 166 All commands in `lisp-mode-shared-map' are inherited by this map.") |
164 | 167 |
230 "Hook run when entering Lisp Interaction mode." | 233 "Hook run when entering Lisp Interaction mode." |
231 :options '(turn-on-eldoc-mode) | 234 :options '(turn-on-eldoc-mode) |
232 :type 'hook | 235 :type 'hook |
233 :group 'lisp) | 236 :group 'lisp) |
234 | 237 |
235 (defun emacs-lisp-mode () | 238 (define-derived-mode emacs-lisp-mode nil "Emacs-Lisp" |
236 "Major mode for editing Lisp code to run in Emacs. | 239 "Major mode for editing Lisp code to run in Emacs. |
237 Commands: | 240 Commands: |
238 Delete converts tabs to spaces as it moves back. | 241 Delete converts tabs to spaces as it moves back. |
239 Blank lines separate paragraphs. Semicolons start comments. | 242 Blank lines separate paragraphs. Semicolons start comments. |
240 \\{emacs-lisp-mode-map} | 243 \\{emacs-lisp-mode-map} |
241 Entry to this mode calls the value of `emacs-lisp-mode-hook' | 244 Entry to this mode calls the value of `emacs-lisp-mode-hook' |
242 if that value is non-nil." | 245 if that value is non-nil." |
243 (interactive) | |
244 (kill-all-local-variables) | |
245 (use-local-map emacs-lisp-mode-map) | |
246 (set-syntax-table emacs-lisp-mode-syntax-table) | |
247 (setq major-mode 'emacs-lisp-mode) | |
248 (setq mode-name "Emacs-Lisp") | |
249 (lisp-mode-variables nil) | 246 (lisp-mode-variables nil) |
250 (setq imenu-case-fold-search nil) | 247 (setq imenu-case-fold-search nil)) |
251 (run-hooks 'emacs-lisp-mode-hook)) | |
252 | 248 |
253 (defvar lisp-mode-map | 249 (defvar lisp-mode-map |
254 (let ((map (make-sparse-keymap))) | 250 (let ((map (make-sparse-keymap))) |
255 (set-keymap-parent map lisp-mode-shared-map) | 251 (set-keymap-parent map lisp-mode-shared-map) |
256 (define-key map "\e\C-x" 'lisp-eval-defun) | 252 (define-key map "\e\C-x" 'lisp-eval-defun) |
257 (define-key map "\C-c\C-z" 'run-lisp) | 253 (define-key map "\C-c\C-z" 'run-lisp) |
258 map) | 254 map) |
259 "Keymap for ordinary Lisp mode. | 255 "Keymap for ordinary Lisp mode. |
260 All commands in `lisp-mode-shared-map' are inherited by this map.") | 256 All commands in `lisp-mode-shared-map' are inherited by this map.") |
261 | 257 |
262 (defun lisp-mode () | 258 (define-derived-mode lisp-mode nil "Lisp" |
263 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. | 259 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. |
264 Commands: | 260 Commands: |
265 Delete converts tabs to spaces as it moves back. | 261 Delete converts tabs to spaces as it moves back. |
266 Blank lines separate paragraphs. Semicolons start comments. | 262 Blank lines separate paragraphs. Semicolons start comments. |
267 \\{lisp-mode-map} | 263 \\{lisp-mode-map} |
268 Note that `run-lisp' may be used either to start an inferior Lisp job | 264 Note that `run-lisp' may be used either to start an inferior Lisp job |
269 or to switch back to an existing one. | 265 or to switch back to an existing one. |
270 | 266 |
271 Entry to this mode calls the value of `lisp-mode-hook' | 267 Entry to this mode calls the value of `lisp-mode-hook' |
272 if that value is non-nil." | 268 if that value is non-nil." |
273 (interactive) | |
274 (kill-all-local-variables) | |
275 (use-local-map lisp-mode-map) | |
276 (setq major-mode 'lisp-mode) | |
277 (setq mode-name "Lisp") | |
278 (lisp-mode-variables t) | 269 (lisp-mode-variables t) |
279 (setq imenu-case-fold-search t) | 270 (setq imenu-case-fold-search t)) |
280 (set-syntax-table lisp-mode-syntax-table) | |
281 (run-hooks 'lisp-mode-hook)) | |
282 | 271 |
283 ;; This will do unless inf-lisp.el is loaded. | 272 ;; This will do unless inf-lisp.el is loaded. |
284 (defun lisp-eval-defun (&optional and-go) | 273 (defun lisp-eval-defun (&optional and-go) |
285 "Send the current defun to the Lisp process made by \\[run-lisp]." | 274 "Send the current defun to the Lisp process made by \\[run-lisp]." |
286 (interactive) | 275 (interactive) |
294 (define-key map "\n" 'eval-print-last-sexp) | 283 (define-key map "\n" 'eval-print-last-sexp) |
295 map) | 284 map) |
296 "Keymap for Lisp Interaction mode. | 285 "Keymap for Lisp Interaction mode. |
297 All commands in `lisp-mode-shared-map' are inherited by this map.") | 286 All commands in `lisp-mode-shared-map' are inherited by this map.") |
298 | 287 |
299 (defun lisp-interaction-mode () | 288 (define-derived-mode lisp-interaction-mode emacs-lisp-mode "Lisp Interaction" |
300 "Major mode for typing and evaluating Lisp forms. | 289 "Major mode for typing and evaluating Lisp forms. |
301 Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression | 290 Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression |
302 before point, and prints its value into the buffer, advancing point. | 291 before point, and prints its value into the buffer, advancing point. |
303 | 292 |
304 Commands: | 293 Commands: |
305 Delete converts tabs to spaces as it moves back. | 294 Delete converts tabs to spaces as it moves back. |
306 Paragraphs are separated only by blank lines. | 295 Paragraphs are separated only by blank lines. |
307 Semicolons start comments. | 296 Semicolons start comments. |
308 \\{lisp-interaction-mode-map} | 297 \\{lisp-interaction-mode-map} |
309 Entry to this mode calls the value of `lisp-interaction-mode-hook' | 298 Entry to this mode calls the value of `lisp-interaction-mode-hook' |
310 if that value is non-nil." | 299 if that value is non-nil.") |
311 (interactive) | |
312 (kill-all-local-variables) | |
313 (use-local-map lisp-interaction-mode-map) | |
314 (setq major-mode 'lisp-interaction-mode) | |
315 (setq mode-name "Lisp Interaction") | |
316 (set-syntax-table emacs-lisp-mode-syntax-table) | |
317 (lisp-mode-variables nil) | |
318 (run-hooks 'lisp-interaction-mode-hook)) | |
319 | 300 |
320 (defun eval-print-last-sexp () | 301 (defun eval-print-last-sexp () |
321 "Evaluate sexp before point; print value into current buffer." | 302 "Evaluate sexp before point; print value into current buffer." |
322 (interactive) | 303 (interactive) |
323 (let ((standard-output (current-buffer))) | 304 (let ((standard-output (current-buffer))) |