Skip to content

Instantly share code, notes, and snippets.

@jewel12
Last active January 4, 2016 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jewel12/8612911 to your computer and use it in GitHub Desktop.
Save jewel12/8612911 to your computer and use it in GitHub Desktop.
Hachioji.pm #37

Perl最高!Emacs最高!

@jewel_x12 です。

最近はPHPを書いています。Niigata.pmにいたりしてました。Perlは書きません。

今後ともよろしくお願い申し上げます。

今書いているコードのテストファイルを開きたい

今開いているファイルがテストのファイルっぽくなかったら、テストファイルっぽいのをhelm-ls-gitの入力にする。 今開いているファイルがテストっぽかったら、テスト対象のファイルっぽいのを探す。

(require 'helm)
(require 'helm-ls-git)

(defun test-finder:input ()
  (let* ((current-file-name (file-name-base (buffer-file-name)))
        (test-file-regexp "_*\\(spec\\|test\\|Test\\)")
        (test-file-query (concat current-file-name
                                 ".*"
                                 test-file-regexp))
        (orig-file-query (replace-regexp-in-string test-file-regexp
                                                   ""
                                                   current-file-name)))
    (if (string-match test-file-regexp current-file-name) orig-file-query test-file-query)))

(defun test-finder ()
  (interactive)
  (helm :sources '(helm-source-ls-git)
        :input (test-finder:input)
        :buffer "helm*test-finder"))

(global-set-key (kbd "C-x C-t") 'test-finder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment