[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode f76ba89 308/346: Fontify (type-inferred) lambda arg
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode f76ba89 308/346: Fontify (type-inferred) lambda arguments |
Date: |
Sun, 29 Aug 2021 11:00:50 -0400 (EDT) |
branch: elpa/d-mode
commit f76ba8982b8b0f2120ab152907001c8df380d78e
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Fontify (type-inferred) lambda arguments
---
d-mode.el | 24 ++++++++++++++++++------
tests/fonts_lambda_params.d | 1 +
tests/fonts_lambda_params.d.html | 1 +
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 06c0c3d..cdd8d79 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: 201911112253
+;; Version: 201911112314
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -469,6 +469,13 @@ Evaluate OLD-FORM if the Emacs version is older than
MIN-VERSION,
"D version of `c-forward-decl-or-cast-1'." ;; checkdoc-params:
(preceding-token-end context last-cast-end)
;; (message "(d-forward-decl-or-cast-1 %S %S %S) @ %S" preceding-token-end
context last-cast-end (point))
+ ;; D: Restore our context, if any
+ (when (eq context 'decl)
+ (save-excursion
+ (c-backward-syntactic-ws)
+ (when (> (point) (point-min))
+ (setq context (or (c-get-char-property (1- (point)) 'd-context)
context)))))
+
;; D: Handle conditional compilation.
;; The "debug" keyword, as well as the "else" keyword following a
;; "version" or "static if", can start a declaration even without a
@@ -606,13 +613,16 @@ 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.
- ((and (eq context 'decl)
+ ((and (memq context '(decl varlist))
(d-forward-type))
(setq type-start decl-start)
(setq id-start (point))
(cond
- ;; Type only
+ ;; Type or name only
((looking-at "[,=)]")
+ (when (eq context 'varlist)
+ (setq id-start type-start)
+ (setq type-start nil))
t)
;; Parameter name
((d-forward-identifier)
@@ -627,13 +637,15 @@ Evaluate OLD-FORM if the Emacs version is older than
MIN-VERSION,
(goto-char type-start)
(d-forward-type))))
- (when (and (eq context 'decl)
+ (when (and (memq context '(decl varlist))
(eq (char-after) ?,))
;; As in c-forward-decl-or-cast-1:
;; Make sure to propagate the `c-decl-arg-start' property to
;; the next argument if it's set in this one, to cope with
;; interactive refontification.
- (c-put-c-type-property (point) 'c-decl-arg-start))
+ (c-put-c-type-property (point) 'c-decl-arg-start)
+ ;; D: Also save whether we're in a varlist.
+ (c-put-char-property (point) 'd-context context))
(when (and (memq context '(top nil))
(eq (char-after) ?\())
@@ -755,7 +767,7 @@ CONTEXT is as in `c-forward-decl-or-cast-1'."
(eq (char-after) ?\{)
(looking-at "=>"))))))
- (setq res (cons 'decl t))
+ (setq res (cons 'varlist t))
;; (message " patching -> %S" res)
)
res))
diff --git a/tests/fonts_lambda_params.d b/tests/fonts_lambda_params.d
index d127f41..bc79b40 100644
--- a/tests/fonts_lambda_params.d
+++ b/tests/fonts_lambda_params.d
@@ -2,3 +2,4 @@
// #run: (d-test-fontification)
auto dg = (Object a, Object b) {};
+alias dg2 = (a, b) {};
diff --git a/tests/fonts_lambda_params.d.html b/tests/fonts_lambda_params.d.html
index 7dc70e2..cc8e711 100644
--- a/tests/fonts_lambda_params.d.html
+++ b/tests/fonts_lambda_params.d.html
@@ -2,3 +2,4 @@
</span><span class="comment-delimiter">// </span><span class="comment">#run:
(d-test-fontification)
</span>
<span class="keyword">auto</span> <span class="variable-name">dg</span> =
(<span class="type">Object</span> <span class="variable-name">a</span>, <span
class="type">Object</span> <span class="variable-name">b</span>) {};
+<span class="keyword">alias</span> <span class="variable-name">dg2</span> =
(<span class="variable-name">a</span>, <span class="variable-name">b</span>) {};
- [nongnu] elpa/d-mode 45c60e0 286/346: Fix fontification of variable declarations with top-level types, (continued)
- [nongnu] elpa/d-mode 45c60e0 286/346: Fix fontification of variable declarations with top-level types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e9a034e 283/346: Tighten decl/arglist recognition, obsoleting another patch, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 05fc5f1 284/346: Consolidate c-forward-decl-or-cast-1 "scope" patch, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 44cf02b 287/346: tests: New testcase, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 73f4bdc 292/346: Emacs 25 compatibility, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8e77187 293/346: Fix fontification of return statements, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode cb97457 297/346: Remove another obsolete hack, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode bc725ef 296/346: Use a conditional compilation macro for version checks, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c77fc0a 307/346: Skip coverage analysis when byte-compiling, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode d9e9d06 311/346: Merge d-forward-module-clause into d-forward-keyword-clause, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f76ba89 308/346: Fontify (type-inferred) lambda arguments,
ELPA Syncer <=
- [nongnu] elpa/d-mode 34f44cf 337/346: .github/workflows/test.yml: Add Emacs 27.1, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 379b00e 144/346: Tweak intro comments a bit, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 7d3edd2 234/346: Add test from issue #94, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 968306a 224/346: Add a test case against the now-removed fontification hack, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8e208b2 232/346: Fix imenu display of functions for imenu-add-to-menubar, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b2c9831 252/346: Make imenu hierarchical, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 69df4a3 254/346: Abbreviate symbol kind in imenu entries, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 12e45cf 258/346: Fix fontification of properties with inferred return type, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 26e7337 253/346: Don't put variables in imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 372c135 274/346: Makefile: Fail on byte-compilation warnings, ELPA Syncer, 2021/08/29