]> 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 b509fdd7cc204456a21db095ad975ebb224a8b52..2c5511be1a2f97bf65e5742e87e9a1fdd01b27df 100644 (file)
@@ -73,9 +73,9 @@
 
 ; (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
+(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?
@@ -84,8 +84,8 @@
 ;; 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)
@@ -337,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
@@ -1028,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
@@ -2066,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