Stefan Kangas [Sun, 3 Jul 2022 12:40:21 +0000 (14:40 +0200)]
Improve navigation keybindings in emacs-news-mode
* lisp/textmodes/emacs-news-mode.el (emacs-news-common-map): New
defvar-keymap. Bind navigation commands as in 'org-mode' and
'outline-minor-mode'.
(emacs-news-mode-map): Inherit from 'emacs-news-common-map'.
(emacs-news-view-mode-map): New defvar-keymap; inherit from
'emacs-news-common-map'.
Eli Zaretskii [Sun, 3 Jul 2022 12:37:50 +0000 (15:37 +0300)]
Fix implementation of 'reset' face values
* src/xfaces.c (Finternal_merge_in_global_face)
(gui_supports_face_attributes_p): Only modify local copy of face
attributes when replacing 'reset' pseudo-values with real values.
(Bug#38771)
Fix `python-nav-beginning-of-defun' line continuation using backslash
* lisp/progmodes/python.el (python-nav--beginning-of-defun): Allow
line continuation using backslash in defuns (bug#55702).
(python-info-looking-at-beginning-of-defun): Add CHECK-STATEMENT
argument.
Make string-limit with encoding return complete glyphs
* lisp/emacs-lisp/subr-x.el (string-limit): Return more correct
results in the CODING-SYSTEM case for coding systems with BOM and
charset designations (bug#48324). Also amend the algorithm to
return complete glyphs, not just complete code points.
* lisp/gnus/nnimap.el (nnimap-retrieve-headers): Don't stream the
UID FETCH commands, since the server may return the results
out-of-order (bug#56332).
* lisp/elec-pair.el (electric-pair--with-text-syntax): New macro.
(electric-pair-syntax-info):
(electric-pair--balance-info):
(electric-pair--syntax-ppss, electric-pair--balance-info): Use it.
(electric-pair--with-uncached-syntax): Remove (bug#49629).
The main bug that this is fixing is `syntax-propertize-function' being
hidden in `electric-pair--balance-info' when the original syntax table
is to be used, not `electric-pair-text-syntax-table'.
Notably, this causes `electric-pair-mode' to often misbehave in HTML
files when pairing angle brackets.
This commit also flushes the cache before installing
`electric-pair-text-syntax-table', to prevent cached syntax for the
original table from affecting things.
Eli Zaretskii [Sun, 3 Jul 2022 09:30:24 +0000 (12:30 +0300)]
Implement pseudo-value 'reset' of face attrributes
* doc/lispref/display.texi (Face Attributes):
* etc/NEWS: Document the new pseudo-value 'reset'.
* src/xfaces.c (realize_named_face, lookup_derived_face)
(gui_supports_face_attributes_p, lookup_named_face)
(Finternal_merge_in_global_face, merge_named_face, merge_faces):
Handle the 'reset' pseudo-value of a face's attribute.
(syms_of_xfaces): New symbol 'reset'.
(RESET_P): New macro.
(check_lface_attrs, Finternal_set_lisp_face_attribute): Allow
'reset' as a value of any attribute except ':inherit'.
(Bug#38771)
Po Lu [Sun, 3 Jul 2022 06:33:02 +0000 (14:33 +0800)]
Fix deadlocks with very old versions of libXi
* src/xfns.c (setup_xi_event_mask, Fx_create_frame): Set
`xi_mask' ourselves if the version of libXi is too old to have
working XIGetSelectedEvents.
* src/xterm.c (x_destroy_window): Free `xi_mask' with xfree in
that case.
Stefan Kangas [Sun, 3 Jul 2022 04:30:38 +0000 (06:30 +0200)]
Merge from origin/emacs-28
dc3d01a5af CC Mode: Fix a c-backward-token-2 call wrongly jumping bac... e390396e68 Doc fixes; don't use obsolete names c85f7c2e8a Don't refer to obsolete alias for insert-char 60ad45c5d2 Don't use obsolete face name in manoj-dark-theme
Po Lu [Sun, 3 Jul 2022 01:41:32 +0000 (09:41 +0800)]
Speed up receiving drops over slow connections
* lisp/x-dnd.el (x-dnd-debug-errors): New variable.
(x-dnd-handle-drag-n-drop-event): Bind
`x-fast-protocol-requests' to t if that is off.
* src/xfns.c (Fx_change_window_property):
(Fx_delete_window_property):
* src/xselect.c (Fx_send_client_message, x_send_client_event):
Don't sync to check for errors if fast protocol requests are
enabled.
* src/xterm.c (x_catch_errors_for_lisp, x_check_errors_for_lisp)
(x_uncatch_errors_for_lisp): New functions.
(syms_of_xterm): New variable `x-fast-protocol-requests'.
* src/xterm.h: Update prototypes.
Alan Mackenzie [Sat, 2 Jul 2022 16:12:59 +0000 (16:12 +0000)]
CC Mode: Fix a c-backward-token-2 call wrongly jumping back over macros.
This fixes bug #56256.
* lisp/progmodes/cc-fonts.el (c-font-lock-c++-lambda-captures): Replace a
c-backward-token-2, which could jump back too far leading to an infinite
loop, with a save-excursion to remember the point we've got to go back to.
Manuel Giraud [Sat, 2 Jul 2022 15:38:36 +0000 (17:38 +0200)]
Add more separators to longlines-mode
* lisp/obsolete/longlines.el (longlines-breakpoint-chars): New
custom to have multiple breakpoint chars.
(longlines-set-breakpoint): Add a target-column parameter and use
`longlines-breakpoint-chars'.
(longlines-find-break-backward, longlines-find-break-foreward):
Use `longlines-breakpoint-chars'.
(longlines-wrap-line): Do not insert space upon merging, just
remove the soft newline. Fix "space before tab" in indent.
(longlines-merge-lines-p): Use the new target-column parameter to
find out if the next line could be merged with the current one.
(longlines-encode-region): Do not replace a soft newline with a
space, just remove it.
* etc/NEWS: New user option 'longlines-breakpoint-chars'
Stefan Kangas [Sat, 2 Jul 2022 13:41:43 +0000 (15:41 +0200)]
Move dired-info and dired-man from dired-x to dired
* lisp/dired-x.el (dired-bind-man, dired-bind-info): Change into
defvars and make obsolete.
(dired-extra-startup): Doc fix.
(dired-info, dired-man): Move from here...
* lisp/dired.el (dired-do-info, dired-do-man): ...to here and
rename. (Bug#21981)
* lisp/dired.el (dired-mode-map): Bind 'I' and 'N' to 'dired-do-info'
and 'dired-do-man'.
* doc/misc/dired-x.texi (Miscellaneous Commands): Remove documentation
of 'dired-info' and 'dired-man'.
* doc/emacs/dired.texi (Dired Enter): Document 'dired-do-info' and
'dired-do-man'.
* etc/NEWS: Announce the above changes.
Po Lu [Sat, 2 Jul 2022 13:55:22 +0000 (21:55 +0800)]
Fix error handling for XCB Xlib
* src/xterm.c (xm_send_drop_message)
(xm_send_top_level_enter_message, xm_send_drag_motion_message)
(xm_send_top_level_leave_message, x_dnd_compute_toplevels)
(x_dnd_send_enter, x_dnd_send_position, x_dnd_send_leave)
(x_dnd_send_drop, handle_one_xevent, x_catch_errors_with_handler)
(x_request_can_fail, x_clean_failable_requests)
(x_ignore_errors_for_next_request, x_stop_ignoring_errors)
(x_uncatch_errors, x_check_errors, x_had_errors_p, x_error_handler)
(frame_set_mouse_pixel_position, x_focus_frame): Record serial
sequences instead of simply the next request when ignoring a
single request. Use XNextRequest instead of NextRequest, since
the latter is unreliable when using Xlib built with XCB.
* src/xterm.h (struct x_failable_request): New struct..
(struct x_display_info): Make failable request variables the
right type.
Command for global adjustments to the default face
* lisp/face-remap.el (global-text-scale-adjust): New command.
(text-scale-adjust): Refer to the new related command.
(global-text-scale-adjust-resizes-frames): New user option.
* lisp/mwheel.el (mouse-wheel-scroll-amount): Add the new command
to the mouse wheel scrolling events.
(mouse-wheel-global-text-scale): New function.
(mouse-wheel-mode): Use the new function with mouse-wheel-mode.
* doc/emacs/display.texi (Text Scale): Document the new command and
the new user option.
* etc/NEWS: Mention the new command and its bindings, and the new
user option.
Make comint-watch-for-password-prompt more resilient
* lisp/comint.el (comint-watch-for-password-prompt): Don't try to
send commands to the process after it's exited (bug#56336). (This
commonly happens when invoked via `M-&'.)
Visuwesh [Thu, 30 Jun 2022 14:06:41 +0000 (19:36 +0530)]
Fix fallout from bug#50143
* lisp/language/ind-util.el (indian-tml-base-table)
(indian-tml-base-digits-table): Add TAMIL OM sign and more Sanskrit
consonants to the table (bug#50143) (bug#56323).
Po Lu [Sat, 2 Jul 2022 06:06:28 +0000 (14:06 +0800)]
Fix drag-and-drop from Chromium family browsers
* lisp/x-dnd.el (x-dnd-copy-types): New defcustom.
(x-dnd-default-test-function): Check if data type warrants using
`copy'.
(x-dnd-do-direct-save): Offer application/octet-stream as well.
Po Lu [Sat, 2 Jul 2022 01:06:36 +0000 (09:06 +0800)]
Return the correct action from the Lisp side of drag-and-drop
* lisp/x-dnd.el (x-dnd-handle-drag-n-drop-event): Select
`window' when handling internal DND events.
(x-dnd-handle-unsupported-drop): Return an appropriate action.
* src/keyboard.c (kbd_buffer_get_event):
* src/termhooks.h (enum event_kind): Delete
`UNSUPPORTED_DROP_EVENT'.
* src/xterm.c (x_dnd_send_unsupported_drop): Set flags instead
of recording input event.
(x_clear_dnd_monitors): Rename to `x_clear_dnd_variables'. Also
clear unsupported drop data.
(x_dnd_begin_drag_and_drop): Run unsupported drop function
inline (and safely), and use its return value if it returned a
symbol.
(syms_of_xterm): Update doc string of
`x-dnd-unsupported-drop-function'.
* lisp/progmodes/elisp-mode.el (elisp-byte-compile-buffer):
Require bytecomp so that byte-compile-dest-file-function is
defined. (The byte compiler didn't catch this, because it's
defined in bytecomp.)
Po Lu [Fri, 1 Jul 2022 08:17:11 +0000 (16:17 +0800)]
Prevent XdndPosition messages from rarely being sent out of band
* src/xterm.c (handle_one_xevent): Don't clear
`x_dnd_waiting_for_status_window' if a pending position message
was sent in reply to an XdndStatus event.
Po Lu [Fri, 1 Jul 2022 08:12:45 +0000 (16:12 +0800)]
Support receiving XDS drops correctly
* etc/NEWS: Announce new feature. It is not yet documented.
* lisp/x-dnd.el (x-dnd-known-types): Add XdndDirectSave0.
(x-dnd-direct-save-function): New defcustom.
(x-dnd-xdnd-to-action): Add `direct-save'.
(x-dnd-maybe-call-test-function): If XDS is present, use `direct-save'.
(x-dnd-find-type): New function.
(x-dnd-handle-xdnd): Handle XDS position and drop messages.
(x-dnd-handle-direct-save): Don't use local-file-uri if nil.
(x-dnd-save-direct): New function.
(x-dnd-handle-octet-stream-for-drop):
(x-dnd-handle-xds-drop): New functions.
Po Lu [Fri, 1 Jul 2022 03:31:25 +0000 (11:31 +0800)]
Add tests for XDS protocol support
* test/lisp/x-dnd-tests.el (x-dnd-tests-xds-property-value): New
variable.
(x-window-property): Handle new kind of window property.
(x-dnd-tests-xds-target-dir, x-dnd-tests-xds-name)
(x-dnd-tests-xds-include-hostname): New variables.
(x-dnd-tests-call-xds-converter): New function.
(x-begin-drag, x-change-window-property):
(x-delete-window-property): New replacement functions.
(x-dnd-tests-do-direct-save-internal): New function.
(x-dnd-tests-do-direct-save): New test.
Po Lu [Fri, 1 Jul 2022 02:23:13 +0000 (10:23 +0800)]
Fix `clipboard-yank' inserting off the kill ring instead of CLIPBOARD
* lisp/select.el (gui-last-cut-in-clipboard)
(gui-last-cut-in-primary): New variables.
(gui-select-text): Set those variables.
(gui--selection-value-internal, gui-selection-value): Don't
return nil if the last cut did not own the chosen
selection. (bug#56325)
Po Lu [Fri, 1 Jul 2022 01:10:34 +0000 (09:10 +0800)]
Disable middle click selection emulation during XDS
* doc/lispref/frames.texi (Drag and Drop): Document new
variable.
* lisp/x-dnd.el (x-dnd-do-direct-save): Disable drop emulation
during XDS drag-and-drop.
* src/keyboard.c (kbd_buffer_get_event): Handle recorded value.
* src/xterm.c (x_dnd_do_unsupported_drop): Return if new
variable is nil.
(x_dnd_send_unsupported_drop): Record value of new variable in
events.
(x_dnd_begin_drag_and_drop): Handle recorded value.
(syms_of_xterm): New variable `x-dnd-use-unsupported-drop'.
F. Jason Park [Fri, 1 Jul 2022 00:15:25 +0000 (17:15 -0700)]
; Help ERC test fixture better withstand reordering
* test/lisp/erc/erc-tests.el (erc-tests--with-process-input-spy):
Shadow hook to prevent the erc-button module from interfering with
tests using this helper.
F. Jason Park [Fri, 18 Jun 2021 11:25:44 +0000 (04:25 -0700)]
Update ERC's Info doc with network-ID related changes
* doc/misc/erc.texi: Update the `erc' and `erc-tls' entry-point
sections with the new :id keyword parameter. Expand the auth-info
related information in the passwords section. Remove all mention of
the variable `erc-rename-buffers', whose "on" behavior has been made
permanent.
* etc/ERC-NEWS: Add new section for future 5.5 release.
F. Jason Park [Wed, 27 Apr 2022 09:27:32 +0000 (02:27 -0700)]
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.
F. Jason Park [Mon, 21 Mar 2022 12:40:16 +0000 (05:40 -0700)]
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)
F. Jason Park [Tue, 22 Mar 2022 02:21:57 +0000 (19:21 -0700)]
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)
F. Jason Park [Mon, 16 Aug 2021 11:38:18 +0000 (04:38 -0700)]
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)
F. Jason Park [Sun, 30 May 2021 07:50:50 +0000 (00:50 -0700)]
Favor network identities in erc-join
* lisp/erc/erc-join.el (erc-autojoin-server-match): Favor network
identities, falling back on old definition.
(erc-autojoin--join): Add new helper containing common code from
hookees `erc-autojoin-after-ident' and `erc-autojoin-channels'.
(erc-autojoin-after-ident, erc-autojoin-channels): No longer make a
point of returning nil because the hooks they're registered on,
`erc-nickserv-identified-hook' and `erc-after-connect', don't stop on
success.
(erc-autojoin--mutate): Add helper for `erc-autojoin-add' and
`erc-autojoin-remove'.
(erc-autojoin-add, erc-autojoin-remove): Favor given network
identities, over networks, when matching keys for
`erc-autojoin-channels-alist'.
* test/lisp/erc/erc-scenarios-base-reconnect.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-newcmd-id.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-newcmd.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-recon-id.el: New file.
* test/lisp/erc/erc-scenarios-join-netid-recon.el: New file.
* test/lisp/erc/resources/erc-scenarios-common.el: New file.
* test/lisp/erc/resources/join/legacy/foonet.eld: New file.
* test/lisp/erc/resources/join/network-id/barnet.eld: New file.
* test/lisp/erc/resources/join/network-id/foonet-again.eld: New file.
* test/lisp/erc/resources/join/network-id/foonet.eld: New file.
* test/lisp/erc/resources/join/reconnect/foonet-again.eld: New file.
* test/lisp/erc/resources/join/reconnect/foonet.eld: New file.
F. Jason Park [Fri, 7 May 2021 08:52:41 +0000 (01:52 -0700)]
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.
F. Jason Park [Thu, 28 Oct 2021 04:13:24 +0000 (21:13 -0700)]
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.
F. Jason Park [Thu, 13 May 2021 12:55:22 +0000 (05:55 -0700)]
Add user-oriented test scenarios for ERC
* test/lisp/erc/erc-scenarios-base-association-nick.el: New file.
* test/lisp/erc/erc-scenarios-base-association-samenet.el: New file.
* test/lisp/erc/erc-scenarios-base-association.el: New file.
* test/lisp/erc/erc-scenarios-base-compat-rename-bouncer.el: New file.
* test/lisp/erc/erc-scenarios-base-misc-regressions.el: New file.
* test/lisp/erc/erc-scenarios-base-netid-bouncer-id.el: New file.
* test/lisp/erc/erc-scenarios-base-netid-bouncer-recon-base.el: New file.
* test/lisp/erc/erc-scenarios-base-netid-bouncer-recon-both.el: New file.
* test/lisp/erc/erc-scenarios-base-netid-bouncer-recon-id.el: New file.
* test/lisp/erc/erc-scenarios-base-netid-bouncer.el: New file.
* test/lisp/erc/erc-scenarios-base-netid-samenet.el: New file.
* test/lisp/erc/erc-scenarios-base-reconnect.el: New file.
* test/lisp/erc/erc-scenarios-base-renick.el: New file.
* test/lisp/erc/erc-scenarios-base-reuse-buffers.el: New file.
* test/lisp/erc/erc-scenarios-base-unstable.el: New file.
* test/lisp/erc/erc-scenarios-base-upstream-recon-soju.el: New file.
* test/lisp/erc/erc-scenarios-base-upstream-recon-znc.el: New file.
* test/lisp/erc/erc-scenarios-misc.el: New file.
* test/lisp/erc/erc-scenarios-services-misc.el: New file.
* test/lisp/erc/resources/base/assoc/bouncer-history/barnet.eld: New file.
* test/lisp/erc/resources/base/assoc/bouncer-history/foonet.eld: New file.
* test/lisp/erc/resources/base/assoc/bumped/again.eld: New file.
* test/lisp/erc/resources/base/assoc/bumped/foisted.eld: New file.
* test/lisp/erc/resources/base/assoc/bumped/refoisted.eld: New file.
* test/lisp/erc/resources/base/assoc/bumped/renicked.eld: New file.
* test/lisp/erc/resources/base/assoc/multi-net/barnet.eld: New file.
* test/lisp/erc/resources/base/assoc/multi-net/foonet.eld: New file.
* test/lisp/erc/resources/base/assoc/reconplay/again.eld: New file.
* test/lisp/erc/resources/base/assoc/reconplay/foonet.eld: New file.
* test/lisp/erc/resources/base/assoc/samenet/chester.eld: New file.
* test/lisp/erc/resources/base/assoc/samenet/tester.eld: New file.
* test/lisp/erc/resources/base/assoc/samenet/tester2.eld: New file.
* test/lisp/erc/resources/base/channel-buffer-revival/foonet.eld: New file.
* test/lisp/erc/resources/base/flood/soju.eld: New file.
* test/lisp/erc/resources/base/gapless-connect/barnet.eld: New file.
* test/lisp/erc/resources/base/gapless-connect/foonet.eld: New file.
* test/lisp/erc/resources/base/gapless-connect/pass-stub.eld: New file.
* test/lisp/erc/resources/base/netid/bouncer/barnet-again.eld: New file.
* test/lisp/erc/resources/base/netid/bouncer/barnet-drop.eld: New file.
* test/lisp/erc/resources/base/netid/bouncer/barnet.eld: New file.
* test/lisp/erc/resources/base/netid/bouncer/foonet-again.eld: New file.
* test/lisp/erc/resources/base/netid/bouncer/foonet-drop.eld: New file.
* test/lisp/erc/resources/base/netid/bouncer/foonet.eld: New file.
* test/lisp/erc/resources/base/netid/bouncer/stub-again.eld: New file.
* test/lisp/erc/resources/base/netid/samenet/chester.eld: New file.
* test/lisp/erc/resources/base/netid/samenet/tester.eld: New file.
* test/lisp/erc/resources/base/reconnect/aborted-dupe.eld: New file.
* test/lisp/erc/resources/base/reconnect/aborted.eld: New file.
* test/lisp/erc/resources/base/reconnect/options-again.eld: New file.
* test/lisp/erc/resources/base/reconnect/options.eld: New file.
* test/lisp/erc/resources/base/reconnect/timer-last.eld: New file.
* test/lisp/erc/resources/base/reconnect/timer.eld: New file.
* test/lisp/erc/resources/base/renick/queries/bouncer-barnet.eld: New file.
* test/lisp/erc/resources/base/renick/queries/bouncer-foonet.eld: New file.
* test/lisp/erc/resources/base/renick/queries/solo.eld: New file.
* test/lisp/erc/resources/base/renick/self/auto.eld: New file.
* test/lisp/erc/resources/base/renick/self/manual.eld: New file.
* test/lisp/erc/resources/base/renick/self/qual-chester.eld: New file.
* test/lisp/erc/resources/base/renick/self/qual-tester.eld: New file.
* test/lisp/erc/resources/base/reuse-buffers/server/barnet.eld: New file.
* test/lisp/erc/resources/base/reuse-buffers/server/foonet.eld: New file.
* test/lisp/erc/resources/base/upstream-reconnect/soju-barnet.eld: New file.
* test/lisp/erc/resources/base/upstream-reconnect/soju-foonet.eld: New file.
* test/lisp/erc/resources/base/upstream-reconnect/znc-barnet.eld: New file.
* test/lisp/erc/resources/base/upstream-reconnect/znc-foonet.eld: New file.
* test/lisp/erc/resources/erc-scenarios-common.el: New file.
* test/lisp/erc/resources/networks/announced-missing/foonet.eld: New file.
* test/lisp/erc/resources/services/password/libera.eld: New file.
Add test cases for locking down fundamental client behavior, much of
it involving the relationship between buffers and connections. Also
add accompanying resources subdir containing canned dialog scripts and
common code needed by various tests. For test cases demoing the
problematic behavior originally described in the initial report, see
update #4 on the bug tracker thread for bug#48598. Most reside in a
file named test/lisp/erc/erc-scenarios-48598.el introduced by the
patch "Add user-oriented test scenarios for ERC".
F. Jason Park [Mon, 3 May 2021 12:54:56 +0000 (05:54 -0700)]
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.