Subject: Re: bug#62833: 30.0.50; ERC 5.6: Rethink buffer-display options and behavior

From: "J.P." <[email-masked]>
Date: Sun, 04 Jun 2023 07:52:20 -0700

Hi Eli,

This is regarding a small prospective change to ERC on Emacs 29 that's
been discussed here and there over the past few months [1]. Basically,
ERC has long defaulted to displaying new buffers in the currently
selected window, with the symbol `buffer' representing this display
style in various user options. Because new buffers are often created as
a result of server-initiated messages or feature-driven automated
mechanisms, like "autojoin", they can suddenly appear unceremoniously
and steal keyboard input. For this reason, `buffer' was deemed a
nuisance (if not a hazard), and the default was changed to a no-op in
ERC 5.5 [2].

However, since then, a faint but steady murmur of discontent has been
thrumming among mostly new and casual users, who've described ERC as
being "broken" in this regard because it provides little to no obvious
feedback following certain fundamental user actions, like connecting to
a server or joining a channel. IOW, users can't tell whether ERC is
responding to a command they've just issued, despite subtle cues, like
activity in the echo area and the mode line.

The solution to all this isn't straightforward, and we're making headway
on it for ERC 5.6. In the meantime, I'm wondering if we might consider
appeasing these disgruntled users somehow. Normally, I'd prefer just
reverting back to `buffer', but because much has been made about its
potential for causing mayhem via unintended sharing, I'm thinking we
might change the default in Emacs 29 to `window-noselect'. This value
tells ERC to show new buffers in a sibling window of the same vertical
combination. Such a change would be accompanied by a bump in the patch
component of our already 29-specific ERC version, bringing us from
5.5.0.29.1 to 5.5.1.29.1. I believe the attached patch does what I've
described.

Thanks,
J.P.

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60428#31
    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62833#17
    https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62833#23

[2] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=51753#71

>From 420a95e855b4e01e57dc1a97dbeac06f6a4af779 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <[email-masked]>
Date: Fri, 19 May 2023 08:10:49 -0700
Subject: [PATCH] Add erc-join-buffer hotfix in new version 5.5.1.29.1

* doc/misc/erc.texi: Change ERCVER to 5.5.1.29.1.
* etc/ERC-NEWS: Add new section for 5.5.1.29.1, and mention the
default for `erc-join-buffer' has changed to `window-noselect'.
* lisp/erc/erc.el (erc-version): Update version to 5.5.1.29.1, and do
the same for the file's Version header.  The rationale for
incrementing the third, "patch" component is that the trailing "29.1"
portion merely indicates (1) that this exact version of ERC is
Emacs-only and does not exist on GNU ELPA and (2) that it contains at
most trivial changes, such as comments and documentation, atop its
corresponding GNU ELPA release, if any (here, there is no such
5.5.1 counterpart on ELPA).
(erc-join-buffer): Change default to `window-noselect'.
* test/lisp/erc/erc-scenarios-base-association.el
(erc-scenarios-networks-merge-server-track): Bind `erc-join-buffer'
to `bury'.
* test/lisp/erc/erc-scenarios-base-reconnect.el
(erc-scenarios-base-reconnect-options--buffer,
erc-scenarios-base-reconnect-options--default): Skip tests because
option `erc-reconnect-display' is bugged in ERC 5.5.  (Bug#62833)
---
 doc/misc/erc.texi                               |  2 +-
 etc/ERC-NEWS                                    | 12 ++++++++++--
 lisp/erc/erc.el                                 |  6 +++---
 test/lisp/erc/erc-scenarios-base-association.el |  1 +
 test/lisp/erc/erc-scenarios-base-reconnect.el   |  4 ++--
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/doc/misc/erc.texi b/doc/misc/erc.texi
index 7f26b9ed181..ca294788c57 100644
--- a/doc/misc/erc.texi
+++ b/doc/misc/erc.texi
@@ -2,7 +2,7 @@
 @c %**start of header
 @setfilename ../../info/erc.info
 @settitle ERC Manual
