From b66a719737205635ec57203b46ae9759d99baed6 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Sun, 20 Feb 2022 08:54:51 -0600 Subject: added tags-from-oneliner function --- src/lib.lisp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/lib.lisp') 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) -- cgit v1.2.3