aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2008-02-19 22:07:33 +0000
committerAlan Mackenzie2008-02-19 22:07:33 +0000
commit3cb5c13209f5311240f0dffa2e85ce5407716292 (patch)
tree77f32a818c38754908469334547500e03e4f4cf4
parent88a46e21049ad174ddf98eca63eb3246a5b91946 (diff)
downloademacs-3cb5c13209f5311240f0dffa2e85ce5407716292.tar.gz
emacs-3cb5c13209f5311240f0dffa2e85ce5407716292.zip
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.
-rw-r--r--lisp/progmodes/cc-defs.el33
1 files changed, 33 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index b509fdd7cc2..588e7c3428e 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -1028,6 +1028,39 @@ MODE is either a mode symbol or a list of mode symbols."
1028 ;; Emacs. 1028 ;; Emacs.
1029 `(remove-text-properties ,from ,to '(,property nil)))) 1029 `(remove-text-properties ,from ,to '(,property nil))))
1030 1030
1031(defun c-clear-char-property-with-value-function (from to property value)
1032 "Remove all text-properties PROPERTY from the region (FROM, TO)
1033which have the value VALUE, as tested by `equal'. These
1034properties are assumed to be over individual characters, having
1035been put there by c-put-char-property. POINT remains unchanged."
1036 (let ((place from) end-place)
1037 (while ; loop round occurrances of (PROPERTY VALUE)
1038 (progn
1039 (while ; loop round changes in PROPERTY till we find VALUE
1040 (and
1041 (< place to)
1042 (not (equal (get-text-property place property) value)))
1043 (setq place (next-single-property-change place property nil to)))
1044 (< place to))
1045 (setq end-place (next-single-property-change place property nil to))
1046 (put-text-property place end-place property nil)
1047 ;; Do we have to do anything with stickiness here?
1048 (setq place end-place))))
1049
1050(defmacro c-clear-char-property-with-value (from to property value)
1051 "Remove all text-properties PROPERTY from the region [FROM, TO)
1052which have the value VALUE, as tested by `equal'. These
1053properties are assumed to be over individual characters, having
1054been put there by c-put-char-property. POINT remains unchanged."
1055 (if c-use-extents
1056 ;; XEmacs
1057 `(let ((-property- ,property))
1058 (map-extents (lambda (ext val)
1059 (if (equal (extent-property ext -property-) val)
1060 (delete-extent ext)))
1061 nil ,from ,to ,value nil -property-))
1062 ;; Gnu Emacs
1063 `(c-clear-char-property-with-value-function ,from ,to ,property ,value)))
1031 1064
1032;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text. 1065;; Macros to put overlays (Emacs) or extents (XEmacs) on buffer text.
1033;; For our purposes, these are characterized by being possible to 1066;; For our purposes, these are characterized by being possible to