Skip to content

Instantly share code, notes, and snippets.

@ainame
Last active December 20, 2015 23:19
Show Gist options
  • Save ainame/6211761 to your computer and use it in GitHub Desktop.
Save ainame/6211761 to your computer and use it in GitHub Desktop.
imenuでsubtestのdescriptionをぶっこ抜く奴。subtest用のminorモード作ってもうちょっとよくしたい。
(defvar cperl-imenu-subtest-extract-description-regexp-pattern
"\\(\s*\\)subtest\s*?['|\"]\\(.*\\)['|\"].*=>.*$")
(defun cperl-imenu-subtest-imenu-create-index ()
(let (index)
(goto-char (point-min))
(while (re-search-forward
cperl-imenu-subtest-extract-description-regexp-pattern
(point-max) t)
(push (cons (concat
(replace-regexp-in-string "\s" "-" (match-string 1))
(match-string 2))
(match-beginning 1)) index))
(nreverse index)))
(add-hook 'cperl-mode-hook
(lambda ()
(set (make-local-variable 'imenu-create-index-function)
'cperl-imenu-subtest-imenu-create-index)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment