- (while (re-search-forward ,regexp limit t)
- (unless (progn
- (goto-char (match-beginning 0))
- (c-skip-comments-and-strings limit))
- (goto-char (match-end 0))
- ,@(mapcar
- (lambda (highlight)
- (if (integerp (car highlight))
- (progn
- (unless (eq (nth 2 highlight) t)
- (error
- "The override flag must currently be t in %s"
- highlight))
- (when (nth 3 highlight)
- (error
- "The laxmatch flag may currently not be set in %s"
- highlight))
- `(save-match-data
- (c-put-font-lock-face
- (match-beginning ,(car highlight))
- (match-end ,(car highlight))
- ,(elt highlight 1))))
- (when (nth 3 highlight)
- (error "Match highlights currently not supported in %s"
- highlight))
- `(progn
- ,(nth 1 highlight)
- (save-match-data ,(car highlight))
- ,(nth 2 highlight))))
- highlights))))
+
+ ;; (while (re-search-forward ,regexp limit t)
+ ;; (unless (progn
+ ;; (goto-char (match-beginning 0))
+ ;; (c-skip-comments-and-strings limit))
+ ;; (goto-char (match-end 0))
+ ;; ,@(mapcar
+ ;; (lambda (highlight)
+ ;; (if (integerp (car highlight))
+ ;; (progn
+ ;; (unless (eq (nth 2 highlight) t)
+ ;; (error
+ ;; "The override flag must currently be t in %s"
+ ;; highlight))
+ ;; (when (nth 3 highlight)
+ ;; (error
+ ;; "The laxmatch flag may currently not be set in %s"
+ ;; highlight))
+ ;; `(save-match-data
+ ;; (c-put-font-lock-face
+ ;; (match-beginning ,(car highlight))
+ ;; (match-end ,(car highlight))
+ ;; ,(elt highlight 1))))
+ ;; (when (nth 3 highlight)
+ ;; (error "Match highlights currently not supported in %s"
+ ;; highlight))
+ ;; `(progn
+ ;; ,(nth 1 highlight)
+ ;; (save-match-data ,(car highlight))
+ ;; ,(nth 2 highlight))))
+ ;; highlights)))
+ ,(c-make-font-lock-search-form regexp highlights))
+
+ nil)))
+
+ (defun c-make-font-lock-BO-decl-search-function (regexp &rest highlights)
+ ;; This function makes a byte compiled function that first moves back
+ ;; to the beginning of the current declaration (if any), then searches
+ ;; forward for matcher elements (as in `font-lock-keywords') and
+ ;; fontifies them.
+ ;;
+ ;; The motivation for moving back to the declaration start is to
+ ;; establish a context for the current text when, e.g., a character
+ ;; is typed on a C++ inheritance continuation line, or a jit-lock
+ ;; chunk starts there.
+ ;;
+ ;; The new function works much like a matcher element in
+ ;; `font-lock-keywords'. It cuts out a little bit of the overhead
+ ;; compared to a real matcher. The main reason is however to pass the
+ ;; real search limit to the anchored matcher(s), since most (if not
+ ;; all) font-lock implementations arbitrarily limit anchored matchers
+ ;; to the same line, and also to insulate against various other
+ ;; irritating differences between the different (X)Emacs font-lock
+ ;; packages.
+ ;;
+ ;; REGEXP is the matcher, which must be a regexp. Only matches
+ ;; where the beginning is outside any comment or string literal are
+ ;; significant.
+ ;;
+ ;; HIGHLIGHTS is a list of highlight specs, just like in
+ ;; `font-lock-keywords', with these limitations: The face is always
+ ;; overridden (no big disadvantage, since hits in comments etc are
+ ;; filtered anyway), there is no "laxmatch", and an anchored matcher
+ ;; is always a form which must do all the fontification directly.
+ ;; `limit' is a variable bound to the real limit in the context of
+ ;; the anchored matcher forms.
+ ;;
+ ;; This function does not do any hidden buffer changes, but the
+ ;; generated functions will. (They are however used in places
+ ;; covered by the font-lock context.)
+
+ ;; Note: Replace `byte-compile' with `eval' to debug the generated
+ ;; lambda more easily.
+ (byte-compile
+ `(lambda (limit)
+ (let ( ;; The font-lock package in Emacs is known to clobber
+ ;; `parse-sexp-lookup-properties' (when it exists).
+ (parse-sexp-lookup-properties
+ (cc-eval-when-compile
+ (boundp 'parse-sexp-lookup-properties)))
+ (BOD-limit
+ (c-determine-limit 1000)))
+ (goto-char
+ (let ((here (point)))
+ (if (eq (car (c-beginning-of-decl-1 BOD-limit)) 'same)
+ (point)
+ here)))
+ ,(c-make-font-lock-search-form regexp highlights))