Skip to content

Instantly share code, notes, and snippets.

@snmsts
Created September 27, 2013 10:49
Show Gist options
  • Save snmsts/6726882 to your computer and use it in GitHub Desktop.
Save snmsts/6726882 to your computer and use it in GitHub Desktop.
test with shlyfile
(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