diff options
| author | Alan Mackenzie | 2019-10-11 19:10:11 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2019-10-11 19:10:11 +0000 |
| commit | 255c892b486eeb507b4533141fec9218b7a67b2f (patch) | |
| tree | d5867104cbb0fe2b0e8586255aa1664a17e6e09f | |
| parent | a93dceda3fdcca18b51cb96461e1b8a4fc61bfd7 (diff) | |
| download | emacs-255c892b486eeb507b4533141fec9218b7a67b2f.tar.gz emacs-255c892b486eeb507b4533141fec9218b7a67b2f.zip | |
C++ Mode: Correctly handle <:, <::, <::>, etc, according to the C++ standard
* lisp/progmodes/cc-engine.el (c-before-change-check-<>-operators): Perform
checking now on an insertion, should point be inside a critical token.
(c-forward-<>-arglist-recur, c-guess-continued-construct): Check for <::, etc.
* lisp/progmodes/cc-langs.el (c-<-pseudo-digraph-cont-regexp)
(c-<-pseudo-digraph-cont-len): New lang variables/constants.
| -rw-r--r-- | lisp/progmodes/cc-engine.el | 19 | ||||
| -rw-r--r-- | lisp/progmodes/cc-langs.el | 17 |
2 files changed, 32 insertions, 4 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 4ca440fd84b..9ed4fe3d88c 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el | |||
| @@ -6922,7 +6922,15 @@ comment at the start of cc-engine.el for more info." | |||
| 6922 | ;; | 6922 | ;; |
| 6923 | ;; FIXME!!! This routine ignores the possibility of macros entirely. | 6923 | ;; FIXME!!! This routine ignores the possibility of macros entirely. |
| 6924 | ;; 2010-01-29. | 6924 | ;; 2010-01-29. |
| 6925 | (when (and (> end beg) | 6925 | (when (and (or (> end beg) |
| 6926 | (and (> c-<-pseudo-digraph-cont-len 0) | ||
| 6927 | (goto-char beg) | ||
| 6928 | (progn | ||
| 6929 | (skip-chars-backward | ||
| 6930 | "^<" (max (- (point) c-<-pseudo-digraph-cont-len) | ||
| 6931 | (point-min))) | ||
| 6932 | (eq (char-before) ?<)) | ||
| 6933 | (looking-at c-<-pseudo-digraph-cont-regexp))) | ||
| 6926 | (or | 6934 | (or |
| 6927 | (progn | 6935 | (progn |
| 6928 | (goto-char beg) | 6936 | (goto-char beg) |
| @@ -7948,7 +7956,8 @@ comment at the start of cc-engine.el for more info." | |||
| 7948 | 7956 | ||
| 7949 | (forward-char) ; Forward over the opening '<'. | 7957 | (forward-char) ; Forward over the opening '<'. |
| 7950 | 7958 | ||
| 7951 | (unless (looking-at c-<-op-cont-regexp) | 7959 | (unless (and (looking-at c-<-op-cont-regexp) |
| 7960 | (not (looking-at c-<-pseudo-digraph-cont-regexp))) | ||
| 7952 | ;; go forward one non-alphanumeric character (group) per iteration of | 7961 | ;; go forward one non-alphanumeric character (group) per iteration of |
| 7953 | ;; this loop. | 7962 | ;; this loop. |
| 7954 | (while (and | 7963 | (while (and |
| @@ -8026,7 +8035,8 @@ comment at the start of cc-engine.el for more info." | |||
| 8026 | (let (id-start id-end subres keyword-match) | 8035 | (let (id-start id-end subres keyword-match) |
| 8027 | (cond | 8036 | (cond |
| 8028 | ;; The '<' begins a multi-char operator. | 8037 | ;; The '<' begins a multi-char operator. |
| 8029 | ((looking-at c-<-op-cont-regexp) | 8038 | ((and (looking-at c-<-op-cont-regexp) |
| 8039 | (not (looking-at c-<-pseudo-digraph-cont-regexp))) | ||
| 8030 | (goto-char (match-end 0))) | 8040 | (goto-char (match-end 0))) |
| 8031 | ;; We're at a nested <.....> | 8041 | ;; We're at a nested <.....> |
| 8032 | ((progn | 8042 | ((progn |
| @@ -12552,7 +12562,8 @@ comment at the start of cc-engine.el for more info." | |||
| 12552 | (/= (char-before placeholder) ?<) | 12562 | (/= (char-before placeholder) ?<) |
| 12553 | (progn | 12563 | (progn |
| 12554 | (goto-char (1+ placeholder)) | 12564 | (goto-char (1+ placeholder)) |
| 12555 | (not (looking-at c-<-op-cont-regexp)))))) | 12565 | (or (not (looking-at c-<-op-cont-regexp)) |
| 12566 | (looking-at c-<-pseudo-digraph-cont-regexp)))))) | ||
| 12556 | (goto-char placeholder) | 12567 | (goto-char placeholder) |
| 12557 | (c-beginning-of-statement-1 containing-sexp t) | 12568 | (c-beginning-of-statement-1 containing-sexp t) |
| 12558 | (if (save-excursion | 12569 | (if (save-excursion |
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el index d092094817c..a6fdc3ec798 100644 --- a/lisp/progmodes/cc-langs.el +++ b/lisp/progmodes/cc-langs.el | |||
| @@ -1406,6 +1406,23 @@ operators." | |||
| 1406 | (lambda (op) (substring op 1))))) | 1406 | (lambda (op) (substring op 1))))) |
| 1407 | (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp)) | 1407 | (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp)) |
| 1408 | 1408 | ||
| 1409 | (c-lang-defconst c-<-pseudo-digraph-cont-regexp | ||
| 1410 | "Regexp matching the continuation of a pseudo digraph starting \"<\". | ||
| 1411 | This is used only in C++ Mode, where \"<::\" is handled as a | ||
| 1412 | template opener followed by the \"::\" operator - usually." | ||
| 1413 | t regexp-unmatchable | ||
| 1414 | c++ "::\\([^:>]\\|$\\)") | ||
| 1415 | (c-lang-defvar c-<-pseudo-digraph-cont-regexp | ||
| 1416 | (c-lang-const c-<-pseudo-digraph-cont-regexp)) | ||
| 1417 | |||
| 1418 | (c-lang-defconst c-<-pseudo-digraph-cont-len | ||
| 1419 | "The maximum length of the main bit of a `c-<pseudp-digraph-cont-regexp' match. | ||
| 1420 | This doesn't count the merely contextual bits of the regexp match." | ||
| 1421 | t 0 | ||
| 1422 | c++ 2) | ||
| 1423 | (c-lang-defvar c-<-pseudo-digraph-cont-len | ||
| 1424 | (c-lang-const c-<-pseudo-digraph-cont-len)) | ||
| 1425 | |||
| 1409 | (c-lang-defconst c->-op-cont-tokens | 1426 | (c-lang-defconst c->-op-cont-tokens |
| 1410 | ;; A list of second and subsequent characters of all multicharacter tokens | 1427 | ;; A list of second and subsequent characters of all multicharacter tokens |
| 1411 | ;; that begin with ">". | 1428 | ;; that begin with ">". |