-
Notifications
You must be signed in to change notification settings - Fork 0
/
ada-imenu.el
77 lines (66 loc) · 2.82 KB
/
ada-imenu.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
;;; ada-imenu.el - Ada mode interface to imenu for Ada Mode -*- lexical-binding:t -*-
;; Copyright (C) 2012, 2013, 2015, 2019 Free Software Foundation, Inc.
;;
;; Author: Simon Wright <simon@pushface.org>
;; Contributors: see ada-mode.el, and specifically Christian Egli
;; <Christian.Egli@hcsd.hac.com> for ada-imenu-generic-expression
;;
;; This file is part of GNU Emacs.
;;
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;
;;; History: see ada_mode.el
;;
(require 'ada-core)
(require 'imenu)
(defconst ada--imenu-comment-re "\\([ \t]*--.*\\)?")
(defconst ada--imenu-subprogram-menu-re
(concat "^[ \t]*\\(overriding[ \t]*\\)?\\(procedure\\|function\\)[ \t\n]+"
"\\(\\(\\sw\\|_\\)+\\)[ \t\n]*\\([ \t\n]\\|([^)]+)"
ada--imenu-comment-re
"\\)[ \t\n]*"
"\\(return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?is[ \t\n]"))
(defvar ada--imenu-generic-expression
(list
(list nil ada--imenu-subprogram-menu-re 3)
(list "*Specs*"
(concat
"^[ \t]*\\(procedure\\|function\\)[ \t\n]+\\(\\(\\sw\\|_\\)+\\)"
"\\("
"\\(" ada--imenu-comment-re "[ \t\n]+\\|[ \t\n]*([^)]+)"
ada--imenu-comment-re "\\)";; parameter list or simple space
"\\([ \t\n]*return[ \t\n]+\\(\\sw\\|[_.]\\)+[ \t\n]*\\)?"
"\\)?;") 2)
'("*Tasks*" "^[ \t]*task[ \t]+\\(type[ \t]+\\)?\\(\\(body[ \t]+\\)?\\(\\sw\\|_\\)+\\)" 2)
'("*Type Defs*" "^[ \t]*\\(sub\\)?type[ \t]+\\(\\(\\sw\\|_\\)+\\)" 2)
'("*Protected*"
"^[ \t]*protected[ \t]+\\(type[ \t]+\\)?\\(\\(body[ \t]+\\)?\\(\\sw\\|_\\)+\\)" 2)
'("*Packages*" "^[ \t]*package[ \t]+\\(\\(body[ \t]+\\)?\\(\\sw\\|[_.]\\)+\\)" 1))
"Imenu generic expression for Ada mode.
See `imenu-generic-expression'. This variable will create several submenus for
each type of entity that can be found in an Ada file.")
(defun ada--imenu-mode ()
;; In 4.01, these were called in 'ada-mode or required to be set in
;; the user's .emacs.
(setq imenu-auto-rescan t)
(setq imenu-case-fold-search t)
(setq imenu-generic-expression ada--imenu-generic-expression)
(setq imenu-sort-function 'imenu--sort-by-name)
(setq imenu-use-markers nil)
(imenu-add-to-menubar "Entities")
)
;; ada--imenu-mode does not depend on file local variables
(add-hook 'ada-mode-hook #'ada--imenu-mode)
(provide 'ada-imenu)
;;; ada-imenu.el ends here