Skip to content

Instantly share code, notes, and snippets.

@cmoore
Created November 25, 2011 09:33
Show Gist options
  • Save cmoore/1393127 to your computer and use it in GitHub Desktop.
Save cmoore/1393127 to your computer and use it in GitHub Desktop.
Autoloader for package.el for emacs > 24
(let ((gmod-have-package (featurep 'package)))
(defun gmod-install-package-el ()
(let (buf (url-retrieve-synchronously
"http://git.savannah.gnu.org/cgit/emacs.git/plain/lisp/emacs-lisp/package.el"))
(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
(if (and (boundp error-msg)
(stringp error-msg))
(message (format "%s" ,error-msg)))
(setq retval (cons 'exception (list ex)))))
retval)
,@cleanupfn))
(gmod-safe-wrap-function
(or (featurep 'package)
(gmod-install-package-el))
"Failed to install package.el :("))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment