1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-28 07:45:00 +00:00
Commit Graph

352 Commits

Author SHA1 Message Date
F. Jason Park
c46e93b1f5 Explain ERC 5.5 regressions in new version 5.5.0.29.1
* 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.
2023-04-26 06:21:29 -07:00
F. Jason Park
7548446194 Release ERC 5.5
* 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.
2023-03-03 13:49:18 -08:00
F. Jason Park
4eac80fcc3 ; Prepare to update ERC version 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.
2023-02-14 08:25:00 -08:00
F. Jason Park
628b624176 Don't load erc-goodies atop erc.el
* 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.
2023-01-20 05:09:29 -08:00
F. Jason Park
183e749270 Don't preserve non-module minor modes in erc-open
* 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.)
2023-01-17 06:09:08 -08:00
F. Jason Park
7b8322f628 Use correct buffer for local-module vars in erc-open
* 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.
2023-01-17 06:09:08 -08:00
F. Jason Park
bb98666d03 ; Fix wrong type in erc-ignore hide-list options
* lisp/erc/erc.el (erc-network-hide-list, erc-channel-hide-list):
Fix type in custom definition.
2023-01-10 06:34:01 -08:00
F. Jason Park
ff35ac9dfa Fix default-port regression in erc-select-read-args
* 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.)
2023-01-02 05:48:39 -08:00
Eli Zaretskii
cae528457c ; Add 2023 to copyright years. 2023-01-01 05:31:12 -05:00
F. Jason Park
2ddc480f44 Warn of absent networks module in ERC
* 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.)
2022-12-28 06:51:38 -08:00
F. Jason Park
63cdbd986b ; Really respect browse-url var in erc-compat
* 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.
2022-12-19 05:49:08 -08:00
F. Jason Park
f04680e067 Fix some naming issues involving query buffers in ERC
* 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.
2022-12-16 06:36:24 -08:00
F. Jason Park
5a9263a872 Increment erc-debug-irc-protocol-version to 2
* lisp/erc/erc.el (erc-debug-irc-protocol-version): Change version to
2 to help dependent tooling detect redacted passwords.
(erc-log-irc-protocol): Don't bother redacting incoming messages.
(Bug#59284.)
2022-12-16 06:36:23 -08:00
F. Jason Park
09c0c6b2ba Limit casemapping to appropriate ranges in ERC
* 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.)
2022-12-14 06:40:55 -08:00
F. Jason Park
44b04c0ac1 Actually accept non-symbols as IDs in erc-open
* 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.)
2022-12-14 06:40:55 -08:00
F. Jason Park
0155fc67be Respect a nil erc-session-password when reconnecting
* 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.)
2022-12-14 06:40:55 -08:00
F. Jason Park
9ac80e8a6e Add dedicated auth-source section in ERC manual
* 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.
2022-12-14 06:40:55 -08:00
F. Jason Park
56a6712bd6 ; * lisp/erc/erc.el (erc-default-target): Fix comment. 2022-12-09 06:35:36 -08:00
F. Jason Park
5258f36168
Accept functions in place of passwords in ERC
* 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.
2022-11-23 21:23:05 -05:00
F. Jason Park
ed8862c404
Add non-IRCv3 SASL module to ERC
* 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.
2022-11-23 21:14:25 -05:00
F. Jason Park
4c4936fab2
Support local ERC modules in erc-mode buffers
* 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.)
2022-11-23 19:56:31 -05:00
F. Jason Park
dc6ff142bc
Make erc--server-reconnecting non-buffer-local
* 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.)
2022-11-23 19:55:39 -05:00
F. Jason Park
da30a4908e
Don't set erc-networks--id until network is known
* 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.
2022-11-23 19:54:40 -05:00
F. Jason Park
ed5022b4ee Improve new connections in erc-handle-irc-url
* 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.)
2022-11-16 21:34:36 -08:00
F. Jason Park
77d6351d60 Default to TLS port when calling erc-tls from lisp
* 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.)
2022-11-16 21:34:36 -08:00
F. Jason Park
46c765ed09 Refactor erc-select-read-args
* 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.)
2022-11-16 21:34:36 -08:00
F. Jason Park
e7f2f6cd92 Improve auto-reconnect visibility in ERC
* 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.)
2022-11-16 21:34:36 -08:00
F. Jason Park
c5d91358b5 Support auth-source-pass in ERC
* 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.)
2022-11-16 21:34:36 -08:00
dickmao
c2d657e7c4 Move ERC's core dependencies to separate file
Asking people to order require's is about as effective
as asking kids to keep off the grass.

