Skip to content

Instantly share code, notes, and snippets.

@syohex
Created November 8, 2012 09:25
Show Gist options
  • Save syohex/4037742 to your computer and use it in GitHub Desktop.
Save syohex/4037742 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