diff options
author | Alan Mackenzie <acm@muc.de> | 2010-02-04 21:15:37 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2010-02-04 21:15:37 +0000 |
commit | dd969a56a57ce94dca1b61b25c8cc4ad102112f7 (patch) | |
tree | 289b43fc72cb1f3f4fca06d27c3c4ec8b1a75c88 /lisp/progmodes/cc-defs.el | |
parent | d5b3979c8a0129ab007179a8d6e554dfbcfaa24d (diff) | |
download | emacs-dd969a56a57ce94dca1b61b25c8cc4ad102112f7.tar.gz |
Change strategy for marking < and > as template delimiters: mark them
strictly in matching pairs.
Diffstat (limited to 'lisp/progmodes/cc-defs.el')
-rw-r--r-- | lisp/progmodes/cc-defs.el | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index bb91dee6ce8..7eb0016ff43 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -1029,6 +1029,44 @@ MODE is either a mode symbol or a list of mode symbols." ;; 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 |