[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode 51dcd68 251/346: Improve comprehension of D constru
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode 51dcd68 251/346: Improve comprehension of D constructors and destructors |
Date: |
Sun, 29 Aug 2021 11:00:40 -0400 (EDT) |
branch: elpa/d-mode
commit 51dcd68d215840a5b31aa8e640b1a209a6b5bfc8
Author: Vladimir Panteleev <git@thecybershadow.net>
Commit: Vladimir Panteleev <git@thecybershadow.net>
Improve comprehension of D constructors and destructors
---
d-mode.el | 29 +++++++++++++++++++----------
tests/imenu2.d | 9 +++++++--
2 files changed, 26 insertions(+), 12 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 7afc0fb..54098ff 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: 201909101234
+;; Version: 201909101903
;; Keywords: D programming language emacs cc-mode
;; Package-Requires: ((emacs "25.1"))
@@ -118,12 +118,16 @@
;; D has pointers
(c-lang-defconst c-type-decl-prefix-key
d (concat "\\("
- "[*(]"
+ "[*(~]"
"\\|"
(c-lang-const c-type-decl-prefix-key)
"\\)"
"\\([^=]\\|$\\)"))
+(c-lang-defconst c-decl-start-re
+ d "[[:alpha:]_@~]")
+ ;; d "[[:alpha:]_@]")
+
;; D has fixed arrays
(c-lang-defconst c-opt-type-suffix-key
d "\\(\\[[^]]*\\]\\|\\.\\.\\.\\|\\*\\)")
@@ -866,10 +870,11 @@ Each list item should be a regexp matching a single
identifier."
(point)))
(id-end (progn
(goto-char id-start)
- (forward-char)
- (c-end-of-current-token)
- (point)))
- (name (buffer-substring-no-properties id-start id-end))
+ (when (d-forward-name)
+ (c-backward-syntactic-ws)
+ (point))))
+ (name (when id-end
+ (buffer-substring-no-properties id-start id-end)))
(id-prev-token (progn
(goto-char id-start)
(c-backward-syntactic-ws)
@@ -883,11 +888,13 @@ Each list item should be a regexp matching a single
identifier."
(let ((end (point)))
(when (c-simple-skip-symbol-backward)
(buffer-substring-no-properties
(point) end)))))
- (next-char (progn
+ (next-char (when id-end
(goto-char id-end)
(c-forward-syntactic-ws)
(char-after)))
(kind (cond
+ ((null name)
+ nil)
((equal id-prev-token "else")
nil) ; false positive after else
((equal name "{")
@@ -960,11 +967,13 @@ Each list item should be a regexp matching a single
identifier."
(defun d-special-case-c-forward-name (orig-fun &rest args)
;; checkdoc-params: (orig-fun args)
"Advice function for fixing cc-mode handling of D constructors."
- (if (not (looking-at (c-make-keywords-re t '("this"))))
+ (if (not (looking-at (c-make-keywords-re t '("this" "~this"))))
(apply orig-fun args)
- (forward-char 4)
+ (goto-char (match-end 1))
t))
+(defsubst d-forward-name () "Shorthand." (d-special-case-c-forward-name
#'c-forward-name))
+
(defun d-around--c-forward-decl-or-cast-1 (orig-fun &rest args)
;; checkdoc-params: (orig-fun args)
"Advice function for fixing cc-mode handling of D constructors."
@@ -1143,7 +1152,7 @@ Key bindings:
;; Check for a normal (non-keyword) identifier.
(and (looking-at c-symbol-start)
(or
- (looking-at (c-make-keywords-re t '("this")))
+ (looking-at (c-make-keywords-re t '("this" "~this")))
(not (looking-at c-keywords-regexp)))
(point)))))
diff --git a/tests/imenu2.d b/tests/imenu2.d
index cc443d8..3ef28b2 100644
--- a/tests/imenu2.d
+++ b/tests/imenu2.d
@@ -1,6 +1,6 @@
// #min-version: 26.1
// #run: (d-test-get-imenu-lines)
-// #out: (5 6 8 13 18 20 24 28 33 37 40 42 46)
+// #out: (5 6 8 13 18 20 24 28 33 37 40 42 46 49 50 51 52)
void run(Parameter!("foo()") command) {}
Parameter!("foo()") run(string command) {}
@@ -37,7 +37,7 @@ else
int gun();
}
-struct S
+class S
{
int fun();
@@ -45,4 +45,9 @@ struct S
{
int gun();
}
+
+ this() {}
+ ~this() {}
+ static this() {}
+ static ~this() {}
}
- [nongnu] elpa/d-mode e70d89f 312/346: Fix fontification of catch statements, (continued)
- [nongnu] elpa/d-mode e70d89f 312/346: Fix fontification of catch statements, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2f7adb1 319/346: Fontify sole lambda params, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode b40a7ab 328/346: Unbundle undercover.el, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a9c05fd 331/346: tests/I0102: Remove #min-version, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 32446a7 338/346: Merge pull request #107 from CyberShadow/github-actions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c3be102 344/346: Cask: Fetch undercover.el directly from git, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 7fdd7b2 343/346: .github/workflows/test.yml: Add final step to call the Coveralls webhook, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 505022e 341/346: tests: New testcase, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 199743d 346/346: tests/I0021: Update condition, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 66796d0 247/346: Rename gplv2.txt -> COPYING, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 51dcd68 251/346: Improve comprehension of D constructors and destructors,
ELPA Syncer <=
- [nongnu] elpa/d-mode f4b3d8a 267/346: Precompute regular expressions for inline keyword lists, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 809586a 266/346: Reorganize code, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 4851fc2 270/346: Fix fontification of "enum" in string literals, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 49cb5a8 275/346: Consolidate c-forward-decl-or-cast-1 annotation patch, ELPA Syncer, 2021/08/29
- [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