]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-defs.el
Close bug#3992.
[gnu-emacs] / lisp / progmodes / cc-defs.el
index f9f5fdc8b1519c95c3961e84d0ed09b24308cb05..39036b743c68bdbd064e14047f8a056d81d9737c 100644 (file)
@@ -1,13 +1,14 @@
 ;;; cc-defs.el --- compile time definitions for CC Mode
 
 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
 ;;   Free Software Foundation, Inc.
 
 ;; Authors:    2003- Alan Mackenzie
 ;;             1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
-;;             1987 Dave Detlefs and Stewart Clamen
+;;             1987 Dave Detlefs
+;;             1987 Stewart Clamen
 ;;             1985 Richard M. Stallman
 ;; Maintainer: bug-cc-mode@gnu.org
 ;; Created:    22-Apr-1997 (split from cc-mode.el)
@@ -94,7 +95,7 @@
 \f
 ;;; Variables also used at compile time.
 
-(defconst c-version "5.31.5"
+(defconst c-version "5.31.8"
   "CC Mode version number.")
 
 (defconst c-version-sym (intern c-version))
@@ -406,7 +407,7 @@ properties to be changed, even in a read-only buffer.
 
 This macro should be placed around all calculations which set
 \"insignificant\" text properties in a buffer, even when the buffer is
-known to be writeable.  That way, these text properties remain set
+known to be writable.  That way, these text properties remain set
 even if the user undoes the command which set them.
 
 This macro should ALWAYS be placed around \"temporary\" internal buffer
@@ -932,7 +933,9 @@ MODE is either a mode symbol or a list of mode symbols."
                (or (memq property prop)
                    (put-text-property pos (1+ pos)
                                       'rear-nonsticky
-                                      (cons property prop))))))))))
+                                      (cons property prop)))))))
+         ;; This won't be used for anything.
+         (t 'ignore))))
 (cc-bytecomp-defun c-put-char-property-fun) ; Make it known below.
 
 (defmacro c-put-char-property (pos property value)
@@ -1007,7 +1010,7 @@ MODE is either a mode symbol or a list of mode symbols."
         `(c-clear-char-property-fun ,pos ',property))))
 
 (defmacro c-clear-char-properties (from to property)
-  ;; Remove all the occurences of the given property in the given
+  ;; Remove all the occurrences of the given property in the given
   ;; region that has been put with `c-put-char-property'.  PROPERTY is
   ;; assumed to be constant.
   ;;
@@ -1032,7 +1035,7 @@ which have the value VALUE, as tested by `equal'.  These
 properties are assumed to be over individual characters, having
 been put there by c-put-char-property.  POINT remains unchanged."
   (let ((place from) end-place)
-    (while                       ; loop round occurrances of (PROPERTY VALUE)
+    (while                       ; loop round occurrences of (PROPERTY VALUE)
        (progn
          (while           ; loop round changes in PROPERTY till we find VALUE
              (and
@@ -1440,22 +1443,33 @@ non-nil, a caret is prepended to invert the set."
                         '1-bit)
                       list)))
 
-    ;; In Emacs >= 23, beginning-of-defun-raw passes its argument to
-    ;; beginning-of-defun-function.  Assume end-of-defun does likewise.
-    (let ((beginning-of-defun-function
-          (lambda (&optional arg)
-            (not (eq arg nil))))
-         mark-ring)
-      (save-excursion
-       (if (beginning-of-defun-raw 1)
-           (setq list (cons 'argumentative-bod-function list)))))
+    ;; Check whether beginning/end-of-defun call
+    ;; beginning/end-of-defun-function nicely, passing through the
+    ;; argument and respecting the return code.
+    (let* (mark-ring
+          (bod-param 'foo) (eod-param 'foo)
+          (beginning-of-defun-function
+           (lambda (&optional arg)
+             (or (eq bod-param 'foo) (setq bod-param 'bar))
+             (and (eq bod-param 'foo)
+                  (setq bod-param arg)
+                  (eq arg 3))))
+          (end-of-defun-function
+           (lambda (&optional arg)
+             (and (eq eod-param 'foo)
+                  (setq eod-param arg)
+                  (eq arg 3)))))
+      (if (save-excursion (and (beginning-of-defun 3) (eq bod-param 3)
+                              (not (beginning-of-defun))
+                              (end-of-defun 3) (eq eod-param 3)
+                              (not (end-of-defun))))
+         (setq list (cons 'argumentative-bod-function list))))
 
     (let ((buf (generate-new-buffer " test"))
          parse-sexp-lookup-properties
          parse-sexp-ignore-comments
          lookup-syntax-properties)
-      (save-excursion
-       (set-buffer buf)
+      (with-current-buffer buf
        (set-syntax-table (make-syntax-table))
 
        ;; For some reason we have to set some of these after the
@@ -1685,6 +1699,9 @@ itself is evaluated."
   ;; `cl-macroexpand-all' inside `c-lang-defconst'.
   (eval form))
 
+;; Only used at compile time - suppress "might not be defined at runtime".
+(declare-function cl-macroexpand-all "cl-extra" (form &optional env))
+
 (defmacro c-lang-defconst (name &rest args)
   "Set the language specific values of the language constant NAME.
 The second argument can optionally be a docstring.  The rest of the