From 8360e66d115b5cb4be1621cf18c976d4a4a3d010 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 1 May 2022 09:26:59 -0500 Subject: Allow passing a list of modes to `+mapc-some-buffers' Due to the way this is written, I can't pass one mode by itself---it must be a list. --- lisp/acdw.el | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lisp/acdw.el b/lisp/acdw.el index e47770b..ac17e46 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el @@ -99,14 +99,20 @@ If body executes without errors, MESSAGE...Done will be displayed." By default, act on all buffers. Both PREDICATE and FUNC are called with no arguments, but within -a `with-current-buffer' form on the currently-active buffer." +a `with-current-buffer' form on the currently-active buffer. + +As a special case, if PREDICATE is a list, it will be interpreted +as a list of major modes. In this case, FUNC will only be called +on buffers derived from one of the modes in PREDICATE." (let ((pred (or predicate t))) (dolist (buf (buffer-list)) (with-current-buffer buf - (when (if (or (eq (car-safe pred) 'closure) - (fboundp pred)) - (funcall pred) - pred) + (when (cond ((or (eq (car-safe pred) 'closure) + (fboundp pred)) + (funcall pred)) + ((listp pred) + (apply #'derived-mode-p pred)) + (t pred)) (funcall func)))))) ;; https://github.com/cstby/emacs.d/blob/main/init.el#L67 -- cgit 1.4.1-21-gabe81