* lisp/erc/erc-backend.el (erc--target, erc-auto-query,
erc-channel-list, erc-channel-users, erc-default-nicks,
erc-default-recipients, erc-format-nick-function,
erc-format-query-as-channel-p, erc-hide-prompt, erc-input-marker,
erc-insert-marker, erc-invitation, erc-join-buffer,
erc-kill-buffer-on-part, erc-kill-server-buffer-on-quit, erc-log-p,
erc-minibuffer-ignored, erc-networks--id, erc-nick,
erc-nick-change-attempt-count, erc-prompt-for-channel-key,
erc-prompt-hidden, erc-reuse-buffers, erc-verbose-server-ping,
erc-whowas-on-nosuchnick): Forward-declare variables.
(erc--open-target, erc--target-from-string, erc-active-buffer,
erc-add-default-channel, erc-banlist-update, erc-buffer-filter,
erc-buffer-list-with-nick, erc-channel-begin-receiving-names,
erc-channel-end-receiving-names, erc-channel-p,
erc-channel-receive-names, erc-cmd-JOIN, erc-connection-established,
erc-current-nick, erc-current-nick-p, erc-current-time,
erc-default-target, erc-delete-default-channel,
erc-display-error-notice, erc-display-server-message,
erc-emacs-time-to-erc-time, erc-format-message,
erc-format-privmessage, erc-get-buffer, erc-handle-login,
erc-handle-user-status-change, erc-ignored-reply-p,
erc-ignored-user-p, erc-is-message-ctcp-and-not-action-p,
erc-is-message-ctcp-p, erc-log-irc-protocol, erc-login,
erc-make-notice, erc-network, erc-networks--id-given,
erc-networks--id-reload, erc-nickname-in-use, erc-parse-user,
erc-process-away, erc-process-ctcp-query, erc-query-buffer-p,
erc-remove-channel-member, erc-remove-channel-users, erc-remove-user,
erc-sec-to-time, erc-server-buffer, erc-set-active-buffer,
erc-set-current-nick, erc-set-modes, erc-time-diff, erc-trim-string,
erc-update-mode-line, erc-update-mode-line-buffer,
erc-wash-quit-reason, erc-display-message, erc-get-buffer-create,
erc-process-ctcp-reply, erc-update-channel-topic, erc-update-modes,
erc-update-user-nick, erc-open, erc-update-channel-member):
Forward-declare functions.
(erc-response): Move to lisp/erc/erc-common.el.
(erc-compat--with-memoization): Use "erc-compat-" prefixed macro.

* lisp/erc/erc-common.el: New file.  Change indentation for
`erc-with-all-buffers-of-server' from 1 to 2.

* lisp/erc/erc-compat.el (erc-compat--with-memoization): Migrate macro
from `erc-backend' and rename.

* lisp/erc/erc-goodies.el: Require `erc-common' instead of `erc'.
(erc-controls-highlight-regexp, erc-controls-remove-regexp,
erc-input-marker, erc-insert-marker, erc-server-process, erc-modules,
erc-log-p): Forward declare variables.
(erc-buffer-list, erc-error, erc-extract-command-from-line):
Forward-declare functions.

* lisp/erc/erc-networks.el (erc--target, erc-insert-marker,
erc-kill-buffer-hook, erc-kill-server-hook, erc-modules,
erc-rename-buffers, erc-reuse-buffers, erc-server-announced-name,
erc-server-connected, erc-server-parameters, erc-server-process,
erc-session-server): Forward declare variables.
(erc--default-target, erc--get-isupport-entry, erc-buffer-filter,
erc-current-nick, erc-display-error-notice, erc-error, erc-get-buffer,
erc-server-buffer, erc-server-process-alive): Forward-declare
functions.
(erc-obsolete-var): Also suppress free-variable warnings.

