Skip to content

Instantly share code, notes, and snippets.

@rummelonp
Forked from syohex/cperl-imenu.el
Created March 15, 2024 06:12
Show Gist options
  • Save rummelonp/7a6583b3dbbe87f53e50dbde113f1aa0 to your computer and use it in GitHub Desktop.
Save rummelonp/7a6583b3dbbe87f53e50dbde113f1aa0 to your computer and use it in GitHub Desktop.
my own perl imenu. Default imenu provides too many information for me
(defun my/cperl-imenu-create-index ()
(let (index)
;; collect subroutine
(goto-char (point-min))
(while (re-search-forward "^\\s-*sub\\s-+\\([^ ]+\\)" nil t)
(push (cons (format "Function: %s" (match-string 1))
(match-beginning 1)) index))
;; collect subtest
(goto-char (point-min))
(let ((desc-re "^\\s-*subtest\\s-+\\(['\"]\\)\\([^\1\r\n]+\\)\\1"))
(while (re-search-forward desc-re nil t)
(push (cons (format "Subtest: %s" (match-string 2))
(match-beginning 2)) index)))
(nreverse index)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment