summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-01-31 23:11:25 +0100
committerGravatar Tom Willemse2014-01-31 23:11:25 +0100
commit11a78c73e84706d865fd5481acb320eee72e4838 (patch)
treea3b092c14fe5855e7958c8198c56e7a7a06ee1ec
parent6c6e09962f71198475fec2a0eddae08dc89e9f22 (diff)
downloademacs-11a78c73e84706d865fd5481acb320eee72e4838.tar.gz
emacs-11a78c73e84706d865fd5481acb320eee72e4838.zip
Update stante-after macro
-rw-r--r--.emacs.d/init.el22
1 files 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."