]> git.eshelyaron.com Git - emacs.git/commitdiff
allow :ensure-system-package to check the presence of files at path
authorJustin Talbott <justin@waymondo.com>
Mon, 9 Jul 2018 21:47:42 +0000 (17:47 -0400)
committerJustin Talbott <justin@waymondo.com>
Mon, 9 Jul 2018 21:48:40 +0000 (17:48 -0400)
closes https://github.com/jwiegley/use-package/issues/660

lisp/use-package/use-package-ensure-system-package.el

index 476a4f2b930cc543678aecd9661312be00f39825..eaf6de79a123106a1c4a5af78fb0891603e3543a 100644 (file)
        (t
         (list (use-package-ensure-system-package-consify arg)))))))
 
+(defun use-package-ensure-system-package-exists? (file-or-exe)
+  "If variable is a string, ensure the file path exists.
+If it is a symbol, ensure the binary exist."
+  (if (stringp file-or-exe)
+      (file-exists-p file-or-exe)
+    (executable-find (symbol-name file-or-exe))))
+
 ;;;###autoload
 (defun use-package-handler/:ensure-system-package (name _keyword arg rest state)
   "Execute the handler for `:ensure-system-package' keyword in `use-package'."
   (let ((body (use-package-process-keywords name rest state)))
     (use-package-concat
      (mapcar #'(lambda (cons)
-                 `(unless (executable-find (symbol-name ',(car cons)))
+                 `(unless (use-package-ensure-system-package-exists? ',(car cons))
                     (async-shell-command ,(cdr cons)))) arg)
      body)))