Created
November 25, 2011 10:28
-
-
Save cmoore/1393217 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
(let ((gmod-have-package (featurep 'package))) | |
(defun gmod-install-url-as-elisp (url) | |
(let ((buf (url-retrieve-synchronously url))) | |
(save-excursion | |
(set-buffer buf) | |
(goto-char (point-min)) | |
(re-search-forward "^$" nil 'move) | |
(eval-region (point) (point-max)) | |
(kill-buffer (current-buffer))))) | |
(defmacro gmod-safe-wrap-function (fn &optional error-msg cleanupfn) | |
`(unwind-protect | |
(let (retval) | |
(condition-case ex | |
(setq retval (progn ,fn)) | |
('error | |
(setq retval nil))) | |
retval) | |
,@cleanupfn)) | |
(defun gmod-has-feature? (pkg) | |
(or (featurep pkg) | |
(gmod-safe-wrap-function (require pkg)))) | |
(defun gmod-install-package-el () | |
(gmod-install-url-as-elisp "http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/package.el")) | |
(defun gmod-install-tabulated-list () | |
(gmod-install-url-as-elisp "http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/tabulated-list.el")) | |
(defun go-team-go () | |
(progn | |
(message "TEAM NERDFORCE, ASSEMBLE!") | |
(or (gmod-has-feature? 'tabulated-list) | |
(gmod-install-tabulated-list)) | |
(or (gmod-has-feature? 'package) | |
(gmod-install-package-el)))) | |
(go-team-go)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment