Created
April 2, 2013 12:31
-
-
Save rlb3/5291863 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (require 's) | |
| (defun rlb3/toggle-file () | |
| (interactive) | |
| (let* ((full-path (buffer-file-name)) | |
| (path (rlb3/remove-ulc full-path)) | |
| (file-type (rlb3/determine-file-type path))) | |
| (if (eq file-type 'test) | |
| (rlb3/jump-to-related-test path) | |
| (rlb3/jump-to-related-module path)))) | |
| (defun rlb3/remove-ulc (path) | |
| (let ((new-path (s-chop-prefix "/usr/local/cpanel/" path ))) | |
| new-path)) | |
| (defun rlb3/determine-file-type (full-path) | |
| (cond ((s-ends-with? ".pm" full-path) 'test) | |
| ((s-ends-with? ".t" full-path) 'module))) | |
| (defun rlb3/jump-to-related-module (path) | |
| (switch-to-buffer (find-file-noselect (rlb3/convert-to-module path)))) | |
| (defun rlb3/jump-to-related-test (path) | |
| (switch-to-buffer (find-file-noselect (rlb3/convert-to-test path)))) | |
| (defun rlb3/convert-to-module (path) | |
| (let* ((new-ext (s-replace ".t" ".pm" path)) | |
| (full-path (s-prepend "/usr/local/cpanel/" (s-chop-prefix "t/" new-ext)))) | |
| (s-replace "-" "/" full-path))) | |
| (defun rlb3/convert-to-test (path) | |
| (let* ((new-ext (s-replace ".pm" ".t" path)) | |
| (full-path (s-prepend "/usr/local/cpanel/t/" (s-replace "/" "-" new-ext)))) | |
| full-path)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment