From: Alan Mackenzie Date: Fri, 11 Oct 2019 19:10:11 +0000 (+0000) Subject: C++ Mode: Correctly handle <:, <::, <::>, etc, according to the C++ standard X-Git-Tag: emacs-27.0.90~1147 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=255c892b486eeb507b4533141fec9218b7a67b2f;p=emacs.git 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. --- 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." ;; ;; FIXME!!! This routine ignores the possibility of macros entirely. ;; 2010-01-29. - (when (and (> end beg) + (when (and (or (> end beg) + (and (> c-<-pseudo-digraph-cont-len 0) + (goto-char beg) + (progn + (skip-chars-backward + "^<" (max (- (point) c-<-pseudo-digraph-cont-len) + (point-min))) + (eq (char-before) ?<)) + (looking-at c-<-pseudo-digraph-cont-regexp))) (or (progn (goto-char beg) @@ -7948,7 +7956,8 @@ comment at the start of cc-engine.el for more info." (forward-char) ; Forward over the opening '<'. - (unless (looking-at c-<-op-cont-regexp) + (unless (and (looking-at c-<-op-cont-regexp) + (not (looking-at c-<-pseudo-digraph-cont-regexp))) ;; go forward one non-alphanumeric character (group) per iteration of ;; this loop. (while (and @@ -8026,7 +8035,8 @@ comment at the start of cc-engine.el for more info." (let (id-start id-end subres keyword-match) (cond ;; The '<' begins a multi-char operator. - ((looking-at c-<-op-cont-regexp) + ((and (looking-at c-<-op-cont-regexp) + (not (looking-at c-<-pseudo-digraph-cont-regexp))) (goto-char (match-end 0))) ;; We're at a nested <.....> ((progn @@ -12552,7 +12562,8 @@ comment at the start of cc-engine.el for more info." (/= (char-before placeholder) ?<) (progn (goto-char (1+ placeholder)) - (not (looking-at c-<-op-cont-regexp)))))) + (or (not (looking-at c-<-op-cont-regexp)) + (looking-at c-<-pseudo-digraph-cont-regexp)))))) (goto-char placeholder) (c-beginning-of-statement-1 containing-sexp t) (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." (lambda (op) (substring op 1))))) (c-lang-defvar c-<-op-cont-regexp (c-lang-const c-<-op-cont-regexp)) +(c-lang-defconst c-<-pseudo-digraph-cont-regexp + "Regexp matching the continuation of a pseudo digraph starting \"<\". +This is used only in C++ Mode, where \"<::\" is handled as a +template opener followed by the \"::\" operator - usually." + t regexp-unmatchable + c++ "::\\([^:>]\\|$\\)") +(c-lang-defvar c-<-pseudo-digraph-cont-regexp + (c-lang-const c-<-pseudo-digraph-cont-regexp)) + +(c-lang-defconst c-<-pseudo-digraph-cont-len + "The maximum length of the main bit of a `c--op-cont-tokens ;; A list of second and subsequent characters of all multicharacter tokens ;; that begin with ">".