Created
September 27, 2013 10:49
-
-
Save snmsts/6726882 to your computer and use it in GitHub Desktop.
test with shlyfile
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
(defun which (bin &key a) | |
(let* ((paths (mapcar #'(lambda (x) (make-pathname :defaults (format nil "~A/" x))) | |
(asdf::split-string (asdf::getenv "PATH") :separator '(#\:)))) | |
found) | |
(setq found (flet ((test (x y) | |
(cl-fad:file-exists-p (merge-pathnames x y)))) | |
(if a | |
(remove bin paths :test (complement #'test)) | |
(find bin paths :test #'test)))) | |
(when found | |
(if a | |
(mapcar #'(lambda (x) (merge-pathnames bin x)) found) | |
(merge-pathnames bin found))))) | |
#+nil(which "emacs") ;; => #P"/usr/bin/emacs" | |
(defun exec (&rest commands) | |
#+debug | |
(progn | |
(format t "~S~%" commands) | |
(force-output t)) | |
(swank-backend::execv (namestring (which (first commands))) | |
commands)) | |
(defun emacs (&rest cmds) | |
(apply #'exec (cons "emacs" cmds))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment