Created
April 23, 2014 14:59
-
-
Save jordonbiondo/11218747 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (cl-defun my-custom-install (package &key then error) | |
| "Install PACKAGE if not installed and configure it. | |
| key :then specifies a function to run when package installs successfully or is already installed. | |
| key :error specifies a function to run when package installation fails | |
| this function recieves one argument, an error object." | |
| (declare (indent defun)) | |
| (condition-case err | |
| (progn (unless (package-installed-p package) | |
| (package-install package)) | |
| (when then (funcall then))) | |
| (error (when error (funcall error err))))) | |
| (my-custom-install 'helm | |
| :then (lambda () | |
| (message "Configuratin'!")) | |
| :error (lambda(err) (message "OH NO! %s" (error-message-string err)))) ;; => "Configuratin'!" | |
| (my-custom-install 'not-a-package | |
| :then (lambda () | |
| (message "Configuratin'!")) | |
| :error (lambda(err) (message "OH NO! %s" (error-message-string err)))) ;; => "OH NO! Package `not-a-package' is not available for installation" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment