1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-03 08:30:09 +00:00
Commit Graph

190 Commits

Author SHA1 Message Date
F. Jason Park
a0ed463bab Spoof channel users in erc-button--phantom-users-mode
* lisp/erc/erc-backend.el (erc--cmem-from-nick-function): Update
forward declaration.
(erc-server-PRIVMSG): Use new name for `erc--user-from-nick-function',
now `erc--cmem-from-nick-function'.
* lisp/erc/erc-button.el (erc-button--phantom-users,
erc-button--phantom-cmems): Rename former to latter.
(erc-button--fallback-user-function,
erc-button--fallback-cmem-function): Rename former to latter.
(erc--phantom-channel-user, erc--phantom-server-user): New superficial
`cl-struct' definitions "subclassing" `erc-channel-user' and
`erc-server-user'.  Note that these symbols lack an `erc-button'
prefix.
(erc-button--add-phantom-speaker): Look for channel member instead of
server user, creating one if necessary.  Return a made-up
`erc-channel-user' along with a fake `erc-server-user'.
(erc-button--get-phantom-user, erc-button--get-phantom-cmem): Rename
former to latter.
(erc-button--phantom-users-mode, erc-button--phantom-users-enable,
erc-button--phantom-users-disable): Use updated "cmem" names for
function-valued interface variables and their implementing functions.
Remove obsolete comment.
(erc-button-add-nickname-buttons): Attempt to query fallback function
for channel member instead of server user.
* lisp/erc/erc.el (erc--user-from-nick-function,
erc--cmem-from-nick-function): Rename former to latter.
(erc--examine-nick, erc--cmem-get-existing): Rename former to
latter.  (Bug#60933)
2023-09-17 16:17:59 -07:00
F. Jason Park
617ddb8089 Consider all windows in erc-scrolltobottom-mode
* etc/ERC-NEWS: Add entry for option `erc-scrolltobottom-all', and
mention explicit hook-depth intervals reserved by ERC.
* lisp/erc/erc-backend.el (erc--hide-prompt): Change hook depth on
`pre-command-hook' from 91 to 80.
* lisp/erc/erc-goodies.el (erc-input-line-position): Mention secondary
role when new option `erc-scroll-to-bottom-relaxed' is non-nil.
(erc-scrolltobottom-all): New option that decides whether module
`scrolltobottom' affects all windows or just the selected one, as it
always has.
(erc-scrolltobottom-relaxed): New option to leave the prompt
stationary instead of forcing it to the bottom of the window.
(erc-scrolltobottom-mode, erc-scrolltobottom-enable,
erc-scrolltobottom-disable): Use `erc--scrolltobottom-setup' instead
of `erc-add-scroll-to-bottom' for adding and removing local hooks and
instead of ranging over buffers when removing them.  Also add and
remove new hook members when `erc-scrolltobottom-all' is non-nil.
(erc--scrolltobottom-relaxed-commands,
erc--scrolltobottom-window-info,
erc--scrolltobottom-post-force-commands,
erc--scrolltobottom-relaxed-skip-commands): New internal variables.
(erc--scrolltobottom-on-pre-command
erc--scrolltobottom-on-post-command): New functions resembling
`erc-possibly-scroll-to-bottom' that try to avoid scrolling repeatedly
for no reason.
(erc--scrolltobottom-on-pre-command-relaxed,
erc--scrolltobottom-on-post-command-relaxed): New commands to help
implement `erc-scroll-to-bottom-relaxed'.
(erc--scrolltobottom-at-prompt-minibuffer-active): New function to
scroll to bottom on window configuration changes when using the
minibuffer.
(erc--scrolltobottom-all): New function to scroll all windows
displaying the current buffer.
(erc-add-scroll-to-bottom): Deprecate this function because it is now
unused in the default client and trivial to implement otherwise.
(erc--scrolltobottom-setup): New generic function to perform teardown
as well as setup depending on the state of the module's mode variable.
Also add an implementation specifically for `erc-scrolltobottom-all'
that locally modifies different sets of hooks depending on
`erc-scrolltobottom-relaxed'.
(erc--scrolltobottom-on-pre-insert): New generic function that
remembers the last `window-start' and maybe the current screen line
before inserting a message, in order to restore it afterward.
(erc--scrolltobottom-confirm): New function, a replacement for
`erc-scroll-to-bottom' that returns non-nil when it's actually
recentered the window.  For now, used only when
`erc-scrolltobottom-all' is enabled.
(erc-move-to-prompt-setup): Add `erc-move-to-prompt' to
`pre-command-hook' at a depth of 70 in the current buffer.
(erc-keep-place-mode, erc-keep-place-enable): Change hook depth from 0
to 85.
(erc--keep-place-indicator-setup): Add overlay arrow `after-string' in
non-graphical settings in case users have time stamps or other content
occupying the left margin.
(erc-keep-place-indicator-mode, erc-keep-place-indicator-enable):
Change hook depth from 90 to 85 locally so as not to conflict with a
value of t, for append.
(erc--keep-place-indicator-on-global-module): Change hook depth from
90 to 85 locally.
* test/lisp/erc/erc-scenarios-scrolltobottom-relaxed.el: New file.
* test/lisp/erc/erc-scenarios-scrolltobottom.el: New file.
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common--term-size, erc-scenarios-common--run-in-term,
erc-scenarios-common-interactive-debug-term-p,
erc-scenarios-common-with-noninteractive-in-term): New test macro and
supporting helper function and variables to facilitate running
scenario-based tests in an inferior Emacs, in term-mode.
(erc-scenarios-common--at-win-end-p,
erc-scenarios-common--above-win-end-p,
erc-scenarios-common--prompt-past-win-end-p,
erc-scenarios-common--recenter-top-bottom-around,
erc-scenarios-common--recenter-top-bottom,
erc-scenarios-scrolltobottom--normal): New test fixture and assertion
helper functions.
* test/lisp/erc/resources/scrolltobottom/help.eld: New file.
(Bug#64855)
2023-09-10 17:58:20 -07:00
F. Jason Park
63d8b2a59a Make erc-fill-wrap work with left-sided stamps
* etc/ERC-NEWS: Remove all mention of option `erc-timestamp-align-to'
supporting a value of `margin', which has been abandoned.  Do mention
leading white space before stamps now having stamp-related properties.
* lisp/erc/erc-backend.el (erc--reveal-prompt, erc--conceal-prompt):
New generic functions with default implementations factored out from
`erc--unhide-prompt' and `erc--hide-prompt'.
(erc--prompt-hidden-p): New internal predicate function.
(erc--unhide-prompt): Defer to `erc--reveal-prompt', and set
`erc-prompt' text property to t.
(erc--hide-prompt): Defer to `erc--conceal-prompt', and set
`erc-prompt' text property to `hidden'.
* lisp/erc/erc-compat.el (erc-compat--29-browse-url-irc): Don't
use `function-equal'.
* lisp/erc/erc-fill.el (erc-fill-wrap-margin-width,
erc-fill-wrap-margin-side): New options to control side and initial
width of `fill-wrap' margin.
(erc-fill--wrap-beginning-of-line): Fix bug involving non-string
valued `display' props.
(erc-fill-wrap-toggle-truncate-lines): New command to re-enable
`visual-line-mode' when toggling off `truncate-lines'.
(erc-fill-wrap-mode-map): Remap `toggle-truncate-lines' to
`erc-fill-wrap-toggle-truncate-lines'.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Update doc string, persist a few local vars, and conditionally set
`erc-stamp--margin-left-p'.  When deactivating, disable
`visual-line-mode' first.
(erc-fill--wrap-continued-message-p): Use `erc-speaker' instead of
heuristics when comparing nicks between consecutive messages.
(erc-fill-wrap-nudge): Update doc string and account for left-sided
stamps.
(erc-timestamp-offset): Add comment regarding conditional guard based
on function-valued option.
* lisp/erc/erc-stamp.el (erc-timestamp-use-align-to): Remove value
variant `margin', which was originally intended to be new in ERC 5.6.
This functionality was all but useless without the internal minor mode
`erc-stamp--display-margin-mode' active.
(erc-stamp-right-margin-width): Remove unused option new in 5.6.
(erc-stamp--display-margin-force): Remove unused function.
(erc-stamp--margin-width, erc-stamp--margin-left-p): New internal
variables.
(erc-stamp--init-margins-on-connect): New function for initializing
mode-managed margin after connecting.
(erc-stamp--adjust-right-margin, erc-stamp--adjust-margin): Rename
function to latter and accommodate left-hand stamps.
(erc-stamp--inherited-props): Move definition higher up in same file.
(erc-stamp--display-margin-mode): Update function name, and adjust
setup and teardown to accommodate left-handed stamps.  Don't add
advice around `erc-insert-timestamp-function'.
(erc-stamp--last-prompt, erc-stamp--display-prompt-in-left-margin):
New function and helper var to convert a normal inserted prompt so
that it appears in the left margin.
(erc-stamp--refresh-left-margin-prompt): Helper for other modules to
quickly refresh prompt outside of insert hooks.
(erc--reveal-prompt, erc--conceal-prompt): New implementations for
when `erc-stamp--display-margin-mode' is active.
(erc-insert-timestamp-left): Convert to generic function and provide
implementation for `erc-stamp--display-margin-mode'.
(erc-stamp--omit-properties-on-folded-lines): New variable, an escape
hatch for propertizing white space before right-side stamps folded
over onto another line.
(erc-insert-timestamp-right): Don't expect `erc-timestamp-align-to' to
ever be the symbol `margin'.  Move handling for that case to one
contingent on the internal minor mode `erc-stamp--display-margin-mode'
being active.  Add text properties preceding stamps that occupy a line
by their lonesome.  See related news entry for rationale.  This is
arguably a breaking change.
* lisp/erc/erc.el (erc--refresh-prompt-hook): New hook variable for
modules to adjust prompt properties whenever it's refreshed.
(erc--refresh-prompt): Fix bug in which user-defined prompt functions
failed to hide when quitting in server buffers.  Run new hook
`erc--refresh-prompt-hook'.
(erc-display-prompt): Add comment noting that the text property
`erc-prompt' now actually matters: it's t while a session is running
and `hidden' when disconnected.
* test/lisp/erc/erc-fill-tests.el (erc-fill--left-hand-stamps): New
test.
* test/lisp/erc/erc-stamp-tests.el
(erc-stamp-tests--use-align-to--nil,
erc-stamp-tests--use-align-to--t): New functions forged from old test
bodies to allow optionally asserting pre-5.6 behavior regarding
leading white space on right-hand stamps that exist on their own line.
(erc-timestamp-use-align-to--nil, erc-timestamp-use-align-to--t):
Parameterize with compatibility flag.
(erc-timestamp-use-align-to--margin,
erc-stamp--display-margin-mode--right): Rename test to latter.
* test/lisp/erc/erc-tests.el (erc-hide-prompt): Add some assertions
for new possible value of `erc-prompt' text property.
* test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: New test
data file.  (Bug#60936)
2023-07-22 07:33:07 -07:00
F. Jason Park
b354b3a53b Allow custom display-buffer actions in ERC
* doc/misc/erc.texi: Add new section under "Integrations" chapter
describing `display-buffer' Custom function choice for ERC's many
buffer-display options.
* etc/ERC-NEWS: Mention new function variant for all buffer-display
options.
* lisp/erc/erc-backend.el: Add forward declaration for
`erc--called-as-input-p' and `erc--display-context'.
(erc--server-reconnect-display-timer,
erc--server-last-reconnect-display-reset): Use new name for option
`erc-reconnect-display', now `erc-auto-reconnect-display'.
(erc--server-determine-join-display-context): New generic function to
determine value of `erc--display-context' during JOINs.
(erc-server-JOIN, erc-server-PRIVMSG): Set `erc--display-context' to a
symbol for the handler's IRC command, like `JOIN', for the benefit of
custom `display-buffer'-like functions running in `erc-setup-buffer'.
(erc-server-471, erc-server-471-functions, erc-server-473,
erc-server-473-functions): New handlers for JOIN rejections.  Also
remove 471 and 473 from comment at bottom of file.
(erc-server-475): Bind `erc--called-as-input-p' so that `erc-cmd-JOIN'
sets `erc-interactive-display' context.
* lisp/erc/erc-join.el (erc-autojoin-mode, erc-autojoin-enable,
erc-autojoin-disable): Kill local variable
`erc-join--requested-channels'.  Add and remove
`erc-join--remove-requested-channels' to/from various server-handler
hooks for JOIN rejection numerics.
(erc-join--requested-channels): New local variable to remember
channels we've attempted to JOIN this session that haven't yet been
confirmed by the server.
(erc-join--remove-requested-channel): New JOIN rejection handler to
stop tracking channel in `erc-join--requested-channels'.
(erc--server-determine-join-display-context): module-specific
implementation of generic function for `erc-autojoin-mode'.
(erc-autojoin--join): Remember channels slated for JOIN'ing.
* lisp/erc/erc.el (erc--buffer-display-choices): New helper constant
for defining common `:type' for all buffer-display options.
(erc-buffer-display, erc-interactive-display,
erc-auto-reconnect-display, erc-receive-query-display): Use helper
`erc--buffer-display-choices' for defining `:type', which
includes a new choice for a `display-buffer'-like function.
(erc-reconnect-display, erc-auto-reconnect-display): Alias former to
latter, now the preferred name.
(erc-reconnect-timeout, erc-auto-reconnect-timeout): Change name from
former to latter.  This option is new in ERC 5.6.
(erc-reconnect-display-server-buffers): New option.
(erc-buffer-do): Revise doc string.
(erc--display-context): New variable, an alist of "context tokens" to
be forwarded as the "action alist" to `erc-buffer-display' functions.
(erc-skip-displaying-selected-window-buffer): New variable, deprecated
at birth, to act as an escape hatch for folks who don't want to skip
the displaying of buffers already showing in the selected window.
(erc--display-buffer-overriding-action): Local variable allowing
modules to influence the displaying of new ERC buffers independently
of user options.
(erc-setup-buffer): Do nothing when the selected window already shows
current buffer unless user has provided a custom display function.
Accommodate new Custom choice function values, like `display-buffer'
and `pop-to-buffer'.
(erc-open): Run `erc-setup-buffer' when option
`erc-reconnect-display-server-buffers' is non-nil, even for existing
server buffers.  Bind `display-buffer-overriding-action' to the value
of `erc--display-buffer-overriding-action' around calls to
`erc-setup-buffer'.
(erc-select-read-args): Add `erc--display-context' to environment.
(erc, erc-tls): Bind `erc--display-context' around calls to
`erc-select-read-args' and main body.
(erc-cmd-JOIN, erc-cmd-QUERY, erc--cmd-reconnect, erc-handle-irc-url):
Add item for `erc-interactive-display' to `erc--display-context'.
(erc-connection-established): Update name of
`erc-reconnect-display-timeout' to
`erc-auto-reconnect-display-timeout'.
(erc-message-english-s471, erc-message-english-s473): New variables,
format templates for JOIN rejection messages.
* test/lisp/erc/erc-scenarios-base-buffer-display.el
(erc-scenarios-base-buffer-display--defwin-recbury-intbuf,
erc-scenarios-base-buffer-display--defwino-recbury-intbuf,
erc-scenarios-base-buffer-display--count-reset-timeout): Use preferred
name `erc-auto-reconnect-display' for `erc-reconnect-display'.
* test/lisp/erc/erc-scenarios-join-display-context.el: New file.
* test/lisp/erc/erc-tests.el (erc--initialize-markers): Fix
unrealistic call to `erc-open'.
(erc-setup-buffer--custom-action): New test.
(erc-select-read-args, erc-tls, erc--interactive, erc-server-select):
Expect new environment binding for `erc--display-context'.
* test/lisp/erc/resources/join/buffer-display/mode-context.eld: New
file.  (Bug#62833)
2023-07-13 18:45:31 -07:00
F. Jason Park
6ce957154b Redo erc-nickname-in-use-functions as a local module
* etc/ERC-NEWS: Mention new module `services-regain'.
* lisp/erc/erc-backend.el: Rename option.
* lisp/erc/erc-services.el (erc-services-regain-alist): Strategies for
regaining a lost nickname on reconnect.  This option, in addition to
the rest of these changes, is a redo of
`erc-nickname-in-use-functions' from commit 8c0c9826 "Add hook to
regain nickname in ERC", which originally stemmed from bug#62044.
(erc-services-retry-nick-on-connect, erc-services-issue-regain,
erc-services-issue-ghost-and-retry-nick): New function variants for
`erc-services-regain-alist.
(erc-services-regain-mode, erc-services-regain-enable,
erc-services-regain-disable): New local module to activate
nick-regaining behavior.
(erc--nickname-in-use-make-request): New method, a services-specific
implementation.
* lisp/erc/erc.el (erc--nickname-in-use-make-request): New generic
function to request alternate nick when first choice is rejected.
(erc-nickname-in-use): Call `erc--nickname-in-use-make-request' to
request alternate nick.
* test/lisp/erc/erc-scenarios-services-misc.el
(erc-scenarios-services-misc--reconnect-retry-nick): Adopt renamed
version of `erc-scenarios-base-renick-auto-regain'.
(erc-scenarios-services-misc--regain-command,
erc-scenarios-services-misc--ghost-and-retry-nick): New tests.
* test/lisp/erc/resources/services/regain/reconnect-retry-again.eld:
New test data file reusing existing blob c0529052 that once lived at
resources/base/renick/regain/normal-again.eld.
* test/lisp/erc/resources/services/regain/reconnect-retry.eld: New
test data file reusing existing blob 9f4df70e5 that once lived at
resources/base/renick/regain/normal.eld.
* test/lisp/erc/resources/services/regain/taken-ghost.eld: New test
data file.
* test/lisp/erc/resources/services/regain/taken-regain.eld New test
data file.
2023-07-01 07:21:30 -07:00
F. Jason Park
56e1922281 Revert "Add hook to regain nickname in ERC"
This reverts commit 8c0c982684.  The
functionality it introduced is likely being migrated to a
"regain"-specific local module to live in the library erc-services.el
alongside the existing `services' module.  Its scope will be expanded
to address common "regain" cases requiring NickServ.  This commit is
being reverted to prevent any confusion that might arise from users
encountering the old interface while the new one is being hashed out
on the tracker.
2023-06-11 20:24:07 -07:00
F. Jason Park
ba44b48184 Add interface for finding users in erc-server-PRIVMSG
* lisp/erc/erc-backend.el (erc-server-PRIVMSG): Call new hook
`erc--user-from-nick-function' for turning the sender's nick into a
channel user, if any.
* lisp/erc/erc-button.el (erc-button--add-phantom-speaker): Redo
completely using simplified API.
(erc-button--fallback-user-function): Add internal function-interface
variable for finding an `erc-server-user' object when the usual places
disappoint.
(erc-button--get-phantom-user): Add new function, a getter for
`erc-button--phantom-users'.
(erc-button--phantom-users-mode): Replace advice subscription for
`erc-button--modify-nick-function' with one for
`erc-button--user-from-nick-function' and one for
`erc-button--fallback-user-function'.
(erc-button--get-user-from-speaker-naive): Remove unused function.
(erc-button--add-nickname-buttons): Call
`erc-button--fallback-user-function' when a user can't be found in
`erc-server-users' or `erc-channel-users'.
* lisp/erc/erc.el (erc--user-from-nick-function): New
function-interface variable for determining an `erc-server-user'
`erc-channel-user' pair from the sender's nick.
(erc--examine-nick): Add new function to serve as default value for
`erc--user-from-nick-function'.  (Bug#60933)
2023-05-05 17:18:01 -07:00
F. Jason Park
3a5a6fce95 Redo line splitting for outgoing messages in ERC
* lisp/erc/erc-backend.el (erc--reject-unbreakable-lines): New
variable, an escape hatch for somewhat regaining pre-5.6
line-splitting behavior.
(erc--split-line): New utility function that doesn't rely on
column-oriented filling.
* lisp/erc/erc.el (erc--pre-send-split-functions): Append
`erc--split-lines' to value.
(erc--split-lines): New function to re-split current selection of
lines.
(erc-send-input): Hard-code line preparation instead of calling
`erc--pre-send-split-functions', in order to bake in traditional
behavior before move to "pre-splitting".
* test/lisp/erc/erc-scenarios-base-split-line.el: New file.
* test/lisp/erc/erc-tests.el (erc--split-line): New test.
(erc-send-current-line): Don't expect a flood argument when
interpreting a command because it's not passed along to the command's
handler.  This was previously misleading because it assigned undue
significance to something that had no bearing on the fate of a
command.
* test/lisp/erc/resources/base/flood/ascii.eld: New file.
* test/lisp/erc/resources/base/flood/koi8-r.eld: New file.
* test/lisp/erc/resources/base/flood/utf-8.eld: New file.
* test/lisp/erc/resources/erc-d/erc-d.el: Don't decode input.
(Bug#62947)
2023-05-05 17:18:01 -07:00
F. Jason Park
90a9c7b7b5 Actually define erc-default-server-functions
* lisp/erc/erc-backend.el: Remove top-level `add-hook' for
`erc-default-server-functions'.
* lisp/erc/erc.el (erc-default-server-hook,
erc-default-server-functions): Officially deprecate the former and
rename it to the latter.
(erc-default-server-handler): Mark obsolete because its replacement
took over years ago.
(erc-debug-missing-hooks): Append instead of mutate.
2023-05-05 17:18:01 -07:00
F. Jason Park
9e1a5a389e Ignore erc-reconnect-display after a timeout
* lisp/erc/erc-backend.el (erc--server-reconnect-display-timer): New
variable to store active timer that, upon firing, zeroes out
`erc--server-last-reconnect-count'.
(erc--server-last-reconnect-on-disconnect): New function to run on
`erc-disconnected-hook'.
(erc--server-last-reconnect-display-reset): New function to ensure the
reconnect-display period ends.
* lisp/erc/erc.el (erc-reconnect-display-timeout): New option to
control how long `erc-reconnect-display' affects the displaying of new
buffers following an automatic reconnection.
(erc-process-input-line): Ensure user input marks the end of the
reconnect-display period.
(erc-cmd-JOIN): Don't bother resetting
`erc--server-last-reconnect-count' because it's now handled by its
sometime caller, `erc-process-input-line'.
(erc-connection-established): Schedule timer and register hook to
reset last-reconnect count and terminate the reconnect-display period.
* test/lisp/erc/erc-scenarios-base-buffer-display.el:
(erc-scenarios-base-buffer-display--reconnect-common): Add new args to
test fixture to allow for asserting display properties at various
stages throughout a session.
(erc-scenarios-base-reconnect-options--buffer,
erc-scenarios-base-buffer-display--defwin-recbury-intbuf): Rename
former to latter and rework to better reflect realistic settings
for the relevant display options.
(erc-scenarios-base-reconnect-options--default,
erc-scenarios-base-buffer-display--defwino-recbury-intbuf): Rename
former to latter and rework to be more realistic.
(erc-scenarios-base-buffer-display--count-reset-timeout): New
test for new option `erc-reconnect-display-timeout'.  (Bug#62833)
2023-05-05 17:18:01 -07:00
F. Jason Park
c9f1ad2a87 Revive option erc-query-on-unjoined-chan-privmsg
* etc/ERC-NEWS: Mention reinstated and renamed legacy option
`erc-query-on-unjoined-chan-privmsg' as well as a change in behavior
for `erc-auto-query', when nil.  Also fix erroneous ChangeLog
reference in 5.5 section.
* lisp/erc/erc-backend.el (erc-server-PRIVMSG): Consider flag
`erc-receive-query-display-defer' and revived option
`erc-query-unjoined-chan-privmsg' when deciding whether to create a
new query buffer.  And only "open" a buffer for an unknown target when
the latter option is non-nil.
* lisp/erc/erc.el (erc-cmd-QUERY): Make error more informative.
(erc-query): Revise deprecation message.
(erc-auto-query, erc-receive-query-display): Swap alias and aliased
and add option to `erc-buffers' group.  Mention the nonstandard
meaning of nil and update package-version to signify a behavioral
change, even though the default value remains untouched.
(erc-receive-query-display-defer): Add new variable, a compatibility
switch to access legacy behavior for `erc-auto-query'.
(erc-query-on-unjoined-chan-privmsg,
erc-ensure-target-buffer-on-privmsg): Revise doc string and add alias.
Change package-version to ERC 5.6 due to slightly refined meaning.
* test/lisp/erc/erc-scenarios-base-attach.el: New file.
* test/lisp/erc/resources/base/channel-buffer-revival/reattach.eld:
New file.  (Bug#62833)
2023-05-05 17:18:01 -07:00
F. Jason Park
89815631f2 Copy over upstream Compat macros to erc-compat
* lisp/erc/erc-backend: (erc--get-isupport-entry): Replace call to
`erc-compat--with-memoization' with the built-in `with-memoization'.
* lisp/erc/erc-compat.el: (erc-compat-function, erc-compat-call): Add
new macros from Compat 29.1.2.0.
(erc-compat--with-memoization): Remove because it's now provided by
Compat.  (Bug#60954.)
2023-04-08 14:23:50 -07:00
F. Jason Park
8c0c982684 Add hook to regain nickname in ERC
* lisp/erc/erc-backend.el (erc-server-reconnect-timeout): Mention
`erc-nickname-in-use-functions' in doc string.
* lisp/erc/erc.el (erc-nickname-in-use-functions,
erc-regain-nick-on-connect): Add abnormal hook and possible value to
handle stale connections preventing a desired nick from being reissued
by the server.  Follows directly from bug#62044.
(erc-nickname-in-use): Call `erc-nickname-in-use-functions'.
* test/lisp/erc/erc-scenarios-base-renick.el
(erc-scenarios-base-renick-auto-regain): New test.
* test/lisp/erc/resources/base/renick/regain/normal-again.eld: New file.
* test/lisp/erc/resources/base/renick/regain/normal.eld: New file.
2023-04-08 14:23:50 -07:00
F. Jason Park
03eddc9924 Add probing erc-server-reconnect-function variant
* lisp/erc/erc-backend.el (erc-server-reconnect-timeout): Replace
questionable claim with recommendation for alternate value when
experiencing nick rejections.
(erc-server-reconnect-function): Add new, somewhat experimental value
`erc-server-delayed-check-reconnect'.
(erc--server-connect-function): Add variable for process-dialing
monitor, a function.
(erc--server-propagate-failed-connection): Add function to serve as
default monitor to run on process creation and maybe execute failure
handlers.
(erc-server-connect): Run `erc--server-connect-function' for async
processes one second after creation.
(erc--server-reconnect-timeout, erc--server-reconnect-timeout-check,
erc--server-reconnect-timeout-scale-function,
erc--server-reconnect-timeout-double): Add supporting variables and
functions for `erc-server-delayed-check-reconnect'.
(erc-server-delayed-check-reconnect): Add possible alternate value for
option `erc-server-reconnect-function' that only attempts to reconnect
after hearing back from the server.
(erc-schedule-reconnect): Ensure previous `erc-server-process' is
deleted.
* test/lisp/erc/erc-scenarios-base-auto-recon.el: New file.
* test/lisp/erc/resources/base/reconnect/just-eof.eld: New file.
* test/lisp/erc/resources/base/reconnect/just-ping.eld: New file.
* test/lisp/erc/resources/base/reconnect/ping-pong.eld: New file.
* test/lisp/erc/resources/base/reconnect/unexpected-disconnect.eld:
New file.
* test/lisp/erc/resources/erc-scenarios-common.el
(erc-scenarios-common--make-bindings): Shadow
`timer-list'.  (Bug#62044.)
2023-04-08 14:23:50 -07:00
F. Jason Park
4da7d24988 Add MOTD command to ERC
* lisp/erc/erc-backend.el (erc-server-402, erc-server-402-functions):
Add new response handler and hook.
* lisp/erc/erc.el (erc-cmd-MOTD): New function to shield erc-network
from handling post-connection MOTD replies.  Thanks to Emanuel Berg
for reporting this (bug#62151).
(erc-message-english-s402): Define new ERR_NOSUCHSERVER message
template.
* test/lisp/erc/erc-scenarios-base-misc-regressions.el: New file.
* test/lisp/erc/resources/base/commands/motd.eld: New file.
2023-04-08 14:23:50 -07:00
F. Jason Park
db7096a532 Yield to erc-move-to-prompt before unhiding prompt
* lisp/erc/erc-backend.el (erc--hide-prompt): Change hook depth from 0
to 91 to allow the `move-to-prompt' module to do its thing.  This
feature was added by bug#54826 and first appeared in Emacs 29.
* lisp/erc/erc-common.el (erc-server-user): Remove erroneous comment.
The `buffers' field is a list of buffers.
* test/lisp/erc/erc-tests.el (erc-hide-prompt): Use `erc--target'
instead of `erc-default-recipients' because this is new code.
2023-02-22 06:33:12 -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
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
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
ae254a65cd
Call erc-login indirectly via new generic wrapper
* lisp/erc/erc-backend (erc--register-connection): Add new internal
generic function that defers to `erc-login' by default.
(erc-process-sentinel, erc-server-connect): Call
`erc--register-connection' instead of `erc-login'.
2022-11-23 20:11:55 -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
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
d4028ead89 Warn of future breaking change to erc-response.tags
* lisp/erc/erc-backend.el (erc-parse-tags-format): New option to
determine type of the `erc-response' "tags" field.
(erc-parse-tags): Defer to internal generic function.
(erc--parse-tags): New function to hold original `erc-parse-tags'
implementation.
(erc--parse-message-tags): New generic function that conditionally
calls `erc--parse-tags', perhaps emitting a warning beforehand.
(erc-parse-server-response): Call `erc--parse-message-tags'.
(Bug#58797.)
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
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
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
c238f568cd Avoid mutating default value of erc-server-last-peers
* lisp/erc/erc-backend.el (erc-server-last-peers): Leave default as
nil instead of a quoted constant.
(erc-server-connect): Initialize `erc-server-last-peers' to a new
value local to a server buffer.
(erc-message): Operate on server's local `erc-server-last-peers' value
instead of the global default.  Prefer replacing value instead of
mutating CDR to make for easier testing.
(erc-server-PRIVMSG): Create a new `erc-server-last-peers' for easier
testing. (Bug#56449)
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
2a05479c22 ; Fix typos: prefer American spelling 2022-07-14 12:13:31 +02:00
dickmao
0bacb8f9e7 Use compatibility macro for ISUPPORT caching in ERC
* lisp/erc/erc-backend.el (erc--with-memoization): Defalias was a
kung-fu I've never seen before. (Bug#56340)
2022-07-06 01:54:55 -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
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
c356f86b51 Update ISUPPORT handling in ERC
* lisp/erc/erc-backend (erc--isupport-params): Add new variable to
hold a hashmap of parsed `erc-server-parameters' in a more useful
format.  But keep `erc-server-parameters' around for public use.  We
currently lack dedicated local variables for certain discovered IRC
session properties, such as what prefix characters are supported for
channels, etc.  And the truth of this needs querying many times per
second at various points.  As such, caching here seems justified but
can be easily removed if deemed otherwise because all ingredients are
internal.
(erc--parse-isupport-value): Add helper function that parses an
ISUPPORT value and returns the component parts with backslash-x hex
escapes removed.  This can probably use some streamlining.
(erc--with-memoization): Add compat alias for use in internal ISUPPORT
getter.  Should be moved to `erc-compat.el' when that library is fully
reincorporated.
(erc--get-isupport-entry): Add internal getter to look up ISUPPORT
items.
(erc-server-005): Treat `erc-server-response' "command args" field as
read-only.  Previously, this field was set to nil after processing,
which was unhelpful to other parts of the library.  Also call above
mentioned helper to parse values.  And add some bookkeeping to handle
negation.

* lisp/erc/erc-capab.el (erc-capab-identify-send-messages): Use
internal ISUPPORT getter.

* lisp/erc/erc.el (erc-cmd-NICK, erc-parse-prefix,
erc-nickname-in-use): Use internal ISUPPORT getter.

* test/lisp/erc/erc-tests.el: Add tests for the above mentioned
changes in erc-backend.el.
2022-06-30 15:03:26 -07:00
F. Jason Park
873499ce06 Allow exemption from flood penalty in erc-backend
* lisp/erc/erc-backend (erc-server-send, erc-server-PING): Change name
of param `forcep' in `erc-server-send' to `force' and change its type
to the union of the symbol `no-penalty' and the set of all other
non-nil values.  In `erc-server-PING', use this exemption when calling
`erc-server-send'.  This fix was fast tracked and summarily
incorporated into bug#48598 because users of the soju bouncer are all
affected.  See update #5 in the bug's email thread under the section
entitled "Riders" for an explanation.
2022-06-30 15:03:26 -07:00
F. Jason Park
c5b78a3379 Customize displaying of ERC buffers on reconnect
* lisp/erc/erc-backend.el (erc--server-last-reconnect-count):
Add variable to record last reconnect tally.

* lisp/erc/erc.el (erc-reconnect-display): Add new option to specify
channel-buffer display behavior on reconnect.
(erc-setup-buffer): Use option `erc-reconnect-display' if warranted.
(erc-cmd-JOIN): Forget last reconnect count when issuing a manual
/JOIN command.
(erc-connection-established): Record reconnect count in internal var
before resetting.
(Bug#51753)
2022-06-30 15:03:26 -07:00
F. Jason Park
a63ed6f78a Remove duplicate ERC prompt on reconnect
* lisp/erc/erc-backend.el (erc--unhide-prompt, erc--hide-prompt,
erc--unhide-prompt-on-self-insert): Add functions to ensure prompt is
hidden on disconnect and shown when a user types /reconnect in a
disconnected server buffer.
(erc-process-sentinel): Register aforementioned function with
`pre-command-hook' when prompt is deleted after disconnecting.
(erc-server-PRIVMSG): Ensure prompt is showing when a new message
arrives from target.

* lisp/erc/erc.el (erc-hide-prompt): Repurpose unused option by
changing meaning slightly to mean "selectively hide prompt when
disconnected."  Also delete obsolete, commented-out code that at some
point used this option in its prior incarnation.
(erc-prompt-hidden): Add new option to specify look of prompt when
hidden.
(erc-unhide-query-prompt): Add option to force-reveal query prompts on
reconnect.
(erc-open): Augment earlier reconnect-detection semantics by
incorporating `erc--server-reconnecting'.  In existing buffers, remove
prompt-related hooks and reveal prompt, if necessary.
(erc-cmd-RECONNECT): Allow a user to reconnect when already
connected (by first disconnecting).
(erc-connection-established): Possibly unhide query prompts.
(Bug#54826)

* test/lisp/erc/erc-tests.el (erc-tests--test-prep,
erc-tests--set-fake-server-process): Factor out some common
buffer-prep boilerplate involving user input and the server process.
Shared with bug#54536.
2022-06-30 15:03:26 -07:00
F. Jason Park
4ae0707704 Accept user keyword arg in ERC entry-point commands
* lisp/erc/erc-backend.el (erc-server-reconnect): Reuse the username
argument from the previous session's USER command when reconnecting.
Also pass the existing client certificate, fixing an issue related to
bug#47788.
(erc-session-user-full-name): Move variable here from erc.el.
(erc-session-username): Add new local variable to store entry point
parameter.

* lisp/erc/erc.el (erc-session-user-full-name): Move variable to
erc-backend.
(erc-open, erc-determine-parameters, erc, erc-tls): Accept new
optional user parameter.
(erc-query): Preserve current `erc-session-username' when calling
`erc-open'.
(erc-login): Use `erc-session-username' instead of deriving it.
(erc-compute-user): Add new function to determine user name from
explicit argument or user options.
(Bug#54824)
2022-06-30 15:03:26 -07:00
F. Jason Park
54414ec846 Initialize erc-server-filter-data in erc-backend
* lisp/erc/erc-backend.el (erc-server-connect): Set
`erc-server-filter-data' to nil upon (re)connecting.

* lisp/erc/erc.el (erc-open): For the sake of clarity, don't
initialize `erc-server-filter-data' here because non-connect
invocations merely set up a target buffer and have no business
touching this variable.
2022-06-30 15:03:26 -07:00
F. Jason Park
0f52e7ac68 Rework mutual dependency between erc and erc-backend
* lisp/erc/erc.el: Declare needed variables exported by erc-backend.el
as special near the top of the file, and only require `erc-backend'
after providing `erc' as a feature at the very end.

* lisp/erc/erc-backend.el: Don't preemptively provide `erc-backend'.

* test/lisp/erc/erc-tests.el (erc--meta--backend-dependencies): Add
utility test to scrape for unused vars that may accumulate over time.
(Bug#54825)
2022-06-30 15:03:26 -07:00
Stefan Kangas
7749ec6aaa Remove some ancient Emacs compat code
* lisp/url/url-util.el (url-percentage): Remove Emacs 19 compat
code.

* lisp/erc/erc-backend.el (erc-server-coding-system):
* lisp/gnus/mm-util.el (mm-iso-8859-x-to-15-table): Remove Emacs
19 compat code; coding-system-p is fboundp.

* lisp/progmodes/cfengine.el (cfengine-fill-paragraph): Remove Emacs
21 compat code.
2022-05-25 09:42:52 +02:00
Lars Ingebrigtsen
5f6e64a316 Don't use `format-message' to make doc strings in erc-backend
* lisp/erc/erc-backend.el (define-erc-response-handler): Use
`format' here instead of `format-message' since Emacs will expand
the doc string later when the user asks for help about the symbols
defined.
2022-05-24 19:02:06 +02:00
Lars Ingebrigtsen
bbf389ea6d Audit quoting the quote character in doc strings
* test/src/regex-emacs-tests.el (regex-tests-compare):
(regex-tests-compare):
(regex-tests-match):
* test/lisp/xml-tests.el (xml-parse-tests--qnames):
* test/lisp/mh-e/mh-thread-tests.el (mh-thread-tests-before-from):
* test/lisp/cedet/srecode-utest-template.el (srecode-utest-map-reset):
* test/lisp/calc/calc-tests.el (calc-tests-equal):
* lisp/window.el (get-lru-window):
(get-mru-window):
(get-largest-window):
(quit-restore-window):
(display-buffer):
* lisp/vc/vc-rcs.el (vc-rcs-consult-headers):
* lisp/url/url-auth.el (url-digest-auth-build-response):
* lisp/tutorial.el (tutorial--find-changed-keys):
* lisp/transient.el (transient-suffix-object):
* lisp/textmodes/rst.el (rst-insert-list-new-item):
* lisp/textmodes/bibtex.el (bibtex-clean-entry):
* lisp/tab-bar.el (tab-bar--key-to-number):
(toggle-frame-tab-bar):
* lisp/ses.el (ses-recalculate-cell):
(ses-define-local-printer):
(ses-prin1):
* lisp/progmodes/xref.el (xref--find-ignores-arguments):
* lisp/progmodes/verilog-mode.el (verilog-single-declaration-end):
* lisp/progmodes/tcl.el (tcl-mode-hook):
* lisp/progmodes/gdb-mi.el (gdb-get-buffer-create):
* lisp/progmodes/elisp-mode.el (elisp--xref-make-xref):
* lisp/play/dunnet.el (dun-room-objects):
* lisp/outline.el (outline--cycle-state):
* lisp/org/ox-publish.el (org-publish-find-property):
* lisp/org/ox-html.el (org-html--unlabel-latex-environment):
* lisp/org/org-table.el (org-table-collapse-header):
* lisp/org/org-plot.el (org--plot/prime-factors):
* lisp/org/org-agenda.el (org-agenda--mark-blocked-entry):
(org-agenda-set-restriction-lock):
* lisp/org/ob-lua.el (org-babel-lua-read-string):
* lisp/org/ob-julia.el (org-babel-julia-evaluate-external-process):
(org-babel-julia-evaluate-session):
* lisp/org/ob-core.el (org-babel-default-header-args):
* lisp/obsolete/mouse-sel.el (mouse-select):
(mouse-select-secondary):
* lisp/net/tramp.el (tramp-methods):
* lisp/net/eww.el (eww-accept-content-types):
* lisp/net/dictionary-connection.el (dictionary-connection-status):
* lisp/minibuffer.el (completion-flex--make-flex-pattern):
* lisp/mh-e/mh-mime.el (mh-have-file-command):
* lisp/mh-e/mh-limit.el (mh-subject-to-sequence):
(mh-subject-to-sequence-threaded):
(mh-subject-to-sequence-unthreaded):
* lisp/mail/feedmail.el (feedmail-queue-buffer-file-name):
(feedmail-vm-mail-mode):
* lisp/ls-lisp.el (ls-lisp--sanitize-switches):
* lisp/keymap.el (key-valid-p):
* lisp/international/ccl.el (ccl-compile-branch-blocks):
* lisp/image/image-converter.el (image-convert):
* lisp/gnus/spam.el (spam-backend-check):
* lisp/gnus/nnselect.el (nnselect-generate-artlist):
* lisp/gnus/nnmairix.el (nnmairix-widget-other):
* lisp/gnus/message.el (message-mailto):
* lisp/gnus/gnus-sum.el (gnus-collect-urls-from-article):
* lisp/gnus/gnus-search.el (gnus-search-prepare-query):
* lisp/frame.el (frame-size-history):
* lisp/eshell/esh-var.el (eshell-parse-variable-ref):
* lisp/eshell/em-dirs.el (eshell-expand-multiple-dots):
* lisp/erc/erc-backend.el (erc-bounds-of-word-at-point):
* lisp/emulation/cua-rect.el (cua--rectangle-operation):
* lisp/emacs-lisp/text-property-search.el (text-property-search-forward):
* lisp/emacs-lisp/package.el (package-desc-suffix):
* lisp/emacs-lisp/faceup.el (faceup-test-explain):
* lisp/emacs-lisp/comp.el (comp-curr-allocation-class):
(comp-alloc-class-to-container):
(comp-add-cstrs):
(comp-remove-type-hints-func):
(batch-byte+native-compile):
* lisp/emacs-lisp/cl-macs.el (cl--optimize):
* lisp/elec-pair.el (electric-pair--syntax-ppss):
* lisp/doc-view.el (doc-view-doc-type):
* lisp/cedet/semantic/symref.el (semantic-symref-tool-alist):
(semantic-symref-hit-to-tag-via-db):
(semantic-symref-hit-to-tag-via-buffer):
* lisp/cedet/semantic/lex-spp.el (semantic-lex-spp-get-overlay):
* lisp/cedet/semantic/java.el (semantic-java-doc-keywords-map):
* lisp/cedet/semantic/find.el (semantic-brute-find-tag-by-function):
* lisp/cedet/semantic/db.el (semanticdb-project-predicate-functions):
* lisp/cedet/semantic.el (semantic-working-type):
* lisp/cedet/ede/files.el (ede-flush-directory-hash):
* lisp/calc/calc.el (calc--header-line):
* lisp/auth-source.el (auth-source-pick-first-password):
(auth-source--decode-octal-string):
* etc/themes/modus-themes.el (modus-themes--paren):
(modus-themes--agenda-habit):
* admin/cus-test.el (cus-test-vars-with-changed-state): Fix
quoting in doc strings.  In code examples, the ' character is
quoted with \\=, and regularize 'foo to `foo', and quote strings
like "foo" instead of 'foo'.
2022-04-22 16:17:22 +02:00
Amin Bandali
f4bfe7834a
ERC: Add new comaintainer, F. Jason Park
* lisp/erc/erc*.el: Add J.P. as my comaintainer to headers.
2022-01-24 10:59:05 -05:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00