Created
November 25, 2011 09:33
-
-
Save cmoore/1393127 to your computer and use it in GitHub Desktop.
Autoloader for package.el for emacs > 24
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-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