-@set ERCVER 5.5.0.29.1
+@set ERCVER 5.5.1.29.1
 @set ERCDIST as distributed with Emacs @value{EMACSVER}
 @include docstyle.texi
 @syncodeindex fn cp
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index 9672a86345b..684ff932d34 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -11,6 +11,16 @@ This file is about changes in ERC, the powerful, modular, and
 extensible IRC (Internet Relay Chat) client distributed with
 GNU Emacs since Emacs version 22.1.
 
+
+* Changes in ERC 5.5.1.29.1
+
+** Option 'erc-join-buffer' defaults to 'window-noselect'.
+In response to pushback about the switch from 'buffer' to 'bury', this
+option's default has once again been changed, this time exclusively
+for Emacs 29.  ERC now attempts to display a new or reassociated
+buffer in another window, creating one if necessary, even when the
+selected window already displays the buffer.
+
 
 * Changes in ERC 5.5
 
@@ -80,8 +90,6 @@ can now opt for an improved 'window-noselect' instead.  It still
 offers the same pronounced visual cue when connecting and joining but
 now avoids any hijacking of the active window as well.
 
-(Edited for ERC 5.5.0.29.1 in Emacs 29.1.)
-
 ** Improved handling of multiline prompt input.
 This means better detection and handling of intervening and trailing
 blanks when 'erc-send-whitespace-lines' is active.  New options have
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index c7e1645ec26..688bd1c4fd4 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -12,7 +12,7 @@
 ;;               David Edmondson ([email-masked])
 ;;               Michael Olson ([email-masked])
 ;;               Kelvin White ([email-masked])
-;; Version: 5.5.0.29.1
+;; Version: 5.5.1.29.1
 ;; Package-Requires: ((emacs "27.1") (compat "29.1.3.4"))
 ;; Keywords: IRC, chat, client, Internet
 ;; URL: https://www.gnu.org/software/emacs/erc.html
@@ -71,7 +71,7 @@
 (require 'iso8601)
 (eval-when-compile (require 'subr-x) (require 'url-parse))
 
-(defconst erc-version "5.5.0.29.1"
+(defconst erc-version "5.5.1.29.1"
   "This version of ERC.")
 
 (defvar erc-official-location
@@ -1469,7 +1469,7 @@ erc-default-port-tls
   "IRC port to use for encrypted connections if it cannot be \
 detected otherwise.")
 
-(defcustom erc-join-buffer 'bury
+(defcustom erc-join-buffer 'window-noselect
   "Determines how to display a newly created IRC buffer.
 
 The available choices are:
diff --git a/test/lisp/erc/erc-scenarios-base-association.el b/test/lisp/erc/erc-scenarios-base-association.el
index a40a4cb7550..3ac1089c541 100644
--- a/test/lisp/erc/erc-scenarios-base-association.el
+++ b/test/lisp/erc/erc-scenarios-base-association.el
@@ -207,6 +207,7 @@ erc-scenarios-networks-merge-server-track
        (dumb-server (erc-d-run "localhost" t 'track 'track))
        (port (process-contact dumb-server :service))
        (erc-server-flood-penalty 0.1)
+       (erc-join-buffer 'bury)
        (expect (erc-d-t-make-expecter)))
 
     (ert-info ("Connect")
diff --git a/test/lisp/erc/erc-scenarios-base-reconnect.el b/test/lisp/erc/erc-scenarios-base-reconnect.el
index 5b4dc549042..63ed21ba644 100644
--- a/test/lisp/erc/erc-scenarios-base-reconnect.el
+++ b/test/lisp/erc/erc-scenarios-base-reconnect.el
@@ -118,7 +118,7 @@ erc-scenarios-common--base-reconnect-options
 
 (ert-deftest erc-scenarios-base-reconnect-options--buffer ()
   :tags '(:expensive-test)
-  (should (eq erc-join-buffer 'bury))
+  (ert-skip "Feature broken in ERC 5.5")
   (should-not erc-reconnect-display)
 
   ;; FooNet (the server buffer) is not switched to because it's
@@ -138,7 +138,7 @@ erc-scenarios-base-reconnect-options--buffer
 
 (ert-deftest erc-scenarios-base-reconnect-options--default ()
   :tags '(:expensive-test)
-  (should (eq erc-join-buffer 'bury))
+  (ert-skip "Feature broken in ERC 5.5")
   (should-not erc-reconnect-display)
 
   (erc-scenarios-common--base-reconnect-options
-- 
2.40.1