From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#50005: 28.0.50; silence a couple byte-compiler warnings in ERC Date: Sun, 12 Sep 2021 05:03:40 -0700 Message-ID: <87fsuavw4j.fsf@neverwas.me> References: <87v94cjd89.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28707"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) To: 50005@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Sep 12 14:04:29 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mPODl-0007ES-7T for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Sep 2021 14:04:29 +0200 Original-Received: from localhost ([::1]:51588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mPODh-0003u2-UL for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 12 Sep 2021 08:04:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mPODK-0003tq-Rz for bug-gnu-emacs@gnu.org; Sun, 12 Sep 2021 08:04:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58875) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mPODK-0005WJ-Di for bug-gnu-emacs@gnu.org; Sun, 12 Sep 2021 08:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mPODK-0004gm-9d for bug-gnu-emacs@gnu.org; Sun, 12 Sep 2021 08:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 12 Sep 2021 12:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50005 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 50005-submit@debbugs.gnu.org id=B50005.163144823518011 (code B ref 50005); Sun, 12 Sep 2021 12:04:02 +0000 Original-Received: (at 50005) by debbugs.gnu.org; 12 Sep 2021 12:03:55 +0000 Original-Received: from localhost ([127.0.0.1]:42188 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPODD-0004gQ-6l for submit@debbugs.gnu.org; Sun, 12 Sep 2021 08:03:55 -0400 Original-Received: from mail-108-mta5.mxroute.com ([136.175.108.5]:45035) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mPOD8-0004g6-2t for 50005@debbugs.gnu.org; Sun, 12 Sep 2021 08:03:53 -0400 Original-Received: from filter004.mxroute.com ([149.28.56.236] filter004.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta5.mxroute.com (ZoneMTA) with ESMTPSA id 17bd9e44cd800074ba.001 for <50005@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sun, 12 Sep 2021 12:03:42 +0000 X-Zone-Loop: d3504d4ce85054c3399e349449a2875faec86fed9225 X-Originating-IP: [149.28.56.236] In-Reply-To: <87v94cjd89.fsf@neverwas.me> (J. P.'s message of "Wed, 11 Aug 2021 06:57:26 -0700") X-AuthUser: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:214131 Archived-At: --=-=-= Content-Type: text/plain v3. Added a missing test dependency. (Note: the first attachment just shows the changes from the last set and is not itself a patch.) --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0000-v2-v3.diff Content-Transfer-Encoding: quoted-printable >From 1b55dcb828093774ebbb83888901644a8c73a67d Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Sun, 12 Sep 2021 02:41:39 -0700 Subject: [PATCH 0/2] *** SUBJECT HERE *** MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit *** BLURB HERE *** F. Jason Park (2): Fix mistake in test for erc-ring-previous-command Fix a couple byte-compiler warnings in erc.el lisp/erc/erc.el | 25 ++++------- test/lisp/erc/erc-tests.el | 91 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 95 insertions(+), 21 deletions(-) Range-diff: -: ---------- > 1: d3cbfba5d6 Fix mistake in test for erc-ring-previous-c= ommand 1: 8a85439cc7 ! 2: 1b55dcb828 Fix a couple byte-compiler warnings in erc.= el @@ Commit message Fix a couple byte-compiler warnings in erc.el =20=20=20=20=20 * lisp/erc/erc.el (erc-lurker-maybe-trim): Prevent warning from - showing up in third-party code re library not loaded by autoloading - rx.el when needed. Also make function do what it claims to. It now - only removes trailing chars typically appended automatically for - uniquifying purposes when a desired nick is already taken. Special - thanks to Mattias Engdeg=C3=A5rd for making this more - respectable. Bug#50005. + showing up in third-party code using this function by autoloading + rx.el when needed. Remove trailing chars appended for uniquifying + purposes when a nick is already taken. Special thanks to Mattias + Engdeg=C3=A5rd for making this more respectable. Bug#50005. =20=20=20=20=20 (erc-with-all-buffers-of-server): Mute byte compiler warning saying - return value unused. Leave possible optimizations for some future - person. + return value unused. Leave optimizations for future contributors. + + * test/lisp/erc/erc-tests.el: add tests for the above and require + erc-networks. =20=20=20=20=20 ## lisp/erc/erc.el ## @@ lisp/erc/erc.el: erc-with-all-buffers-of-server @@ lisp/erc/erc.el: erc-lurker-maybe-trim (defcustom erc-lurker-hide-list nil =20=20=20=20=20 ## test/lisp/erc/erc-tests.el ## +@@ + (require 'ert) + (require 'erc) + (require 'erc-ring) ++(require 'erc-networks) +=20 + (ert-deftest erc--read-time-period () + (cl-letf (((symbol-function 'read-string) (lambda (&rest _) ""))) @@ test/lisp/erc/erc-tests.el: erc--read-time-period (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "1d"))) (should (equal (erc--read-time-period "foo: ") 86400)))) --=20 2.31.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-mistake-in-test-for-erc-ring-previous-command.patch >From d3cbfba5d6efe49aa25f7d7dc550e54a36e0d5a1 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 13 May 2021 02:27:08 -0700 Subject: [PATCH 1/2] Fix mistake in test for erc-ring-previous-command * test/lisp/erc/erc-tests.el (erc-ring-previous-command): The variable erc-send-completed-hook was previously set to nil permanently, which would affect other tests. --- test/lisp/erc/erc-tests.el | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index d13397274a..9efcf4a703 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -61,13 +61,16 @@ erc-ring-previous-command (with-current-buffer (get-buffer-create "*#fake*") (erc-mode) (insert "\n\n") - (setq erc-input-marker (make-marker) ; these are all local - erc-insert-marker (make-marker) - erc-send-completed-hook nil) + (should-not (local-variable-if-set-p 'erc-send-completed-hook)) + (set (make-local-variable 'erc-send-completed-hook) nil) ; skip t (globals) + (setq erc-input-marker (make-marker) + erc-insert-marker (make-marker)) (set-marker erc-insert-marker (point-max)) (erc-display-prompt) (should (= (point) erc-input-marker)) - (add-hook 'erc-pre-send-functions #'erc-add-to-input-ring nil t) + ;; Just in case erc-ring-mode is already on + (setq-local erc-pre-send-functions nil) + (add-hook 'erc-pre-send-functions #'erc-add-to-input-ring) ;; (cl-letf (((symbol-function 'erc-process-input-line) (lambda (&rest _) -- 2.31.1 --=-=-= Content-Type: text/x-patch; charset=utf-8 Content-Disposition: attachment; filename=0002-Fix-a-couple-byte-compiler-warnings-in-erc.el.patch Content-Transfer-Encoding: quoted-printable >From 1b55dcb828093774ebbb83888901644a8c73a67d Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Wed, 21 Jul 2021 00:26:38 -0700 Subject: [PATCH 2/2] Fix a couple byte-compiler warnings in erc.el MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit * lisp/erc/erc.el (erc-lurker-maybe-trim): Prevent warning from showing up in third-party code using this function by autoloading rx.el when needed. Remove trailing chars appended for uniquifying purposes when a nick is already taken. Special thanks to Mattias Engdeg=C3=A5rd for making this more respectable. Bug#50005. (erc-with-all-buffers-of-server): Mute byte compiler warning saying return value unused. Leave optimizations for future contributors. * test/lisp/erc/erc-tests.el: add tests for the above and require erc-networks. --- lisp/erc/erc.el | 25 ++++-------- test/lisp/erc/erc-tests.el | 80 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 17 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index e0fda41f8e..0c1db585b8 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1732,20 +1732,11 @@ erc-with-all-buffers-of-server where PRED matches or in all buffers of the server process if PRED is nil." (declare (indent 1) (debug (form form body))) - ;; Make the evaluation have the correct order - (let ((pre (make-symbol "pre")) - (pro (make-symbol "pro"))) - `(let* ((,pro ,process) - (,pre ,pred) - (res (mapcar (lambda (buffer) - (with-current-buffer buffer - ,@forms)) - (erc-buffer-list ,pre - ,pro)))) - ;; Silence the byte-compiler by binding the result of mapcar to - ;; a variable. - (ignore res) - res))) + (macroexp-let2 nil pred pred + `(erc-buffer-filter (lambda () + (when (or (not ,pred) (funcall ,pred)) + ,@forms)) + ,process))) =20 (define-obsolete-function-alias 'erc-iswitchb #'erc-switch-to-buffer "25.1= ") (defun erc--switch-to-buffer (&optional arg) @@ -2583,9 +2574,9 @@ erc-lurker-maybe-trim Returns NICK unmodified unless `erc-lurker-trim-nicks' is non-nil." (if erc-lurker-trim-nicks - (replace-regexp-in-string - (regexp-opt-charset (string-to-list erc-lurker-ignore-chars)) - "" nick) + (string-trim-right + nick (rx-to-string `(+ (in ,@(string-to-list + erc-lurker-ignore-chars))))) nick)) =20 (defcustom erc-lurker-hide-list nil diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 9efcf4a703..0533d04491 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -24,6 +24,7 @@ (require 'ert) (require 'erc) (require 'erc-ring) +(require 'erc-networks) =20 (ert-deftest erc--read-time-period () (cl-letf (((symbol-function 'read-string) (lambda (&rest _) ""))) @@ -47,6 +48,85 @@ erc--read-time-period (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "1d"))) (should (equal (erc--read-time-period "foo: ") 86400)))) =20 +(ert-deftest erc-with-all-buffers-of-server () + (let (proc-exnet + proc-onet + erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook) + + (with-current-buffer (get-buffer-create "OtherNet") + (erc-mode) + (setq proc-onet (start-process "sleep" (current-buffer) "sleep" "1") + erc-server-process proc-onet + erc-network 'OtherNet) + (set-process-query-on-exit-flag erc-server-process nil)) + + (with-current-buffer (get-buffer-create "ExampleNet") + (erc-mode) + (setq proc-exnet (start-process "sleep" (current-buffer) "sleep" "1") + erc-server-process proc-exnet + erc-network 'ExampleNet) + (set-process-query-on-exit-flag erc-server-process nil)) + + (with-current-buffer (get-buffer-create "#foo") + (erc-mode) + (setq erc-server-process proc-exnet) + (setq erc-default-recipients '("#foo"))) + + (with-current-buffer (get-buffer-create "#spam") + (erc-mode) + (setq erc-server-process proc-onet) + (setq erc-default-recipients '("#spam"))) + + (with-current-buffer (get-buffer-create "#bar") + (erc-mode) + (setq erc-server-process proc-onet) + (setq erc-default-recipients '("#bar"))) + + (with-current-buffer (get-buffer-create "#baz") + (erc-mode) + (setq erc-server-process proc-exnet) + (setq erc-default-recipients '("#baz"))) + + (should (eq (get-buffer-process "ExampleNet") proc-exnet)) + (erc-with-all-buffers-of-server (get-buffer-process "ExampleNet") + nil + (kill-buffer)) + + (should-not (get-buffer "ExampleNet")) + (should-not (get-buffer "#foo")) + (should-not (get-buffer "#baz")) + (should (get-buffer "OtherNet")) + (should (get-buffer "#bar")) + (should (get-buffer "#spam")) + + (let* ((test (lambda () (not (string=3D (buffer-name) "#spam")))) + (calls 0) + (get-test (lambda () (cl-incf calls) test))) + + (erc-with-all-buffers-of-server proc-onet + (funcall get-test) + (kill-buffer)) + + (should (=3D calls 1))) + + (should-not (get-buffer "OtherNet")) + (should-not (get-buffer "#bar")) + (should (get-buffer "#spam")) + (kill-buffer "#spam"))) + +(ert-deftest erc-lurker-maybe-trim () + (let (erc-lurker-trim-nicks + (erc-lurker-ignore-chars "_`")) + + (should (string=3D "nick`" (erc-lurker-maybe-trim "nick`"))) + + (setq erc-lurker-trim-nicks t) + (should (string=3D "nick" (erc-lurker-maybe-trim "nick`"))) + (should (string=3D "ni`_ck" (erc-lurker-maybe-trim "ni`_ck__``"))) + + (setq erc-lurker-ignore-chars "_-`") ; set of chars, not character alts + (should (string=3D "nick" (erc-lurker-maybe-trim "nick-_`"))))) + (ert-deftest erc-ring-previous-command-base-case () (ert-info ("Create ring when nonexistent and do nothing") (let (erc-input-ring --=20 2.31.1 --=-=-=--