all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "J.P." <jp@neverwas.me>
To: 67220@debbugs.gnu.org
Cc: emacs-erc@gnu.org
Subject: bug#67220: 30.0.50; ERC 5.6: Prefer parameter-driven MODE processing in ERC
Date: Sat, 13 Apr 2024 15:17:00 -0700	[thread overview]
Message-ID: <877ch09acj.fsf__25935.2406299271$1713046705$gmane$org@neverwas.me> (raw)
In-Reply-To: <87o7cabou8.fsf@neverwas.me> (J. P.'s message of "Tue, 20 Feb 2024 17:14:39 -0800")

[-- Attachment #1: Type: text/plain, Size: 731 bytes --]

"J.P." <jp@neverwas.me> writes:

>> I think it's worth correcting this in ERC 5.6. Proposed changes
>> attached. (The first patch is unrelated.)
>
> These changes now live on master as
>
>   3d87e343276 * Use modern fallback for channel name detection in ERC
>   25d15391f26 * Normalize ISUPPORT params with empty values in ERC
>
> If anyone experiences new difficulties related to detecting channel
> names, these are likely to blame.

A regression involving `erc-query-buffer-p' has surfaced that basically
makes the function unsuable in many situations. The root cause is some
combination of stupdiity and laziness on my part, as usual. The attached
patch should fix the issue. Thanks to Libera user mekeor for reporting
this.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-regression-involving-erc-query-buffer-p.patch --]
[-- Type: text/x-patch, Size: 2967 bytes --]

From 415bde2403aa9564d138d0f504df36e6f9e956a3 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <jp@neverwas.me>
Date: Sat, 13 Apr 2024 14:58:13 -0700
Subject: [PATCH] Fix regression involving erc-query-buffer-p

* lisp/erc/erc.el (erc-query-buffer-p): Don't return non-nil in
non-ERC buffers and server buffers, and continue to honor string
arguments.  The regression was introduced by 3d87e343 "Use modern
fallback for channel name detection in ERC".  Thanks to Libera user
mekeor for reporting this bug.
* test/lisp/erc/erc-tests.el (erc-query-buffer-p): New test.
(Bug#67220)
---
 lisp/erc/erc.el            |  9 +++++++--
 test/lisp/erc/erc-tests.el | 29 +++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index 4ed77655f19..ecb884fb1ab 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -1662,8 +1662,13 @@ erc-open-server-buffer-p
 
 (defun erc-query-buffer-p (&optional buffer)
   "Return non-nil if BUFFER is an ERC query buffer.
-If BUFFER is nil, the current buffer is used."
-  (not (erc-channel-p (or buffer (current-buffer)))))
+If BUFFER is nil, use the current buffer."
+  (and-let* ((target (if buffer
+                         (progn (when (stringp buffer)
+                                  (setq buffer (get-buffer buffer)))
+                                (buffer-local-value 'erc--target buffer))
+                       erc--target)))
+    (not (erc--target-channel-p target))))
 
 (defun erc-ison-p (nick)
   "Return non-nil if NICK is online."
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 22432a68034..52c6f8e75b6 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1227,6 +1227,35 @@ erc-channel-p
 
   (erc-tests-common-kill-buffers))
 
+(ert-deftest erc-query-buffer-p ()
+  ;; Nil in a non-ERC buffer.
+  (should-not (erc-query-buffer-p))
+  (should-not (erc-query-buffer-p (current-buffer)))
+  (should-not (erc-query-buffer-p (buffer-name)))
+
+  (erc-tests-common-make-server-buf)
+  ;; Nil in a server buffer.
+  (should-not (erc-query-buffer-p))
+  (should-not (erc-query-buffer-p (current-buffer)))
+  (should-not (erc-query-buffer-p (buffer-name)))
+
+  ;; Nil in a channel buffer.
+  (with-current-buffer (erc--open-target "#chan")
+    (should-not (erc-query-buffer-p))
+    (should-not (erc-query-buffer-p (current-buffer)))
+    (should-not (erc-query-buffer-p (buffer-name))))
+
+  ;; Non-nil in a query buffer.
+  (with-current-buffer (erc--open-target "alice")
+    (should (erc-query-buffer-p))
+    (should (erc-query-buffer-p (current-buffer)))
+    (should (erc-query-buffer-p (buffer-name))))
+
+  (should (erc-query-buffer-p (get-buffer "alice")))
+  (should (erc-query-buffer-p "alice"))
+
+  (erc-tests-common-kill-buffers))
+
 (ert-deftest erc--valid-local-channel-p ()
   (ert-info ("Local channels not supported")
     (let ((erc--isupport-params (make-hash-table)))
-- 
2.44.0


  parent reply	other threads:[~2024-04-13 22:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-16  2:13 bug#67220: 30.0.50; ERC 5.6: Prefer parameter-driven MODE processing in ERC J.P.
2023-11-17 18:30 ` J.P.
     [not found] ` <87zfzcnsg1.fsf@neverwas.me>
2023-11-18 22:14   ` J.P.
     [not found]   ` <87il5yogj7.fsf@neverwas.me>
2023-11-21 14:30     ` J.P.
     [not found]     ` <87il5vfab9.fsf@neverwas.me>
2023-11-24 22:13       ` J.P.
2024-01-19  1:21 ` J.P.
     [not found] ` <87mst2unhi.fsf@neverwas.me>
2024-01-25 21:45   ` J.P.
2024-02-14  1:45 ` J.P.
     [not found] ` <871q9fhl8j.fsf@neverwas.me>
2024-02-21  1:14   ` J.P.
     [not found]   ` <87o7cabou8.fsf@neverwas.me>
2024-04-13 22:17     ` J.P. [this message]
     [not found]     ` <877ch09acj.fsf@neverwas.me>
2024-04-23 22:35       ` J.P.

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='877ch09acj.fsf__25935.2406299271$1713046705$gmane$org@neverwas.me' \
    --to=jp@neverwas.me \
    --cc=67220@debbugs.gnu.org \
    --cc=emacs-erc@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.