]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/lisp-mode.el
authors.el trivia
[gnu-emacs] / lisp / emacs-lisp / lisp-mode.el
index 114e9755039c5a541218cebfaf2811cb429945e5..95eb8c963be99bbcc99279d4e69d10dfb86213c7 100644 (file)
@@ -1,6 +1,6 @@
 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands
 
-;; Copyright (C) 1985-1986, 1999-2011 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1986, 1999-2012 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: lisp, languages
 (defvar font-lock-string-face)
 
 (defvar lisp-mode-abbrev-table nil)
+(define-abbrev-table 'lisp-mode-abbrev-table ()
+  "Abbrev table for Lisp mode.")
 
-(define-abbrev-table 'lisp-mode-abbrev-table ())
+(defvar emacs-lisp-mode-abbrev-table nil)
+(define-abbrev-table 'emacs-lisp-mode-abbrev-table ()
+  "Abbrev table for Emacs Lisp mode.
+It has `lisp-mode-abbrev-table' as its parent."
+  :parents (list lisp-mode-abbrev-table))
 
 (defvar emacs-lisp-mode-syntax-table
   (let ((table (make-syntax-table))
 (put 'autoload 'doc-string-elt 3)
 (put 'defun    'doc-string-elt 3)
 (put 'defun*    'doc-string-elt 3)
+(put 'defmethod 'doc-string-elt 3)
 (put 'defvar   'doc-string-elt 3)
 (put 'defcustom 'doc-string-elt 3)
 (put 'deftheme 'doc-string-elt 2)
@@ -205,7 +212,6 @@ score-mode.el.  KEYWORDS-CASE-INSENSITIVE non-nil means that for
 font-lock keywords will not be case sensitive."
   (when lisp-syntax
     (set-syntax-table lisp-mode-syntax-table))
-  (setq local-abbrev-table lisp-mode-abbrev-table)
   (make-local-variable 'paragraph-ignore-fill-prefix)
   (setq paragraph-ignore-fill-prefix t)
   (make-local-variable 'fill-paragraph-function)
@@ -297,7 +303,7 @@ font-lock keywords will not be case sensitive."
       `(menu-item ,(purecopy "Untrace All") untrace-all
                  :help ,(purecopy "Untrace all currently traced functions")))
     (define-key tracing-map [tr-uf]
-      `(menu-item ,(purecopy "Untrace function...") untrace-function
+      `(menu-item ,(purecopy "Untrace Function...") untrace-function
                  :help ,(purecopy "Untrace function, and possibly activate all remaining advice")))
     (define-key tracing-map [tr-sep] menu-bar-separator)
     (define-key tracing-map [tr-q]
@@ -358,7 +364,7 @@ font-lock keywords will not be case sensitive."
       `(menu-item ,(purecopy "Byte-compile and Load") emacs-lisp-byte-compile-and-load
                  :help ,(purecopy "Byte-compile the current file (if it has changed), then load compiled code")))
     (define-key menu-map [byte-compile]
-      `(menu-item ,(purecopy "Byte-compile this File") emacs-lisp-byte-compile
+      `(menu-item ,(purecopy "Byte-compile This File") emacs-lisp-byte-compile
                  :help ,(purecopy "Byte compile the file containing the current buffer")))
     (define-key menu-map [separator-eval] menu-bar-separator)
     (define-key menu-map [ielm]
@@ -509,7 +515,7 @@ if that value is non-nil."
       `(menu-item ,(purecopy "Evaluate Defun") eval-defun
                  :help ,(purecopy "Evaluate the top-level form containing point, or after point")))
     (define-key menu-map [eval-print-last-sexp]
-      `(menu-item ,(purecopy "Evaluate and print") eval-print-last-sexp
+      `(menu-item ,(purecopy "Evaluate and Print") eval-print-last-sexp
                  :help ,(purecopy "Evaluate sexp before point; print value into current buffer")))
     (define-key menu-map [edebug-defun-lisp-interaction]
       `(menu-item ,(purecopy "Instrument Function for Debugging") edebug-defun
@@ -525,7 +531,6 @@ if that value is non-nil."
   "Keymap for Lisp Interaction mode.
 All commands in `lisp-mode-shared-map' are inherited by this map.")
 
-(defvar lisp-interaction-mode-abbrev-table lisp-mode-abbrev-table)
 (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
@@ -540,7 +545,8 @@ 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.")
+if that value is non-nil."
+  :abbrev-table nil)
 
 (defun eval-print-last-sexp ()
   "Evaluate sexp before point; print value into current buffer.
@@ -770,7 +776,7 @@ this command arranges for all errors to enter the debugger."
 Reset the `defvar' and `defcustom' variables to the initial value.
 Reinitialize the face according to the `defface' specification."
   ;; The code in edebug-defun should be consistent with this, but not
-  ;; the same, since this gets a macroexpended form.
+  ;; the same, since this gets a macroexpanded form.
   (cond ((not (listp form))
         form)
        ((and (eq (car form) 'defvar)
@@ -790,25 +796,25 @@ Reinitialize the face according to the `defface' specification."
        ;; `defface' is macroexpanded to `custom-declare-face'.
        ((eq (car form) 'custom-declare-face)
         ;; Reset the face.
-        (setq face-new-frame-defaults
-              (assq-delete-all (eval (nth 1 form) lexical-binding)
-                                face-new-frame-defaults))
-        (put (eval (nth 1 form) lexical-binding) 'face-defface-spec nil)
-        ;; Setting `customized-face' to the new spec after calling
-        ;; the form, but preserving the old saved spec in `saved-face',
-        ;; imitates the situation when the new face spec is set
-        ;; temporarily for the current session in the customize
-        ;; buffer, thus allowing `face-user-default-spec' to use the
-        ;; new customized spec instead of the saved spec.
-        ;; Resetting `saved-face' temporarily to nil is needed to let
-        ;; `defface' change the spec, regardless of a saved spec.
-        (prog1 `(prog1 ,form
-                  (put ,(nth 1 form) 'saved-face
-                       ',(get (eval (nth 1 form) lexical-binding)
-                               'saved-face))
-                  (put ,(nth 1 form) 'customized-face
-                       ,(nth 2 form)))
-          (put (eval (nth 1 form) lexical-binding) 'saved-face nil)))
+        (let ((face-symbol (eval (nth 1 form) lexical-binding)))
+          (setq face-new-frame-defaults
+                (assq-delete-all face-symbol face-new-frame-defaults))
+          (put face-symbol 'face-defface-spec nil)
+          (put face-symbol 'face-documentation (nth 3 form))
+          ;; Setting `customized-face' to the new spec after calling
+          ;; the form, but preserving the old saved spec in `saved-face',
+          ;; imitates the situation when the new face spec is set
+          ;; temporarily for the current session in the customize
+          ;; buffer, thus allowing `face-user-default-spec' to use the
+          ;; new customized spec instead of the saved spec.
+          ;; Resetting `saved-face' temporarily to nil is needed to let
+          ;; `defface' change the spec, regardless of a saved spec.
+          (prog1 `(prog1 ,form
+                    (put ,(nth 1 form) 'saved-face
+                         ',(get face-symbol 'saved-face))
+                    (put ,(nth 1 form) 'customized-face
+                         ,(nth 2 form)))
+            (put face-symbol 'saved-face nil))))
        ((eq (car form) 'progn)
         (cons 'progn (mapcar 'eval-defun-1 (cdr form))))
        (t form)))
@@ -1103,25 +1109,31 @@ is the buffer position of the start of the containing expression."
 
 (defun lisp-indent-function (indent-point state)
   "This function is the normal value of the variable `lisp-indent-function'.
-It is used when indenting a line within a function call, to see if the
-called function says anything special about how to indent the line.
+The function `calculate-lisp-indent' calls this to determine
+if the arguments of a Lisp function call should be indented specially.
 
 INDENT-POINT is the position where the user typed TAB, or equivalent.
 Point is located at the point to indent under (for default indentation);
 STATE is the `parse-partial-sexp' state for that position.
 
-If the current line is in a call to a Lisp function
-which has a non-nil property `lisp-indent-function',
-that specifies how to do the indentation.  The property value can be
-* `defun', meaning indent `defun'-style;
+If the current line is in a call to a Lisp function that has a non-nil
+property `lisp-indent-function' (or the deprecated `lisp-indent-hook'),
+it specifies how to indent.  The property value can be:
+
+* `defun', meaning indent `defun'-style
+  \(this is also the case if there is no property and the function
+  has a name that begins with \"def\", and three or more arguments);
+
 * an integer N, meaning indent the first N arguments specially
-  like ordinary function arguments and then indent any further
+  (like ordinary function arguments), and then indent any further
   arguments like a body;
-* a function to call just as this function was called.
-  If that function returns nil, that means it doesn't specify
-  the indentation.
 
-This function also returns nil meaning don't specify the indentation."
+* a function to call that returns the indentation (or nil).
+  `lisp-indent-function' calls this function with the same two arguments
+  that it itself received.
+
+This function returns either the indentation to use, or nil if the
+Lisp function does not specify a special indentation."
   (let ((normal-indent (current-column)))
     (goto-char (1+ (elt state 1)))
     (parse-partial-sexp (point) calculate-lisp-indent-last-sexp 0 t)