[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode f6228c7 025/346: * Add pointer type support
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode f6228c7 025/346: * Add pointer type support |
Date: |
Sun, 29 Aug 2021 10:59:58 -0400 (EDT) |
branch: elpa/d-mode
commit f6228c7f67f96b848284051a0a46db106160d814
Author: finalpatch <fengli@gmail.com>
Commit: finalpatch <fengli@gmail.com>
* Add pointer type support
* Fix auto/immutable variable face
* Move 'template' to c-class-decl-kwds
* Add imenu support
* Fix fontification of the first declariation after a protection level lable
---
d-mode.el | 54 +++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 45 insertions(+), 9 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index 66e61b4..d8a8cd1 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -77,6 +77,15 @@
;; constants are evaluated then.
(c-add-language 'd-mode 'java-mode))
+;; 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-identifier-ops
;; For recognizing "~this", ".foo", and "foo.bar.baz" as identifiers
d '((prefix "~")(prefix ".")(left-assoc ".")))
@@ -145,22 +154,22 @@ operators."
;; Keywords that can prefix normal declarations of identifiers
(c-lang-defconst c-modifier-kwds
- d '("__gshared" "auto" "abstract" "const" "deprecated" "extern"
- "final" "immutable" "inout" "lazy" "mixin" "override" "private"
- "protected" "public" "scope" "shared" "static" "synchronized"
- "volatile" "__vector"))
+ d '("__gshared" "abstract" "const" "deprecated" "extern"
+ "final" "in" "out" "inout" "lazy" "mixin" "override" "private"
+ "protected" "public" "ref" "scope" "shared" "static" "synchronized"
+ "volatile"))
(c-lang-defconst c-class-decl-kwds
;; Keywords introducing declarations where the following block (if any)
;; contains another declaration level that should be considered a class.
- d '("class" "struct" "union" "interface"))
+ d '("class" "struct" "union" "interface" "template"))
;; (c-lang-defconst c-brace-list-decl-kwds
;; d '("enum"))
(c-lang-defconst c-type-modifier-kwds
- d '("__gshared" "const" "immutable" "inout" "lazy" "shared" "volatile"
- "invariant" "enum" "__vector"))
+ d '("__gshared" "const" "inout" "lazy" "shared" "volatile"
+ "invariant" "enum"))
(c-lang-defconst c-type-prefix-kwds
;; Keywords where the following name - if any - is a type name, and
@@ -275,7 +284,7 @@ operators."
(c-lang-defconst c-other-kwds
;; Keywords not accounted for by any other `*-kwds' language constant.
d '("__gshared" "__traits" "assert" "cast" "is" "nothrow" "pure" "ref"
- "sizeof" "template" "typeid" "typeof"))
+ "sizeof" "typeid" "typeof"))
(defcustom d-font-lock-extra-types nil
@@ -360,6 +369,22 @@ operators."
(easy-menu-define d-menu d-mode-map "D Mode Commands"
(cons "D" (c-lang-const c-mode-menu d)))
+(defvar d-imenu-generic-expression
+ `(("*Classes*" "^\\s-*\\<class\\s-+\\([a-zA-Z0-9_]+\\)" 1)
+ ("*Interfaces*" "^\\s-*\\<interface\\s-+\\([a-zA-Z0-9_]+\\)" 1)
+ ("*Structs*" "^\\s-*\\<struct\\s-+\\([a-zA-Z0-9_]+\\)" 1)
+ ("*Templates*"
"^\\s-*\\(?:mixin\\s-+\\)?\\<template\\s-+\\([a-zA-Z0-9_]+\\)" 1)
+ (nil
+ ,(concat
+ "^\\s-*"
+ "\\(?:[_a-z@]+\\s-+\\)*" ; qualifiers
+ "\\(?:[][_a-zA-Z0-9.!]+\\)\\s-+" ; type
+ "\\([_a-zA-Z0-9]+\\)\\s-*" ; function name
+ "\\(?:([^)]*)\\s-*\\)?" ; type arguments
+ "([^)]*)\\s-*" ; arguments
+ "\\(?:[a-z]+\\s-*\\)?" ; pure/const etc.
+ "\\(?:;\\|[ \t\n]*{\\)") 1))) ; ; or {
+
;;----------------------------------------------------------------------------
;;;###autoload (add-to-list 'auto-mode-alist '("\\.d[i]?\\'" . d-mode))
@@ -385,7 +410,18 @@ Key bindings:
(c-common-init 'd-mode)
(easy-menu-add d-menu)
(c-run-mode-hooks 'c-mode-common-hook 'd-mode-hook)
- (c-update-modeline))
+ (c-update-modeline)
+ (setq imenu-generic-expression d-imenu-generic-expression))
+
+(font-lock-add-keywords
+ 'd-mode
+ '(("\\<\\(auto\\|immutable\\)\\>" 1 font-lock-keyword-face)
+ ("^[ \t]*\\(?:[_a-zA-Z0-9]+[ \t\n]+\\)*\\([_a-zA-Z0-9]+\\)[
\t\n]+\\([_a-zA-Z0-9]+\\)[ \t\n]*;"
+ (1 font-lock-type-face)
+ (2 font-lock-variable-name-face))
+ ("^[ \t]*\\(?:[_a-zA-Z0-9]+[ \t\n]+\\)*\\([_a-zA-Z0-9]+\\)[
\t\n]+\\([_a-zA-Z0-9]+\\)[ \t\n]*("
+ (1 font-lock-type-face)
+ (2 font-lock-function-name-face))))
(provide 'd-mode)
- [nongnu] elpa/d-mode 0268bde 022/346: Added __vector as a keyword in the same categories at const and shared., (continued)
- [nongnu] elpa/d-mode 0268bde 022/346: Added __vector as a keyword in the same categories at const and shared., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 72d2022 026/346: improve d-mode imenu method name indexing, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 9a17cb1 036/346: Add more D attributes to c-protection-kwds. Handle initializers in c-protection-kwds workaround., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a1dccad 017/346: Added override to c-modifier-kwds. Changed functionp to fboundp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode d2a3306 011/346: remove commented lines, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 68ee0fe 012/346: Parent mode is conditional for compatibility, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 685f825 013/346: Parent mode is conditional for compatibility, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 5a2577f 019/346: Merge pull request #4 from roysc/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 47c29cb 021/346: Merge pull request #5 from roysc/master, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e9fb18b 024/346: Bump version number post release., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f6228c7 025/346: * Add pointer type support,
ELPA Syncer <=
- [nongnu] elpa/d-mode ac3c6db 029/346: allow * in typenames, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 4214c49 031/346: fix a bug that incorrectly fontifies struct/class keywords (when the type has type arguments) in type face., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode adae36d 028/346: allow !.[] in typenames, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode ca12483 039/346: fix auto/immutable in comments, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 473fa33 040/346: Revert the 'Emergency Emacs 23 fixes', ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 9651a31 042/346: Remove warning regarding missing group., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 3c9f78b 046/346: wording: `init file' rather than `.emacs', ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode fce658e 047/346: let minor-mode automatically set syntax table, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 2d6f15d 049/346: Update the date of the file to better represent reality., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 9482533 008/346: Declare the 2.0.5 release., ELPA Syncer, 2021/08/29