Comment 1 for bug 1922146

Revision history for this message
Ergus (ergus) wrote :

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)
 (let ((l (split-string str ":" t)))
    (list (car l)
   (string-to-number (nth 1 l))
  #'global-imeny-action
   (nth 2 l))))

(defun my/imenu-create-index-function ()
  (let ((file (buffer-file-name)))
    (when file
      (mapcar #'my/parse
       (with-temp-buffer
  (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)
```