emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 255c892: C++ Mode: Correctly handle <:, <::, <::>,


From: Alan Mackenzie
Subject: [Emacs-diffs] master 255c892: C++ Mode: Correctly handle <:, <::, <::>, etc, according to the C++ standard
Date: Fri, 11 Oct 2019 15:13:08 -0400 (EDT)

branch: master
commit 255c892b486eeb507b4533141fec9218b7a67b2f
Author: Alan Mackenzie <address@hidden>
Commit: Alan Mackenzie <address@hidden>

    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.
---
 lisp/progmodes/cc-engine.el | 19 +++++++++++++++----
 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 4ca440f..9ed4fe3 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 d092094..a6fdc3e 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-<pseudp-digraph-cont-regexp' 
match.
+This doesn't count the merely contextual bits of the regexp match."
+  t 0
+  c++ 2)
+(c-lang-defvar c-<-pseudo-digraph-cont-len
+              (c-lang-const c-<-pseudo-digraph-cont-len))
+
 (c-lang-defconst c->-op-cont-tokens
   ;; A list of second and subsequent characters of all multicharacter tokens
   ;; that begin with ">".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]