Created
April 9, 2013 08:49
-
-
Save taiyoh/5344132 to your computer and use it in GitHub Desktop.
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
;; via http://d.hatena.ne.jp/trotr/20090822/1250958096 | |
;; ------------------------------------------------ | |
(require 'cl) | |
(defun myenv-string-join (sequence separator) | |
(mapconcat #'identity sequence separator)) | |
(defsubst myenv-parent-dir (path) | |
"return parent directory path of argument." | |
(substring-no-properties (file-name-directory path) 0 -1)) | |
(defsubst myenv-find-target-file-dir (path target) | |
(let* ((src (nreverse (split-string (myenv-parent-dir path) "/"))) | |
(paths (maplist #'(lambda (l) (myenv-string-join (reverse l) "/")) src))) | |
(loop for path in paths | |
if (file-exists-p (concat path "/" target)) | |
return path))) | |
(defun myenv-find-cpanfile-dir (path) | |
(myenv-find-target-file-dir path "cpanfile")) | |
(defun myenv-carton-path () | |
(plenv-trim (shell-command-to-string "which carton"))) | |
(defun myenv-perl-path (local-file) | |
(let* ((carton-path (myenv-carton-path)) | |
(cpanfile-dir (myenv-find-cpanfile-dir (file-name-directory buffer-file-name)))) | |
(if cpanfile-dir | |
(if carton-path | |
(list carton-path (list "exec" (concat "PERL_CARTON_PATH=" cpanfile-dir) (concat "-I" cpanfile-dir "/lib") "--" (guess-plenv-perl-path) "-wc" local-file)) | |
(list (guess-plenv-perl-path) (list "-wc" local-file))) | |
(list (guess-plenv-perl-path) (list "-wc" local-file))))) | |
;; ------------------------------------------------ | |
(defun flymake-perl-init () | |
(let* ((temp-file (flymake-init-create-temp-buffer-copy | |
'flymake-create-temp-with-folder-structure)) | |
(local-file (file-relative-name | |
temp-file | |
(file-name-directory buffer-file-name)))) | |
(myenv-perl-path local-file))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment