Skip to content

Instantly share code, notes, and snippets.

@TakesxiSximada
Last active September 18, 2020 11:21
Show Gist options
  • Save TakesxiSximada/beb8e1944af406c3fb4f74b6e0e3b5fe to your computer and use it in GitHub Desktop.
Save TakesxiSximada/beb8e1944af406c3fb4f74b6e0e3b5fe to your computer and use it in GitHub Desktop.
Require to install executable

Require to install executable

Check if the executable is installed and assist in the installation. However, the installation itself is not performed. Just display the message.

Install

By quelpa

(require 'quelpa)

(quelpa '(change-case :fetcher git :url "[email protected]:beb8e1944af406c3fb4f74b6e0e3b5fe.git"))

By El-Get

(require 'el-get)

(el-get-bundle gist:beb8e1944af406c3fb4f74b6e0e3b5fe:require-to-install-executable :type "git")

How to use it

(require 'require-to-install-executable)

(require-to-install-executable "jq package" "jq"
			       :darwin "brew install jq"
			       :windows-nt "ninst install jq")

Bug report and Contributing

We haven’t prepared those flows yet. For the time being, please write the steps to reproduce the bug in this gist comment, or attach the patch file in diff format. Welcome them.

Release notes

Version 1 (2020-09-18)

  • First implements.
;;; require-to-install-executable.el --- Check if the executable is installed and assist in the installation -*- lexical-binding: t -*-
;; Copyright (C) 2020 TakesxiSximada
;; Author: TakesxiSximada <[email protected]>
;; Maintainer: TakesxiSximada <[email protected]>
;; Repository: https://gist.github.com/TakesxiSximada/beb8e1944af406c3fb4f74b6e0e3b5fe
;; Version: 1
;; Package-Version: 20200918.2255
;; Package-Requires: nil
;; Date: 2020-09-18
;; change-case.el is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.
;;
;; The require-to-install-executable.el is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with change-case.el. If not, see http://www.gnu.org/licenses.
;;; Commentary:
;; Check if the executable is installed and assist in the installation.
;; However, the installation itself is not performed. Just display the message.
;;; Code:
(defmacro require-to-install-executable (name test &rest install-docs)
`(let ((installed? (cond ((booleanp ,test)
,test)
((stringp ,test)
(executable-find ,test))
(t
(eval ,test)))))
(if (not installed?)
(message
(format "Require to install: %s: %s" ,name
,(plist-get install-docs (intern (concat ":" (symbol-name system-type)))))))))
(provide 'require-to-install-executable)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment