[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/d-mode 72d2022 026/346: improve d-mode imenu method name i
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/d-mode 72d2022 026/346: improve d-mode imenu method name indexing |
Date: |
Sun, 29 Aug 2021 10:59:58 -0400 (EDT) |
branch: elpa/d-mode
commit 72d2022b606c1ce72bc3e09ecd0679fa057d9496
Author: finalpatch <fengli@gmail.com>
Commit: finalpatch <fengli@gmail.com>
improve d-mode imenu method name indexing
---
d-mode.el | 45 +++++++++++++++++++++++++++++++++++----------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/d-mode.el b/d-mode.el
index d8a8cd1..dba2dde 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -369,21 +369,46 @@ operators."
(easy-menu-define d-menu d-mode-map "D Mode Commands"
(cons "D" (c-lang-const c-mode-menu d)))
+(defconst d-imenu-method-name-pattern
+ (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]*\\(?:if\\|{\\)\\)")) ; ';' or 'if' or '{'
+
+(defun d-imenu-method-index-function ()
+ (and
+ (let ((pt))
+ (setq pt (re-search-backward d-imenu-method-name-pattern nil t))
+ ;; The method name regexp will match lines like
+ ;; "return foo(x);" or "static if(x) {"
+ ;; so we exclude type name 'static' or 'return' here
+ (while (let ((type (match-string 1)))
+ (and type
+ (or (string= type "static")
+ (string= type "return"))))
+ (setq pt (re-search-backward d-imenu-method-name-pattern nil t)))
+ pt)
+ ;; Do not count invisible definitions.
+ (let ((invis (invisible-p (point))))
+ (or (not invis)
+ (progn
+ (while (and invis
+ (not (bobp)))
+ (setq invis (not (re-search-backward
+ d-imenu-method-name-pattern nil 'move))))
+ (not invis))))))
+
(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 {
+ (nil d-imenu-method-index-function 2)))
;;----------------------------------------------------------------------------
;;;###autoload (add-to-list 'auto-mode-alist '("\\.d[i]?\\'" . d-mode))
- [nongnu] elpa/d-mode f0947a2 005/346: Merge /tmp/russel/Emacs-D-Mode, (continued)
- [nongnu] elpa/d-mode f0947a2 005/346: Merge /tmp/russel/Emacs-D-Mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c68bc67 001/346: The Epoch., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 8b467a3 006/346: Extend the README.md a little., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode f6d79da 009/346: Update the version number psot release., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e15f60d 016/346: Merge branch 'master' of https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode 5ccf545 007/346: Added keywords, improved indentation of 'template'., ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode e0dac81 010/346: changed d-mode to a proper derived mode, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode a587c35 014/346: Merge pull request #3 from roysc/patch-derive, ELPA Syncer, 2021/08/29
- [nongnu] elpa/d-mode c4a8921 018/346: Added '^^=' to assignement operators, ELPA Syncer, 2021/08/29
- [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 <=
- [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, 2021/08/29
- [nongnu] elpa/d-mode ac3c6db 029/346: allow * in typenames, ELPA Syncer, 2021/08/29