From 801306861920124a4ca68d925829f957d748aa37 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 11 Sep 2023 21:21:42 -0700 Subject: [PATCH 3/4] [5.6] Skip erc-ignored-user-p when erc-ignore-list is empty * lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't bother with `erc-ignored-user-p' and `erc-ignored-reply-p' when their associated options are null. * 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. * test/lisp/erc/erc-scenarios-base-buffer-display.el (erc-scenarios-base-buffer-display--defwin-recbury-intbuf): Extend timeout. --- lisp/erc/erc-backend.el | 7 ++++--- lisp/erc/erc-common.el | 5 +++-- lisp/erc/erc.el | 2 ++ test/lisp/erc/erc-scenarios-base-buffer-display.el | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 9e121ec1e92..596e504b39f 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -113,6 +113,8 @@ erc-ensure-target-buffer-on-privmsg (defvar erc-format-nick-function) (defvar erc-format-query-as-channel-p) (defvar erc-hide-prompt) +(defvar erc-ignore-list) +(defvar erc-ignore-reply-list) (defvar erc-input-marker) (defvar erc-insert-marker) (defvar erc-invitation) @@ -1902,8 +1904,8 @@ erc--server-determine-join-display-context (cmd (erc-response.command parsed)) (tgt (car (erc-response.command-args parsed))) (msg (erc-response.contents parsed))) - (if (or (erc-ignored-user-p sender-spec) - (erc-ignored-reply-p msg tgt proc)) + (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)) (let* ((sndr (erc-parse-user sender-spec)) @@ -1918,7 +1920,6 @@ erc--server-determine-join-display-context ,@erc--display-context)) 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 67c2cf8535b..e680666156b 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -472,8 +472,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 07ba32d1cca..a65739cf861 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -6832,6 +6832,8 @@ erc-delete-query (setq erc-default-recipients d2) (error "Current target is not a QUERY")))) +;; FIXME spin this ignore stuff off into its own module, 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'. diff --git a/test/lisp/erc/erc-scenarios-base-buffer-display.el b/test/lisp/erc/erc-scenarios-base-buffer-display.el index df292a8c113..ef544b4dcd0 100644 --- a/test/lisp/erc/erc-scenarios-base-buffer-display.el +++ b/test/lisp/erc/erc-scenarios-base-buffer-display.el @@ -109,7 +109,7 @@ erc-scenarios-base-buffer-display--defwin-recbury-intbuf (with-current-buffer (erc-d-t-wait-for 10 (get-buffer "#spam")) (should (eq (window-buffer) (get-buffer "#spam"))) ;; Option `buffer' replaces entire window (no split) - (erc-d-t-wait-for 5 (frame-root-window-p (selected-window))))))))) + (erc-d-t-wait-for 10 (frame-root-window-p (selected-window))))))))) (ert-deftest erc-scenarios-base-buffer-display--defwino-recbury-intbuf () :tags '(:expensive-test) -- 2.41.0