;;; 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, 2009, 2010
+;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
;; Free Software Foundation, Inc.
;; Authors: 2003- Alan Mackenzie
;; 1985 Richard M. Stallman
;; Maintainer: bug-cc-mode@gnu.org
;; Created: 22-Apr-1997 (split from cc-mode.el)
-;; Version: See cc-mode.el
-;; Keywords: c languages oop
+;; Keywords: c languages
+;; Package: cc-mode
;; This file is part of GNU Emacs.
;; Emacs.
`(remove-text-properties ,from ,to '(,property nil))))
+(defmacro c-search-forward-char-property (property value &optional limit)
+ "Search forward for a text-property PROPERTY having value VALUE.
+LIMIT bounds the search. The comparison is done with `equal'.
+
+Leave point just after the character, and set the match data on
+this character, and return point. If VALUE isn't found, Return
+nil; point is then left undefined."
+ `(let ((place (point)))
+ (while
+ (and
+ (< place ,(or limit '(point-max)))
+ (not (equal (get-text-property place ,property) ,value)))
+ (setq place (next-single-property-change
+ place ,property nil ,(or limit '(point-max)))))
+ (when (< place ,(or limit '(point-max)))
+ (goto-char place)
+ (search-forward-regexp ".") ; to set the match-data.
+ (point))))
+
+(defmacro c-search-backward-char-property (property value &optional limit)
+ "Search backward for a text-property PROPERTY having value VALUE.
+LIMIT bounds the search. The comparison is done with `equal'.
+
+Leave point just before the character, set the match data on this
+character, and return point. If VALUE isn't found, Return nil;
+point is then left undefined."
+ `(let ((place (point)))
+ (while
+ (and
+ (> place ,(or limit '(point-min)))
+ (not (equal (get-text-property (1- place) ,property) ,value)))
+ (setq place (previous-single-property-change
+ place ,property nil ,(or limit '(point-min)))))
+ (when (> place ,(or limit '(point-max)))
+ (goto-char place)
+ (search-backward-regexp ".") ; to set the match-data.
+ (point))))
+
(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
(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)
+ (remove-text-properties place end-place (cons property nil))
;; Do we have to do anything with stickiness here?
(setq place end-place))))
;; This macro does a hidden buffer change.
`(progn
(c-put-char-property ,beg 'category 'c-cpp-delimiter)
- (c-put-char-property ,end 'category 'c-cpp-delimiter)))
+ (if (< ,end (point-max))
+ (c-put-char-property ,end 'category 'c-cpp-delimiter))))
(defmacro c-clear-cpp-delimiters (beg end)
;; This macro does a hidden buffer change.
`(progn
(c-clear-char-property ,beg 'category)
- (c-clear-char-property ,end 'category)))
+ (if (< ,end (point-max))
+ (c-clear-char-property ,end 'category))))
(defsubst c-comment-out-cpps ()
;; Render all preprocessor constructs syntactically commented out.