aboutsummaryrefslogtreecommitdiffstats
path: root/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/init.el40
1 files changed, 28 insertions, 12 deletions
diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el
index bfdf935..ec036da 100644
--- a/emacs/.emacs.d/init.el
+++ b/emacs/.emacs.d/init.el
@@ -50,24 +50,40 @@
;; This macro is inspired by use-package, but I want to maintain some
;; control of the syntax I use to configure my settings.
-(defmacro ensure-package (package &rest args)
- "Make sure PACKAGE is installed.
+(defmacro ensure-library (library &rest args)
+ "Make sure LIBRARY is installed.
ARGS should be a plist which may contain one of the following options:
-- :from
+- :package
Specify which package should actually be installed to ensure
- the library named in PACKAGE exists."
+ the library named in LIBRARY exists.
+
+- :path
+
+ Specify a path to add to the load path to be able to load this
+ package."
+ (declare (indent 1))
(let ((library-symbol (cl-gensym))
- (package-symbol (cl-gensym)))
- `(eval-when-compile
- (let ((,library-symbol ',package)
- (,package-symbol ',(or (plist-get args :from) package)))
- (unless (and (package-installed-p ,package-symbol)
- (locate-library (symbol-name ,library-symbol)))
- (package-install ,package-symbol))
- (require ,library-symbol)))))
+ (package-symbol (cl-gensym))
+ (path-symbol (cl-gensym))
+ (package (or (plist-get args :package) library))
+ (path (plist-get args :path)))
+ `(progn
+ (eval-and-compile
+ (let ((,path-symbol ,path))
+ (if ,path-symbol
+ (add-to-list 'load-path
+ (if (file-name-absolute-p ,path-symbol)
+ ,path-symbol
+ (concat user-emacs-directory ,path-symbol))))))
+ (eval-when-compile
+ (let ((,library-symbol ',library)
+ (,package-symbol ',package))
+ (unless (require ,library-symbol nil :noerror)
+ (package-install ,package-symbol)
+ (require ,library-symbol)))))))
;;;; Helper functions: