[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode 1e5c7c3 227/346: Fix parsing of declarations follow
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode 1e5c7c3 227/346: Fix parsing of declarations following protection group |
Date: |
Sun, 29 Aug 2021 11:00:36 -0400 (EDT) |
branch: elpa/d-mode
commit 1e5c7c3510b19338eca3201c8e5f38805322df1e
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Fix parsing of declarations following protection group
Apparently, all that was missing was defining c-post-protection-token?
Replaces the last "hideous hack".
---
d-mode.el | 44 ++++---------------------------------------
tests/fonts_protection.d | 9 +++++++++
tests/fonts_protection.d.html | 9 +++++++++
3 files changed, 22 insertions(+), 40 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index f2d4826..c2f5aae 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: 201909091656
+;; Version: 201909091759
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -180,6 +180,9 @@ operators."
d (cl-set-difference (c-lang-const c-block-prefix-disallowed-chars)
'(?:)))
+(c-lang-defconst c-post-protection-token
+ d ":")
+
(defconst doxygen-font-lock-doc-comments
(let ((symbol "[a-zA-Z0-9_]+")
(header "^ \\* "))
@@ -1014,45 +1017,6 @@ Key bindings:
(cc-imenu-init d-imenu-generic-expression))
;;----------------------------------------------------------------------------
-;; "Hideous hacks" to support appropriate font-lock behaviour.
-;;
-;; * public/protected/private appear both in c-modifier-kwds and in
-;; c-protection-kwds. This causes cc-mode to fail parsing the first
-;; declaration after an access level label (because cc-mode trys to
-;; parse them as modifier but will fail due to the colon). But
-;; unfortunately we cannot remove them from either c-modifier-kwds
-;; or c-protection-kwds. Removing them from the former causes valid
-;; syntax like "private int foo() {}" to fail. Removing them from
-;; the latter cause indentation of the access level labels to
-;; fail. The solution used here is to use font-lock-add-keywords to
-;; add back the syntax highlight.
-
-(defconst d-var-decl-pattern "^[ \t]*\\(?:[_a-zA-Z0-9]+[
\t\n]+\\)*\\([_a-zA-Z0-9.!]+\\)\\(?:\\[[^]]*\\]\\|\\*\\)?[
\t\n]+\\([_a-zA-Z0-9]+\\)[ \t\n]*[;=]")
-(defconst d-fun-decl-pattern "^[ \t]*\\(?:[_a-zA-Z0-9]+[
\t\n]+\\)*\\([_a-zA-Z0-9.!]+\\)\\(?:\\[[^]]*\\]\\|\\*\\)?[
\t\n]+\\([_a-zA-Z0-9]+\\)[ \t\n]*(")
-(defmacro d-try-match-decl (regex)
- "Helper macro." ;; checkdoc-params: regex
- `(let ((pt))
- (setq pt (re-search-forward ,regex limit t))
- (while (let ((type (match-string 1)))
- (and pt type
- (save-match-data
- (string-match (c-lang-const c-regular-keywords-regexp)
type))))
- (setq pt (re-search-forward ,regex limit t)))
- pt))
-(defun d-match-var-decl (limit)
- "Helper function." ;; checkdoc-params: limit
- (d-try-match-decl d-var-decl-pattern))
-(defun d-match-fun-decl (limit)
- "Helper function." ;; checkdoc-params: limit
- (d-try-match-decl d-fun-decl-pattern))
-
-(font-lock-add-keywords
- 'd-mode
- '((d-match-var-decl (1 font-lock-type-face) (2 font-lock-variable-name-face))
- (d-match-fun-decl (1 font-lock-type-face) (2 font-lock-function-name-face)))
- t)
-
-;;----------------------------------------------------------------------------
(defun d--on-func-identifier ()
"Version of `c-on-identifier', but also match D constructors."
diff --git a/tests/fonts_protection.d b/tests/fonts_protection.d
new file mode 100644
index 0000000..7a3e237
--- /dev/null
+++ b/tests/fonts_protection.d
@@ -0,0 +1,9 @@
+// #min-version: 26.1
+// #run: (d-test-fontification)
+
+class C
+{
+ Type var1, var2;
+public:
+ Type var3, var4;
+}
diff --git a/tests/fonts_protection.d.html b/tests/fonts_protection.d.html
new file mode 100644
index 0000000..1908b70
--- /dev/null
+++ b/tests/fonts_protection.d.html
@@ -0,0 +1,9 @@
+<span class="comment-delimiter">// </span><span class="comment">#min-version:
26.1
+</span><span class="comment-delimiter">// </span><span class="comment">#run:
(d-test-fontification)
+</span>
+<span class="keyword">class</span> <span class="type">C</span>
+{
+ <span class="type">Type</span> <span class="variable-name">var1</span>,
<span class="variable-name">var2</span>;
+<span class="keyword">public</span>:
+ <span class="type">Type</span> <span class="variable-name">var3</span>,
<span class="variable-name">var4</span>;
+}
- [nongnu] elpa/d-mode 8647147 208/346: Fix tests' minimum Emacs versions, (continued)
- [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, 2021/08/29
- [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 <=
- [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
- [nongnu] elpa/d-mode ed4428c 272/346: Fix fontification of "invariant", ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 300708d 268/346: Fix imenu for template members, ELPA Syncer, 2021/08/29