* lisp/erc/erc.el: Require `erc-networks', `erc-goodies', and
`erc-backend' at top of file.  Don't require `erc-compat'.
(erc--server-last-reconnect-count, erc--server-reconnecting,
erc-channel-members-changed-hook, erc-network, erc-networks--id,
erc-server-367-functions, erc-server-announced-name,
erc-server-connect-function, erc-server-connected,
erc-server-current-nick, erc-server-lag, erc-server-last-sent-time,
erc-server-process, erc-server-quitting, erc-server-reconnect-count,
erc-server-reconnecting, erc-session-client-certificate,
erc-session-connector, erc-session-port, erc-session-server,
erc-session-user-full-name) Remove superfluous forward declarations.
(erc-message-parsed, tabbar--local-hlf, motif-version-string):
Relocate forward declares to central location.
(erc-session-password): Move to `erc-backend'.
(erc-downcase, erc-with-server-buffer, erc-server-user,
erc-channel-user, erc-get-channel-user, erc-get-server-user): Move to
lisp/erc/erc-common.el.
(erc-add-server-user, erc-remove-server-user,
erc-channel-user-owner-p, erc-channel-user-admin-p,
erc-channel-user-op-p, erc-channel-user-halfop-p,
erc-channel-user-voice-p): Convert from inline functions to normal
functions.
(define-erc-module, erc--target, erc--target-channel,
erc--target-channel-local, erc-log, erc-log-aux, erc-with-buffer,
erc-with-all-buffers-of-server): Move to lisp/erc/erc-common.el.
(erc-channel-members-changed-hook): Relocate option to avoid compiler
warning.
(erc-input, erc--input-split): Move to lisp/erc/erc-common.el.
(erc-controls-strip): Remove forward declaration temporarily until
this file stops requiring `erc-goodies'.

* test/lisp/erc/erc-networks-tests.el: Require `erc' instead of
`erc-networks'.
* test/lisp/erc/erc.el (erc--meta--backend-dependencies): Remove
obsolete test.  Don't require `erc-networks'. Bug#56340.
2022-11-04 19:32:23 -07:00
F. Jason Park
0606b095d2 * lisp/erc/erc.el (erc-cmd-RECONNECT): Fix macro arg. 2022-11-04 19:32:23 -07:00
F. Jason Park
4a1a4bf0e2 Accommodate missing spec values in erc-format-message
* 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.
2022-10-10 18:48:01 -07:00
Stefan Monnier
d28581101a Remove redundant let-bindings of inhibit-point-motion-hooks
`inhibit-point-motion-hooks` has defaulted to t (and been declared
obsolete) since Emacs-25, so remove left-over bindings to that
now default value.

