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

[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() {}
 }



reply via email to

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