diff options
author | Tharre <tharre3@gmail.com> | 2016-10-07 20:53:06 +0000 |
---|---|---|
committer | Tharre <tharre3@gmail.com> | 2016-10-16 15:23:59 +0000 |
commit | edbcca8cd2b93b8c88eb62c431d04ea832b73180 (patch) | |
tree | bac188c0ee4c1c214dd50568e70783a7ee2c3565 /.emacs.d/site-lisp/with-package.el | |
parent | d4f1a0f27100ff2f4380fa4cf38b09e7f0c051f7 (diff) | |
download | dotfiles-edbcca8cd2b93b8c88eb62c431d04ea832b73180.tar.gz dotfiles-edbcca8cd2b93b8c88eb62c431d04ea832b73180.tar.xz dotfiles-edbcca8cd2b93b8c88eb62c431d04ea832b73180.zip |
Reorganise dotfiles
Diffstat (limited to '.emacs.d/site-lisp/with-package.el')
-rw-r--r-- | .emacs.d/site-lisp/with-package.el | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/.emacs.d/site-lisp/with-package.el b/.emacs.d/site-lisp/with-package.el new file mode 100644 index 0000000..3dfc52d --- /dev/null +++ b/.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) |