Skip to content

Instantly share code, notes, and snippets.

@stefaneng
Last active December 28, 2015 01:19
Show Gist options
  • Save stefaneng/7420118 to your computer and use it in GitHub Desktop.
Save stefaneng/7420118 to your computer and use it in GitHub Desktop.
Emacs macro to ensure that a package is installed before configuring
(defmacro ensure-installed-package (package &rest body)
"Ensures PACKAGE is installed and then performs body. Place package configurations in BODY"
(declare (indent 1))
`(progn
(when (not (package-installed-p ,package))
(package-install ,package))
,@body))
;; USAGE:
(ensure-installed-package 'haskell-mode
;; Configure package here
(add-hook 'haskell-mode-hook 'turn-on-haskell-indent))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment