* doc/misc/erc.texi: Bump version to 5.5.0.29.1.
* etc/ERC-NEWS: Don't hype bugged option `erc-reconnect-display'.
* lisp/erc/erc-dcc.el (erc-dcc-do-GET-command): Add comment explaining
parsing bug in ERC 5.5 (bug#62444).
* lisp/erc/erc-networks.el (erc-networks-on-MOTD-end): Mention known
/MOTD bug in error notice so people don't waste energy reporting
it (bug#62151).
* lisp/erc/erc.el: Change Version header to 5.5.0.29.1. Don't bother
updating the `customize-package-emacs-version-alist' entry
because no option defaults are affected.
(erc-version): Change version to 5.5.0.29.1.
(erc-reconnect-display, erc-query-on-unjoined-chan-privmsg): Add
warning to doc strings and `custom-set' functions. It's believed that
these bugs degrade the user experience significantly enough to warrant
such mentions (bug#62833).
(erc-query): Fix erroneous redirect string in deprecation spec.
Do not merge to master.
* doc/misc/erc.texi: Update ERCVER to 5.5.
* lisp/erc/erc.el: Increment main version header to 5.5. Update
Compat version in package-requires header to 29.1.3.4. Update
`customize-package-emacs-version-alist' entry by mapping ERC 5.5 to
Emacs 29.1.
(erc-version): Update value to 5.5.
* doc/misc/erc.texi: Mention in various places that ERC is also
available from GNU ELPA.
* etc/ERC-NEWS: Mention Compat dependency and shorten title for
auth-source section.
* lisp/erc/erc-backend.el: (erc-server-reconnect-function,
erc-tags-format): Update package version to 5.5.
(erc--parse-message-tags): Downcase warning "type" to remain
consistent with all other ERC warnings.
* lisp/erc/erc-button.el: (erc-button-alist): Change package-version
to 5.5.
* lisp/erc/erc-match.el (erc-match-quote-when-adding): Update package
version to 5.5.
* lisp/erc/erc-sasl.el: Mention actual info node in Commentary.
(erc-sasl): Update package version to 5.5.
(erc-sasl-password): Reword doc string.
(erc-sasl-auth-source-function): Capitalize "info" in doc string.
* lisp/erc/erc-services.el (erc-auth-source-services-function): Update
package version to 5.5. Capitalize "info" in doc string. Change
choice type from const to function-item.
* lisp/erc/erc.el (erc-password): Capitalize "info" in doc string.
(erc-inhibit-multiline-input, erc-ask-about-multiline-input,
erc-prompt-hidden, erc-hide-prompt, erc-unhide-query-prompt,
erc-join-buffer, erc-reconnect-display, erc-kill-server-hook,
erc-kill-channel-hook, erc-kill-buffer-hook,
erc-url-connect-function): Update package version to 5.5.
(erc-auth-source-server-function, erc-auth-source-join-function):
Update package version to 5.5. Change choice type from const to
function-item. Capitalize "info" in doc string.
(erc-tls): Capitalize "info" in doc string.
* lisp/erc/erc.el: Commit c2d657e7c4
"Move ERC's core dependencies to a separate file" ironed out ERC's
interwoven dependencies for the better but didn't cleanly sidestep the
goodies interdependency, specifically with regard to custom options.
This reverts the tiny portion impacting this aspect by once again
requiring `erc-goodies' at the very end of ERC's main library. Special
thanks to Libera.Chat user jrm for reporting this bug.
* lisp/erc/erc-common.el (define-erc-module): Add symbol property
`erc-module' to minor modes defined as part of a module.
* lisp/erc/erc.el (erc--merge-local-modes): Be more conservative when
persisting local minor-mode state across ERC sessions. User and
third-party modes that were not defined via `define-erc-modules'
should be left alone.
(erc-open): Run major-mode hooks and enable minor modes after prompt
has been set up. This ensures that module-setup code can access a
fully initialized `erc-input-marker'.
* test/lisp/erc/erc-tests.el (erc--merge-local-modes): Add mocks for
`erc-module' symbol property and a test case covering some foreign ERC
mode.
(define-erc-module--global, define-erc-module--local): Expect the
`erc-module' symbol property to be defined for mode symbols and
aliases. (Bug#60784.)
* lisp/erc/erc.el (erc--target-priors): New internal variable to do
for target buffers what `erc--server-reconnecting' does for server
buffers.
(erc-open): Source the state of a local module's mode variable from
its actual buffer rather than its server buffer. Additionally, make
all local variables from a prior session available to
module-activation functions and `erc-mode' hooks, even when
`erc-reuse-buffers' is nil. This bug arrived with the introduction of
"local-modules" (bug#57955).
* test/lisp/erc/erc-scenarios-base-local-modules.el
(erc-scenarios-base-local-modules--toggle-helpers): Remove useless
`with-current-buffer'.
(erc-scenarios-base-local-modules--local-var, erc--phony-sblm--enable,
erc--phony-sblm--disable, erc--phony-sblm--mode): Add fake local
module and data var for test scenario.
(erc-scenarios-base-local-modules--var-persistence) Add slightly hacky
test case with promise to improve later when splitting the file.
* lisp/erc/erc.el (erc--warn-unencrypted): New function, likely
temporary, to warn new users connecting interactively to the default
server, "irc.libara.chat", via the default non-TLS port, 6667.
(erc-select-read-args): Remove stray code from incomplete feature
introduced by bug#56514. Ensure connecting always works with default
port, which is non-TLS. Respect `erc-prompt-for-password' when user
pastes URL containing password component into "server" prompt. Maybe
add `erc--warn-unencrypted' as one-off hook for impending connection.
* test/lisp/erc/erc-tests.el (erc-select-read-args): Always expect
password prompt and sometimes a non-TLS port when `erc' called
interactively. (Bug#60428.)
* doc/misc/erc.texi: Add linkable note in Modules chapter about some
modules being required. Also tweak markup in auth-source section.
* etc/ERC-NEWS: Mention the special role of `networks'.
* lisp/erc/erc-backend.el (erc--server-post-connect-hook): Add
internal hook for core modules to perform post-network-process,
pre-protocol config validation even when they haven't been loaded.
(erc--register-connection): Run `erc--server-post-connect-hook'.
* lisp/erc/erc-networks.el (erc-networks--bouncer-targets,
erc-networks-on-MOTD-end): Fix comments and doc strings. Also change
former from constant to internal variable in case adjustment needed
between releases.
(erc-networks--warn-on-connect): New function to warn about the
`networks' module being absent from `erc-modules'. This could
probably run at any time up to and including when the logical IRC
connection is established, but doing so at the process/protocol
boundary seems ideal.
* lisp/erc/erc-sasl.el (erc--register-connection): Defer to base
method instead of calling `erc-login' explicitly.
* lisp/erc/erc.el (erc-generate-new-buffer-name): Don't reconcile
buffer names when networks module not in play.
(erc-format-target-and/or-network): Don't assume networks module
loaded.
* test/lisp/erc/erc-scenarios-base-unstable.el:
(erc-scenarios-networks-no-module): New test.
* test/lisp/erc/resources/networks/no-module/basic.eld: New test data
file. (Bug#60331.)
* lisp/erc/erc-compat.el: Do what was supposed to be done by
75f26646d4 "; Be nicer when updating
browse-url var in erc-compat". This is the less harmful version of
that patch (from bug#59976#8) but without the cl-lib requirement since
users may not want to load the main ERC library right away.
* lisp/erc/erc.el: Clarify some comments regarding the core API.
* lisp/erc/erc-networks.el
(erc-networks-rename-surviving-target-buffer): Don't kill a surviving
target buffer when another, non-target buffer, possibly not even
belonging to ERC, already exists and sports the target's name.
(erc-networks--reconcile-buffer-names): Always append a network-ID
suffix to a target buffer's name if another buffer of that name
already exists. (Bug#59976.)
* lisp/erc/erc.el (erc, erc-tls): Revise `:id' portion of doc strings.
Thanks to Mike Kazantsev for the suggestion and for filing this bug
and helping solve it.
* test/lisp/erc/erc-networks-tests.el:
(erc-networks-rename-surviving-target-buffer--query-non-target): Add
new test.
* test/lisp/erc/erc-scenarios-base-association-query.el: New file.
* test/lisp/erc/resources/base/assoc/queries/netnick.eld: New file.
* test/lisp/erc/resources/base/assoc/queries/non-erc.eld: New file.
* lisp/erc/erc-common.el (erc-downcase): Use case table for
`erc-downcase' so that case conversions are limited to the ASCII
interval.
* lisp/erc/erc.el (erc-casemapping--rfc1459-strict,
erc--casemapping-rfc1459): Make these case tables instead of
translation tables. The functions in case-table.el modify the
standard syntax table, but that doesn't seem to make sense here,
right?
* test/lisp/erc/erc-tests.el (erc-downcase): Add cases showing
mappings outside of the ASCII range. (Bug#59976.)
* lisp/erc/erc.el (erc-generate-new-buffer-name): Despite what it says
in the documentation, only symbols were being accepted as valid `:id'
entry-point arguments. This uses the interned `princ' representation
of the argument instead.
* test/lisp/erc/erc-scenarios-base-netid-samenet.el
(erc-scenarios-common--base-network-id-same-network): Randomly specify
a string for the ID param instead of a non-nil symbol when opening a
new connection.
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common-assert-initial-buf-name): Adjust helper to allow
for non-symbol IDs. (Bug#59976.)
* lisp/erc/erc.el (erc-open): Simplify `old-vars' expression.
(erc--compute-server-password): Only compute a server password when
first connecting. For compatibility, this respects third-party code
that expects session passwords in target buffers when initially
non-nil.
* test/lisp/erc/erc-scenarios-services-misc.el
(erc-scenarios-services-auth-source-reconnect): Add new test.
* test/lisp/erc/resources/services/auth-source/recon.eld: Add new test
data file. (Bug#59858.)
* doc/misc/erc.texi: Move auth-source description from the Password
subheading of the Advanced chapter's Connecting section to the new
Integrations section as a new node, Auth-Source, and give it a bit
more structure. Fix various misuses of xref vs. pxref. Convert URL
subheading to subsection and add anchor. Prefer "backend" as a single
word, based on usage in other manuals. Also replace loud "warning" in
SASL troubleshooting section.
* etc/ERC-NEWS: Re-link auth-source mention.
* lisp/erc/erc-sasl.el (erc-sasl-auth-source-function): Update info
node in doc string.
* lisp/erc/erc-services.el (erc-auth-source-services-function):
Re-link auth-source info node in doc string.
* lisp/erc/erc.el (erc-password, erc-auth-source-server-function,
erc-auth-source-join-function): Re-link auth-source info node in doc
strings.
* lisp/erc/erc-backend.el (erc-session-password): Add comment
explaining type is now string, nil, or function.
* lisp/erc/erc-compat.el (erc-compat--29-auth-source-pass-search):
Use obfuscation from auth-source function when available.
* lisp/erc/erc-sasl.el (erc-sasl--read-password,
erc-server-AUTHENTICATE): Use `erc--unfun'.
* lisp/erc/erc-services.el (erc-nickserv-get-password,
erc-nickserv-send-identify): Use `erc--unfun'.
* lisp/erc/erc.el (erc--unfun): New function for unwrapping a
password couched in a getter.
(erc--debug-irc-protocol-mask-secrets): Add variable to indicate
whether to mask passwords in debug logs.
(erc--mask-secrets): New function to swap masked secret with question
marks in debug logs.
(erc-log-irc-protocol): Conditionally mask secrets when
`erc--debug-irc-protocol-mask-secrets' is non-nil.
(erc--auth-source-search): Don't unwrap secret from function before
returning.
(erc-server-join-channel, erc-login): Use `erc--unfun'.
* test/lisp/erc/erc-services-tests.el
(erc-services-tests--wrap-search): Add helper for `erc--unfun'.
(erc-services-tests--auth-source-standard,
erc-services-tests--auth-source-announced,
erc-services-tests--auth-source-overrides, erc-nickserv-get-password):
Use `erc--unfun'.
* test/lisp/erc/erc-tests.el (erc--debug-irc-protocol-mask-secrets):
Add test for masking secrets with `erc--unfun' and friends.
* doc/misc/erc.texi: Add SASL section in Advanced Usage chapter to
document the new SASL module.
* etc/ERC-NEWS: Mention addition of erc-sasl module for SASL support.
* lisp/erc/erc-compat.el
(erc-compat--29-sasl-scram-construct-gs2-header,
erc-compat--29-sasl-scram-client-first-message,
erc-compat--29-sasl-scram--client-final-message): Fix encoding bug and
add minimal authorization support with copies of SASL functions
introduced in Emacs 29.
* lisp/erc/erc.el (erc-modules): Add `sasl'.
* lisp/erc/erc-sasl.el: New file (bug#29108).
* test/lisp/erc/erc-sasl-tests.el: New file.
* test/lisp/erc/erc-scenarios-sasl.el: New file.
* test/lisp/erc/resources/sasl/plain-failed.eld: New file.
* test/lisp/erc/resources/sasl/plain.eld: New file.
* test/lisp/erc/resources/sasl/scram-sha-1.eld: New file.
* test/lisp/erc/resources/sasl/scram-sha-256.eld: New file.
* test/lisp/erc/resources/sasl/external.eld: New file.
* doc/misc/erc.texi: Mention local modules in Modules chapter.
* etc/ERC-NEWS: Mention changes to `erc-update-modules'.
* lisp/erc/erc.el (erc-migrate-modules): Add some missing mappings.
(erc-modules): When a user removes a module, disable it and kill its
local variable in all ERC buffers.
(erc-update-modules): Move body of `erc-update-modules' to new
internal function.
(erc--update-modules): Add new function, a renamed and slightly
modified version of `erc-update-modules'. Specifically, change return
value from nil to a list of minor-mode commands for local modules.
Use `custom-variable-p' to detect flavor.
(erc--merge-local-modes): Add helper for finding local modules
already active as minor modes in an ERC buffer.
(erc-open): Replace `erc-update-modules' with `erc--update-modules'.
Defer enabling of local modules via `erc--update-modules' until after
buffer is initialized with other local vars. Also defer major-mode
hooks so they can detect things like whether the buffer is a server or
target buffer. Also ensure local module setup code can detect when
`erc-open' was called with a non-nil `erc--server-reconnecting'.
* lisp/erc/erc-common.el (erc--module-name-migrations,
erc--features-to-modules, erc--modules-to-features): Add alists of
old-to-new module names to support module-name migrations.
(erc--assemble-toggle): Add new helper for constructing mode toggles,
like `erc-sasl-enable'.
(define-erc-modules): Defer to `erc--assemble-toggle' to create toggle
commands.
(erc--normalize-module-symbol): Add helper for `erc-migrate-modules'.
* lisp/erc/erc-goodies.el: Require cl-lib.
* test/lisp/erc/erc-tests.el (erc-migrate-modules,
erc--update-modules): Add rudimentary unit tests asserting correct
module-name mappings.
(erc--merge-local-modes): Add test for helper.
(define-erc-module--global, define-erc-module--local): Add tests
asserting module-creation macro. (Bug#57955.)
* lisp/erc/erc-backend.el (erc--server-reconnecting): Mention expected
non-nil value type in doc string.
(erc-server-connect): Don't set `erc--server-reconnecting'.
(erc-server--reconnect): Let-bind `erc--server-reconnecting' instead
of setting it locally in the server buffer. Set it to an alist
containing the current buffer's local variables.
(erc-process-sentinel-2): Don't set `erc--server-reconnect'.
* lisp/erc/erc.el (erc--cmd-reconnect): Clean up some assertions.
(Bug#57955.)
* lisp/erc/erc-networks.el (erc-networks--id-given): Accept a null
argument.
(erc-networks--id-on-connect): Remove unused function.
(erc-networks--id-equal-p): Add method for comparing initialized and
unset IDs.
(erc-networks--update-server-identity): Ensure `erc-networks--id' is
set before continuing search.
(erc-networks--init-identity): Don't assume `erc-networks--id' is
non-nil. Add branch condition to reload ID on non-nil case.
(erc-networks-on-MOTD-end): Let init-ID function handle renaming of
server buffer.
* lisp/erc/erc.el (erc-open): For continued sessions, try copying over
the last network ID.
(erc--auth-source-determine-params-default): Don't expect a network ID
to have been initialized.
(erc-set-current-nick): When connected, reload network ID. Leave
comment warning that it may be unneeded.
* lisp/erc/erc-backend.el (erc-server-NICK, erc-server-433): Unless
already connected, schedule ID reload when server rejects or mandates
a nick change.
* test/lisp/erc/erc-scenarios-base-association-nick.el
(erc-scenarios-base-association-nick-bumped,
erc-scenarios-base-association-nick-bumped-mandated-renick): Update to
reflect more liberal association behavior when renamed by IRCd.
* doc/misc/erc.texi: Add new Integrations section to the info manual
under Advanced Usage.
* etc/ERC-NEWS: Add new section mentioning improved UX when clicking
on irc:// links.
* lisp/erc/erc.el (erc-handle-irc-url): Add optional "scheme"
parameter. Fix `erc-open' invocation so that the server buffer is
named correctly by deferring to a new customizable opener. Arrange
for JOINing a channel in a manner similar to ERC's autojoin module.
(erc-url-connect-function): Add new option for creating a new ERC
connection based on info parsed from a URL.
(erc--url-default-connect-function): New function to serve as an
interactive-only fallback when a user hasn't specified a URL connect
function.
* lisp/erc/erc-compat.el (erc-compat--29-browse-url--irc): Add new
compatibility function for `browse-url-irc' and include it in
`browse-url-default-handlers' on Emacs versions below 29.
* test/lisp/erc/erc-tests.el (erc-tests--make-server-buf,
erc-tests--make-client-buf): Add helpers for creating dummy ERC
buffers.
(erc-handle-irc-url): Add test.
* test/lisp/erc/erc-scenarios-misc.el (erc-scenarios-handle-irc-url):
Add new test.
* test/lisp/erc/resources/join/legacy/foonet.eld: Relax
timeout. (Bug#56514.)
* lisp/erc/erc.el (erc-normalize-port): Add standard IANA port-name
mappings for 6667 and 6697.
(erc-open): Add note to doc string explaining that params `connect'
and `channel' are mutually exclusive.
(erc-tls): Call `erc-compute-port' with override.
(erc-compute-port): Call `erc-normalize-port' with result'.
* test/lisp/erc/erc-tests.el (erc-tls): Add simplistic test focusing
on default parameters. (Bug#56514.)
* lisp/erc/erc-backend.el (erc--server-connect-dumb-ipv6-regexp): Add
liberal pattern for matching bracketed IPv6 addresses.
(erc-server-connect): Remove brackets from IPv6 hosts before
connecting.
* lisp/erc/erc.el (erc--ensure-url): Add compat adapter to massage
partial URLs given as input that may be missing the scheme:// portion.
(erc-select-read-args): Keep bracketed IPv6 hosts
intact. Make this function fully URL-aware (was only partially so).
Accept optional `input' argument.
* lisp/erc/erc-tests.el (erc-tests--ipv6-examples,
erc--server-connect-dumb-ipv6-regexp, erc-select-read-args): Add test
reading user input during interactive invocations of entry points.
(Bug#56514.)
* lisp/erc/erc-backend.el (erc--server-reconnect-timer): New variable.
(erc-server-reconnect-function): New user option.
(erc-process-sentinel-2): Display time remaining until next
reconnection attempt. Also remove condition case and move bulk of
else condition logic to `erc-schedule-reconnect'. More importantly,
no longer set `erc--server-reconnecting here').
(erc-server-connect): Initialize `erc--server-reconnect-timer' to nil.
(erc-server-reconnect): Set `erc-server--reconnecting' here.
(erc--mode-line-process-reconnecting): New constant to store value for
"reconnect" state of `mode-line-process'.
(erc--cancel-auto-reconnect-timer): New function to cancel
auto-reconnect timer and print message.
(erc-schedule-reconnect): New function for scheduling another
reconnect attempt.
* lisp/erc/erc.el (erc-open): Only update mode line for target
buffers. For server buffers, let `erc-login' and/or process sentinels
take care of it.
(erc--cmd-reconnect, erc-cmd-RECONNECT): Rename latter to former, a
new function, but repurpose existing to recognize newly allowed
additional arguments and act accordingly. In new internal function,
cancel an existing auto-reconnect timer, if any, before proceeding.
Defer to `erc-server-reconnect' to set `erc--server-reconnecting'.
Fix `with-suppressed-warnings' form.
(erc-update-mode-line-buffer): Show "reconnecting in Ns" for
`mode-line-process' when awaiting an automatic reconnect attempt.
(erc-message-english-reconnecting,
erc-message-english-reconnect-canceled): Add new message functions to
English catalog.
* lisp/erc/erc-pcomplete.el (pcomplete/erc-mode/RECONNECT): Perform
completion for newly subcommand-aware `erc-cmd-RECONNECT'.
* lisp/erc/erc-scenarios-base-reconnect
(erc-scenarios-base-cancel-reconnect): Add new test case for canceling
reconnect timers. (Bug#58840.)
* doc/misc/erc.texi: Mention that the auth-source-pass backend is
supported.
* lisp/erc/erc-compat.el (erc-compat--29-auth-source-pass-search,
erc-compat--29-auth-source-pass--build-result-many,
erc-compat--29-auth-source-pass--retrieve-parsed,
erc-compat--29-auth-source-pass-backend-parse,
erc-compat--auth-source-backend-parser-functions): Adapt some yet
unreleased functions from auth-source-pass that mimic the netrc
backend, and add forward declarations to support them.
* lisp/erc/erc.el (erc--auth-source-search): Use own auth-source-pass
erc-compat backend.
* test/lisp/erc/erc-services-tests.el
(erc-join-tests--auth-source-pass-entries): Remove useless items.
(erc--auth-source-search--pass-standard,
erc--auth-source-search--pass-announced,
erc--auth-source-search--pass-overrides): Remove `ert-skip' guard.
(Bug#58985.)
* lisp/erc/erc.el (erc-format-message): Although not mentioned in its
log message, commit 5281946fbf "Make
format-spec accept function substitutions" also fixed a bug involving
the `ignore-missing' parameter of `format-spec'. Until now, ERC has
been relying on the old behavior to gracefully handle malformed server
messages. This commit tries to regain that functionality.
* lisp/erc/erc.el (erc-join-buffer): Change default value to `bury'.
(erc-setup-buffer): Make `window-noselect' behave more like its
description and abstain from ever replacing the current buffer.
* test/lisp/erc/erc-scenarios-base-reconnect.el
(erc-scenarios-common-base-reconnect-options): Update helper to handle
new default value for option `erc-join-buffer'.
(erc-scenarios-base-reconnect-options--buffer): Update and rename
function `erc-scenarios-base-reconnect-options--default'.
(erc-scenarios-base-reconnect-options--default): Update and rename
function `erc-scenarios-base-reconnect-options--bury'.
* etc/ERC-NEWS: Update existing display-buffers section for 5.5.
(Bug#51753)
* lisp/erc/erc-match.el (erc-match-quote-when-adding) Add new option
to quote new items added to match lists.
(erc-add-entry-to-list): Add optional `alt' parameter indicating
whether to flip the behavior indicated by
`erc-match-quote-when-adding'.
(erc-add-pal, erc-add-fool, erc-add-keyword, erc-add-dangerous-host):
Pass universal arg to `erc-add-entry-to-list' as `alt' argument.
(erc-match-pal-p, erc-match-fool-p, erc-match-keyword-p,
erc-match-dangerous-host-p): Don't bother matching when list is nil.
* lisp/erc/erc.el (erc-list-match (lst str): Join input list as regexp
union instead of looping over items.
* etc/ERC-NEWS: Update misc-UX section for 5.5.
* test/lisp/erc/erc-match-tests.el: New file. (Bug#56450)
* lisp/erc/erc.el (erc-inhibit-multiline-input): Add option to cap the
number of lines to be sent before admonishing the user.
(erc-ask-about-multiline-input): Add option to ask instead of warning
user when `erc-inhibit-multiline-input' is reached.
(erc--check-prompt-input-for-excess-lines): Add validator to possibly
warn when too many lines are submitted for transmission.
* test/lisp/erc/erc-tests.el
(erc--check-prompt-input-for-excess-lines): Add test.
(Bug#54536)
* lisp/erc/erc.el (erc--pre-send-split-functions): Add new internal
hook allowing members to revise individual lines before sending. This
was created with an eye toward possibly exporting it publicly as a
customizable option.
(erc-last-input-time): Tweak meaning of variable to match likely
original intent, which is that it's only updated on successful calls
to `erc-send-current-line'.
(erc--discard-trailing-multiline-nulls): Conditionally truncate list
of lines to be sent, skipping trailing blanks. This constitutes a
behavioral change. But, considering the nature of the bug being
fixed, it is thought to be justified.
(erc--input-split): Add new internal struct containing split input
lines and flag for command detection.
(erc--input-line-delim-regexp): Add regex var for splitting multiline
prompt input.
(erc--blank-in-multiline-p): Add helper for detecting blank lines.
(erc--check-prompt-input-for-multiline-blanks,
erc--check-prompt-input-for-point-in-bounds,
erc--check-prompt-input-for-running-process): New functions to
encapsulate logic for various pre-flight idiot checks.
(erc--check-prompt-input-functions): Add new hook for validating
prompt input prior to clearing it, internal for now.
(erc-send-current-line): Pre-screen for blank lines and bail out if
necessary.
(erc-send-input): Add optional param to skip checking for blank lines.
Call hook `erc--pre-send-split-functions'.
* test/lisp/erc/erc-tests.el (erc-ring-previous-command): Use new test
helper.
(erc--input-line-delim-regexp,
erc--blank-in-multiline-input-p): Add tests.
(erc-tests--send-prep, erc-tests--set-fake-server-process,
erc-tests--with-process-input-spy): Add test helpers.
(erc--check-prompt-input-functions, erc-send-current-line,
erc-send-whitespace-lines): Add tests.
(Bug#54536)
* lisp/erc/erc.el (erc-send-input-line): Restore remedial single-space
padding to ensure empty messages typed at the prompt without an
explicit /msg aren't rejected by the server. This behavior is only
noticeable when `erc-send-whitespace-lines' is active.
* test/lisp/erc/erc-tests.el (erc-process-input-line): Add trailing
newline to more correctly simulate how it's actually called by
`erc-send-input'. (Bug#50008)
* lisp/erc/erc.el (erc-password): Deprecate variable only used by
`erc-select-read-args'. Server passwords are primarily used as
surrogates for other forms of authentication. Such use is common but
nonstandard and often discouraged in favor of the de facto standard,
SASL. Folks in the habit of invoking `erc(-tls)' interactively should
be encouraged to use auth-source instead.
(erc-select-read-args): Before this change, `erc-select-read-args'
offered to use the value of a non-nil `erc-password' as the :password
argument for `erc' and `erc-tls', referring to it as the "default"
password. And when `erc-prompt-for-password' was nil and
`erc-password' wasn't, the latter was passed along unconditionally.
This only further complicated an already confusing situation for new
users, who in most cases shouldn't be worried about sending a PASS
command at all. Until SASL arrives, they should provide server
passwords manually or learn to use auth-source.
(erc-auth-source-server-function, erc-auth-source-join-function): New
user options for retrieving a password externally, ostensibly by
calling `auth-source-search'.
(erc--auth-source-determine-params-defaults): New helper for
`erc--auth-source-search' with potential for exporting publicly in the
future. Favors :host and :port fields above others. Prioritizes
network IDs over announced servers and dialed endpoints.
(erc--auth-source-determine-params-merge): Add new function for
merging contextual and default parameters. This is another contender
for possible exporting.
(erc--auth-source-search): New function for consulting auth-source and
sorting the result as filtered and prioritized by the previously
mentioned helpers.
(erc-auth-source-search): New function to serve as default
value for auth-source query-function options.
(erc-server-join-channel): Use user option for consulting auth-source
facility. Also accept nil for first argument (instead of server).
(erc-cmd-JOIN): Use above-mentioned facilities when joining new
channel. Omit server when calling `erc-server-join-channel'. Don't
filter target buffers twice. Don't call `switch-to-buffer', which
would create phantom buffers with names like target/server that were
never used. IOW, only switch to existing target buffers.
(erc--compute-server-password): Add new helper function for
determining password.
(erc-open, erc-determine-parameters): Move password figuring from the
first to the latter.
* lisp/erc/erc-services.el
(erc-auth-source-services-function): Add new option for consulting
auth-source in a NickServ context.
(erc-nickserv-get-password): Pass network-context ID, when looking up
password in `erc-nickserv-passwords' and when formatting prompt for
user input.
(erc-nickserv-passwords): Add comment to custom option definition type
tag.
* test/lisp/erc/erc-services-tests.el: Add new test file for above
changes. For now, stash auth-source-related tests here until a
suitable home can be found.
* lisp/erc/erc-join.el (erc-autojoin--join): Don't pass session-like
entity from `erc-autojoin-channels-alist' match to
`erc-server-join-channel'. Allow that function to decide for itself
which host to look up if necessary.
* test/lisp/erc/resources/base/auth-source/foonet.eld: New file.
* test/lisp/erc/resources/base/auth-source/nopass.eld: New file.
* test/lisp/erc/resources/erc-scenarios-common.el: New file.
* test/lisp/erc/resources/services/auth-source/libera.eld: New file.
* test/lisp/erc/erc-scenarios-auth-source.el: New file.
* test/lisp/erc/erc-scenarios-base-reuse-buffers.el: New file.
* test/lisp/erc/erc-scenarios-join-auth-source.el: New file.
* test/lisp/erc/resources/base/reuse-buffers/channel/barnet.eld: New file.
* test/lisp/erc/resources/base/reuse-buffers/channel/foonet.eld: New file.
* test/lisp/erc/resources/join/auth-source/foonet.eld: New file.
(Bug#48598)
* lisp/erc/erc-backend.el (erc-server-JOIN): Use `erc--open-target'
instead of `erc-join'.
(erc-server-PRIVMSG): Don't call `erc-auto-query' at all, and instead
borrow the portion of its logic that detects when a query buffer
should be created instead of a channel buffer.
* lisp/erc/erc.el (erc-cmd-QUERY): Update the mode line explicitly
after calling `erc-query' in case it's needed after `erc-setup-buffer'
runs. Simplify.
(erc-query, erc--open-target): Replace uses of `erc-query'
with `erc--open-target' and make the former obsolete. Don't call
`erc-update-mode-line' because `erc-open' already does that.
(erc-auto-query): Make this function obsolete. It was previously only
used in erc-backend.el and only sewed confusion.
(erc-query-on-unjoined-chan-privmsg): Add note questioning its role.
It was previously only used by the now deprecated `erc-auto-query'.
* test/lisp/erc/erc-scenarios-misc.el
(erc-scenarios-base-mask-target-routing): Add test for server masks.
* test/lisp/erc/resources/base/mask-target-routing/foonet.eld: New file.
* lisp/erc/erc.el (erc-kill-buffer-function): Don't add hook when
loading file. Move to major-mode setup and make buffer-local instead.
Depends on tests in bug#48598.
* lisp/erc/erc-backend.el (erc-server-connected): Revise doc string.
(erc-server-reconnect, erc-server-JOIN): Reuse original ID param from
the first connection when calling `erc-open'.
(erc-server-NICK): Apply same name generation process used by
`erc-open'; except here, do so for the purpose of "re-nicking".
Update network identifier and maybe buffer names after a user's own
nick changes.
* lisp/erc/erc-networks.el (erc-networks--id, erc-networks--id-fixed,
erc-networks--id-qualifying): Define new set of structs to contain all
info relevant to specifying a unique identifier for a network context.
Add a new variable `erc-networks--id' to store a local reference to a
`erc-networks--id' object, shared among all buffers in a logical
session.
(erc-networks--id-given, erc-networks--id-create,
erc-networks--id-on-connect, erc-networks--id--equal-p,
erc-networks--id-qualifying-init-parts,
erc-networks--id-qualifying-init-symbol,
erc-networks--id-qualifying-grow-id,
erc-networks--id-qualifying-reset-id,
erc-networks--id-qualifying-prefix-length,
erc-networks--id-qualifying-update, erc-networks--id-reload,
erc-networks--id-ensure-comparable, erc-networks--id-sort-buffers):
Add new functions to support management of `erc-networks--id' struct
instances.
(erc-networks--id-sep): New variable for to help when formatting
buffer names.
(erc-obsolete-var): Define new generic context rewriter.
(erc-networks-shrink-ids-and-buffer-names,
erc-networks--refresh-buffer-names,
erc-networks--shrink-ids-and-buffer-names-any): Add functions to
reassess all network IDs and shrink them if necessary along with
affected buffer names. Also add function to rename buffers so that
their names are unique. Register these on all three of ERC's
kill-buffer hooks because an orphaned target buffer is enough to keep
its session alive.
(erc-networks-rename-surviving-target-buffer): Add new function that
renames a target buffer when it becomes the sole bearer of a name
based on a target that has become unique across all sessions and, in
most cases, all networks. IOW, remove the @NETWORK-ID suffix from the
last remaining channel or query buffer after its namesakes have all
been killed off. Register this function with ERC's target-related
kill-buffer hooks.
(erc-networks--examine-targets): Add new utility function that visits
all ERC buffers and runs callbacks when a buffer-name collision is
encountered.
(erc-networks--qualified-sep): Add constant to hold separator between
target and suffix.
(erc-networks--construct-target-buffer-name,
erc-networks--ensure-unique-target-buffer-name,
erc-networks--ensure-unique-server-buffer-name,
erc-networks--maybe-update-buffer-name): Add helpers to support
`erc-networks--reconcile-buffer-names' and friends.
(erc-networks--reconcile-buffer-names): Add new buffer-naming strategy
function and helper for `erc-generate-new-buffer-name' that only run
in target buffers.
(erc-determine-network, erc-networks--determine): Deprecate former and
partially replace with latter, which demotes RPL_ISUPPORT-derived
NETWORK name to fallback in favor of known `erc-networks-alist'
members as part of shift to network-based connection-identity policy.
Return sentinel on failure. Expect `erc-server-announced-name' to be
set, and signal when it's not.
(erc-networks--name-missing-sentinel): Value returned when new
function `erc-networks--determine' fails to find network name. The
rationale for not making this customizable is that the value signifies
the pathological case where a user of an uncommon IRC setup has not
yet set a mapping from announced- to network name. And the chances of
there being multiple unknown networks is low.
(erc-set-network-name, erc-networks--set-name): Deprecate former and
partially replace with latter. Ding with helpful message, and don't
set `erc-network' when network name is not found.
(erc-networks--ensure-announced): Add new fallback function to ensure
`erc-server-announced-name' is set. Register with post-MOTD hooks.
(erc-unset-network-name): Deprecate function unused internally.
(erc-networks--insert-transplanted-content,
erc-networks--reclaim-orphaned-target-buffers,
erc-networks--copy-over-server-buffer-contents,
erc--update-server-identity): Add helpers for
`erc-networks--rename-server-buffer'. The first re-associates all
existing target buffers that ought to be owned by the new server
process. The second grabs buffer text from an old, dead server buffer
before killing it. It then inserts that text above everything in the
current, replacement server buffer. The other two massage the IDs of
related sessions, possibly renaming them as well. They may also
uniquify the current session's network ID.
(erc-networks--init-identity): Add new function to perform one-time
session-related setup. This could be combined with
`erc-set-network-name'.
(erc-networks--rename-server-buffer): Add new function to replace
`erc-unset-network-name' as default `erc-disconnected-hook' member;
renames server buffers once network is discovered; added to/removed
from `erc-after-connect' hook on `erc-networks' minor mode.
(erc-networks--bouncer-targets): Add constant to hold target symbols
of well known bouncer-configuration bots.
(erc-networks-on-MOTD-end): Add primary network-context handler to run
on 376/422 functions, just before logical connection is officially
established.
(erc-networks-enable, erc-networks-mode): Register main network-setup
handler with 376/422 hooks.
* lisp/erc/erc.el (erc-rename-buffers): Change this option's default
to t, remove the only instance where it's actually used, and make it
an obsolete variable.
(erc-reuse-buffers): Make this an obsolete variable, but take pains to
ensure its pre-28.1 behavior is preserved. That is, undo the
regression involving unwanted automatic reassociation of channel
buffers during joins, which arrived in ERC 5.4 and effectively
inverted the meaning of this variable, when nil, for channel buffers,
all without accompanying documentation or announcement.
(erc-generate-new-buffer-name): Replace current policy of appending a
slash and the invocation host name. Favor instead temporary names for
server buffers and network-based uniquifying suffixes for channels and
query buffers. Fall back to the TCP host:port<n> convention when
necessary. Accept additional optional params after the others.
(erc-get-buffer-create): Don't generate a new name when reconnecting,
just return the same buffer. `erc-open' starts from a clean slate
anyway, so this just keeps things simple. Also add optional params.
(erc-open): Add new ID param to for a network identifier explicitly
passed to an entry-point command. This is stored in the `given' slot
of the `erc-network--id' object. Also initialize the latter in new
connections and otherwise copy it over. As part of the push to recast
erc-networks.el as an essential library, set `erc-network' explicitly,
when known, rather than via hooks.
(erc, erc-tls): Add new ID keyword parameter and pass it to
`erc-open'.
(erc-log-irc-protocol): Use `erc--network-id' instead of the function
`erc-network' to determine preferred peer name.
(erc-format-target-and/or-network): This is called frequently from
mode-line updates, so renaming buffers here is not ideal. Instead, do
so in `erc-networks--rename-server-buffer'.
(erc-kill-server-hook): Add `erc-networks-shrink-ids-and-buffer-names'
as default member.
(erc-kill-channel-hook, erc-kill-buffer-hook): Add
`erc-networks-shrink-ids-and-buffer-names' and
`erc-networks-rename-surviving-target-buffer' as default member.
* test/lisp/erc/erc-tests.el (erc-log-irc-protocol): Use network-ID
focused internal API.
* test/lisp/erc/erc-networks-tests.el: Add new file that includes
tests for the above network-ID focused functions.
See bug#48598 for background on all of the above.
* lisp/erc/erc.el (erc-default-recipients, erc-default-target):
Explain that the variable has fallen out of favor and that the
function may have been used historically by third-party code for
detecting channel subscription status, even though that's never been
the case internally since at least the adoption of version control.
Recommend newer alternatives.
(erc--current-buffer-joined-p): Add possibly temporary predicate for
detecting whether a buffer's target is a joined channel. The existing
means are inconsistent, as discussed in bug#48598. The mere fact that
they are disparate is unfriendly to new contributors. For example, in
the function `erc-autojoin-channels', the `process-status' of the
`erc-server-process' is used to detect whether a buffer needs joining.
That's fine in that specific situation, but it won't work elsewhere.
And neither will checking whether `erc-default-target' is nil, so
long as `erc-delete-default-channel' and friends remain in play.
(erc-add-default-channel, erc-delete-default-channel, erc-add-query,
erc-delete-query): Deprecate these helpers, which rely on an unused
usage variant of `erc-default-recipients'.
* lisp/erc/erc-services.el: remove stray `erc-default-recipients'
declaration.
* lisp/erc/erc-backend.el (erc-server-NICK, erc-server-JOIN,
erc-server-KICK, erc-server-PART): wrap deprecated helpers to suppress
warnings.
* lisp/erc/erc-join.el (erc-autojoin-channels): Use helper to detect
whether a buffer needs joining. Prefer this to server liveliness, as
explained above.
* lisp/erc/erc.el (erc--target, erc--target-channel,
erc--target-channel-local): Add new structs to hold info on a buffer's
target; stored in a local variable of the same name.
(erc--target-from-string): Add standalone constructor for
`erc--target'.
(erc--default-target): Add temporary internal getter to ease
transition to `erc--target' everywhere.
(erc-open): Create above items in non-server buffers.
* lisp/erc/erc-backend.el (erc-server-NICK): Recreate `erc--target'
when necessary.
* lisp/erc/erc.el (erc--valid-local-channel-p): Add internal helper to
determine whether an IRC channel is local according to its network's
CHANTYPES ISUPPORT parameter.
* test/lisp/erc/erc-tests.el (erc--valid-local-channel-p): Add test
for this helper.