Mercurial > hg > xemacs-beta
comparison lisp/lisp-mode.el @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | b8cc9ab3f761 |
children |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
1 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands. | 1 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands. |
2 | 2 |
3 ;; Copyright (C) 1985, 1996, 1997 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1985, 1996, 1997 Free Software Foundation, Inc. |
4 ;; Copyright (C) 1995 Tinker Systems. | 4 ;; Copyright (C) 1995 Tinker Systems |
5 | 5 |
6 ;; Maintainer: FSF | 6 ;; Maintainer: FSF |
7 ;; Keywords: lisp, languages, dumped | 7 ;; Keywords: lisp, languages, dumped |
8 | 8 |
9 ;; This file is part of XEmacs. | 9 ;; This file is part of XEmacs. |
30 ;; This file is dumped with XEmacs. | 30 ;; This file is dumped with XEmacs. |
31 | 31 |
32 ;; The base major mode for editing Lisp code (used also for Emacs Lisp). | 32 ;; The base major mode for editing Lisp code (used also for Emacs Lisp). |
33 ;; This mode is documented in the Emacs manual | 33 ;; This mode is documented in the Emacs manual |
34 | 34 |
35 ;; July/05/97 slb Converted to use easymenu. | |
36 | |
35 ;;; Code: | 37 ;;; Code: |
36 | 38 |
37 (defgroup lisp nil | 39 (defgroup lisp nil |
38 "Lisp support, including Emacs Lisp." | 40 "Lisp support, including Emacs Lisp." |
39 :group 'languages | 41 :group 'languages |
42 (defvar lisp-mode-syntax-table nil) | 44 (defvar lisp-mode-syntax-table nil) |
43 (defvar emacs-lisp-mode-syntax-table nil) | 45 (defvar emacs-lisp-mode-syntax-table nil) |
44 (defvar lisp-mode-abbrev-table nil) | 46 (defvar lisp-mode-abbrev-table nil) |
45 | 47 |
46 ;; XEmacs change | 48 ;; XEmacs change |
47 (defvar lisp-interaction-mode-popup-menu | 49 (defvar lisp-interaction-mode-popup-menu nil) |
50 (defvar lisp-interaction-mode-popup-menu-1 | |
48 (purecopy '("Lisp-Interaction" | 51 (purecopy '("Lisp-Interaction" |
49 ["Evaluate Last %_S-expression" eval-last-sexp] | 52 ["Evaluate Last S-expression" eval-last-sexp] |
50 ["Evaluate %_Whole Buffer" eval-current-buffer] | 53 ["Evaluate Entire Buffer" eval-current-buffer] |
51 ["Evaluate Re%_gion" eval-region | 54 ["Evaluate Region" eval-region |
52 :active (region-exists-p)] | 55 :active (region-exists-p)] |
53 "---" | 56 "---" |
54 ["%_Evaluate This Defun" eval-defun] | 57 ["Evaluate This Defun" eval-defun] |
55 ["%_Instrument This Defun for Debugging" edebug-defun] | 58 ;; FSF says "Instrument Function for Debugging" |
59 ["Debug This Defun" edebug-defun] | |
56 "---" | 60 "---" |
57 ["Find %_Function Source..." find-function | 61 ["Trace a Function" trace-function-background] |
58 :active (fboundp 'find-function)] | 62 ["Untrace All Functions" untrace-all |
59 ["Find %_Variable Source..." find-variable | |
60 :active (fboundp 'find-variable)] | |
61 ["%_Trace Function..." trace-function-background] | |
62 ["%_Untrace All Functions" untrace-all | |
63 :active (fboundp 'untrace-all)] | 63 :active (fboundp 'untrace-all)] |
64 "---" | 64 "---" |
65 ["%_Comment Out Region" comment-region | 65 ["Comment Out Region" comment-region |
66 :active (region-exists-p)] | 66 :active (region-exists-p)] |
67 ["Indent Region" indent-region | |
68 :active (region-exists-p)] | |
69 ["Indent Line" lisp-indent-line] | |
67 "---" | 70 "---" |
68 ["Indent %_Line or Region" | 71 ["Debug On Error" (setq debug-on-error (not debug-on-error)) |
69 (if (region-exists-p) | 72 :style toggle :selected debug-on-error] |
70 (call-interactively 'indent-region) | 73 ["Debug On Quit" (setq debug-on-quit (not debug-on-quit)) |
71 (call-interactively 'lisp-indent-line))] | 74 :style toggle :selected debug-on-quit] |
72 ["Indent B%_alanced Expression" indent-sexp] | 75 ["Debug on Signal" (setq debug-on-signal (not debug-on-signal)) |
73 ["Indent %_Defun" | 76 :style toggle :selected debug-on-signal] |
74 (progn | |
75 (beginning-of-defun) | |
76 (indent-sexp))] | |
77 "---" | |
78 "Look for debug-on-error under Options->General" | |
79 ))) | 77 ))) |
80 | 78 |
81 (defvar emacs-lisp-mode-popup-menu | 79 (defvar emacs-lisp-mode-popup-menu nil) |
80 (defvar emacs-lisp-mode-popup-menu-1 | |
82 (purecopy | 81 (purecopy |
83 (nconc | 82 (nconc |
84 '("Emacs-Lisp" | 83 '("Emacs-Lisp" |
85 ["%_Byte-Compile This File" emacs-lisp-byte-compile] | 84 ["Byte-compile This File" emacs-lisp-byte-compile] |
86 ["B%_yte-Compile/Load This File" emacs-lisp-byte-compile-and-load] | 85 ["Byte-compile/load This" emacs-lisp-byte-compile-and-load] |
87 ["Byte-%_Recompile Directory..." byte-recompile-directory] | 86 ["Byte-recompile Directory..." byte-recompile-directory] |
88 "---") | 87 "---") |
89 (cdr lisp-interaction-mode-popup-menu)))) | 88 (cdr lisp-interaction-mode-popup-menu-1)))) |
90 | 89 |
91 ;Don't have a menubar entry in Lisp Interaction mode. Otherwise, the | 90 ;Don't have a menubar entry in Lisp Interaction mode. Otherwise, the |
92 ;*scratch* buffer has a Lisp menubar item! Very confusing. | 91 ;*scratch* buffer has a Lisp menubar item! Very confusing. |
93 ;Jan Vroonhof really wants this, so it's back. --ben | 92 ;(defvar lisp-interaction-mode-menubar-menu |
94 (defvar lisp-interaction-mode-menubar-menu | 93 ; (purecopy (cons "Lisp" (cdr lisp-interaction-mode-popup-menu)))) |
95 (purecopy (cons "%_Lisp" (cdr lisp-interaction-mode-popup-menu)))) | 94 |
96 | 95 (defvar emacs-lisp-mode-menubar-menu nil) |
97 (defvar emacs-lisp-mode-menubar-menu | 96 (defvar emacs-lisp-mode-menubar-menu-1 |
98 (purecopy (cons "%_Lisp" (cdr emacs-lisp-mode-popup-menu)))) | 97 (purecopy (cons "Lisp" (cdr emacs-lisp-mode-popup-menu-1)))) |
99 | 98 |
100 (if (not emacs-lisp-mode-syntax-table) | 99 (if (not emacs-lisp-mode-syntax-table) |
101 (let ((i 0)) | 100 (let ((i 0)) |
102 (setq emacs-lisp-mode-syntax-table (make-syntax-table)) | 101 (setq emacs-lisp-mode-syntax-table (make-syntax-table)) |
103 (while (< i ?0) | 102 (while (< i ?0) |
273 (kill-all-local-variables) | 272 (kill-all-local-variables) |
274 (use-local-map emacs-lisp-mode-map) | 273 (use-local-map emacs-lisp-mode-map) |
275 (set-syntax-table emacs-lisp-mode-syntax-table) | 274 (set-syntax-table emacs-lisp-mode-syntax-table) |
276 ;; XEmacs changes | 275 ;; XEmacs changes |
277 (setq major-mode 'emacs-lisp-mode | 276 (setq major-mode 'emacs-lisp-mode |
278 mode-popup-menu emacs-lisp-mode-popup-menu | 277 ;; mode-popup-menu emacs-lisp-mode-popup-menu |
279 mode-name "Emacs-Lisp") | 278 mode-name "Emacs-Lisp") |
280 (if (and (featurep 'menubar) | 279 ;; (if (and (featurep 'menubar) |
281 current-menubar) | 280 ;; current-menubar) |
282 (progn | 281 ;; (progn |
283 ;; make a local copy of the menubar, so our modes don't | 282 ;; make a local copy of the menubar, so our modes don't |
284 ;; change the global menubar | 283 ;; change the global menubar |
285 (set-buffer-menubar current-menubar) | 284 ;; (set-buffer-menubar current-menubar) |
286 (add-submenu nil emacs-lisp-mode-menubar-menu))) | 285 ;; (add-submenu nil emacs-lisp-mode-menubar-menu))) |
286 (unless emacs-lisp-mode-popup-menu | |
287 (easy-menu-define emacs-lisp-mode-popup-menu emacs-lisp-mode-map "" | |
288 emacs-lisp-mode-popup-menu-1)) | |
289 (easy-menu-add emacs-lisp-mode-popup-menu) | |
287 (lisp-mode-variables nil) | 290 (lisp-mode-variables nil) |
288 (run-hooks 'emacs-lisp-mode-hook)) | 291 (run-hooks 'emacs-lisp-mode-hook)) |
289 | |
290 (put 'emacs-lisp-mode 'font-lock-lisp-like t) | |
291 | 292 |
292 (defvar lisp-mode-map () | 293 (defvar lisp-mode-map () |
293 "Keymap for ordinary Lisp mode. | 294 "Keymap for ordinary Lisp mode. |
294 All commands in `shared-lisp-mode-map' are inherited by this map.") | 295 All commands in `shared-lisp-mode-map' are inherited by this map.") |
295 | 296 |
361 (interactive) | 362 (interactive) |
362 (kill-all-local-variables) | 363 (kill-all-local-variables) |
363 (use-local-map lisp-interaction-mode-map) | 364 (use-local-map lisp-interaction-mode-map) |
364 (setq major-mode 'lisp-interaction-mode) | 365 (setq major-mode 'lisp-interaction-mode) |
365 (setq mode-name "Lisp Interaction") | 366 (setq mode-name "Lisp Interaction") |
366 (setq mode-popup-menu lisp-interaction-mode-popup-menu) | 367 ;; XEmacs change |
367 (if (and (featurep 'menubar) | 368 ;; (setq mode-popup-menu lisp-interaction-mode-popup-menu) |
368 current-menubar) | 369 (unless lisp-interaction-mode-popup-menu |
369 (progn | 370 (easy-menu-define lisp-interaction-mode-popup-menu |
370 ;; make a local copy of the menubar, so our modes don't | 371 lisp-interaction-mode-map |
371 ;; change the global menubar | 372 "" |
372 (set-buffer-menubar current-menubar) | 373 lisp-interaction-mode-popup-menu-1)) |
373 (add-submenu nil lisp-interaction-mode-menubar-menu))) | 374 (easy-menu-add lisp-interaction-mode-popup-menu) |
375 | |
374 (set-syntax-table emacs-lisp-mode-syntax-table) | 376 (set-syntax-table emacs-lisp-mode-syntax-table) |
375 (lisp-mode-variables nil) | 377 (lisp-mode-variables nil) |
376 (run-hooks 'lisp-interaction-mode-hook)) | 378 (run-hooks 'lisp-interaction-mode-hook)) |
377 | 379 |
378 (defun eval-print-last-sexp () | 380 (defun eval-print-last-sexp () |
754 (put 'save-restriction 'lisp-indent-function 0) | 756 (put 'save-restriction 'lisp-indent-function 0) |
755 (put 'save-match-data 'lisp-indent-function 0) | 757 (put 'save-match-data 'lisp-indent-function 0) |
756 (put 'let 'lisp-indent-function 1) | 758 (put 'let 'lisp-indent-function 1) |
757 (put 'let* 'lisp-indent-function 1) | 759 (put 'let* 'lisp-indent-function 1) |
758 (put 'let-specifier 'lisp-indent-function 1) | 760 (put 'let-specifier 'lisp-indent-function 1) |
759 (put 'flet 'lisp-indent-function 1) | |
760 (put 'while 'lisp-indent-function 1) | 761 (put 'while 'lisp-indent-function 1) |
761 (put 'if 'lisp-indent-function 2) | 762 (put 'if 'lisp-indent-function 2) |
762 (put 'catch 'lisp-indent-function 1) | 763 (put 'catch 'lisp-indent-function 1) |
763 (put 'condition-case 'lisp-indent-function 2) | 764 (put 'condition-case 'lisp-indent-function 2) |
764 (put 'call-with-condition-handler 'lisp-indent-function 2) | 765 (put 'call-with-condition-handler 'lisp-indent-function 2) |