* lisp/dabbrev.el (dabbrev--search):
* lisp/format.el (format-insert-file):
* lisp/forms.el (forms-next-field, forms-prev-field):
* lisp/minibuf-eldef.el (minibuf-eldef-setup-minibuffer):
* lisp/simple.el (primitive-undo):
* lisp/cedet/semantic/edit.el (semantic-change-function):
* lisp/cedet/srecode/fields.el (srecode-field-mod-hook):
* lisp/cedet/srecode/insert.el (srecode-insert-fcn):
* lisp/erc/erc-button.el (erc-button-add-buttons):
* lisp/erc/erc.el (erc-display-line):
* lisp/eshell/em-script.el (eshell-source-file):
* lisp/eshell/em-smart.el (eshell-smart-scroll-window):
* lisp/eshell/esh-arg.el (eshell-parse-arguments):
* lisp/eshell/esh-cmd.el (eshell-with-temp-command):
* lisp/eshell/esh-mode.el (eshell-send-input, eshell-output-filter):
* lisp/gnus/gnus-art.el (gnus-with-article-headers)
(article-hide-headers, article-hide-boring-headers)
(article-decode-mime-words, article-decode-charset)
(article-decode-encoded-words, article-decode-group-name)
(article-decode-idna-rhs, article-hide-list-identifiers)
(article-strip-banner, article-really-strip-banner)
(article-strip-leading-blank-lines)
(article-strip-multiple-blank-lines, article-strip-leading-space)
(article-strip-trailing-space, article-strip-all-blank-lines)
(gnus-article-narrow-to-signature, gnus-article-show-hidden-text)
(article-date-ut, article-verify-x-pgp-sig)
(gnus-article-only-boring-p, gnus-article-highlight-signature)
(gnus-article-add-buttons, gnus-signature-toggle, gnus-button-push):
* lisp/gnus/gnus-cite.el (gnus-article-highlight-citation)
(gnus-article-fill-cited-article, gnus-article-hide-citation)
(gnus-article-toggle-cited-text, gnus-article-hide-citation-maybe)
(gnus-cite-parse-wrapper, gnus-cite-add-face, gnus-cite-toggle):
* lisp/gnus/gnus-gravatar.el (gnus-gravatar-insert):
* lisp/gnus/gnus-rfc1843.el (rfc1843-decode-article-body):
* lisp/gnus/gnus-sum.el (gnus-summary-toggle-header):
* lisp/gnus/gnus-util.el (gnus-fetch-field):
* lisp/gnus/message.el (message-fetch-field, message-reply)
(message-followup, message-hide-headers):
* lisp/net/goto-addr.el (goto-address-fontify):
* lisp/obsolete/linum.el (linum-update-window):
* lisp/play/zone.el (zone-shift-left, zone-shift-right)
(zone-fill-out-screen):
* lisp/progmodes/opascal.el (opascal-save-excursion):
* lisp/progmodes/vhdl-mode.el (vhdl-prepare-search-2):
* lisp/textmodes/enriched.el (enriched-encode):
* lisp/textmodes/flyspell.el (flyspell-word-search-backward)
(flyspell-word-search-forward):
* lisp/textmodes/table.el (table--point-entered/left-cell-function):
Remove let-binding of `inhibit-point-motion-hooks`.
2022-10-07 12:16:47 -04:00
F. Jason Park
132d5cb0a3 Bury new ERC buffers by default
* 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)
2022-09-19 17:54:46 -07:00
F. Jason Park
01de334c78 Offer to regexp-quote new items in erc-match commands
* 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)
2022-09-19 17:54:46 -07:00
F. Jason Park
7df5b4deb8 Don't record undo history in erc-protocol buffers
* lisp/erc/erc.el (erc-log-irc-protocol): Disable undo history.
2022-09-19 17:54:46 -07:00
F. Jason Park
f6b6614c32 Add compat from GNU ELPA as a soft dependency in ERC
* lisp/erc/erc-backend.el (erc-parse-server-response,
erc--parse-isupport-value): Remove sub-28 compat code involving
`string-search'.

* lisp/erc/erc-compat.el: Require compat package, but don't error
when absent.

* lisp/erc/erc-dcc.el (erc-dcc-member): Remove `string-search' compat
code.
(erc-dcc-unquote-filename): Remove `string-replace' compat code.

* lisp/erc/erc-speedbar.el (erc-speedbar-expand-server,
erc-speedbar-expand-channel, erc-speedbar-expand-user): Remove
`string-search' compat code.

* lisp/erc/erc.el: Add compat version 28.1.2.0 to Package-Requires
header and require `erc-compat' after other libraries.
(erc--valid-local-channel-p): Remove `string-search' compat code.
(erc-update-mode-line-buffer): Remove `string-replace' compat code.
(erc-message-english-PART): Remove `string-replace' compat code.
2022-07-27 05:19:09 -07:00
F. Jason Park
4a5499910a Fix CTCP regression in erc-server-PRIVMSG
* lisp/erc/erc-backend.el (erc-server-PRIVMSG): Don't create a query
buffer for non-ACTION CTCP messages.

* test/lisp/erc/erc-scenarios-misc.el (erc-scenarios-dcc-chat-accept):
Add test for basic DCC CHAT accept dialog.

