diff options
| author | Alan Mackenzie | 2019-05-18 15:20:49 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2019-05-18 15:20:49 +0000 |
| commit | 95fb826dc58965eac287c0826831352edf2e56f7 (patch) | |
| tree | 32857db5b79ef4dcac22a4b5be2fd8a6c3972a30 /lisp/progmodes | |
| parent | 67b6c1b295afb0c2f51a2e01e19ab4682845148e (diff) | |
| download | emacs-95fb826dc58965eac287c0826831352edf2e56f7.tar.gz emacs-95fb826dc58965eac287c0826831352edf2e56f7.zip | |
CC Mode: Handle several consecutive noise macros in declaration contexts.
In the bug scenario, the second and subsequent noise macros with parentheses
were getting font-lock-type-face.
* lisp/progmodes/cc-engine.el (c-end-of-token)
(c-forward-noise-clause-not-macro-decl): New functions.
(c-find-decl-prefix-search): Handle noise macros by skipping over them.
(c-forward-decl-or-cast-1): In the loop checking for types, skip over all
consecutive noise macros with parens, not just one.
Diffstat (limited to 'lisp/progmodes')
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 41bab270daa..c0f044ddfeb 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -4491,6 +4491,30 @@ comment at the start of cc-engine.el for more info." | |||
| 4491 | (goto-char pos)))))) | 4491 | (goto-char pos)))))) |
| 4492 | (< (point) start))) | 4492 | (< (point) start))) |
| 4493 | 4493 | ||
| 4494 | (defun c-end-of-token (&optional back-limit) | ||
| 4495 | ;; Move to the end of the token we're just before or in the middle of. | ||
| 4496 | ;; BACK-LIMIT may be used to bound the backward search; if given it's | ||
| 4497 | ;; assumed to be at the boundary between two tokens. Return non-nil if the | ||
| 4498 | ;; point is moved, nil otherwise. | ||
| 4499 | ;; | ||
| 4500 | ;; This function might do hidden buffer changes. | ||
| 4501 | (let ((start (point))) | ||
| 4502 | (cond ;; ((< (skip-syntax-backward "w_" (1- start)) 0) | ||
| 4503 | ;; (skip-syntax-forward "w_")) | ||
| 4504 | ((> (skip-syntax-forward "w_") 0)) | ||
| 4505 | ((< (skip-syntax-backward ".()" back-limit) 0) | ||
| 4506 | (while (< (point) start) | ||
| 4507 | (if (looking-at c-nonsymbol-token-regexp) | ||
| 4508 | (goto-char (match-end 0)) | ||
| 4509 | ;; `c-nonsymbol-token-regexp' should always match since | ||
| 4510 | ;; we've skipped backward over punctuation or paren | ||
| 4511 | ;; syntax, but move forward in case it doesn't so that | ||
| 4512 | ;; we don't leave point earlier than we started with. | ||
| 4513 | (forward-char)))) | ||
| 4514 | (t (if (looking-at c-nonsymbol-token-regexp) | ||
| 4515 | (goto-char (match-end 0))))) | ||
| 4516 | (> (point) start))) | ||
| 4517 | |||
| 4494 | (defun c-end-of-current-token (&optional back-limit) | 4518 | (defun c-end-of-current-token (&optional back-limit) |
| 4495 | ;; Move to the end of the current token. Do not move if not in the | 4519 | ;; Move to the end of the current token. Do not move if not in the |
| 4496 | ;; middle of one. BACK-LIMIT may be used to bound the backward | 4520 | ;; middle of one. BACK-LIMIT may be used to bound the backward |
| @@ -5878,9 +5902,14 @@ comment at the start of cc-engine.el for more info." | |||
| 5878 | ;; comment style has removed face properties from a construct, | 5902 | ;; comment style has removed face properties from a construct, |
| 5879 | ;; and is relying on `c-font-lock-declarations' to add them | 5903 | ;; and is relying on `c-font-lock-declarations' to add them |
| 5880 | ;; again. | 5904 | ;; again. |
| 5881 | (and (< (point) cfd-limit) | 5905 | (cond |
| 5882 | (looking-at c-doc-line-join-re) | 5906 | ((looking-at c-noise-macro-name-re) |
| 5883 | (goto-char (match-end 0))))) | 5907 | (c-forward-noise-clause-not-macro-decl nil)) ; Returns t. |
| 5908 | ((looking-at c-noise-macro-with-parens-name-re) | ||
| 5909 | (c-forward-noise-clause-not-macro-decl t)) ; Always returns t. | ||
| 5910 | ((and (< (point) cfd-limit) | ||
| 5911 | (looking-at c-doc-line-join-re)) | ||
| 5912 | (goto-char (match-end 0)))))) | ||
| 5884 | ;; Set the position to continue at. We can avoid going over | 5913 | ;; Set the position to continue at. We can avoid going over |
| 5885 | ;; the comments skipped above a second time, but it's possible | 5914 | ;; the comments skipped above a second time, but it's possible |
| 5886 | ;; that the comment skipping has taken us past `cfd-prop-match' | 5915 | ;; that the comment skipping has taken us past `cfd-prop-match' |
| @@ -5909,6 +5938,8 @@ comment at the start of cc-engine.el for more info." | |||
| 5909 | ;; o The first token after the end of submatch 1 in | 5938 | ;; o The first token after the end of submatch 1 in |
| 5910 | ;; `c-decl-prefix-or-start-re' when that submatch matches. This | 5939 | ;; `c-decl-prefix-or-start-re' when that submatch matches. This |
| 5911 | ;; submatch is typically a (L or R) brace or paren, a ;, or a ,. | 5940 | ;; submatch is typically a (L or R) brace or paren, a ;, or a ,. |
| 5941 | ;; As a special case, noise macros are skipped over and the next | ||
| 5942 | ;; token regarded as the spot. | ||
| 5912 | ;; o The start of each `c-decl-prefix-or-start-re' match when | 5943 | ;; o The start of each `c-decl-prefix-or-start-re' match when |
| 5913 | ;; submatch 1 doesn't match. This is, for example, the keyword | 5944 | ;; submatch 1 doesn't match. This is, for example, the keyword |
| 5914 | ;; "class" in Pike. | 5945 | ;; "class" in Pike. |
| @@ -7439,6 +7470,21 @@ comment at the start of cc-engine.el for more info." | |||
| 7439 | (c-forward-syntactic-ws)) | 7470 | (c-forward-syntactic-ws)) |
| 7440 | t) | 7471 | t) |
| 7441 | 7472 | ||
| 7473 | (defun c-forward-noise-clause-not-macro-decl (maybe-parens) | ||
| 7474 | ;; Point is at a noise macro identifier, which, when MAYBE-PARENS is | ||
| 7475 | ;; non-nil, optionally takes paren arguments. Go forward over this name, | ||
| 7476 | ;; and when there may be optional parens, any parenthesis expression which | ||
| 7477 | ;; follows it, but DO NOT go over any macro declaration which may come | ||
| 7478 | ;; between them. Always return t. | ||
| 7479 | (c-end-of-token) | ||
| 7480 | (when maybe-parens | ||
| 7481 | (let ((here (point))) | ||
| 7482 | (c-forward-comments) | ||
| 7483 | (if (not (and (eq (char-after) ?\() | ||
| 7484 | (c-go-list-forward))) | ||
| 7485 | (goto-char here)))) | ||
| 7486 | t) | ||
| 7487 | |||
| 7442 | (defun c-forward-keyword-clause (match) | 7488 | (defun c-forward-keyword-clause (match) |
| 7443 | ;; Submatch MATCH in the current match data is assumed to surround a | 7489 | ;; Submatch MATCH in the current match data is assumed to surround a |
| 7444 | ;; token. If it's a keyword, move over it and any immediately | 7490 | ;; token. If it's a keyword, move over it and any immediately |
| @@ -9053,7 +9099,10 @@ This function might do hidden buffer changes." | |||
| 9053 | ((and c-opt-cpp-prefix | 9099 | ((and c-opt-cpp-prefix |
| 9054 | (looking-at c-noise-macro-with-parens-name-re)) | 9100 | (looking-at c-noise-macro-with-parens-name-re)) |
| 9055 | (setq noise-start (point)) | 9101 | (setq noise-start (point)) |
| 9056 | (c-forward-noise-clause) | 9102 | (while |
| 9103 | (and | ||
| 9104 | (c-forward-noise-clause) | ||
| 9105 | (looking-at c-noise-macro-with-parens-name-re))) | ||
| 9057 | (setq kwd-clause-end (point)))) | 9106 | (setq kwd-clause-end (point)))) |
| 9058 | 9107 | ||
| 9059 | (when (setq found-type (c-forward-type t)) ; brace-block-too | 9108 | (when (setq found-type (c-forward-type t)) ; brace-block-too |