diff options
author | Case Duckworth | 2022-05-01 09:26:59 -0500 |
---|---|---|
committer | Case Duckworth | 2022-05-01 09:26:59 -0500 |
commit | 8360e66d115b5cb4be1621cf18c976d4a4a3d010 (patch) | |
tree | 666e597e4dec685d47af19f620c9d275bb9ce187 | |
parent | Add geiser-guile (diff) | |
download | emacs-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.
-rw-r--r-- | lisp/acdw.el | 16 |
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." | |||
99 | By default, act on all buffers. | 99 | By default, act on all buffers. |
100 | 100 | ||
101 | Both PREDICATE and FUNC are called with no arguments, but within | 101 | Both PREDICATE and FUNC are called with no arguments, but within |
102 | a `with-current-buffer' form on the currently-active buffer." | 102 | a `with-current-buffer' form on the currently-active buffer. |
103 | |||
104 | As a special case, if PREDICATE is a list, it will be interpreted | ||
105 | as a list of major modes. In this case, FUNC will only be called | ||
106 | on 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 |