diff options
Diffstat (limited to 'lisp/acdw.el')
-rw-r--r-- | lisp/acdw.el | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lisp/acdw.el b/lisp/acdw.el index 75e1755..a9ef893 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el | |||
@@ -1,6 +1,8 @@ | |||
1 | ;;; acdw.el -- bits and bobs -*- lexical-binding: t; -*- | 1 | ;;; acdw.el -- bits and bobs -*- lexical-binding: t; -*- |
2 | ;; by C. Duckworth <acdw@acdw.net> | 2 | ;; by C. Duckworth <acdw@acdw.net> |
3 | (require 'cl-lib) | 3 | (require 'cl-lib) |
4 | ;; def.el is here | ||
5 | (require 'def) | ||
4 | 6 | ||
5 | ;;; Define both a directory and a function expanding to a file in that directory | 7 | ;;; Define both a directory and a function expanding to a file in that directory |
6 | 8 | ||
@@ -197,6 +199,22 @@ If body executes without errors, MESSAGE...Done will be displayed." | |||
197 | `(let* ((,this ,(car clauses))) | 199 | `(let* ((,this ,(car clauses))) |
198 | (if ,this ,this (either ,@(cdr clauses))))))) | 200 | (if ,this ,this (either ,@(cdr clauses))))))) |
199 | 201 | ||
202 | (defun mapc-buffers (fn &optional pred) | ||
203 | "Perform FN on buffers matching PRED. | ||
204 | If PRED is nil or absent, perform FN on all buffers. Both FN and | ||
205 | PRED are called within a `with-current-buffer' form and without | ||
206 | arguments." | ||
207 | (let ((pred (cond | ||
208 | ((listp pred) | ||
209 | (lambda () (apply #'derived-mode-p pred))) | ||
210 | ((functionp pred) pred) | ||
211 | ((null pred) (lambda () t)) | ||
212 | (:else (user-error "Bad predicate"))))) | ||
213 | (dolist (buf (buffer-list)) | ||
214 | (with-current-buffer buf | ||
215 | (when (funcall pred) | ||
216 | (funcall fn)))))) | ||
217 | |||
200 | ;; https://emacs.stackexchange.com/a/39324/37239 | 218 | ;; https://emacs.stackexchange.com/a/39324/37239 |
201 | ;; XXX: This shit don't work rn | 219 | ;; XXX: This shit don't work rn |
202 | (defun ignore-invisible-overlays (fn) | 220 | (defun ignore-invisible-overlays (fn) |
@@ -233,5 +251,22 @@ When called with prefix ARG, unconditionally switch buffer." | |||
233 | (switch-to-buffer (other-buffer) nil t) | 251 | (switch-to-buffer (other-buffer) nil t) |
234 | (other-window 1))) | 252 | (other-window 1))) |
235 | 253 | ||
254 | ;;; Set variables more better-er | ||
255 | ;; Now this doesn't do `setf'-style stuff. | ||
256 | |||
257 | (defmacro setc (&rest args) | ||
258 | "Customize user options using ARGS like `setq'." | ||
259 | (declare (debug setq)) | ||
260 | (unless (zerop (mod (length args) 2)) | ||
261 | (user-error "Dangling argument: %S" var)) | ||
262 | (let (form) | ||
263 | (while args | ||
264 | (push `(customize-set-variable | ||
265 | ',(pop args) | ||
266 | ,(pop args) | ||
267 | "Set by `setc'.") | ||
268 | form)) | ||
269 | `(progn ,@(nreverse form)))) | ||
270 | |||
236 | (provide 'acdw) | 271 | (provide 'acdw) |
237 | ;;; acdw.el ends here | 272 | ;;; acdw.el ends here |