diff options
| author | Alan Mackenzie | 2016-01-08 22:42:47 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2016-01-08 22:42:47 +0000 |
| commit | 457738ffba806a638ca3597741ecd103241790be (patch) | |
| tree | 168c6e546afbe33cdb334aaaae727a3f61dcfd91 | |
| parent | d57724a879ce60f0567bf323b884f917f4e94937 (diff) | |
| download | emacs-457738ffba806a638ca3597741ecd103241790be.tar.gz emacs-457738ffba806a638ca3597741ecd103241790be.zip | |
Correctly analyze brace arguments in templated C++ function declarations.
* lisp/progmodes/cc-defs.el (c-go-list-forward, c-go-list-backward): add
POS and LIMIT parameters, like the other c-go-list-* functions have.
* lisp/progmodes/cc-engine.el (c-restore-<>-properties): Check backwards
for a ?\( rather than a ?<. (c-looking-at-inexpr-block): Handle names
followed by template specifiers.
| -rw-r--r-- | lisp/progmodes/cc-defs.el | 46 | ||||
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 9 |
2 files changed, 36 insertions, 19 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index 77e949c59d4..000995c5b53 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el | |||
| @@ -654,23 +654,35 @@ right side of it." | |||
| 654 | ;; Wrappers for common scan-lists cases, mainly because it's almost | 654 | ;; Wrappers for common scan-lists cases, mainly because it's almost |
| 655 | ;; impossible to get a feel for how that function works. | 655 | ;; impossible to get a feel for how that function works. |
| 656 | 656 | ||
| 657 | (defmacro c-go-list-forward () | 657 | (defmacro c-go-list-forward (&optional pos limit) |
| 658 | "Move backward across one balanced group of parentheses. | 658 | "Move forward across one balanced group of parentheses starting at POS or |
| 659 | 659 | point. Return POINT when we succeed, NIL when we fail. In the latter case, | |
| 660 | Return POINT when we succeed, NIL when we fail. In the latter case, leave | 660 | leave point unmoved. |
| 661 | point unmoved." | 661 | |
| 662 | `(c-safe (let ((endpos (scan-lists (point) 1 0))) | 662 | A LIMIT for the search may be given. The start position is assumed to be |
| 663 | (goto-char endpos) | 663 | before it." |
| 664 | endpos))) | 664 | (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 0)) (point)))) |
| 665 | 665 | (if limit | |
| 666 | (defmacro c-go-list-backward () | 666 | `(save-restriction |
| 667 | "Move backward across one balanced group of parentheses. | 667 | (if ,limit |
| 668 | 668 | (narrow-to-region (point-min) ,limit)) | |
| 669 | Return POINT when we succeed, NIL when we fail. In the latter case, leave | 669 | ,res) |
| 670 | point unmoved." | 670 | res))) |
| 671 | `(c-safe (let ((endpos (scan-lists (point) -1 0))) | 671 | |
| 672 | (goto-char endpos) | 672 | (defmacro c-go-list-backward (&optional pos limit) |
| 673 | endpos))) | 673 | "Move backward across one balanced group of parentheses starting at POS or |
| 674 | point. Return POINT when we succeed, NIL when we fail. In the latter case, | ||
| 675 | leave point unmoved. | ||
| 676 | |||
| 677 | A LIMIT for the search may be given. The start position is assumed to be | ||
| 678 | after it." | ||
| 679 | (let ((res `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 0)) (point)))) | ||
| 680 | (if limit | ||
| 681 | `(save-restriction | ||
| 682 | (if ,limit | ||
| 683 | (narrow-to-region ,limit (point-max))) | ||
| 684 | ,res) | ||
| 685 | res))) | ||
| 674 | 686 | ||
| 675 | (defmacro c-up-list-forward (&optional pos limit) | 687 | (defmacro c-up-list-forward (&optional pos limit) |
| 676 | "Return the first position after the list sexp containing POS, | 688 | "Return the first position after the list sexp containing POS, |
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 3301d415923..98699df0cab 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -5688,8 +5688,8 @@ comment at the start of cc-engine.el for more info." | |||
| 5688 | (c-backward-token-2) | 5688 | (c-backward-token-2) |
| 5689 | (setq c-restricted-<>-arglists | 5689 | (setq c-restricted-<>-arglists |
| 5690 | (and (not (looking-at c-opt-<>-sexp-key)) | 5690 | (and (not (looking-at c-opt-<>-sexp-key)) |
| 5691 | (progn (c-backward-syntactic-ws) ; to < or , | 5691 | (progn (c-backward-syntactic-ws) ; to ( or , |
| 5692 | (and (memq (char-before) '(?< ?,)) | 5692 | (and (memq (char-before) '(?\( ?,)) ; what about <? |
| 5693 | (not (eq (c-get-char-property (point) 'c-type) | 5693 | (not (eq (c-get-char-property (point) 'c-type) |
| 5694 | 'c-decl-arg-start))))))) | 5694 | 'c-decl-arg-start))))))) |
| 5695 | (or (c-forward-<>-arglist nil) | 5695 | (or (c-forward-<>-arglist nil) |
| @@ -9106,6 +9106,11 @@ comment at the start of cc-engine.el for more info." | |||
| 9106 | (goto-char containing-sexp) | 9106 | (goto-char containing-sexp) |
| 9107 | (if (or (save-excursion | 9107 | (if (or (save-excursion |
| 9108 | (c-backward-syntactic-ws lim) | 9108 | (c-backward-syntactic-ws lim) |
| 9109 | (while (and (eq (char-before) ?>) | ||
| 9110 | (c-get-char-property (1- (point)) | ||
| 9111 | 'syntax-table) | ||
| 9112 | (c-go-list-backward nil lim)) | ||
| 9113 | (c-backward-syntactic-ws lim)) | ||
| 9109 | (and (> (point) (or lim (point-min))) | 9114 | (and (> (point) (or lim (point-min))) |
| 9110 | (c-on-identifier))) | 9115 | (c-on-identifier))) |
| 9111 | (and c-special-brace-lists | 9116 | (and c-special-brace-lists |