aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2022-02-20 08:54:51 -0600
committerColin Okay <okay@toyful.space>2022-02-20 08:54:51 -0600
commitb66a719737205635ec57203b46ae9759d99baed6 (patch)
treeca0ea8dda08db74ca575c88c96b1979839d8547f
parent2c49e526105cd04d4b76bc204929ee8b8a9f6c6b (diff)
added tags-from-oneliner function
-rw-r--r--src/lib.lisp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/lib.lisp b/src/lib.lisp
index ec65d13..d1b8db6 100644
--- a/src/lib.lisp
+++ b/src/lib.lisp
@@ -63,13 +63,20 @@
(when (uiop:file-exists-p (last-search-file))
(nth n (uiop:read-file-form (last-search-file)))))
-(defun command-on-system (cmd)
- )
+(defun executable-on-system-p (name)
+ "A hack that heuristically determins whether or not an executable
+with the provided name is on the system. It is not perfect. It
+consults the environment PATH, and looks for the command in any of
+the directories that appear in the value of that variable."
+ #+(unix)
+ (loop for path in (str:split ":" (uiop:getenv "PATH"))
+ for directory = (cons :absolute
+ (cdr (str:split "/" path)))
+ thereis (uiop:file-exists-p
+ (make-pathname :name name :directory directory))))
(defun tags-from-oneliner (oneliner)
- (loop for cmd? in (ppcre:split " +" oneliner)
- when (command-on-system cmd?)
- collect cmd?))
+ (remove-if-not #'executable-on-system-p (ppcre:split " +" oneliner)))
(defun prompt (prompt &key (out-stream *standard-output*) (in-stream *standard-input*))
(princ prompt out-stream)