* test/lisp/erc/resources/dcc/chat/accept-dcc.eld: New file.
* test/lisp/erc/resources/dcc/chat/accept.eld: New file.
2022-07-27 05:19:09 -07:00
Stefan Kangas
329ec11b0f ; Normalize some "Author" headers 2022-07-20 22:38:01 +02:00
Stefan Kangas
739e3dbe05 Remove many items obsolete since 24.1
* lisp/allout.el (allout-abbreviate-flattened-numbering)
(allout-mode-deactivate-hook):
* lisp/ansi-color.el (ansi-color-unfontify-region):
* lisp/auth-source.el (auth-source-hide-passwords)
(auth-source-user-or-password)
(auth-source-forget-user-or-password):
* lisp/cedet/data-debug.el (data-debug-map):
* lisp/cedet/semantic/grammar.el (semantic-grammar-syntax-table)
(semantic-grammar-map):
* lisp/chistory.el (command-history-map):
* lisp/comint.el (comint-dynamic-complete)
(comint-dynamic-complete-as-filename)
(comint-dynamic-simple-complete):
* lisp/dired-x.el (read-filename-at-point)
(dired-x-submit-report):
* lisp/dos-fns.el (register-name-alist, make-register)
(register-value, set-register-value, intdos, mode25, mode4350):
* lisp/emacs-lisp/bytecomp.el (byte-compile-disable-print-circle):
* lisp/emacs-lisp/chart.el (chart-map):
* lisp/emacs-lisp/package.el (package-menu-view-commentary):
* lisp/emacs-lock.el (toggle-emacs-lock, emacs-lock-from-exiting):
* lisp/erc/erc.el (erc-complete-word):
* lisp/eshell/em-cmpl.el (eshell-cmpl-suffix-list):
* lisp/eshell/esh-util.el (eshell-for):
* lisp/files.el (inhibit-first-line-modes-regexps)
(inhibit-first-line-modes-suffixes):
* lisp/gnus/gnus-msg.el (gnus-outgoing-message-group)
(gnus-debug-files, gnus-debug-exclude-variables):
* lisp/gnus/gnus-registry.el (gnus-registry-user-format-function-M):
* lisp/gnus/gnus.el (gnus-local-domain, gnus-carpal):
* lisp/gnus/nnimap.el (nnimap-split-rule):
* lisp/iimage.el (turn-on-iimage-mode):
* lisp/image.el (image-extension-data, image-library-alist):
* lisp/mail/emacsbug.el (report-emacs-bug-pretest-address):
* lisp/mail/mail-utils.el (rmail-dont-reply-to):
* lisp/mail/mailalias.el (mail-complete-function)
(mail-completion-at-point-function):
* lisp/mail/rmail.el (rmail-dont-reply-to-names)
(rmail-default-dont-reply-to-names):
* lisp/mail/sendmail.el (mail-mailer-swallows-blank-line)
(mail-sent-via):
* lisp/menu-bar.el (menu-bar-kill-ring-save):
* lisp/minibuffer.el (completion-annotate-function)
(minibuffer-local-filename-must-match-map):
* lisp/msb.el (msb-after-load-hooks):
* lisp/obsolete/eieio-compat.el (eieio-defmethod)
(eieio-defgeneric):
* lisp/obsolete/info-edit.el (Info-edit-map):
* lisp/obsolete/starttls.el (starttls-any-program-available):
* lisp/progmodes/cfengine.el (cfengine-mode-abbrevs):
* lisp/progmodes/cwarn.el (turn-on-cwarn-mode):
* lisp/progmodes/make-mode.el (makefile-complete):
* lisp/progmodes/meta-mode.el (meta-complete-symbol)
(meta-mode-map):
* lisp/progmodes/pascal.el (pascal-toggle-completions)
(pascal-last-completions, pascal-show-completions):
* lisp/progmodes/prolog.el (prolog-char-quote-workaround):
* lisp/progmodes/which-func.el (which-func-mode): [FUNCTION]
* lisp/simple.el (count-lines-region, minibuffer-completing-symbol):
* lisp/speedbar.el (speedbar-syntax-table, speedbar-key-map):
* lisp/strokes.el (strokes-report-bug):
* lisp/subr.el (condition-case-no-debug):
* lisp/term/ns-win.el (ns-alternatives-map)
(ns-store-cut-buffer-internal):
* lisp/term/w32-win.el (w32-default-color-map):
* lisp/term/x-win.el (x-cut-buffer-or-selection-value):
* lisp/textmodes/bibtex.el (bibtex-complete)
(bibtex-entry-field-alist):
* lisp/textmodes/reftex-index.el (reftex-index-map)
(reftex-index-phrases-map):
* lisp/textmodes/reftex-sel.el (reftex-select-label-map)
(reftex-select-bib-map):
* lisp/textmodes/reftex-toc.el (reftex-toc-map):
* lisp/textmodes/rst.el (rst-block-face, rst-external-face)
(rst-definition-face, rst-directive-face, rst-comment-face)
(rst-emphasis1-face, rst-emphasis2-face, rst-literal-face)
(rst-reference-face):
* lisp/vc/vc-hooks.el (vc-toggle-read-only):
* lisp/view.el (view-return-to-alist)
(view-return-to-alist-update): Remove many functions and variables
obsolete since 24.1.

