From 545e0fbd648fb7129d557c8c43d87ce0fea891f5 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 11 Sep 2023 21:21:42 -0700 Subject: [PATCH 10/11] [5.6] Skip erc-ignored-user-p when erc-ignore-list is empty * lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't bother running `erc-ignored-user-p' and `erc-ignored-reply-p' when their associated options are null. The option `erc-ignore-list' is buffer-local when set, and `erc-ignored-user-p' looks for it in the server buffer. But response handlers run in server buffers anyway, so this shouldn't break anything. Also remove unneeded call to reassign trailing response contents. * lisp/erc/erc-common.el (erc-get-server-user): Rearrange so `erc-with-server-buffer' doesn't have to switch to the server buffer because `erc-downcase' can run in channels as well. * lisp/erc/erc.el (erc-ignored-user-p): Add comment. --- lisp/erc/erc-backend.el | 7 ++++--- lisp/erc/erc-common.el | 5 +++-- lisp/erc/erc.el | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index d548a788bc0..0f6f7e2d4c3 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1913,8 +1913,10 @@ erc--server-determine-join-display-context (tgt (car (erc-response.command-args parsed))) (msg (erc-response.contents parsed))) (defvar erc-minibuffer-ignored) - (if (or (erc-ignored-user-p sender-spec) - (erc-ignored-reply-p msg tgt proc)) + (defvar erc-ignore-list) + (defvar erc-ignore-reply-list) + (if (or (and erc-ignore-list (erc-ignored-user-p sender-spec)) + (and erc-ignore-reply-list (erc-ignored-reply-p msg tgt proc))) (when erc-minibuffer-ignored (message "Ignored %s from %s to %s" cmd sender-spec tgt)) (defvar erc--msg-prop-overrides) @@ -1932,7 +1934,6 @@ erc--server-determine-join-display-context ,@erc--msg-prop-overrides)) s buffer fnick) - (setf (erc-response.contents parsed) msg) (setq buffer (erc-get-buffer (if privp nick tgt) proc)) ;; Even worth checking for empty target here? (invalid anyway) (unless (or buffer noticep (string-empty-p tgt) (eq ?$ (aref tgt 0)) diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index cb820c812b3..d343a148afc 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -498,8 +498,9 @@ erc-get-channel-user (define-inline erc-get-server-user (nick) "Find NICK in the current server's `erc-server-users' hash table." (inline-letevals (nick) - (inline-quote (erc-with-server-buffer - (gethash (erc-downcase ,nick) erc-server-users))))) + (inline-quote + (gethash (erc-downcase ,nick) + (erc-with-server-buffer erc-server-users))))) (defmacro erc--with-dependent-type-match (type &rest features) "Massage Custom :type TYPE with :match function that pre-loads FEATURES." diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 8e7162fec89..4c56bc8e058 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -7737,6 +7737,8 @@ erc-delete-query (setq erc-default-recipients d2) (error "Current target is not a QUERY")))) +;; FIXME move all ignore-related functionality to its own module, +;; required and enabled by default (until some major version change). (defun erc-ignored-user-p (spec) "Return non-nil if SPEC matches something in `erc-ignore-list'. -- 2.42.0