Feature request. Add imenu support it is trivial.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
global-tags.el |
Fix Released
|
Medium
|
Felipe Lema |
Bug Description
Hi Felipe:
I have been looking in the api you made for this and I think that adding support to imenu throw global could be almost trivial.
global provides the option -f that returns the tags in the current file.
Example: `global -f mysource.c`
```
mystruct 2 main.c struct mystruct{
fun1 6 main.c int fun1(int a)
fun2 11 main.c int fun2(
main 18 main.c int main(int argc, char *argv[])
```
and imenu just needs a function that returns an alist with the special format
```
(index-name index-position function arguments…)
```
so it only needs a function to parse the first output and return something like:
```
'(("fun1" 2 #'global-
("fun2" 6 #'global-
...
)
```
Where:
```
(defun global-imeny-action (tag line regex)
(goto-line line)
(search-forward regex)
(search-backward regex))
```
The whole documentation for imenu is here:
https:/
Could you consider to add this to this package. Because a different package only for this is IMO useless.
Thanks in advance,
Ergus.
Changed in global-tags.el: | |
importance: | Undecided → Medium |
assignee: | nobody → Felipe Lema (morenonatural) |
status: | New → In Progress |
BTW:
Just to extend this a little bit. The following (untested) code more or less should work.
```
(defun global-imeny-action (tag line regex)
(goto-line line)
(search-forward regex)
(search-backward regex))
(defun my/parse (str) to-number (nth 1 l)) imeny-action
(let ((l (split-string str ":" t)))
(list (car l)
(string-
#'global-
(nth 2 l))))
(defun my/imenu- create- index-function () file-name) ))
(with-temp- buffer
(let ((file (buffer-
(when file
(mapcar #'my/parse
(shell-command (concat "global -f --result \"grep\" " file) t)
(split-string (buffer-string) "\n" t)
)))))
(setq imenu-create- index-function 'my/imenu- create- index-function)
#
```