]> code.delx.au - gnu-emacs/blobdiff - lisp/emacs-lisp/lisp-mode.el
2005-09-24 Emilio C. Lopes <eclig@gmx.net>
[gnu-emacs] / lisp / emacs-lisp / lisp-mode.el
index 2e829080c9c8c1121c07846a9279c775c57b5696..e50d5bd125c7c6ded607d8a8d0ea1ec8812ece5a 100644 (file)
@@ -1,7 +1,7 @@
 ;;; lisp-mode.el --- Lisp mode, and its idiosyncratic commands
 
-;; Copyright (C) 1985, 1986, 1999, 2000, 2001, 2003, 2004, 2005
-;;           Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1986, 1999, 2000, 2001, 2002, 2003, 2004,
+;;   2005 Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
 ;; Keywords: lisp, languages
@@ -20,8 +20,8 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
 
 ;;; Commentary:
 
 
 ;;; Code:
 
+(defvar font-lock-comment-face)
+(defvar font-lock-doc-face)
+(defvar font-lock-keywords-case-fold-search)
+(defvar font-lock-string-face)
+
 (defvar lisp-mode-abbrev-table nil)
 
 (defvar emacs-lisp-mode-syntax-table
       (while (< i 128)
        (modify-syntax-entry i "_   " table)
        (setq i (1+ i)))
-      (modify-syntax-entry ?  "    " table)
+      (modify-syntax-entry ?\s "    " table)
       (modify-syntax-entry ?\t "    " table)
       (modify-syntax-entry ?\f "    " table)
       (modify-syntax-entry ?\n ">   " table)
-      ;; Give CR the same syntax as newline, for selective-display.
-      (modify-syntax-entry ?\^m ">   " table)
+;;; This is probably obsolete since nowadays such features use overlays.
+;;;      ;; Give CR the same syntax as newline, for selective-display.
+;;;      (modify-syntax-entry ?\^m ">   " table)
       (modify-syntax-entry ?\; "<   " table)
       (modify-syntax-entry ?` "'   " table)
       (modify-syntax-entry ?' "'   " table)
@@ -91,6 +97,7 @@
                              '("defun" "defun*" "defsubst" "defmacro"
                                "defadvice" "define-skeleton"
                                "define-minor-mode" "define-derived-mode"
+                               "define-generic-mode"
                                "define-compiler-macro" "define-modify-macro"
                                "defsetf" "define-setf-expander"
                                "define-method-combination"
 (put 'defmacro 'doc-string-elt 3)
 (put 'defmacro* 'doc-string-elt 3)
 (put 'defsubst 'doc-string-elt 3)
+(put 'defstruct 'doc-string-elt 2)
 (put 'define-skeleton 'doc-string-elt 2)
 (put 'define-derived-mode 'doc-string-elt 4)
 (put 'define-compilation-mode 'doc-string-elt 3)
   (setq paragraph-ignore-fill-prefix t)
   (make-local-variable 'fill-paragraph-function)
   (setq fill-paragraph-function 'lisp-fill-paragraph)
+  ;; Adaptive fill mode gets the fill wrong for a one-line paragraph made of
+  ;; a single docstring.  Let's fix it here.
+  (set (make-local-variable 'adaptive-fill-function)
+       (lambda () (if (looking-at "\\s-+\"[^\n\"]+\"\\s-*$") "")))
   ;; Adaptive fill mode gets in the way of auto-fill,
   ;; and should make no difference for explicit fill
   ;; because lisp-fill-paragraph should do the job.
   ;; Look within the line for a ; following an even number of backslashes
   ;; after either a non-backslash or the line beginning.
   (setq comment-start-skip "\\(\\(^\\|[^\\\\\n]\\)\\(\\\\\\\\\\)*\\);+ *")
+  (make-local-variable 'font-lock-comment-start-skip)
+  ;; Font lock mode uses this only when it KNOWS a comment is starting.
+  (setq font-lock-comment-start-skip ";+ *")
   (make-local-variable 'comment-add)
   (setq comment-add 1)                 ;default to `;;' in comment-region
   (make-local-variable 'comment-column)
   (setq comment-column 40)
   ;; Don't get confused by `;' in doc strings when paragraph-filling.
   (set (make-local-variable 'comment-use-global-state) t)
+  (make-local-variable 'comment-indent-function)
+  (setq comment-indent-function 'lisp-comment-indent)
   (make-local-variable 'imenu-generic-expression)
   (setq imenu-generic-expression lisp-imenu-generic-expression)
   (make-local-variable 'multibyte-syntax-as-symbol)
@@ -612,10 +629,23 @@ Reinitialize the face according to the `defface' specification."
        ;; `defface' is macroexpanded to `custom-declare-face'.
        ((eq (car form) 'custom-declare-face)
         ;; Reset the face.
-        (put (eval (nth 1 form)) 'face-defface-spec nil)
         (setq face-new-frame-defaults
               (assq-delete-all (eval (nth 1 form)) face-new-frame-defaults))
-        form)
+        (put (eval (nth 1 form)) '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)) 'saved-face))
+                  (put ,(nth 1 form) 'customized-face
+                       ,(nth 2 form)))
+          (put (eval (nth 1 form)) 'saved-face nil)))
        ((eq (car form) 'progn)
         (cons 'progn (mapcar 'eval-defun-1 (cdr form))))
        (t form)))
@@ -696,7 +726,7 @@ which see."
               (setq debug-on-error new-value))
             value)))))
 \f
-
+;; Used for comment-indent-function in Lisp modes.
 (defun lisp-comment-indent ()
   (if (looking-at "\\s<\\s<\\s<")
       (current-column)