From: Alan Mackenzie <acm@muc.de>
Date: Sun, 29 Jun 2014 11:26:47 +0000 (+0000)
Subject: Don't call c-parse-state when c++-template-syntax-table is active.
X-Git-Tag: emacs-25.0.90~2636^2~74^2~13
X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e3be29073e79a306ccdbdbdb8d4caf2863de760e;p=emacs.git

Don't call c-parse-state when c++-template-syntax-table is active.
* progmodes/cc-engine.el (c-guess-continued-construct CASE G)
(c-guess-basic-syntax CASE 5D.3): Rearrange so that
c-syntactic-skip-backwards isn't called with the pertinent syntax
table.
---

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5293d8dda92..5f9084f4cbb 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2014-06-29  Alan Mackenzie  <acm@muc.de>
+
+	Don't call c-parse-state when c++-template-syntax-table is active.
+	* progmodes/cc-engine.el (c-guess-continued-construct CASE G)
+	(c-guess-basic-syntax CASE 5D.3): Rearrange so that
+	c-syntactic-skip-backwards isn't called with the pertinent syntax
+	table.
+
 2014-06-28  Stephen Berman  <stephen.berman@gmx.net>
 
 	* calendar/todo-mode.el (todo-set-top-priorities): Fix logic to
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el
index 1606cfb3357..594ff053d44 100644
--- a/lisp/progmodes/cc-defs.el
+++ b/lisp/progmodes/cc-defs.el
@@ -823,6 +823,8 @@ be after it."
 (defmacro c-with-syntax-table (table &rest code)
   ;; Temporarily switches to the specified syntax table in a failsafe
   ;; way to execute code.
+  ;; Maintainers' note: If TABLE is `c++-template-syntax-table', DON'T call
+  ;; any forms inside this that call `c-parse-state'.  !!!!
   `(let ((c-with-syntax-table-orig-table (syntax-table)))
      (unwind-protect
 	 (progn
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 6b406b0d89c..7404241af9b 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -9355,16 +9355,16 @@ comment at the start of cc-engine.el for more info."
 		    (not (looking-at c-<-op-cont-regexp))))))
       (c-with-syntax-table c++-template-syntax-table
 	(goto-char placeholder)
-	(c-beginning-of-statement-1 containing-sexp t)
-	(if (save-excursion
-	      (c-backward-syntactic-ws containing-sexp)
-	      (eq (char-before) ?<))
-	    ;; In a nested template arglist.
-	    (progn
-	      (goto-char placeholder)
-	      (c-syntactic-skip-backward "^,;" containing-sexp t)
-	      (c-forward-syntactic-ws))
-	  (back-to-indentation)))
+	(c-beginning-of-statement-1 containing-sexp t))
+      (if (save-excursion
+	    (c-backward-syntactic-ws containing-sexp)
+	    (eq (char-before) ?<))
+	  ;; In a nested template arglist.
+	  (progn
+	    (goto-char placeholder)
+	    (c-syntactic-skip-backward "^,;" containing-sexp t)
+	    (c-forward-syntactic-ws))
+	(back-to-indentation))
       ;; FIXME: Should use c-add-stmt-syntax, but it's not yet
       ;; template aware.
       (c-add-syntax 'template-args-cont (point) placeholder))
@@ -10022,16 +10022,16 @@ comment at the start of cc-engine.el for more info."
 			    (eq (char-after placeholder) ?<))))))
 	    (c-with-syntax-table c++-template-syntax-table
 	      (goto-char placeholder)
-	      (c-beginning-of-statement-1 lim t)
-	      (if (save-excursion
-		    (c-backward-syntactic-ws lim)
-		    (eq (char-before) ?<))
-		  ;; In a nested template arglist.
-		  (progn
-		    (goto-char placeholder)
-		    (c-syntactic-skip-backward "^,;" lim t)
-		    (c-forward-syntactic-ws))
-		(back-to-indentation)))
+	      (c-beginning-of-statement-1 lim t))
+	    (if (save-excursion
+		  (c-backward-syntactic-ws lim)
+		  (eq (char-before) ?<))
+		;; In a nested template arglist.
+		(progn
+		  (goto-char placeholder)
+		  (c-syntactic-skip-backward "^,;" lim t)
+		  (c-forward-syntactic-ws))
+	      (back-to-indentation))
 	    ;; FIXME: Should use c-add-stmt-syntax, but it's not yet
 	    ;; template aware.
 	    (c-add-syntax 'template-args-cont (point) placeholder))
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index d2d2de8801a..ee002b7bc7b 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -394,7 +394,9 @@ The syntax tables aren't stored directly since they're quite large."
   ;; lists are parsed.  Note that this encourages incorrect parsing of
   ;; templates since they might contain normal operators that uses the
   ;; '<' and '>' characters.  Therefore this syntax table might go
-  ;; away when CC Mode handles templates correctly everywhere.
+  ;; away when CC Mode handles templates correctly everywhere.  WHILE
+  ;; THIS SYNTAX TABLE IS CURRENT, `c-parse-state' MUST _NOT_ BE
+  ;; CALLED!!!
   t   nil
   (java c++) `(lambda ()
 	 (let ((table (funcall ,(c-lang-const c-make-mode-syntax-table))))