Last active
December 20, 2015 23:19
-
-
Save ainame/6211761 to your computer and use it in GitHub Desktop.
imenuでsubtestのdescriptionをぶっこ抜く奴。subtest用のminorモード作ってもうちょっとよくしたい。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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