emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/d-mode 0b8ed61 152/346: Fix highlighting of const variable


From: ELPA Syncer
Subject: [nongnu] elpa/d-mode 0b8ed61 152/346: Fix highlighting of const variable declarations
Date: Sun, 29 Aug 2021 11:00:20 -0400 (EDT)

branch: elpa/d-mode
commit 0b8ed61236f3d6f56c0b63b44d31336a1071518e
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>

    Fix highlighting of const variable declarations
    
    Move the "const" keyword to the same mechanism used for "auto" and
    "immutable".
    
    Fixes #30.
---
 d-mode-test.el     |  1 +
 d-mode.el          | 12 ++++++------
 tests/I0030.d      | 12 ++++++++++++
 tests/I0030.d.html | 12 ++++++++++++
 4 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/d-mode-test.el b/d-mode-test.el
index 56b4f04..1026016 100644
--- a/d-mode-test.el
+++ b/d-mode-test.el
@@ -296,6 +296,7 @@ is expected to succeed, and nil otherwise."
 (d-test-deftest fonts "tests/fonts.d" t)
 (d-test-deftest i0021 "tests/I0021.d" t)
 (d-test-deftest i0026 "tests/I0026.d" t)
+(d-test-deftest i0030 "tests/I0030.d" t)
 (d-test-deftest i0035 "tests/I0035.d" (version< "24.4" emacs-version))
 (d-test-deftest i0039 "tests/I0039.d" (version< "24.4" emacs-version))
 (d-test-deftest i0064 "tests/I0064.d" t)
diff --git a/d-mode.el b/d-mode.el
index 9724631..a231662 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:  201610111435
+;; Version:  201610111813
 ;; Keywords:  D programming language emacs cc-mode
 
 ;;;; NB Version number is date and time yyyymmddhhMM UTC.
@@ -245,7 +245,7 @@ The expression is added to `compilation-error-regexp-alist' 
and
 
 ;; Keywords that can prefix normal declarations of identifiers
 (c-lang-defconst c-modifier-kwds
-  d '("__gshared" "abstract" "const" "deprecated" "extern"
+  d '("__gshared" "abstract" "deprecated" "extern"
       "final" "in" "out" "inout" "lazy" "mixin" "override" "private"
       "protected" "public" "ref" "scope" "shared" "static" "synchronized"
       "volatile" "__vector"))
@@ -259,7 +259,7 @@ The expression is added to `compilation-error-regexp-alist' 
and
 ;;   d '("enum"))
 
 (c-lang-defconst c-type-modifier-kwds
-  d '("__gshared" "const" "inout" "lazy" "shared" "volatile"
+  d '("__gshared" "inout" "lazy" "shared" "volatile"
       "invariant" "enum" "__vector"))
 
 (c-lang-defconst c-type-prefix-kwds
@@ -288,7 +288,7 @@ The expression is added to `compilation-error-regexp-alist' 
and
 (c-lang-defconst c-protection-kwds
   ;; Access protection label keywords in classes.
   d '("deprecated" "static" "extern" "final" "synchronized" "override"
-      "abstract" "scope" "const" "inout" "shared" "__gshared"
+      "abstract" "scope" "inout" "shared" "__gshared"
       "private" "package" "protected" "public" "export"))
 
 ;;(c-lang-defconst c-postfix-decl-spec-kwds
@@ -624,7 +624,7 @@ Key bindings:
 ;;----------------------------------------------------------------------------
 ;; "Hideous hacks" to support appropriate font-lock behaviour.
 ;;
-;; * auto/immutable: If we leave them in c-modifier-kwds (like
+;; * auto/const/immutable: If we leave them in c-modifier-kwds (like
 ;;   c++-mode) then in the form "auto var;" var will be highlighted in
 ;;   type name face. Moving auto/immutable to font-lock-add-keywords
 ;;   lets cc-mode seeing them as a type name, so the next symbol can
@@ -657,7 +657,7 @@ Key bindings:
 (defun d-match-fun-decl (limit)
   (d-try-match-decl d-fun-decl-pattern))
 (defun d-match-auto (limit)
-  (c-syntactic-re-search-forward "\\<\\(auto\\|immutable\\)\\>" limit t))
+  (c-syntactic-re-search-forward "\\<\\(auto\\|const\\|immutable\\)\\>" limit 
t))
 
 (font-lock-add-keywords
  'd-mode
diff --git a/tests/I0030.d b/tests/I0030.d
new file mode 100644
index 0000000..e269971
--- /dev/null
+++ b/tests/I0030.d
@@ -0,0 +1,12 @@
+// #run: (d-test-fontification)
+
+const class C
+{
+       int getFoo() const { return 42; }
+
+       const void bar()
+       {
+               auto foo = getFoo();
+               const baz = getFoo();
+       }
+}
diff --git a/tests/I0030.d.html b/tests/I0030.d.html
new file mode 100644
index 0000000..463753e
--- /dev/null
+++ b/tests/I0030.d.html
@@ -0,0 +1,12 @@
+<span class="comment-delimiter">// </span><span class="comment">#run: 
(d-test-fontification)
+</span>
+<span class="keyword">const class</span> C
+{
+       <span class="type">int</span> <span 
class="function-name">getFoo</span>() <span class="keyword">const</span> { 
<span class="keyword">return</span> 42; }
+
+       <span class="keyword">const</span> <span class="type">void</span> <span 
class="function-name">bar</span>()
+       {
+               <span class="keyword">auto</span> <span 
class="variable-name">foo</span> = getFoo();
+               <span class="keyword">const</span> <span 
class="variable-name">baz</span> = getFoo();
+       }
+}



reply via email to

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