[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode f07f365 201/346: Fix fontification of constructor p
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode f07f365 201/346: Fix fontification of constructor parameters |
Date: |
Sun, 29 Aug 2021 11:00:31 -0400 (EDT) |
branch: elpa/d-mode
commit f07f365906340c4b1eeeade04ce48d095989c8c2
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Fix fontification of constructor parameters
Fixes issue #82.
---
d-mode-test.el | 1 +
d-mode.el | 31 ++++++++++++++++++++++++++++++-
tests/I0082.d | 8 ++++++++
tests/I0082.d.html | 8 ++++++++
4 files changed, 47 insertions(+), 1 deletion(-)
diff --git a/d-mode-test.el b/d-mode-test.el
index 50f206c..3c74f3f 100644
--- a/d-mode-test.el
+++ b/d-mode-test.el
@@ -318,6 +318,7 @@ is expected to succeed, and nil otherwise."
(d-test-deftest i0069 "tests/I0069.txt" t)
(d-test-deftest i0070 "tests/I0070.d" (version< "24.4" emacs-version))
(d-test-deftest i0072 "tests/I0072.txt" t)
+(d-test-deftest i0082 "tests/I0082.d" (version< "24.4" emacs-version))
(d-test-deftest i0090 "tests/I0090.d" t)
;;----------------------------------------------------------------------------
diff --git a/d-mode.el b/d-mode.el
index affa862..e8baef1 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: 201908300712
+;; Version: 201909051329
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "24.3"))
@@ -833,6 +833,35 @@ Each list item should be a regexp matching a single
identifier."
(advice-add 'c-forward-decl-or-cast-1 :around
#'d-around--c-forward-decl-or-cast-1))
;;----------------------------------------------------------------------------
+;;; Fixes fontification of constructor parameter lists in D code.
+
+(defun d-special-case-looking-at-2 (orig-fun regexp)
+ ;; checkdoc-params: (orig-fun regexp)
+ "Advice function for fixing cc-mode handling of D constructors."
+ (if (and
+ (eq regexp c-not-decl-init-keywords)
+ (apply orig-fun (c-make-keywords-re t '("this")) nil)) ; looking-at
"this"
+ nil
+ (apply orig-fun regexp nil)))
+
+(defun d-around--c-font-lock-declarations (orig-fun &rest args)
+ ;; checkdoc-params: (orig-fun args)
+ "Advice function for fixing cc-mode handling of D constructors."
+ (if (not (c-major-mode-is 'd-mode))
+ (apply orig-fun args)
+ (progn
+ (add-function :around (symbol-function 'looking-at)
+ #'d-special-case-looking-at-2)
+ (unwind-protect
+ (apply orig-fun args)
+ (remove-function (symbol-function 'looking-at)
+ #'d-special-case-looking-at-2)
+ ))))
+
+(when (version<= "24.4" emacs-version)
+ (advice-add 'c-font-lock-declarations :around
#'d-around--c-font-lock-declarations))
+
+;;----------------------------------------------------------------------------
;; Borrowed from
https://github.com/josteink/csharp-mode/blob/master/csharp-mode.el
(defun d--syntax-propertize-function (beg end)
"Apply syntax table properties to special constructs in region BEG to END.
diff --git a/tests/I0082.d b/tests/I0082.d
new file mode 100644
index 0000000..820a1d6
--- /dev/null
+++ b/tests/I0082.d
@@ -0,0 +1,8 @@
+// #run: (d-test-fontification)
+
+struct S
+{
+ this(Object o) {}
+ this(Object* o) {}
+ this(Object * o) {}
+}
diff --git a/tests/I0082.d.html b/tests/I0082.d.html
new file mode 100644
index 0000000..eb75859
--- /dev/null
+++ b/tests/I0082.d.html
@@ -0,0 +1,8 @@
+<span class="comment-delimiter">// </span><span class="comment">#run:
(d-test-fontification)
+</span>
+<span class="keyword">struct</span> <span class="type">S</span>
+{
+ <span class="keyword">this</span>(<span class="type">Object</span>
<span class="variable-name">o</span>) {}
+ <span class="keyword">this</span>(<span class="type">Object</span>*
<span class="variable-name">o</span>) {}
+ <span class="keyword">this</span>(<span class="type">Object</span> *
<span class="variable-name">o</span>) {}
+}
- [nongnu] elpa/d-mode af6dbfa 183/346: Generalize StorageClass/VisibilityAttribute parsing in imenu, (continued)
- [nongnu] elpa/d-mode af6dbfa 183/346: Generalize StorageClass/VisibilityAttribute parsing in imenu, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2964263 184/346: Fix imenu with alias templates, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 71e8bda 196/346: Improve constructor handling and fix constructor contract indentation, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 28810ef 194/346: Add test for function contracts, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 1bce6c4 191/346: Somewhat improve fontification of module names, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b413942 198/346: Tighten K&R region detection, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 07cb4d0 199/346: Add d-lineup-arglists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode d3ceb14 200/346: Make d--imenu-rx-def-start a compile-time constant, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 0b6a089 217/346: .travis.yml: Try using a emacs-travis.mk which does not use FTP, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 653661e 220/346: Fix parsing qualified types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f07f365 201/346: Fix fontification of constructor parameters,
ELPA Syncer <=
- [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, 2021/08/29