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: Wed, 11 Aug 2021 06:57:26 -0700 Message-ID: <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="21841"; 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 Wed Aug 11 15:58:54 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 1mDokp-0005CN-8w for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 15:58:47 +0200 Original-Received: from localhost ([::1]:39064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDoko-000808-9C for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 Aug 2021 09:58:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58184) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDok6-0005P3-Mc for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 09:58:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDok6-0008Pp-Bp for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 09:58:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mDok6-0005zR-8B for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 09:58: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: Wed, 11 Aug 2021 13:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50005 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.162869026322992 (code B ref -1); Wed, 11 Aug 2021 13:58:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 11 Aug 2021 13:57:43 +0000 Original-Received: from localhost ([127.0.0.1]:36179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDojm-0005yl-JS for submit@debbugs.gnu.org; Wed, 11 Aug 2021 09:57:43 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:49568) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mDojl-0005yd-3e for submit@debbugs.gnu.org; Wed, 11 Aug 2021 09:57:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDojk-00048L-RB for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 09:57:40 -0400 Original-Received: from mail-108-mta175.mxroute.com ([136.175.108.175]:40257) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mDoji-00080e-C1 for bug-gnu-emacs@gnu.org; Wed, 11 Aug 2021 09:57:40 -0400 Original-Received: from filter004.mxroute.com ([149.28.56.236] filter004.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta175.mxroute.com (ZoneMTA) with ESMTPSA id 17b3580f7d300074ba.001 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Wed, 11 Aug 2021 13:57:29 +0000 X-Zone-Loop: da776d27cd3e802a930ec36ade0511e277d48f4466df X-Originating-IP: [149.28.56.236] X-AuthUser: masked@neverwas.me X-Zone-Spam-Resolution: no action X-Zone-Spam-Status: No, score=-0.1, required=15, tests=[ARC_NA=0, NEURAL_SPAM=0, FROM_HAS_DN=0, HAS_ATTACHMENT=0, FROM_EQ_ENVFROM=0, MIME_TRACE=0, MIME_GOOD=-0.1, RCPT_COUNT_ONE=0, MID_RHS_MATCH_FROM=0, RCVD_COUNT_ZERO=0, TO_DN_NONE=0] Received-SPF: pass client-ip=136.175.108.175; envelope-from=jp@neverwas.me; helo=mail-108-mta175.mxroute.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:211598 Archived-At: --=-=-= Content-Type: text/plain Tags: patch Hi, the commit log for this bug mentions two warnings. The one concerning regexp-opt.el doesn't actually show up in make output currently, but it's emitted under fairly mundane circumstances. Moreover, the actual offending function, `erc-lurker-maybe-trim', doesn't really behave as advertised, so I've tried tackling that here as well. As for `erc-with-all-buffers-of-server': out of deference to existing code, I've left the "eval only once" stuff in play, even though a quick survey of use cases at various call sites shows it's not really needed. I also didn't bother with other possible tweaks, like (for example) using `macroexp-copyable-p' for the `macroexp-let2' test param, which would omit the superfluous let-binding of symbol expressions (variables) in expanded code. I guess I figured if we're going that far, we might as well replace the call to `erc-buffer-filter' with a `dolist' or similar or even redo the filter itself (and friends) completely. But if you buy into any of the nonsense I've been spewing in other bugs [1], then you'll agree all of that can wait because ERC has more pressing concerns. Thanks. P.S. I also snuck in a tweak to an existing ERC test so it'll play nicer with others; hope that's okay. [1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=48598 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=49860 In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.30, cairo version 1.17.4) of 2021-08-09 built on localhost Repository revision: aeec97fae0ccfcc4dc406a5e0e4c0a94b834cac4 Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12011000 System Description: Fedora 34 (Workstation Edition) Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM GTK3 ZLIB Important settings: value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t indent-tabs-mode: t transient-mark-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail rmail-loaddefs auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map text-property-search time-date subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils iso-transl tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote threads dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting cairo move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 51538 6355) (symbols 48 6607 1) (strings 32 18255 1368) (string-bytes 1 616656) (vectors 16 14292) (vector-slots 8 185252 10153) (floats 8 21 47) (intervals 56 205 0) (buffers 992 10)) --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-mistake-in-test-for-erc-ring-previous-command.patch >From 88475f43ed983a348f9ae3c4e143745e04919065 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 Content-Disposition: attachment; filename=0002-Fix-a-couple-byte-compiler-warnings-in-erc.el.patch >From d54b99bb722616189d1939038b5d2993f9ccfd6f 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 * lisp/erc/erc.el (erc-lurker-maybe-trim): Prevent warning from showing up in third party code re library not loaded. 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. (erc-with-all-buffers-of-server): Mute byte compiler warning saying return value unused. Leave possible optimizations for some future person. --- lisp/erc/erc.el | 25 ++++-------- test/lisp/erc/erc-tests.el | 79 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 18 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 73202016ba..16a08a6823 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))) (define-obsolete-function-alias 'erc-iswitchb #'erc-switch-to-buffer "25.1") (defun erc--switch-to-buffer (&optional arg) @@ -2572,7 +2563,7 @@ erc-lurker-trim-nicks (defcustom erc-lurker-ignore-chars "`_" "Characters at the end of a nick to strip for activity tracking purposes. - +The usual rules regarding ]^\\ and - in \"character alternatives\ apply. See also `erc-lurker-trim-nicks'." :group 'erc-lurker :type 'string) @@ -2583,9 +2574,7 @@ 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 (concat "[" erc-lurker-ignore-chars "]+")) nick)) (defcustom erc-lurker-hide-list nil diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 9efcf4a703..b1d2c2a06a 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el @@ -47,6 +47,85 @@ erc--read-time-period (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "1d"))) (should (equal (erc--read-time-period "foo: ") 86400)))) +(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= (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 (= 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= "nick`" (erc-lurker-maybe-trim "nick`"))) + + (setq erc-lurker-trim-nicks t) + (should (string= "nick" (erc-lurker-maybe-trim "nick`"))) + (should (string= "ni`_ck" (erc-lurker-maybe-trim "ni`_ck__``"))) + + (setq erc-lurker-ignore-chars "_-`") ; 95-96 + (should (string= "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 -- 2.31.1 --=-=-=--