Mercurial > emacs
changeset 80156:fa9371f081be
Set of changes so that "obtrusive" syntactic elements in a
C/C++/ObjC preprocessor line (e.g. an unbalanced string quote or
unmatched paren) don't interact syntactically with stuff outside
the CPP line.
(c-clear-char-property-with-value-function)
(c-clear-char-property-with-value): New function and macro which remove
text-properties `equal' to a supplied value.
author | Alan Mackenzie <acm@muc.de> |
---|---|
date | Tue, 19 Feb 2008 22:07:33 +0000 |
parents | 78cb7fb87a03 |
children | e67a400370f5 |
files | lisp/progmodes/cc-defs.el |
diffstat | 1 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/progmodes/cc-defs.el Tue Feb 19 22:04:34 2008 +0000 +++ b/lisp/progmodes/cc-defs.el Tue Feb 19 22:07:33 2008 +0000 @@ -1028,6 +1028,39 @@ ;; 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))) ;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text. ;; For our purposes, these are characterized by being possible to