[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode 6a19457 244/346: Fix function calls being mis-parse
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode 6a19457 244/346: Fix function calls being mis-parsed as declarations after static else |
Date: |
Sun, 29 Aug 2021 11:00:39 -0400 (EDT) |
branch: elpa/d-mode
commit 6a19457dba7e8fd7a4da6ac8ee646703ca656ae3
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Fix function calls being mis-parsed as declarations after static else
---
d-mode.el | 21 ++++++++++++++++++---
tests/fonts.d | 3 +++
tests/fonts.d.html | 3 +++
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index c8419a8..d6756df 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -7,7 +7,7 @@
;; Maintainer: Russel Winder <russel@winder.org.uk>
;; Vladimir Panteleev <vladimir@thecybershadow.net>
;; Created: March 2007
-;; Version: 201909092149
+;; Version: 201909092218
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -428,8 +428,10 @@ The expression is added to
`compilation-error-regexp-alist' and
d nil)
(c-lang-defconst c-other-decl-kwds
- d (append (list "else")
- (c-lang-const d-storage-class-kwds)))
+ d (c-lang-const d-storage-class-kwds))
+
+(c-lang-defconst c-decl-start-kwds
+ d '("else"))
(c-lang-defconst c-other-kwds
;; Keywords not accounted for by any other `*-kwds' language constant.
@@ -688,6 +690,19 @@ Each list item should be a regexp matching a single
identifier."
(looking-at (c-make-keywords-re t '("in"))))))
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 (c-make-keywords-re t '("else")))
+ (goto-char (match-end 1))
+ (c-forward-syntactic-ws)
+ (apply orig-fun args))
+
(t
(add-function :around (symbol-function 'c-forward-name)
#'d-special-case-c-forward-name)
diff --git a/tests/fonts.d b/tests/fonts.d
index faaecff..7cb6789 100644
--- a/tests/fonts.d
+++ b/tests/fonts.d
@@ -13,3 +13,6 @@ void main()
}
version(none) string readLink();
+
+static if (true) {} else fun();
+static if (true) {} else void fun();
diff --git a/tests/fonts.d.html b/tests/fonts.d.html
index 214d0e3..ff8b85d 100644
--- a/tests/fonts.d.html
+++ b/tests/fonts.d.html
@@ -13,3 +13,6 @@
}
<span class="keyword">version</span>(none) <span class="type">string</span>
<span class="function-name">readLink</span>();
+
+<span class="keyword">static if</span> (<span class="constant">true</span>) {}
<span class="keyword">else</span> fun();
+<span class="keyword">static if</span> (<span class="constant">true</span>) {}
<span class="keyword">else</span> <span class="type">void</span> <span
class="function-name">fun</span>();
- [nongnu] elpa/d-mode f07f365 201/346: Fix fontification of constructor parameters, (continued)
- [nongnu] elpa/d-mode f07f365 201/346: Fix fontification of constructor parameters, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode fd8e70a 209/346: Partially implement D type modifiers (const/immutable/etc.), ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8647147 208/346: Fix tests' minimum Emacs versions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 9ad04a1 213/346: Fix parsing/fontification of some expressions with periods, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 5146f2d 215/346: Clear some cc-mode constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3f669a1 231/346: Replace regex-based imenu implementation with cc-mode-based, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode db2c33f 225/346: Fix parsing of D lambda literals' parameter lists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 1598b12 248/346: Switch to GPL v3 (or later), ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 24fffad 242/346: Fix parsing of declarations after "static else", ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a8aad35 241/346: Fix imenu false positive with "static if", ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 6a19457 244/346: Fix function calls being mis-parsed as declarations after static else,
ELPA Syncer <=
- [nongnu] elpa/d-mode 3077252 238/346: Correctness fix in d-forward-type, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 1e5c7c3 227/346: Fix parsing of declarations following protection group, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f8c37b9 260/346: Implement parsing module names in import and module declarations, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3c7db4a 255/346: Fix imenu context with multiple nesting, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3ed3b7b 257/346: Simplify imenu testing code, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f1d37dd 263/346: Fix byte-compiled version, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 060d1f3 249/346: Fix parsing of version(...) and other non-scope blocks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2529eb2 259/346: Add a TODO, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8d30f6b 246/346: Add back the old imenu implementation for Emacs 25, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 7d39bdf 269/346: Add missing "package" keyword to c-modifier-kwds, ELPA Syncer, 2021/08/29