aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-02-22 20:13:31 +0000
committerDave Love2000-02-22 20:13:31 +0000
commit535eadacb130c0f0252d578d6d4ced6dec48db22 (patch)
tree2c1f59f78fdfe82d372124b0cdbcc1f86a4be4e3
parent69b05ea4825294fc8c94890238aefbdec9be0c89 (diff)
downloademacs-535eadacb130c0f0252d578d6d4ced6dec48db22.tar.gz
emacs-535eadacb130c0f0252d578d6d4ced6dec48db22.zip
(emacs-lisp-mode-syntax-table)
(lisp-mode-map, lisp-interaction-mode-map): Define all inside defvar. (lisp-mode-syntax-table): Set up for #|...|# comments. (lisp-imenu-generic-expression): Purecopy strings. Use syntax classes. Match `defface'. (emacs-lisp-mode-hook): Add checkdoc-minor-mode to options. (eval-defun-1): Fix for defcustom. (lisp-indent-region): Doc fix.
-rw-r--r--lisp/emacs-lisp/lisp-mode.el143
1 files changed, 71 insertions, 72 deletions
diff --git a/lisp/emacs-lisp/lisp-mode.el b/lisp/emacs-lisp/lisp-mode.el
index d08ef0660a3..9d7cd8a75fd 100644
--- a/lisp/emacs-lisp/lisp-mode.el
+++ b/lisp/emacs-lisp/lisp-mode.el
@@ -1,6 +1,6 @@
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, 1986, 1999 Free Software Foundation, Inc. 3;; Copyright (C) 1985, 1986, 1999, 2000 Free Software Foundation, Inc.
4 4
5;; Maintainer: FSF 5;; Maintainer: FSF
6;; Keywords: lisp, languages 6;; Keywords: lisp, languages
@@ -25,79 +25,81 @@
25;;; Commentary: 25;;; Commentary:
26 26
27;; The base major mode for editing Lisp code (used also for Emacs Lisp). 27;; The base major mode for editing Lisp code (used also for Emacs Lisp).
28;; This mode is documented in the Emacs manual 28;; This mode is documented in the Emacs manual.
29 29
30;;; Code: 30;;; Code:
31 31
32(defvar lisp-mode-syntax-table nil "") 32(defvar lisp-mode-abbrev-table nil)
33(defvar emacs-lisp-mode-syntax-table nil "")
34(defvar lisp-mode-abbrev-table nil "")
35 33
36(if (not emacs-lisp-mode-syntax-table) 34(defvar emacs-lisp-mode-syntax-table
35 (let ((table (make-syntax-table)))
37 (let ((i 0)) 36 (let ((i 0))
38 (setq emacs-lisp-mode-syntax-table (make-syntax-table))
39 (while (< i ?0) 37 (while (< i ?0)
40 (modify-syntax-entry i "_ " emacs-lisp-mode-syntax-table) 38 (modify-syntax-entry i "_ " table)
41 (setq i (1+ i))) 39 (setq i (1+ i)))
42 (setq i (1+ ?9)) 40 (setq i (1+ ?9))
43 (while (< i ?A) 41 (while (< i ?A)
44 (modify-syntax-entry i "_ " emacs-lisp-mode-syntax-table) 42 (modify-syntax-entry i "_ " table)
45 (setq i (1+ i))) 43 (setq i (1+ i)))
46 (setq i (1+ ?Z)) 44 (setq i (1+ ?Z))
47 (while (< i ?a) 45 (while (< i ?a)
48 (modify-syntax-entry i "_ " emacs-lisp-mode-syntax-table) 46 (modify-syntax-entry i "_ " table)
49 (setq i (1+ i))) 47 (setq i (1+ i)))
50 (setq i (1+ ?z)) 48 (setq i (1+ ?z))
51 (while (< i 128) 49 (while (< i 128)
52 (modify-syntax-entry i "_ " emacs-lisp-mode-syntax-table) 50 (modify-syntax-entry i "_ " table)
53 (setq i (1+ i))) 51 (setq i (1+ i)))
54 (modify-syntax-entry ? " " emacs-lisp-mode-syntax-table) 52 (modify-syntax-entry ? " " table)
55 (modify-syntax-entry ?\t " " emacs-lisp-mode-syntax-table) 53 (modify-syntax-entry ?\t " " table)
56 (modify-syntax-entry ?\f " " emacs-lisp-mode-syntax-table) 54 (modify-syntax-entry ?\f " " table)
57 (modify-syntax-entry ?\n "> " emacs-lisp-mode-syntax-table) 55 (modify-syntax-entry ?\n "> " table)
58 ;; Give CR the same syntax as newline, for selective-display. 56 ;; Give CR the same syntax as newline, for selective-display.
59 (modify-syntax-entry ?\^m "> " emacs-lisp-mode-syntax-table) 57 (modify-syntax-entry ?\^m "> " table)
60 (modify-syntax-entry ?\; "< " emacs-lisp-mode-syntax-table) 58 (modify-syntax-entry ?\; "< " table)
61 (modify-syntax-entry ?` "' " emacs-lisp-mode-syntax-table) 59 (modify-syntax-entry ?` "' " table)
62 (modify-syntax-entry ?' "' " emacs-lisp-mode-syntax-table) 60 (modify-syntax-entry ?' "' " table)
63 (modify-syntax-entry ?, "' " emacs-lisp-mode-syntax-table) 61 (modify-syntax-entry ?, "' " table)
64 ;; Used to be singlequote; changed for flonums. 62 ;; Used to be singlequote; changed for flonums.
65 (modify-syntax-entry ?. "_ " emacs-lisp-mode-syntax-table) 63 (modify-syntax-entry ?. "_ " table)
66 (modify-syntax-entry ?# "' " emacs-lisp-mode-syntax-table) 64 (modify-syntax-entry ?# "' " table)
67 (modify-syntax-entry ?\" "\" " emacs-lisp-mode-syntax-table) 65 (modify-syntax-entry ?\" "\" " table)
68 (modify-syntax-entry ?\\ "\\ " emacs-lisp-mode-syntax-table) 66 (modify-syntax-entry ?\\ "\\ " table)
69 (modify-syntax-entry ?\( "() " emacs-lisp-mode-syntax-table) 67 (modify-syntax-entry ?\( "() " table)
70 (modify-syntax-entry ?\) ")( " emacs-lisp-mode-syntax-table) 68 (modify-syntax-entry ?\) ")( " table)
71 (modify-syntax-entry ?\[ "(] " emacs-lisp-mode-syntax-table) 69 (modify-syntax-entry ?\[ "(] " table)
72 (modify-syntax-entry ?\] ")[ " emacs-lisp-mode-syntax-table) 70 (modify-syntax-entry ?\] ")[ " table)
73 ;; All non-word multibyte characters should be `symbol'. 71 ;; All non-word multibyte characters should be `symbol'.
74 (map-char-table 72 (map-char-table
75 (function (lambda (key val) 73 (function (lambda (key val)
76 (and (>= key 256) 74 (and (>= key 256)
77 (/= (char-syntax key) ?w) 75 (/= (char-syntax key) ?w)
78 (modify-syntax-entry key "_ " 76 (modify-syntax-entry key "_ "
79 emacs-lisp-mode-syntax-table)))) 77 table))))
80 (standard-syntax-table)))) 78 (standard-syntax-table)))
81 79 table))
82(if (not lisp-mode-syntax-table) 80
83 (progn (setq lisp-mode-syntax-table 81(defvar lisp-mode-syntax-table
84 (copy-syntax-table emacs-lisp-mode-syntax-table)) 82 (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
85 (modify-syntax-entry ?\| "\" " lisp-mode-syntax-table) 83 (modify-syntax-entry ?\| "\" " table)
86 (modify-syntax-entry ?\[ "_ " lisp-mode-syntax-table) 84 (modify-syntax-entry ?\[ "_ " table)
87 (modify-syntax-entry ?\] "_ " lisp-mode-syntax-table))) 85 (modify-syntax-entry ?\] "_ " table)
86 (modify-syntax-entry ?# "' 14bn" table)
87 (modify-syntax-entry ?| "' 23b" table)
88 table))
88 89
89(define-abbrev-table 'lisp-mode-abbrev-table ()) 90(define-abbrev-table 'lisp-mode-abbrev-table ())
90 91
91(defvar lisp-imenu-generic-expression 92(defvar lisp-imenu-generic-expression
92 '( 93 (list
93 (nil 94 (list nil
94 "^\\s-*(def\\(un\\|subst\\|macro\\|advice\\|ine-skeleton\\)\ 95 (purecopy "^\\s-*(def\\(un\\|subst\\|macro\\|advice\\|\
95\\s-+\\([-A-Za-z0-9+*|:/]+\\)" 2) 96ine-skeleton\\|ine-minor-mode\\)\\s-+\\(\\sw\\(\\sw\\|\\s_\\)+\\)") 2)
96 ("Variables" 97 (list (purecopy "Variables")
97 "^\\s-*(def\\(var\\|const\\|custom\\)\\s-+\\([-A-Za-z0-9+*|:/]+\\)" 2) 98 (purecopy "^\\s-*(def\\(var\\|const\\|custom\\)\\s-+\
98 ("Types" 99\\(\\sw\\(\\sw\\|\\s_\\)+\\)") 2)
99 "^\\s-*(def\\(group\\|type\\|struct\\|class\\|ine-condition\ 100 (list (purecopy "Types")
100\\|ine-widget\\)\\s-+'?\\([-A-Za-z0-9+*|:/]+\\)" 101 (purecopy "^\\s-*(def\\(group\\|type\\|struct\\|class\\|\
102ine-condition\\|ine-widget\\|face\\)\\s-+'?\\(\\sw\\(\\sw\\|\\s_\\)+\\)")
101 2)) 103 2))
102 104
103 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.") 105 "Imenu generic expression for Lisp mode. See `imenu-generic-expression'.")
@@ -210,7 +212,7 @@ All commands in `shared-lisp-mode-map' are inherited by this map.")
210 (require 'bytecomp) 212 (require 'bytecomp)
211 ;; Recompile if file or buffer has changed since last compilation. 213 ;; Recompile if file or buffer has changed since last compilation.
212 (if (and (buffer-modified-p) 214 (if (and (buffer-modified-p)
213 (y-or-n-p (format "save buffer %s first? " (buffer-name)))) 215 (y-or-n-p (format "Save buffer %s first? " (buffer-name))))
214 (save-buffer)) 216 (save-buffer))
215 (let ((compiled-file-name (byte-compile-dest-file buffer-file-name))) 217 (let ((compiled-file-name (byte-compile-dest-file buffer-file-name)))
216 (if (file-newer-than-file-p compiled-file-name buffer-file-name) 218 (if (file-newer-than-file-p compiled-file-name buffer-file-name)
@@ -219,7 +221,7 @@ All commands in `shared-lisp-mode-map' are inherited by this map.")
219 221
220(defcustom emacs-lisp-mode-hook nil 222(defcustom emacs-lisp-mode-hook nil
221 "Hook run when entering Emacs Lisp mode." 223 "Hook run when entering Emacs Lisp mode."
222 :options '(turn-on-eldoc-mode imenu-add-menubar-index) 224 :options '(turn-on-eldoc-mode imenu-add-menubar-index checkdoc-minor-mode)
223 :type 'hook 225 :type 'hook
224 :group 'lisp) 226 :group 'lisp)
225 227
@@ -253,17 +255,15 @@ if that value is non-nil."
253 (setq imenu-case-fold-search nil) 255 (setq imenu-case-fold-search nil)
254 (run-hooks 'emacs-lisp-mode-hook)) 256 (run-hooks 'emacs-lisp-mode-hook))
255 257
256(defvar lisp-mode-map () 258(defvar lisp-mode-map
259 (let ((map (make-sparse-keymap)))
260 (set-keymap-parent map shared-lisp-mode-map)
261 (define-key map "\e\C-x" 'lisp-eval-defun)
262 (define-key map "\C-c\C-z" 'run-lisp)
263 map)
257 "Keymap for ordinary Lisp mode. 264 "Keymap for ordinary Lisp mode.
258All commands in `shared-lisp-mode-map' are inherited by this map.") 265All commands in `shared-lisp-mode-map' are inherited by this map.")
259 266
260(if lisp-mode-map
261 ()
262 (setq lisp-mode-map (make-sparse-keymap))
263 (set-keymap-parent lisp-mode-map shared-lisp-mode-map)
264 (define-key lisp-mode-map "\e\C-x" 'lisp-eval-defun)
265 (define-key lisp-mode-map "\C-c\C-z" 'run-lisp))
266
267(defun lisp-mode () 267(defun lisp-mode ()
268 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp. 268 "Major mode for editing Lisp code for Lisps other than GNU Emacs Lisp.
269Commands: 269Commands:
@@ -291,18 +291,16 @@ if that value is non-nil."
291 (interactive) 291 (interactive)
292 (error "Process lisp does not exist")) 292 (error "Process lisp does not exist"))
293 293
294(defvar lisp-interaction-mode-map () 294(defvar lisp-interaction-mode-map
295 (let ((map (make-sparse-keymap)))
296 (set-keymap-parent map shared-lisp-mode-map)
297 (define-key map "\e\C-x" 'eval-defun)
298 (define-key map "\e\t" 'lisp-complete-symbol)
299 (define-key map "\n" 'eval-print-last-sexp)
300 map)
295 "Keymap for Lisp Interaction mode. 301 "Keymap for Lisp Interaction mode.
296All commands in `shared-lisp-mode-map' are inherited by this map.") 302All commands in `shared-lisp-mode-map' are inherited by this map.")
297 303
298(if lisp-interaction-mode-map
299 ()
300 (setq lisp-interaction-mode-map (make-sparse-keymap))
301 (set-keymap-parent lisp-interaction-mode-map shared-lisp-mode-map)
302 (define-key lisp-interaction-mode-map "\e\C-x" 'eval-defun)
303 (define-key lisp-interaction-mode-map "\e\t" 'lisp-complete-symbol)
304 (define-key lisp-interaction-mode-map "\n" 'eval-print-last-sexp))
305
306(defun lisp-interaction-mode () 304(defun lisp-interaction-mode ()
307 "Major mode for typing and evaluating Lisp forms. 305 "Major mode for typing and evaluating Lisp forms.
308Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression 306Like Lisp mode except that \\[eval-print-last-sexp] evals the Lisp expression
@@ -404,10 +402,11 @@ With argument, print output into current buffer."
404 (cdr-safe (cdr-safe form))) 402 (cdr-safe (cdr-safe form)))
405 ;; Force variable to be bound. 403 ;; Force variable to be bound.
406 (cons 'defconst (cdr form))) 404 (cons 'defconst (cdr form)))
407 ((and (eq (car form) 'defcustom) 405 ;; `defcustom' is now macroexpanded to `custom-declare-variable'.
408 (default-boundp (nth 1 form))) 406 ((and (eq (car form) 'custom-declare-variable)
407 (default-boundp (eval (nth 1 form))))
409 ;; Force variable to be bound. 408 ;; Force variable to be bound.
410 (set-default (nth 1 form) (eval (nth 2 form))) 409 (set-default (eval (nth 1 form)) (eval (nth 2 form)))
411 form) 410 form)
412 ((eq (car form) 'progn) 411 ((eq (car form) 'progn)
413 (cons 'progn (mapcar 'eval-defun-1 (cdr form)))) 412 (cons 'progn (mapcar 'eval-defun-1 (cdr form))))
@@ -499,8 +498,8 @@ Return the result of evaluation."
499 (let ((comment-start nil) (comment-start-skip nil)) 498 (let ((comment-start nil) (comment-start-skip nil))
500 (do-auto-fill))))) 499 (do-auto-fill)))))
501 500
502(defvar lisp-indent-offset nil "") 501(defvar lisp-indent-offset nil)
503(defvar lisp-indent-function 'lisp-indent-function "") 502(defvar lisp-indent-function 'lisp-indent-function)
504 503
505(defun lisp-indent-line (&optional whole-exp) 504(defun lisp-indent-line (&optional whole-exp)
506 "Indent current line as Lisp code. 505 "Indent current line as Lisp code.
@@ -616,7 +615,7 @@ is the buffer position of the start of the containing expression."
616 (backward-prefix-chars)) 615 (backward-prefix-chars))
617 (t 616 (t
618 ;; Indent beneath first sexp on same line as 617 ;; Indent beneath first sexp on same line as
619 ;; calculate-lisp-indent-last-sexp. Again, it's 618 ;; `calculate-lisp-indent-last-sexp'. Again, it's
620 ;; almost certainly a function call. 619 ;; almost certainly a function call.
621 (goto-char calculate-lisp-indent-last-sexp) 620 (goto-char calculate-lisp-indent-last-sexp)
622 (beginning-of-line) 621 (beginning-of-line)
@@ -869,8 +868,8 @@ ENDPOS is encountered."
869 (setq outer-loop-done (= (point) last-point)) 868 (setq outer-loop-done (= (point) last-point))
870 (setq last-point (point))))))) 869 (setq last-point (point)))))))
871 870
872;; Indent every line whose first char is between START and END inclusive.
873(defun lisp-indent-region (start end) 871(defun lisp-indent-region (start end)
872 "Indent every line whose first char is between START and END inclusive."
874 (save-excursion 873 (save-excursion
875 (let ((endmark (copy-marker end))) 874 (let ((endmark (copy-marker end)))
876 (goto-char start) 875 (goto-char start)