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

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

[nongnu] elpa/d-mode 55c8cb0 306/346: Fontify types in function paramete


From: ELPA Syncer
Subject: [nongnu] elpa/d-mode 55c8cb0 306/346: Fontify types in function parameter lists
Date: Sun, 29 Aug 2021 11:00:50 -0400 (EDT)

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

    Fontify types in function parameter lists
    
    Now that we have a sufficiently correct understanding of D syntax, we
    can use it to fontify more things. In this case, single items in a
    'decl context should always mean types (whether they occur in the
    compile-time or run-time parameter list).
---
 d-mode.el                    | 15 +++++++++------
 tests/I0093_546738540.d.html |  2 +-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/d-mode.el b/d-mode.el
index 2da456c..06c0c3d 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:  201911112251
+;; Version:  201911112253
 ;; Keywords:  D programming language emacs cc-mode
 ;; Package-Requires: ((emacs "25.1"))
 
@@ -606,15 +606,18 @@ Evaluate OLD-FORM if the Emacs version is older than 
MIN-VERSION,
         ;; lists.  For functions, they indicate the type of an
         ;; anonymous parameter; for lambdas, they indicate the name
         ;; of a parameter with an inferred type.
-        ;; Currently we don't fontify them as either.
         ((and (eq context 'decl)
               (d-forward-type))
          (setq type-start decl-start)
          (setq id-start (point))
-         (and (d-forward-identifier)   ; parameter name
-                (progn
-                  (c-forward-syntactic-ws)
-                  (looking-at "[,=)]")))))
+         (cond
+          ;; Type only
+          ((looking-at "[,=)]")
+           t)
+          ;; Parameter name
+          ((d-forward-identifier)
+           (c-forward-syntactic-ws)
+           (looking-at "[,=)]")))))
 
       ;; Valid declaration, process it.
 
diff --git a/tests/I0093_546738540.d.html b/tests/I0093_546738540.d.html
index 79dba61..7f39ecb 100644
--- a/tests/I0093_546738540.d.html
+++ b/tests/I0093_546738540.d.html
@@ -1,5 +1,5 @@
 <span class="comment-delimiter">// </span><span class="comment">#run: 
(d-test-fontification)
 </span>
-<span class="type">void</span> <span class="function-name">f</span>(T)(<span 
class="keyword">scope return</span> <span class="type">T</span> <span 
class="variable-name">x</span>)
+<span class="type">void</span> <span class="function-name">f</span>(<span 
class="type">T</span>)(<span class="keyword">scope return</span> <span 
class="type">T</span> <span class="variable-name">x</span>)
 {
 }



reply via email to

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