Skip to content

Commit

Permalink
Add aliases to imenu
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberShadow committed Oct 11, 2016
1 parent fda6318 commit d7f46a2
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
42 changes: 41 additions & 1 deletion d-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
;; Maintainer: Russel Winder <russel@winder.org.uk>
;; Vladimir Panteleev <vladimir@thecybershadow.net>
;; Created: March 2007
;; Version: 201610111950
;; Version: 201610111956
;; Keywords: D programming language emacs cc-mode

;;;; NB Version number is date and time yyyymmddhhMM UTC.
Expand Down Expand Up @@ -638,6 +638,46 @@ The expression is added to `compilation-error-regexp-alist' and
(zero-or-more (any " \t\n"))
(or ":" "{"))
1)
;; NB: We can't easily distinguish aliases declared outside
;; functions from local ones, so just search for those that are
;; declared at the beginning of lines.
("*Aliases*"
,(rx
line-start
"alias"
(one-or-more (syntax whitespace))
(submatch
(one-or-more
(any ?_
(?0 . ?9)
(?A . ?Z)
(?a . ?z))))
(zero-or-more (syntax whitespace))
"=")
1)
("*Aliases*"
,(rx
line-start
"alias"
(one-or-more (syntax whitespace))
(one-or-more
(not (any ";")))
(one-or-more (syntax whitespace))
(submatch
(one-or-more
(any ?_
(?0 . ?9)
(?A . ?Z)
(?a . ?z))))
(zero-or-more (syntax whitespace))
";"
(zero-or-more (syntax whitespace))
(or
eol
"//"
"/*")
)
1)
(nil d-imenu-method-index-function 2)))

;;----------------------------------------------------------------------------
Expand Down
11 changes: 10 additions & 1 deletion tests/imenu.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// #run: (d-test-get-imenu-lines)
// #out: (4 6 11 14 17 19 22 25 33 34 37 40 43 46 49)
// #out: (4 6 11 14 17 19 22 25 33 34 37 40 43 46 49 52 54 56)

void foo(int x) {}

Expand Down Expand Up @@ -48,3 +48,12 @@ private final class C

public struct S
{}

alias xmlParse = parseDocument!XmlParseConfig;

alias parseDocument!XmlParseConfig xmlParse;

void test()
{
alias foo = bar;
}

0 comments on commit d7f46a2

Please sign in to comment.