Skip to content

Instantly share code, notes, and snippets.

@cmoore
Created November 25, 2011 10:28
Show Gist options
  • Save cmoore/1393217 to your computer and use it in GitHub Desktop.
Save cmoore/1393217 to your computer and use it in GitHub Desktop.
(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