[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master bd969326e96 04/11: Add alias erc-buffer-do for erc-buffer-filter
From: |
F. Jason Park |
Subject: |
master bd969326e96 04/11: Add alias erc-buffer-do for erc-buffer-filter |
Date: |
Mon, 12 Jun 2023 00:15:54 -0400 (EDT) |
branch: master
commit bd969326e96584249b6c140d972f7b27ab3274f6
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Add alias erc-buffer-do for erc-buffer-filter
* lisp/erc/erc-goodies.el (erc-scrolltobottom-enable,
erc-scrolltobottom-mode): Prefer `erc-buffer-do' to
`erc-buffer-filter'.
(erc-move-to-prompt-mode, erc-move-to-prompt-enable): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc-imenu.el (erc-imenu-mode, erc-imenu-enable): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc-match.el (erc-match-enable, erc-match-mode): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable): Prefer
`erc-buffer-do' to `erc-buffer-filter'.
* lisp/erc/erc.el (erc-buffer-filter): Improve doc string.
(erc-buffer-do): Add alias for new code to prefer when calling
`erc-buffer-filter' for effect. Do this because continually having to
refer back to the doc strings and implementations of the latter as
well as `erc-buffer-p', `erc-buffer-list', and co. is unproductive.
(erc-buffer-list): Use `always' as fallback predicate.
---
lisp/erc/erc-goodies.el | 6 ++----
lisp/erc/erc-imenu.el | 2 +-
lisp/erc/erc-match.el | 2 +-
lisp/erc/erc-stamp.el | 2 +-
lisp/erc/erc.el | 17 ++++++++++++-----
5 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el
index 01eae4b63c5..afc05148506 100644
--- a/lisp/erc/erc-goodies.el
+++ b/lisp/erc/erc-goodies.el
@@ -53,8 +53,7 @@ argument to `recenter'."
"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))
@@ -119,8 +118,7 @@ Put this function on `erc-insert-post-hook' and/or
`erc-send-post-hook'."
(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
diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el
index 9864d7c4042..60df4e9ac8e 100644
--- a/lisp/erc/erc-imenu.el
+++ b/lisp/erc/erc-imenu.el
@@ -139,7 +139,7 @@ Don't rely on this function, read it first!"
(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
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index 86883260413..0c58524cd9f 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -55,7 +55,7 @@ highlighted."
((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)
diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index 500f6f3c0c9..78a8b1bc100 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -168,7 +168,7 @@ from entering them and instead jump over them."
(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)
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 0349dc67dbd..d68d27e76d0 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1830,8 +1830,9 @@ If PROC is not supplied, all processes are searched."
(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."
@@ -1843,15 +1844,21 @@ 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)
- master updated (b6d48190609 -> edfbdb3f165), F. Jason Park, 2023/06/12
- master 67f7ac2bbee 05/11: Deprecate nicknames entry in erc-button-alist, F. Jason Park, 2023/06/12
- master 2daa71f9329 09/11: Don't insert prompt input before markers in ERC, F. Jason Park, 2023/06/12
- master 1c3f6aa98f5 07/11: Measure stamps pixel-wise with erc-fill-wrap, F. Jason Park, 2023/06/12
- master d880a08f959 08/11: Cement ordering of essential hook members in ERC, F. Jason Park, 2023/06/12
- master ac80e377830 02/11: ; * doc/misc/erc.texi: Fix reconnecting in SOCKS example., F. Jason Park, 2023/06/12
- master a4df7483295 01/11: Prefer emacs-news-mode in etc/ERC-NEWS, F. Jason Park, 2023/06/12
- master 56e1922281d 10/11: Revert "Add hook to regain nickname in ERC", F. Jason Park, 2023/06/12
- master bd969326e96 04/11: Add alias erc-buffer-do for erc-buffer-filter,
F. Jason Park <=
- master 0f76bed4928 03/11: ; * lisp/erc/erc.el (erc-send-input-line-function): Doc., F. Jason Park, 2023/06/12
- master e560f9af8e8 06/11: Allow ERC modules to extend erc-nick-popup-alist, F. Jason Park, 2023/06/12
- master edfbdb3f165 11/11: Define missing groups for ERC modules, F. Jason Park, 2023/06/12