* lisp/textmodes/bibtex.el (bibtex-entry-alist): Don't use above
removed variable 'bibtex-entry-field-alist'.
* lisp/cedet/data-debug.el (data-debug-edebug-expr)
(data-debug-eval-expression):
* lisp/emacs-lisp/trace.el (trace--read-args):
* lisp/files-x.el (read-file-local-variable-value):
* lisp/simple.el (read--expression): Don't use above removed variable
'minibuffer-completing-symbol'.
* lisp/textmodes/rst.el (rst-font-lock-keywords): Don't use above
removed variables.
* src/w32fns.c (Fw32_default_color_map): Delete obsolete function.
(syms_of_w32fns): Delete defsubr for above defun.
* src/keyboard.c (syms_of_keyboard) <Vdeferred_action_list>
<Vdeferred_action_function>: Delete DEFVARs.
<Qdeferred_action_function>: Delete DEFSYM.
(syms_of_keyboard_for_pdumper): Adjust for above change.
(command_loop_1): Don't run deferred-action-function hook.
* lisp/subr.el (deferred-action-list, deferred-action-function):
Delete obsoletion statements.
* lisp/emacs-lisp/ert-x.el (ert-simulate-command): Don't run
'deferred-action-list' hook.
* doc/lispref/hooks.texi (Standard Hooks): Delete
'deferred-action-function'.

* lisp/emacs-lisp/lisp.el (field-complete):
* lisp/eshell/em-cmpl.el (eshell-cmpl-initialize):
* lisp/gnus/gnus-msg.el (gnus-inews-insert-gcc):
* lisp/gnus/nnmail.el (nnmail-fancy-expiry-target):
* lisp/mail/mail-utils.el (mail-dont-reply-to):
* lisp/mail/sendmail.el (sendmail-send-it):
* lisp/mail/smtpmail.el (smtpmail-send-it):
* lisp/minibuffer.el (minibuffer-completion-help):
* lisp/progmodes/python.el: Don't use above removed items.
* lisp/emacs-lisp/eieio-core.el:
* lisp/mail/mailalias.el (mail-complete-alist): Doc fixes; don't refer
to above removed items.
; * etc/NEWS: List removed items.
2022-07-08 14:10:38 +02:00
Eli Zaretskii
a08bb27517 ; Fix documentation of recent ERC changes
* lisp/erc/erc.el (erc-inhibit-multiline-input)
(erc-ask-about-multiline-input): Doc fixes.

* doc/misc/erc.texi (Connecting): Fix typos, grammar, wording,
punctuation, markup, and indexing.
2022-07-01 10:13:07 +03:00
F. Jason Park
10237840d0 Optionally prevent sending multiline input in ERC
* 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)
2022-06-30 15:19:53 -07:00
F. Jason Park
f46547294d Improve ERC's handling of multiline prompt input
* 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)
2022-06-30 15:19:53 -07:00
F. Jason Park
a9d89d083a Fix regression in erc-send-input-line
* 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)
2022-06-30 15:19:53 -07:00
F. Jason Park
0590224343 Standardize auth-source queries in ERC
* 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)
2022-06-30 15:18:22 -07:00
F. Jason Park
1767b0bd7e Don't call erc-auto-query twice on PRIVMSG
* 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.
2022-06-30 15:16:46 -07:00
F. Jason Park
7c47d6c52d Register erc-kill-buffer-function locally
* 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.
2022-06-30 15:15:27 -07:00
F. Jason Park
752e860db4 Address long-standing ERC buffer-naming issues
* 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.
2022-06-30 15:03:26 -07:00
F. Jason Park
e958a2b726 Discourage ill-defined use of buffer targets in ERC
* 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.
2022-06-30 15:03:26 -07:00
F. Jason Park
529e46f128 Add eventual replacement for erc-default-recipients
* 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.
2022-06-30 15:03:26 -07:00
F. Jason Park
1c24af0fcb Add helper to determine local channels in ERC
* 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.
2022-06-30 15:03:26 -07:00