Function: font-lock-match-c-style-declaration-item-and-skip-to-next

font-lock-match-c-style-declaration-item-and-skip-to-next is a byte-compiled function defined in font-lock.el.gz.

Signature

(font-lock-match-c-style-declaration-item-and-skip-to-next LIMIT)

Documentation

Match, and move over, any declaration/definition item after point.

Matches after point, but ignores leading whitespace and * characters. Does not move further than LIMIT.

The expected syntax of a declaration/definition item is word (preceded by optional whitespace and * characters and proceeded by optional whitespace) optionally followed by a (. Everything following the item (but belonging to it) is expected to be skip-able by scan-sexps, and items are expected to be separated with a , and to be terminated with a ;.

Thus the regexp matches after point: word (
^^^^ ^
Where the match subexpressions are: 1 2

The item is delimited by (match-beginning 1) and (match-end 1). If (match-beginning 2) is non-nil, the item is followed by a (.

This function could be MATCHER in a MATCH-ANCHORED font-lock-keywords item.

Source Code

;; Defined in /usr/src/emacs/lisp/font-lock.el.gz
;;; Various regexp information shared by several modes.
;; ;; Information specific to a single mode should go in its load library.

;; Font Lock support for C, C++, Objective-C and Java modes is now in
;; cc-fonts.el (and required by cc-mode.el).  However, the below function
;; should stay in font-lock.el, since it is used by other libraries.  sm.

(defun font-lock-match-c-style-declaration-item-and-skip-to-next (limit)
  "Match, and move over, any declaration/definition item after point.
Matches after point, but ignores leading whitespace and `*' characters.
Does not move further than LIMIT.

The expected syntax of a declaration/definition item is `word' (preceded by
optional whitespace and `*' characters and proceeded by optional whitespace)
optionally followed by a `('.  Everything following the item (but belonging to
it) is expected to be skip-able by `scan-sexps', and items are expected to be
separated with a `,' and to be terminated with a `;'.

Thus the regexp matches after point:	word (
					^^^^ ^
Where the match subexpressions are:	  1  2

The item is delimited by (match-beginning 1) and (match-end 1).
If (match-beginning 2) is non-nil, the item is followed by a `('.

This function could be MATCHER in a MATCH-ANCHORED `font-lock-keywords' item."
  (when (looking-at "[ \n\t*]*\\(\\sw+\\)[ \t\n]*\\(((?\\)?")
    (when (and (match-end 2) (> (- (match-end 2) (match-beginning 2)) 1))
      ;; If `word' is followed by a double open-paren, it's probably
      ;; a macro used for "int myfun P_ ((int arg1))".  Let's go back one
      ;; word to try and match `myfun' rather than `P_'.
      (let ((pos (point)))
	(skip-chars-backward " \t\n")
	(skip-syntax-backward "w")
	(unless (looking-at "\\(\\sw+\\)[ \t\n]*\\sw+[ \t\n]*\\(((?\\)?")
	  ;; Looks like it was something else, so go back to where we
	  ;; were and reset the match data by rematching.
	  (goto-char pos)
	  (looking-at "[ \n\t*]*\\(\\sw+\\)[ \t\n]*\\(((?\\)?"))))
    (save-match-data
      (condition-case nil
	  (save-restriction
	    ;; Restrict to the LIMIT.
	    (narrow-to-region (point-min) limit)
	    (goto-char (match-end 1))
	    ;; Move over any item value, etc., to the next item.
	    (while (not (looking-at "[ \t\n]*\\(\\(,\\)\\|;\\|\\'\\)"))
	      (goto-char (or (scan-sexps (point) 1) (point-max))))
	    (if (match-end 2)
		(goto-char (match-end 2))))
	(error t)))))