From 11a78c73e84706d865fd5481acb320eee72e4838 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Fri, 31 Jan 2014 23:11:25 +0100 Subject: Update stante-after macro --- .emacs.d/init.el | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index d94791a..1e3138c 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -37,24 +37,22 @@ (autoload 'xmodmap-mode "xmodmap-mode" nil t) ;;;; Macros + +;; http://www.lunaryorn.com/2013/06/25/introducing-with-eval-after-load/ (defmacro stante-after (feature &rest forms) "After FEATURE is loaded, evaluate FORMS. FEATURE may be an unquoted feature symbol or a file name, see `eval-after-load'." (declare (indent 1) (debug t)) - ;; Byte compile the body. If the feature is not available, ignore - ;; warnings. Taken from - ;; http://lists.gnu.org/archive/html/bug-gnu-emacs/2012-11/msg01262.html - (let ((loaded (if (symbolp feature) - (require feature nil :no-error) - (load feature :no-error :no-message)))) - `(,(if loaded - 'progn - (message "stante-after: cannot find %s" feature) - 'with-no-warnings) - (eval-after-load ',feature - `(funcall (function ,(lambda () ,@forms))))))) + `(,(if (or (not byte-compile-current-file) + (if (symbolp feature) + (require feature nil :noerror) + (load feature :no-message :no-error))) + `progn + (message "stante-after: cannot find %s" feature) + 'with-no-warnings) + (with-eval-after-load ',feature ,@forms))) (defmacro oni:add-hooks (hook &rest functions) "Add to HOOK each function in FUNCTIONS." -- cgit v1.2.3-54-g00ecf