branch: elpa/d-mode
commit 4dd90f38bc4ea548f35be618b2d3b85f0037f9b5
Author: Vladimir Panteleev <[email protected]>
Commit: Vladimir Panteleev <[email protected]>
Consolidate c-forward-decl-or-cast-1 "else" patch
---
d-mode.el | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 7277088..610913f 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -7,7 +7,7 @@
;; Maintainer: Russel Winder <[email protected]>
;; Vladimir Panteleev <[email protected]>
;; Created: March 2007
-;; Version: 201911081535
+;; Version: 201911081541
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -561,6 +561,18 @@ Fixes cc-mode handling of D constructors."
;;
;; This function might do hidden buffer changes.
+ ;; D: The "else" following a "version" or "static if" can start a
+ ;; declaration even without a { } block. For this reason, "else" is
+ ;; in `c-decl-start-kwds'.
+ ;; However, cc-mode invokes `c-forward-decl-or-cast-1' with point
+ ;; at the "else" keyword, which, when followed by a function call,
+ ;; is mis-parsed as a function declaration.
+ ;; Fix this by moving point forward, past the "else" keyword, to
+ ;; put cc-mode on the right track.
+ (when (looking-at (d-make-keywords-re t '("else")))
+ (goto-char (match-end 1))
+ (c-forward-syntactic-ws))
+
;; D: Work around a cc-mode bug(?) in which the c-forward-annotation
;; calls in c-forward-decl-or-cast-1 do not advance the start
;; position, causing the annotation to be fontified as the function
@@ -1548,19 +1560,6 @@ Fixes cc-mode handling of D constructors."
(looking-at "(")))
nil)
- ;; D: The "else" following a "version" or "static if" can start a
- ;; declaration even without a { } block. For this reason, "else" is
- ;; in `c-decl-start-kwds'.
- ;; However, cc-mode invokes `c-forward-decl-or-cast-1' with point
- ;; at the "else" keyword, which, when followed by a function call,
- ;; is mis-parsed as a function declaration.
- ;; Fix this by moving point forward, past the "else" keyword, to
- ;; put cc-mode on the right track.
- ((looking-at (d-make-keywords-re t '("else")))
- (goto-char (match-end 1))
- (c-forward-syntactic-ws)
- (apply #'d-forward-decl-or-cast-1 args))
-
(t
(apply #'d-forward-decl-or-cast-1 args))))