summary refs log tree commit diff stats
path: root/lisp/yoke.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/yoke.el')
-rw-r--r--lisp/yoke.el72
1 files changed, 42 insertions, 30 deletions
diff --git a/lisp/yoke.el b/lisp/yoke.el index 4f40869..68b02c4 100644 --- a/lisp/yoke.el +++ b/lisp/yoke.el
@@ -47,20 +47,20 @@ installed to `yoke-dir'."
47 (let ((generated-autoload-file 47 (let ((generated-autoload-file
48 (expand-file-name (format "%s-autoloads.el" pkg) dir)) 48 (expand-file-name (format "%s-autoloads.el" pkg) dir))
49 (backup-inhibited t) 49 (backup-inhibited t)
50 (version-control 'never) 50 (version-control 'never)
51 (message-log-max nil) 51 (message-log-max nil)
52 (inhibit-message t)) 52 (inhibit-message t))
53 (unless (file-exists-p generated-autoload-file) 53 (unless (file-exists-p generated-autoload-file)
54 (let ((find-file-hook nil) 54 (let ((find-file-hook nil)
55 (write-file-functions nil) 55 (write-file-functions nil)
56 (debug-on-error nil) 56 (debug-on-error nil)
57 (left-margin 0)) 57 (left-margin 0))
58 (if (fboundp 'make-directory-autoloads) 58 (if (fboundp 'make-directory-autoloads)
59 (make-directory-autoloads dir generated-autoload-file) 59 (make-directory-autoloads dir generated-autoload-file)
60 (and (fboundp 'update-directory-autoloads) 60 (and (fboundp 'update-directory-autoloads)
61 (update-directory-autoloads dir))))) 61 (update-directory-autoloads dir)))))
62 (when-let ((buf (find-buffer-visiting generated-autoload-file))) 62 (when-let ((buf (find-buffer-visiting generated-autoload-file)))
63 (kill-buffer buf)) 63 (kill-buffer buf))
64 (load generated-autoload-file :noerror :nomessage))) 64 (load generated-autoload-file :noerror :nomessage)))
65 (t (user-error "Directory \"%s\" doesn't exist." dir))) 65 (t (user-error "Directory \"%s\" doesn't exist." dir)))
66 dir)) 66 dir))
@@ -83,13 +83,13 @@ Similar-ish to `plist-get', but works on non-proper plists."
83 ,g)))) 83 ,g))))
84 84
85(defun delete2 (list &rest elems) 85(defun delete2 (list &rest elems)
86 "Delete ELEM and the next item from LIST." 86 "Delete each element of ELEMS, and the next item, from LIST."
87 (let ((r nil)) 87 (let ((r nil))
88 (while (consp list) 88 (while (consp list)
89 (if (member (car list) elems) 89 (if (member (car list) elems)
90 (setq list (cdr list)) 90 (setf list (cdr list))
91 (setq r (cons (car list) r))) 91 (setf r (cons (car list) r)))
92 (setq list (cdr list))) 92 (setf list (cdr list)))
93 (reverse r))) 93 (reverse r)))
94 94
95(defun eval-after-init (fn) 95(defun eval-after-init (fn)
@@ -105,17 +105,17 @@ FEATURES can be an atom or a list; as an atom it works like
105`with-eval-after-load'. The special feature `init' will evaluate 105`with-eval-after-load'. The special feature `init' will evaluate
106BODY after Emacs is finished initializing." 106BODY after Emacs is finished initializing."
107 (declare (indent 1) 107 (declare (indent 1)
108 (debug (form def-body))) 108 (debug (form def-body)))
109 (if (eq features 'init) 109 (if (eq features 'init)
110 `(eval-after-init (lambda () ,@body)) 110 `(eval-after-init (lambda () ,@body))
111 (unless (listp features) 111 (unless (listp features)
112 (setq features (list features))) 112 (setf features (list features)))
113 (if (null features) 113 (if (null features)
114 (macroexp-progn body) 114 (macroexp-progn body)
115 (let* ((this (car features)) 115 (let* ((this (car features))
116 (rest (cdr features))) 116 (rest (cdr features)))
117 `(with-eval-after-load ',this 117 `(with-eval-after-load ',this
118 (eval-after ,rest ,@body)))))) 118 (eval-after ,rest ,@body))))))
119 119
120(defun yoke-pkg-name (pkg) 120(defun yoke-pkg-name (pkg)
121 (intern (format "yoke:%s" pkg))) 121 (intern (format "yoke:%s" pkg)))
@@ -131,7 +131,7 @@ BODY after Emacs is finished initializing."
131 (unless nil unlessp) ; :unless PREDICATE 131 (unless nil unlessp) ; :unless PREDICATE
132 &allow-other-keys) 132 &allow-other-keys)
133 "Yoke a PKG into your Emacs session." 133 "Yoke a PKG into your Emacs session."
134 (declare (indent defun)) 134 (declare (indent 2))
135 (let ((name (yoke-pkg-name pkg)) 135 (let ((name (yoke-pkg-name pkg))
136 (body (delete2 body 136 (body (delete2 body
137 :depends :when :unless :after :load))) 137 :depends :when :unless :after :load)))
@@ -141,11 +141,11 @@ BODY after Emacs is finished initializing."
141 (*yoke-repo* ,repo) 141 (*yoke-repo* ,repo)
142 (*yoke-dest* ,(when repo `(yoke-repo-dir ',pkg ,repo)))) 142 (*yoke-dest* ,(when repo `(yoke-repo-dir ',pkg ,repo))))
143 ,@(cond 143 ,@(cond
144 ((and whenp unlessp) 144 ((and whenp unlessp)
145 `((when (or (not ,when) ,unless) 145 `((when (or (not ,when) ,unless)
146 (cl-return-from ,name nil)))) 146 (cl-return-from ,name nil))))
147 (whenp `((unless ,when (cl-return-from ,name nil)))) 147 (whenp `((unless ,when (cl-return-from ,name nil))))
148 (unlessp `((when ,unless (cl-return-from ,name nil))))) 148 (unlessp `((when ,unless (cl-return-from ,name nil)))))
149 ,@(cl-loop for (pkg* repo* load-path*) in depends 149 ,@(cl-loop for (pkg* repo* load-path*) in depends
150 collect `(or (yoke-lasso ',pkg* ,repo* ,load-path*) 150 collect `(or (yoke-lasso ',pkg* ,repo* ,load-path*)
151 (cl-return-from ,name nil))) 151 (cl-return-from ,name nil)))
@@ -157,3 +157,15 @@ BODY after Emacs is finished initializing."
157 body)) 157 body))
158 (:success ',pkg) 158 (:success ',pkg)
159 (t (message "%s: %s" ',name e)))))) 159 (t (message "%s: %s" ',name e))))))
160
161;;; Extras
162
163(defun yoke-imenu-insinuate ()
164 "Insinuate `yoke' forms for `imenu'."
165 (require 'imenu)
166 (setf (alist-get "Yoke" imenu-generic-expression nil nil #'equal)
167 (list (rx (: "(yoke" (+ space)
168 (group (+ (not space)))
169 (+ space)
170 (group (+ (not space)))))
171 1)))