about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
authorCase Duckworth2022-05-01 09:26:59 -0500
committerCase Duckworth2022-05-01 09:26:59 -0500
commit8360e66d115b5cb4be1621cf18c976d4a4a3d010 (patch)
tree666e597e4dec685d47af19f620c9d275bb9ce187 /lisp
parentAdd geiser-guile (diff)
downloademacs-8360e66d115b5cb4be1621cf18c976d4a4a3d010.tar.gz
emacs-8360e66d115b5cb4be1621cf18c976d4a4a3d010.zip
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw.el16
1 files 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."
99By default, act on all buffers. 99By default, act on all buffers.
100 100
101Both PREDICATE and FUNC are called with no arguments, but within 101Both PREDICATE and FUNC are called with no arguments, but within
102a `with-current-buffer' form on the currently-active buffer." 102a `with-current-buffer' form on the currently-active buffer.
103
104As a special case, if PREDICATE is a list, it will be interpreted
105as a list of major modes. In this case, FUNC will only be called
106on buffers derived from one of the modes in PREDICATE."
103 (let ((pred (or predicate t))) 107 (let ((pred (or predicate t)))
104 (dolist (buf (buffer-list)) 108 (dolist (buf (buffer-list))
105 (with-current-buffer buf 109 (with-current-buffer buf
106 (when (if (or (eq (car-safe pred) 'closure) 110 (when (cond ((or (eq (car-safe pred) 'closure)
107 (fboundp pred)) 111 (fboundp pred))
108 (funcall pred) 112 (funcall pred))
109 pred) 113 ((listp pred)
114 (apply #'derived-mode-p pred))
115 (t pred))
110 (funcall func)))))) 116 (funcall func))))))
111 117
112;; https://github.com/cstby/emacs.d/blob/main/init.el#L67 118;; https://github.com/cstby/emacs.d/blob/main/init.el#L67