aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2016-10-10 13:48:00 +0200
committerGravatar Tom Willemse2016-10-10 13:48:00 +0200
commitcfdefc4a8bdf0a1ee175b346fc9023eb11d1e56a (patch)
tree8d55833c72c2efdba82af76ce10275cc55d28db6
parentbea7b141b7fca852dae6910b5232a193ebcc4255 (diff)
downloadnew-dotfiles-cfdefc4a8bdf0a1ee175b346fc9023eb11d1e56a.tar.gz
new-dotfiles-cfdefc4a8bdf0a1ee175b346fc9023eb11d1e56a.zip
Stop using the ensure-library macro
There are simpler ways to achieve the same thing.
-rw-r--r--emacs/.emacs.d/init.org134
1 files changed, 20 insertions, 114 deletions
diff --git a/emacs/.emacs.d/init.org b/emacs/.emacs.d/init.org
index 4bac09a..601b7ed 100644
--- a/emacs/.emacs.d/init.org
+++ b/emacs/.emacs.d/init.org
@@ -30,6 +30,15 @@ To start off, first I need to enable lexical binding.
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/")))
#+END_SRC
+ Add all my vendored packages to the load path.
+
+ #+BEGIN_SRC emacs-lisp
+ (eval-and-compile
+ (mapc (lambda (d) (add-to-list 'load-path d))
+ (directory-files
+ (locate-user-emacs-file "vendor-lisp/") t "^[^.]")))
+ #+END_SRC
+
Initialize package.el so that packages can be loaded and used. This
also needs to be done at both run-time and compile-time so packages
can be installed at compile-time.
@@ -75,48 +84,17 @@ To start off, first I need to enable lexical binding.
#+BEGIN_SRC emacs-lisp
(eval-when-compile
- (silently "Refresh packages"
- (package-refresh-contents)))
- #+END_SRC
-
- This macro is inspired by use-package, but I want to maintain some
- control of the syntax I use to configure my settings.
-
- #+BEGIN_SRC emacs-lisp
- (defmacro ensure-library (library &rest args)
- "Make sure LIBRARY is installed.
-
- ARGS should be a plist which may contain one of the following options:
-
- - :package
-
- Specify which package should actually be installed to ensure
- 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))
- (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)))))))
+ (let* ((not-installed (seq-remove 'package-installed-p
+ package-selected-packages))
+ (available (seq-filter (lambda (p)
+ (assq p package-archive-contents))
+ not-installed))
+ (difference (- (length not-installed) (length available))))
+ (when (> difference 0)
+ (silently "Refresh packages"
+ (package-refresh-contents)))
+ (when available
+ (mapc (lambda (p) (package-install p t)) available))))
#+END_SRC
* Site lisp
@@ -258,8 +236,6 @@ To start off, first I need to enable lexical binding.
with people who don't pay attention to it, it has worked flawlessly.
#+BEGIN_SRC emacs-lisp
- (ensure-library destroy-trailing-whitespace
- :path "vendor-lisp/destroy-trailing-whitespace")
(require 'destroy-trailing-whitespace)
(global-destroy-trailing-whitespace-mode)
#+END_SRC
@@ -285,8 +261,6 @@ To start off, first I need to enable lexical binding.
* Theme
#+BEGIN_SRC emacs-lisp
- (ensure-library yoshi-theme
- :path "vendor-lisp/yoshi-theme")
(add-to-list 'custom-theme-load-path
(concat user-emacs-directory "vendor-lisp/yoshi-theme"))
(load-theme 'yoshi :no-confirm)
@@ -297,7 +271,6 @@ To start off, first I need to enable lexical binding.
I really don't need to see some of the minor modes.
#+BEGIN_SRC emacs-lisp
- (ensure-library diminish)
(require 'diminish)
#+END_SRC
@@ -307,16 +280,6 @@ To start off, first I need to enable lexical binding.
vertically. I'm surprised how much I like it. I've tried Swiper
before and I didn't like that so much.
- #+BEGIN_SRC emacs-lisp
- (ensure-library ivy)
- #+END_SRC
-
- Also install the =flx= package to allow ivy to use fuzzy matching.
-
- #+BEGIN_SRC emacs-lisp
- (ensure-library flx)
- #+END_SRC
-
Since I immediately use and enable Ivy, there's no need to autoload
it, so require it to keep the byte-compiler quiet.
@@ -350,10 +313,6 @@ To start off, first I need to enable lexical binding.
Counsel is a group of functions that use Ivy to specialize on
certain built-in commands, such as M-x.
- #+BEGIN_SRC emacs-lisp
- (ensure-library counsel)
- #+END_SRC
-
Since I enable Counsel mode immediately, there's no point in leaving
it to be autoloaded. Requiring it keeps the byte-compiler happy.
@@ -510,10 +469,6 @@ To start off, first I need to enable lexical binding.
first, but once you get the hang of using it, you won't want to
live without it.
- #+BEGIN_SRC emacs-lisp
- (ensure-library paredit)
- #+END_SRC
-
Don't show that paredit is enabled, it should be obvious from the
effects it has. This will save some precious real-estate on my mode
line.
@@ -555,15 +510,10 @@ To start off, first I need to enable lexical binding.
Flycheck lets me see (compiler) errors, warnings and info messages
while writing code.
- #+BEGIN_SRC emacs-lisp
- (ensure-library flycheck)
- #+END_SRC
-
When developing packages with Cask, some special care needs to be
taken to ensure the checkers work correctly.
#+BEGIN_SRC emacs-lisp
- (ensure-library flycheck-cask)
(add-hook 'flycheck-mode-hook 'flycheck-cask-setup)
#+END_SRC
@@ -588,8 +538,6 @@ To start off, first I need to enable lexical binding.
Show the error message at point in a tooltip.
#+BEGIN_SRC emacs-lisp
- (ensure-library flycheck-pos-tip)
-
(with-eval-after-load 'flycheck
(require 'flycheck-pos-tip)
(flycheck-pos-tip-mode))
@@ -623,7 +571,6 @@ To start off, first I need to enable lexical binding.
commit.
#+BEGIN_SRC emacs-lisp
- (ensure-library diff-hl)
(require 'diff-hl)
(global-diff-hl-mode)
#+END_SRC
@@ -633,10 +580,6 @@ To start off, first I need to enable lexical binding.
Hydra is an interesting way of managing keybindings, I want to
experiment.
- #+BEGIN_SRC emacs-lisp
- (ensure-library hydra)
- #+END_SRC
-
Add a hydra for org.
#+BEGIN_SRC emacs-lisp
@@ -664,7 +607,6 @@ To start off, first I need to enable lexical binding.
Projectile is, thus far, the best project module for Emacs.
#+BEGIN_SRC emacs-lisp
- (ensure-library projectile)
(require 'projectile)
#+END_SRC
@@ -755,11 +697,6 @@ To start off, first I need to enable lexical binding.
might release it as a package, but for now I keep it with the rest
of my configuration.
- #+BEGIN_SRC emacs-lisp
- (ensure-library mbsync-conf-mode
- :path "vendor-lisp/mbsync-conf-mode")
- #+END_SRC
-
Since it isn't installed by package.el, I need to specify the
autoload myself.
@@ -782,11 +719,6 @@ To start off, first I need to enable lexical binding.
release it as a package, but for now I keep it with the rest of my
configuration.
- #+BEGIN_SRC emacs-lisp
- (ensure-library msmtprc-mode
- :path "vendor-lisp/msmtprc-mode")
- #+END_SRC
-
Since it isn't installed by package.el, I need to specify the
autoload myself.
@@ -831,10 +763,6 @@ To start off, first I need to enable lexical binding.
Web mode is a good general-purpose web template mode. It works well
with many template languages and PHP as well.
- #+BEGIN_SRC emacs-lisp
- (ensure-library web-mode)
- #+END_SRC
-
Enable a specialized whitespace mode for web mode that shows tabs
at the beginning of a line.
@@ -868,15 +796,9 @@ To start off, first I need to enable lexical binding.
** Clojure mode
- #+BEGIN_SRC emacs-lisp
- (ensure-library clojure-mode)
- #+END_SRC
-
Install extra font-locking for clojure.
#+BEGIN_SRC emacs-lisp
- (ensure-library clojure-mode-extra-font-locking)
-
(with-eval-after-load 'clojure-mode
(require 'clojure-mode-extra-font-locking))
#+END_SRC
@@ -909,10 +831,6 @@ To start off, first I need to enable lexical binding.
Cider is like Slime for Common Lisp. This configuration is copied
from the one provided by Clojure for the Brave and True.
- #+BEGIN_SRC emacs-lisp
- (ensure-library cider)
- #+END_SRC
-
Provides minibuffer documentation for the code you're typing into
the repl.
@@ -961,10 +879,6 @@ To start off, first I need to enable lexical binding.
do just about anything with Git without leaving the comfort of your
Emacs session.
- #+BEGIN_SRC emacs-lisp
- (ensure-library magit)
- #+END_SRC
-
Show refined diffs in magit. This makes it much easier to see
/what/ has changed on a line.
@@ -1179,10 +1093,6 @@ To start off, first I need to enable lexical binding.
I switched to Circe from ERC because I couldn't make the
customizations I wanted to, Circe seems much better at this.
- #+BEGIN_SRC emacs-lisp
- (ensure-library circe)
- #+END_SRC
-
Make sure that Emacs knows these function exist when the file is
being compiled.
@@ -1233,9 +1143,6 @@ To start off, first I need to enable lexical binding.
Align all nicks.
#+BEGIN_SRC emacs-lisp
- (ensure-library sermon
- :path "vendor-lisp/sermon")
-
(with-eval-after-load 'circe
(require 'sermon)
(enable-sermon))
@@ -1264,7 +1171,6 @@ To start off, first I need to enable lexical binding.
this.
#+BEGIN_SRC emacs-lisp
- (ensure-library jabber)
(eval-when-compile (require 'jabber))
#+END_SRC