]> code.delx.au - gnu-emacs/blobdiff - lisp/progmodes/cc-defs.el
Fix up comment convention on the arch-tag lines.
[gnu-emacs] / lisp / progmodes / cc-defs.el
index b406355438412146e900b635fa665a0024617eda..2c5511be1a2f97bf65e5742e87e9a1fdd01b27df 100644 (file)
@@ -1,10 +1,11 @@
 ;;; 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  Free Software
-;;   Foundation, Inc.
+;;   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+;;   Free Software Foundation, Inc.
 
-;; Authors:    1998- Martin Stjernholm
+;; Authors:    2003- Alan Mackenzie
+;;             1998- Martin Stjernholm
 ;;             1992-1999 Barry A. Warsaw
 ;;             1987 Dave Detlefs and Stewart Clamen
 ;;             1985 Richard M. Stallman
@@ -17,7 +18,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 
 ; (eval-after-load "font-lock"  ; 2006-07-09.  font-lock is now preloaded
 ;   '
-(if (and (not (featurep 'cc-fix)) ; only load the file once.
-           (featurep 'xemacs) ; There is now (2005/12) code in GNU Emacs CVS
-                              ; to make the call to f-l-c-k throw an error.
-            (let (font-lock-keywords)
-              (font-lock-compile-keywords '("\\<\\>"))
-             font-lock-keywords))     ; did the previous call foul this up?
-       (load "cc-fix")) ;)
+(if (and (featurep 'xemacs)    ; There is now (2005/12) code in GNU Emacs CVS
+                               ; to make the call to f-l-c-k throw an error.
+        (not (featurep 'cc-fix)) ; only load the file once.
+        (let (font-lock-keywords)
+          (font-lock-compile-keywords '("\\<\\>"))
+          font-lock-keywords))     ; did the previous call foul this up?
+    (load "cc-fix")) ;)
 
 ;; The above takes care of the delayed loading, but this is necessary
 ;; to ensure correct byte compilation.
 (eval-when-compile
-  (if (and (not (featurep 'cc-fix))
-          (featurep 'xemacs)
+  (if (and (featurep 'xemacs)
+          (not (featurep 'cc-fix))
           (progn
             (require 'font-lock)
             (let (font-lock-keywords)
@@ -95,7 +96,7 @@
 \f
 ;;; Variables also used at compile time.
 
-(defconst c-version "5.31.4"
+(defconst c-version "5.31.5"
   "CC Mode version number.")
 
 (defconst c-version-sym (intern c-version))
@@ -336,11 +337,11 @@ to it is returned.  This function does not modify the point or the mark."
 (defmacro c-region-is-active-p ()
   ;; Return t when the region is active.  The determination of region
   ;; activeness is different in both Emacs and XEmacs.
-  (if (cc-bytecomp-fboundp 'region-active-p)
-      ;; XEmacs.
-      '(region-active-p)
-    ;; Emacs.
-    'mark-active))
+  (if (cc-bytecomp-boundp 'mark-active)
+      ;; Emacs.
+      'mark-active
+    ;; XEmacs.
+    '(region-active-p)))
 
 (defmacro c-set-region-active (activate)
   ;; Activate the region if ACTIVE is non-nil, deactivate it
@@ -424,6 +425,8 @@ The return value is the value of the last form in BODY."
          (inhibit-read-only t) (inhibit-point-motion-hooks t)
          before-change-functions after-change-functions
          deactivate-mark
+         buffer-file-name buffer-file-truename ; Prevent primitives checking
+                                               ; for file modification
          ,@varlist)
      (unwind-protect
         (progn ,@body)
@@ -579,6 +582,24 @@ right side of it."
 ;; Wrappers for common scan-lists cases, mainly because it's almost
 ;; impossible to get a feel for how that function works.
 
+(defmacro c-go-list-forward ()
+  "Move backward across one balanced group of parentheses.
+
+Return POINT when we succeed, NIL when we fail.  In the latter case, leave
+point unmoved."
+  `(c-safe (let ((endpos (scan-lists (point) 1 0)))
+            (goto-char endpos)
+            endpos)))
+
+(defmacro c-go-list-backward ()
+  "Move backward across one balanced group of parentheses.
+
+Return POINT when we succeed, NIL when we fail.  In the latter case, leave
+point unmoved."
+  `(c-safe (let ((endpos (scan-lists (point) -1 0)))
+            (goto-char endpos)
+            endpos)))
+
 (defmacro c-up-list-forward (&optional pos limit)
   "Return the first position after the list sexp containing POS,
 or nil if no such position exists.  The point is used if POS is left out.
@@ -689,7 +710,8 @@ be after it."
            ;; c-parse-state to between 3 and 60 times faster when
            ;; braces are hung.  It can also degrade performance by
            ;; about as much when braces are not hung.
-           '(let (pos)
+           '(let (beginning-of-defun-function end-of-defun-function
+                                              pos)
               (while (not pos)
                 (save-restriction
                   (widen)
@@ -699,7 +721,7 @@ be after it."
                  ((bobp) (setq pos (point-min)))
                  ((not pos)
                   (let ((distance (skip-chars-backward "^{")))
-                    ;; unbalanced parenthesis, while illegal C code,
+                    ;; unbalanced parenthesis, while invalid C code,
                     ;; shouldn't cause an infloop!  See unbal.c
                     (when (zerop distance)
                       ;; Punt!
@@ -712,7 +734,8 @@ be after it."
                  ))
               (goto-char pos)))
        ;; Emacs, which doesn't have buffer-syntactic-context-depth
-       (beginning-of-defun))
+       (let (beginning-of-defun-function end-of-defun-function)
+        (beginning-of-defun)))
      ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at the
      ;; open brace.
      (and defun-prompt-regexp
@@ -721,7 +744,7 @@ be after it."
 
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; V i r t u a l   S e m i c o l o n s 
+;; V i r t u a l   S e m i c o l o n s
 ;;
 ;; In most CC Mode languages, statements are terminated explicitly by
 ;; semicolons or closing braces.  In some of the CC modes (currently only AWK
@@ -765,7 +788,7 @@ be after it."
 ;;
 ;; The macro `c-vsemi-status-unknown-p' will typically check the cacheing
 ;; scheme used by the `c-at-vsemi-p-fn', hence the name - the status is
-;; "unknown" if there is no cache entry current for the line. 
+;; "unknown" if there is no cache entry current for the line.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defmacro c-at-vsemi-p (&optional pos)
@@ -1005,6 +1028,39 @@ MODE is either a mode symbol or a list of mode symbols."
     ;; Emacs.
     `(remove-text-properties ,from ,to '(,property nil))))
 
+(defun c-clear-char-property-with-value-function (from to property value)
+  "Remove all text-properties PROPERTY from the region (FROM, TO)
+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)
+       (progn
+         (while           ; loop round changes in PROPERTY till we find VALUE
+             (and
+              (< place to)
+              (not (equal (get-text-property place property) value)))
+           (setq place (next-single-property-change place property nil to)))
+         (< place to))
+      (setq end-place (next-single-property-change place property nil to))
+      (put-text-property place end-place property nil)
+      ;; Do we have to do anything with stickiness here?
+      (setq place end-place))))
+
+(defmacro c-clear-char-property-with-value (from to property value)
+  "Remove all text-properties PROPERTY from the region [FROM, TO)
+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."
+  (if c-use-extents
+    ;; XEmacs
+      `(let ((-property- ,property))
+        (map-extents (lambda (ext val)
+                       (if (equal (extent-property ext -property-) val)
+                           (delete-extent ext)))
+                     nil ,from ,to ,value nil -property-))
+  ;; Gnu Emacs
+    `(c-clear-char-property-with-value-function ,from ,to ,property ,value)))
 \f
 ;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text.
 ;; For our purposes, these are characterized by being possible to
@@ -1495,8 +1551,8 @@ might be present:
                    (i.e. the syntax class `|').
 'pps-extended-state `parse-partial-sexp' returns a list with at least 10
                    elements, i.e. it contains the position of the start of
-                   the last comment or string. It's always set - CC Mode no
-                   longer works in emacsen without this feature.
+                   the last comment or string.  It's always set - CC Mode
+                    no longer works in emacsen without this feature.
 'posix-char-classes The regexp engine understands POSIX character classes.
 'col-0-paren        It's possible to turn off the ad-hoc rule that a paren
                    in column zero is the start of a defun.
@@ -2043,5 +2099,5 @@ quoted."
 \f
 (cc-provide 'cc-defs)
 
-;;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
+;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda
 ;;; cc-defs.el ends here