"This mode causes the prompt to stay at the end of the window."
((add-hook 'erc-mode-hook #'erc-add-scroll-to-bottom)
(add-hook 'erc-insert-done-hook #'erc-possibly-scroll-to-bottom)
- (unless erc--updating-modules-p
- (erc-buffer-filter #'erc-add-scroll-to-bottom)))
+ (unless erc--updating-modules-p (erc-buffer-do #'erc-add-scroll-to-bottom)))
((remove-hook 'erc-mode-hook #'erc-add-scroll-to-bottom)
(remove-hook 'erc-insert-done-hook #'erc-possibly-scroll-to-bottom)
(dolist (buffer (erc-buffer-list))
(define-erc-module move-to-prompt nil
"This mode causes the point to be moved to the prompt when typing text."
((add-hook 'erc-mode-hook #'erc-move-to-prompt-setup)
- (unless erc--updating-modules-p
- (erc-buffer-filter #'erc-move-to-prompt-setup)))
+ (unless erc--updating-modules-p (erc-buffer-do #'erc-move-to-prompt-setup)))
((remove-hook 'erc-mode-hook #'erc-move-to-prompt-setup)
(dolist (buffer (erc-buffer-list))
(with-current-buffer buffer
(define-erc-module imenu nil
"Simple Imenu integration for ERC."
((add-hook 'erc-mode-hook #'erc-imenu-setup)
- (unless erc--updating-modules-p (erc-buffer-filter #'erc-imenu-setup)))
+ (unless erc--updating-modules-p (erc-buffer-do #'erc-imenu-setup)))
((remove-hook 'erc-mode-hook #'erc-imenu-setup)
(erc-with-all-buffers-of-server nil nil
(when erc-imenu--create-index-function
((add-hook 'erc-insert-modify-hook #'erc-match-message 'append)
(add-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec)
(unless erc--updating-modules-p
- (erc-buffer-filter #'erc-match--modify-invisibility-spec))
+ (erc-buffer-do #'erc-match--modify-invisibility-spec))
(erc--modify-local-map t "C-c C-k" #'erc-go-to-log-matches-buffer))
((remove-hook 'erc-insert-modify-hook #'erc-match-message)
(remove-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec)
(add-hook 'erc-mode-hook #'erc-stamp--recover-on-reconnect)
(add-hook 'erc--pre-clear-functions #'erc-stamp--reset-on-clear)
(unless erc--updating-modules-p
- (erc-buffer-filter #'erc-munge-invisibility-spec)))
+ (erc-buffer-do #'erc-munge-invisibility-spec)))
((remove-hook 'erc-mode-hook #'erc-munge-invisibility-spec)
(remove-hook 'erc-insert-modify-hook #'erc-add-timestamp)
(remove-hook 'erc-send-modify-hook #'erc-add-timestamp)
(defun erc-buffer-filter (predicate &optional proc)
"Return a list of `erc-mode' buffers matching certain criteria.
-PREDICATE is a function executed with each buffer, if it returns t, that buffer
-is considered a valid match.
+Call PREDICATE without arguments in all ERC buffers or only those
+belonging to a non-nil PROC. Expect it to return non-nil in
+buffers that should be included in the returned list.
PROC is either an `erc-server-process', identifying a certain
server connection, or nil which means all open connections."
(erc--buffer-p buf predicate proc)))
(buffer-list)))))
+(defalias 'erc-buffer-do 'erc-buffer-filter
+ "Call FUNCTION in all ERC buffers or only those for PROC.
+Expect users to prefer this alias to `erc-buffer-filter' in cases
+where the latter would only be called for effect and its return
+value thrown away.
+
+\(fn FUNCTION &optional PROC)")
+
(defun erc-buffer-list (&optional predicate proc)
"Return a list of ERC buffers.
PREDICATE is a function which executes with every buffer satisfying
the predicate. If PREDICATE is passed as nil, return a list of all ERC
buffers. If PROC is given, the buffers local variable `erc-server-process'
needs to match PROC."
- (unless predicate
- (setq predicate (lambda () t)))
- (erc-buffer-filter predicate proc))
+ (erc-buffer-filter (or predicate #'always) proc))
(define-obsolete-function-alias 'erc-iswitchb #'erc-switch-to-buffer "25.1")
(defun erc--switch-to-buffer (&optional arg)