diff options
author | Tharre <tharre3@gmail.com> | 2015-09-14 20:19:14 +0200 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2016-10-07 20:13:36 +0000 |
commit | 98ba0e744bdf99ce0a894451700f11c39dc2579b (patch) | |
tree | 0586076ab8c7f3acde1bfef4375e6d4bdcd76003 /shell/_emacs.d/site-lisp/with-package.el | |
parent | 71a55046a49ea4f340638fc989fbad1a6b001ca7 (diff) | |
download | dotfiles-98ba0e744bdf99ce0a894451700f11c39dc2579b.tar.gz dotfiles-98ba0e744bdf99ce0a894451700f11c39dc2579b.tar.xz dotfiles-98ba0e744bdf99ce0a894451700f11c39dc2579b.zip |
emacs: actually install .emacs.d
Diffstat (limited to 'shell/_emacs.d/site-lisp/with-package.el')
-rw-r--r-- | shell/_emacs.d/site-lisp/with-package.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/shell/_emacs.d/site-lisp/with-package.el b/shell/_emacs.d/site-lisp/with-package.el new file mode 100644 index 0000000..3dfc52d --- /dev/null +++ b/shell/_emacs.d/site-lisp/with-package.el @@ -0,0 +1,31 @@ +(require 'cl) + +;; will be available at emacs 24.4 +(unless (fboundp 'with-eval-after-load) + "Do magic from the future" + (defmacro with-eval-after-load (file &rest body) + `(eval-after-load ,file + `(funcall (function ,(lambda () ,@body)))))) + +(defmacro with-package (packages &rest body) + "After pkg macro" + (declare (indent defun)) + (when (symbolp packages) ;; make a list if necessary + (setf packages (list packages))) + `(progn + (dolist (p ',packages) + (when (not (package-installed-p p)) + (package-install p)) + (with-eval-after-load p ,@body)))) + +(defmacro with-package* (packages &rest body) + "After pkg macro*" + (declare (indent defun)) + (when (symbolp packages) ;; make a list if necessary + (setf packages (list packages))) + `(prog1 + (with-package ,packages ,@body) + (dolist (p ',packages) + (require p)))) + +(provide 'with-package) |