From 259363fd4f21d796c3c6a35be6398aed3f493a73 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 3 Jan 2023 23:02:26 -0600 Subject: bleh --- lisp/acdw.el | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'lisp/acdw.el') 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 @@ ;;; acdw.el -- bits and bobs -*- lexical-binding: t; -*- ;; by C. Duckworth (require 'cl-lib) +;; def.el is here +(require 'def) ;;; Define both a directory and a function expanding to a file in that directory @@ -197,6 +199,22 @@ If body executes without errors, MESSAGE...Done will be displayed." `(let* ((,this ,(car clauses))) (if ,this ,this (either ,@(cdr clauses))))))) +(defun mapc-buffers (fn &optional pred) + "Perform FN on buffers matching PRED. +If PRED is nil or absent, perform FN on all buffers. Both FN and +PRED are called within a `with-current-buffer' form and without +arguments." + (let ((pred (cond + ((listp pred) + (lambda () (apply #'derived-mode-p pred))) + ((functionp pred) pred) + ((null pred) (lambda () t)) + (:else (user-error "Bad predicate"))))) + (dolist (buf (buffer-list)) + (with-current-buffer buf + (when (funcall pred) + (funcall fn)))))) + ;; https://emacs.stackexchange.com/a/39324/37239 ;; XXX: This shit don't work rn (defun ignore-invisible-overlays (fn) @@ -233,5 +251,22 @@ When called with prefix ARG, unconditionally switch buffer." (switch-to-buffer (other-buffer) nil t) (other-window 1))) +;;; Set variables more better-er +;; Now this doesn't do `setf'-style stuff. + +(defmacro setc (&rest args) + "Customize user options using ARGS like `setq'." + (declare (debug setq)) + (unless (zerop (mod (length args) 2)) + (user-error "Dangling argument: %S" var)) + (let (form) + (while args + (push `(customize-set-variable + ',(pop args) + ,(pop args) + "Set by `setc'.") + form)) + `(progn ,@(nreverse form)))) + (provide 'acdw) ;;; acdw.el ends here -- cgit 1.4.1-21-gabe81