aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp/erc (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Fix overlapping logs from erc-truncate-buffer-on-saveF. Jason Park2023-12-231-0/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-button.el (erc-button--display-error-notice-with-keys): Currently, internal "error notices" do not have timestamps. However, this causes alignment issues for non-`fill-wrap' users of left-sided stamps. The heuristic used by this change for detecting such stamps is weak and prone to false negatives. * lisp/erc/erc-log.el (erc-log-mode, erc-log-enable): Set explicit depth for `erc--pre-clear-functions' to 50. (erc-save-buffer-in-logs): Fix partial regression in which redundant text would appear in logs that have undergone truncation via an interactive call to this command when the deprecated option `erc-truncate-on-save' is non-nil. * lisp/erc/erc-stamp.el (erc-stamp-mode, erc-stamp-enable): Set depth for `erc--pre-clear-functions' to 40. (erc-stamp--reset-on-clear): Only add `erc-stamp--insert-date-hook' when `erc-stamp--date-mode' is active. * lisp/erc/erc.el (erc-cmd-CLEAR): Rework to honor but improve upon the old behavior when called from lisp. Do this by attempting to find the beginning of the current message and excluding it from the truncated portion of the buffer. A NEWS entry describing this behavior already exists for 5.6. * test/lisp/erc/erc-scenarios-log.el (erc-scenarios-log--save-buffer-in-logs/truncate-on-save): New test. These changes originate from bug#60936.
* Replace some uses of erc-errorF. Jason Park2023-12-233-23/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-button.el (erc-button--display-error-notice-with-keys-and-warn): Use `erc--lwarn' so the warnings buffer is overridable for testing. * lisp/erc/erc-sasl.el (erc-sasl-mode, erc-sasl-enable): Signal an `error' instead of calling `erc-error', which continues execution. In this special case, the session cannot continue initializing, since connection registration can't reasonably be expected to complete successfully. (erc-sasl--destroy): Don't run `erc-quit-hook', and issue a warning of level `:error' to get users' attention instead of calling `ding'. * lisp/erc/erc-speedbar.el (erc-speedbar--emulate-sidebar-set-window-preserve-size): Don't set window parameters. Doing this basically made `erc-speedbar-toggle-nicknames-window-lock' unusable. (erc-speedbar--toggle-nicknames-sidebar): Manually unlock the window after toggling. (erc-nickbar-mode, erc-nickbar-enable, erc-nickbar-disable): Don't `ding' when called in a non-ERC buffer, and make sure to call `erc-speedbar--ensure' from an ERC buffer. Also, don't disable minor-mode var when speedbar buffer doesn't exist because that doesn't ensure it'll be created the next time around, and users may count on the activation state remaining consistent. (erc-speedbar-toggle-nicknames-window-lock): Make usable from lisp with explicit numeric arg. * lisp/erc/erc-status-sidebar.el (erc-bufbar-mode, erc-bufbar-enable): Only create the side window from an erc-mode buffer to ensure the ratio is preserved when burying the current buffer, e.g., with `custom-buffer-done'. * lisp/erc/erc.el (erc--warnings-buffer-name, erc--lwarn): New function, an analog of `lwarn', that allows for overriding the warnings buffer with the new variable `erc--warnings-buffer-name'. (erc-cmd-SERVER): Add comment. * test/lisp/erc/erc-scenarios-sasl.el (erc-scenarios-sasl--plain-fail): Expect warning instead of error. * test/lisp/erc/erc-scenarios-status-sidebar.el (erc-scenarios-status-sidebar--bufbar): Refresh when interactive as well. * test/lisp/erc/resources/sasl/plain-failed.eld: Expect EOF instead of "CAP END". (Bug#63595)
* ; Fix some doc strings in ERCF. Jason Park2023-12-231-1/+1
| | | | | | | | * lisp/erc/erc-networks.el: Lose some unneeded forward declarations. * lisp/erc/erc.el (erc-open-socks-tls-stream): Don't conflate SOCKS with TOR by mentioning a ".onion" address for the `host' parameter. * test/lisp/erc/erc-tests.el (erc--check-prompt-input-for-multiline-blanks): Extend timeout.
* Add erc-track integration to erc-nicksF. Jason Park2023-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-button.el (erc-button--nick): Add `face-cache' slot. (erc-button-add-nickname-buttons): Pass `erc-button--nick' object, if created', as the boolean NICK-P parameter when calling `erc-button-add-button'. Keeping the latter function ignorant of `erc-button--nick' is of course preferable, but some coordination is now required to convey and use the "face cache". We can introduce an abstraction, like a local variable, if this becomes an issue. (erc-button-add-button): Use `erc--merge-prop' instead of `erc-button-add-face' to apply button faces. Hold off on deprecating the latter because it provides unique functionality for nesting faces. Also, consult NICK-P if it's an `erc-button--nick' object for the various overriding faces it knows about. * lisp/erc/erc-nicks.el (erc-nicks-track-faces): New option. (erc-nicks--get-face): Make generated face `:inherit' from `erc-nicks-backing-face'. (erc-nicks--highlight): Just return the generated face instead of combining it with `erc-nicks-backing-face'. (erc-nicks--highlight-button): Set the `face-cache' slot of the `erc-button--nick' object when `track' is loaded and initialized. (erc-nicks-mode, erc-nicks-enable, erc-nicks-disable): Add and remove `track' integration. (erc-nicks--reject-uninterned-faces): New function to remove faces created by `nicks' from buttonized speakers and mentions. Conform to `erc-track--face-reject-function' interface. (erc-nicks--ourps, erc-nicks--check-normals): New function and helper for `erc-track--alt-normals-function' interface. (erc-nicks--setup-track-integration): New function. (erc-nicks--remember-face-for-track): New function to cache nick faces owned by this module. * lisp/erc/erc.el (erc--merge-prop): Add new optional parameter `cache-fn', and when non-nil, call it, assigning the returned value to that of the merged property. * test/lisp/erc/erc-nicks-tests.el (erc-nicks-list-faces): Skip the "Inherit: " button. (Bug#67767)
* Cache shortened channel names in erc-trackF. Jason Park2023-12-171-0/+36
| | | | | | | | | | | | | | * lisp/erc/erc-track.el (erc-track--shortened-names): New variable to stash both the latest inputs and most recent result of `erc-track-shorten-function'. (erc-track--shortened-names-current-hash, erc-track--shortened-names-set, erc-track--shortened-names-get): New pair of generalized-variable functions and helper variable for accessing and mutating `erc-track--shorten-prefixes'. (erc-modified-channels-display): Avoid redundant calls to `erc-track-shorten-function'. Mainly for use during batch processing. * test/lisp/erc/erc-track-tests.el (erc-track--shortened-names): New test. (Bug#67767)
* Promote "normal" faces in erc-trackF. Jason Park2023-12-171-0/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Add entry for new behavior involving the option `erc-track-faces-normal-list'. * lisp/erc/erc-button.el (erc-button-nick-default-face): New face to serve as default for `erc-button-nickname-face'. (erc-button-nickname-face): Change default value to `erc-button-nick-default-face'. * lisp/erc/erc-track.el (erc-track--massage-nick-button-faces): New function to serve as Custom :set function for priority and "normal" face-list options. (erc-track-faces-normal-list): Fix Custom :type by loading `erc-button' during validation so Customize chooses the correct UI instead of a generic form field with "(mismatch)" printed alongside the "STATE" button. (erc-track-faces-priority-list, erc-track-faces-normal-list): Remove values for "buttonized" `match' module faces that, if retained, would need updating to feature `erc-button-nick-default-face' instead of `erc-nick-default-face'. However, as noted in the NEWS entry, this ordering of button face atop match face is not possible. Use :set function to massage saved user values. (erc-track-ignore-normal-contenders-p): New compatibility switch to access pre-5.6 behavior, in which faces in `erc-track-faces-normal-list' were only considered for promotion to the mode line if the current face occupying that pole position wasn't present. (erc-track-mode, erc-track-enable, erc-track-disable): Add comments regarding perceived futility of hooking on `erc-server-001-functions' and likely unneeded hook removal. Run common buffer-local setup and teardown. (erc-track--normal-faces): New local variable, a snapshot of `erc-track-faces-normal-list'. (erc-track--setup): New function to stash `erc-track-faces-normal-list' on init. (erc-track-select-mode-line-face): Offer alternate explanation of certain particulars in doc string. (erc-track--alt-normals-function): New function-valued variable to allow other modules to intervene in deciding whether to pursue and promote a "normal" contending face. (erc-track--select-mode-line-face): New function similar to its public namesake except that it considers other viable candidates among the "normal" alternatives. (erc-track-modified-channels): Only run face selection portion when faces are actually found. Use `erc-track--select-mode-line-face' instead of `erc-track-select-mode-line-face'. * test/lisp/erc/erc-track-tests.el (erc-track-select-mode-line-face): New test. (erc-track-tests--select-mode-line-face): New fixture function. (erc-track--select-mode-line-face): New test. (Bug#67767)
* Consolidate status-prefix slots of erc-channel-userF. Jason Park2023-12-171-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Mention change even though the API remains undisturbed. * lisp/erc/erc-common.el (erc-channel-user): "Encode" status prefix slots `voice', `halfop', `op', `admin', and `owner' as single `status' slot. Add backward-compatible constructor. Although the old layout was overly sparse, since the vast majority of users have no membership status at all, the point here is not to trade time for space but rather to improve human readability of ERC buffer substrings containing text props that reference `erc-channel-user' objects. * lisp/erc/erc.el (erc--define-channel-user-status-compat-getter): Helper macro for declaring compat-oriented "getters" for status-prefix slots of `erc-channel-user'. (erc-channel-user-voice, erc-channel-user-halfop, erc-channel-user-op, erc-channel-user-admin, erc-channel-user-owner): Add compat getters. These are not new functions. They were previously defined by the `erc-channel-user' `cl-defstruct' in erc-common.el. (erc--update-cusr-status-if-changed): New helper macro to make `erc-update-current-channel-member' more readable. (erc-update-current-channel-member): Collapse some overly verbose "unrolled" forms using helper macro and more compact expressions. * test/lisp/erc/erc-tests.el (erc-channel-user): New test.
* Use templates for formatting chat messages in ERCF. Jason Park2023-12-177-36/+353
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/misc/erc.texi: Replace option `erc-format-nick-function' with `erc-show-speaker-membership-status'. * etc/ERC-NEWS: Mention shift to template-based speaker formatting. Also mention in-buffer STATUSMSG support and various name changes and new formatting-related options. * lisp/erc/erc-backend.el (erc-format-privmessage): Remove forward declaration. (erc--determine-speaker-message-format-args): Add forward declaration. (erc--statusmsg-target): New utility function for detecting whether the current target is status-prefixed. (erc-current-message-catalog): Move here from lisp/erc/erc.el. (erc--message-speaker-catalog): New variable. (erc--speaker-status-prefix-wanted-p): New variable specifically for the function `erc-format-@nick' to signal it wants status-prefixes prepended to the displayed nick. (erc-server-PRIVMSG): Initialize `let'-bound value of `erc--msg-prop-overrides' to a dummy `erc--tmp' property with a null value that `erc-display-message' will "strip" before calling its hooks. Move away from the rather blunt symbol `msg' as a useful value for `erc--msg'. Instead, allow `erc-display-message' to assign the most appropriate value based on context. Also, bind the variable `erc-current-message-catalog' to whatever the buffer's `erc--message-speaker-catalog' happens to be. Future internal modules can set this to alternative catalogs as needed. Additionally, detect STATUSMSG prefixes on targets and inform the formatting logic of the verdict. Lastly, and most importantly, use the function `erc--determine-speaker-message-format-args' instead of `erc-format-privmessage' for message formatting. Pass along the returned "catalog key" and spec parameters to `erc-display-message'. However, for NOTICEs, continue to render the string, as before, for the two "echo notice" hooks. * lisp/erc/erc-common.el (erc--ctcp-response): New "subsclass" of `erc-response' for smuggling extra information to CTCP query handlers in a mostly backwards-compatible way. The same approach could be taken with the "echo notice" hooks mentioned above. * lisp/erc/erc-dcc.el (erc-dcc-chat-filter): Add `erc--spkr' and `erc--speaker' properties even though these chat buffers are not `erc-mode' buffers. * lisp/erc/erc-fill.el (erc-fill--wrap-last-msg, erc-fill--wrap-max-lull): Add doc strings. (erc-fill--wrap-continued-message-p): Rework to look for `erc--spkr'- `erc--msg' combinations as indicators of speaker continuity. (erc-fill--wrap-rejigger-region): Remove reference to the no longer relevant `erc-stamp-type'. Instead, use the `erc--msg' property combined with the `erc-timestamp' field to detect date stamps because all are currently left-sided. * lisp/erc/erc-stamp.el (erc-stamp--propertize-left-date-stamp): Don't add superfluous `erc-stamp-type' property. * lisp/erc/erc.el (erc--msg-props): Revise purpose and meaning of `erc--msg' by removing possible value `msg', which was previously meant to indicate that a message had a "speaker". Instead, rely on the separate `erc--spkr' property to convey this information, with `erc--msg' now expressing a "type" or "role". (erc--use-language-catalog-for-ctcp-action-p): New variable, a compatibility switch to help transition from the `ACTION' entry of the language catalog to the `ctcp-action' family of entries in the new `-speaker' catalog. (erc--ensure-spkr-prop): Update to include any passed-in environmental overrides. (erc--send-action-display): Restore pre-5.6 behavior when compatibility flag enabled. Otherwise, use new `-speaker' catalog for formatting inserted message. (erc--send-message-external): Overhaul to behave more faithfully in mimicking a line submitted at the prompt of the current target buffer. (erc--own-property-names): Remove `erc-stamp-type'. (erc-ensure-target-buffer-on-privmsg): Add new choice variant for old default behavior and change meaning of default to mean "except for STATUSMSGs". This option is newly revived for ERC 5.6. (erc--message-speaker-statusmsg, erc--message-speaker-statusmsg-input, erc--message-speaker-input, erc--message-speaker-input-chan-privmsg, erc--message-speaker-input-chan-notice, erc--message-speaker-input-query-privmsg, erc--message-speaker-input-query-notice, erc--message-speaker-chan-privmsg, erc--message-speaker-query-privmsg, erc--message-speaker-chan-notice, erc--message-speaker-query-notice, erc--message-speaker-ctcp-action, erc--message-speaker-ctcp-action-input, erc--message-speaker-ctcp-action-statusmsg, erc--message-speaker-ctcp-action-statusmsg-input): New variables for new `speaker' format-template catalog. (erc--speakerize-nick): New helper function. (erc--determine-speaker-message-format-args): New function to find the appropriate format key from various contextual parameters. Could become the default of a function-valued variable for internal use. (erc-show-speaker-membership-status): New option. (erc-format-nick-function, erc-speaker-from-channel-member-function): Declare former as an obsolete alias for the latter, and redefine purpose slightly. (erc-format-nick-function, erc-determine-speaker-from-user): Rename former to latter and obsolete the old name. (erc-format-nick, erc-determine-speaker-from-user): Rename former to latter and obsolete old name. (erc-format-@nick): Deprecate and adapt for use with new template-based formatting paradigm. (erc-format-my-nick): Move `erc-speaker' text prop toward head of list, meaning it will end up beneath `font-lock-face' in the final output. (erc--format-speaker-input-message): New function to replace `erc-format-my-nick' in-tree. (erc-process-ctcp-query): Don't bind `erc--msg' to `msg'. Instead, rely on `erc-display-message' to set it to the current template key. (erc-ctcp-query-ACTION): Prefer using formatting template, but attempt to simulate pre-5.6 behavior when compatibility flag enabled. (erc-display-msg): Use `erc--format-speaker-input-message' instead of `erc-format-my-nick'. Ignore `erc--msg-prop-overrides' with null values. (erc-current-message-catalog): Move to erc-backend.el. * test/lisp/erc/erc-scenarios-base-statusmsg.el: New file. * test/lisp/erc/erc-scenarios-stamp.el (erc-scenarios-stamp--left/display-margin-mode): Expect format catalog key instead of unhelpful `msg' as value of `erc--msg' prop. * test/lisp/erc/erc-tests.el (erc-message): Render format template in mock function and expect string in assertions. (erc-tests--format-privmessage): New function, a helper for the following test. (erc-format-privmessage, erc--determine-speaker-message-format-args): Rename former to latter and suppress deprecation warning. (erc--determine-speaker-message-format-args/queries, erc--determine-speaker-message-format-args/queries-as-channel): New tests. (erc-tests--format-my-nick): New helper function for the following test. (erc--format-speaker-input-message): New test. * test/lisp/erc/resources/base/display-message/statusmsg.eld: New file. (Bug#67677) ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-post-01.eld: ; Update. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-pre-01.eld: ; Update.
* Add erc--spkr text property to chat messagesF. Jason Park2023-12-1713-15/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Mention combined face ordering for "/me" messages. * lisp/erc/erc-backend.el (erc-server-PRIVMSG): Bind `erc--msg-prop-overrides' for the extent of this function's execution, which means a large amount of code will see this variable as being non-nil. However, no calls to `erc-display-message' or `erc-display-msg' should occur other than the one handling the final insertion. Code needing to influence the current message's "msg props" can push new pairs onto this value, which will override any existing collisions. * lisp/erc/erc-fill.el (erc-fill): Switch to `erc--spkr' as sentinel property. (erc-fill--wrap-continued-message-p): Look for `erc--spkr' property instead of `erc-speaker'. * lisp/erc/erc.el (erc--msg-props): Mention `erc--spkr' in doc. (erc--send-action-perform-ctcp): Add `erc--spkr' property. Fix bug in which `erc-my-nick-face' appeared below `erc-input-face' in the speaker portion. (erc--ensure-spkr-prop): New helper function to propagate speaker metadata. (erc--ranked-properties): Add `erc--spkr', `erc--ctcp', and `erc--ephemeral'. (erc-display-message): Use default hash table size when initializing. Remove unnecessary assignment of `msg' to `erc--msg' for PRIVMSG and NOTICE commands. Bind `string' below `erc--msg-props' so that implementers of the function form of the `erc-format-message' templating interface can read and write the current context's "msg props". (erc--own-property-names): Add all `erc--msg-props' props by subsumation. (erc--get-speaker-bounds): Use `erc--spkr' instead of `erc--msg' as a sentinel to detect a chat message guaranteed to have an `erc--speaker' text-property interval. (erc-format-privmessage, erc-format-my-nick, erc-ctcp-query-ACTION): Add `erc--spkr' to `erc--msg-prop-overrides' when available. * test/lisp/erc/erc-fill-tests.el: (erc-fill-tests--insert-privmsg): Bind `erc--msg-prop-overrides'. (erc-fill-tests--compare): Require environment variable value to match current test name exactly when saving snapshots. Add `erc--msg-props' individually to white list. * test/lisp/erc/erc-tests.el (erc--order-text-properties-from-hash): Include `erc--spkr'. (Bug#60936) (Bug#67677) ; * test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-post-01.eld: ; Update. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-pre-01.eld: ; Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-01-start.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-02-right.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-03-left.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-04-reset.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/spacing-01-mono.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: Update.
* Clarify warning for process-dependent input in ERCF. Jason Park2023-12-171-2/+2
| | | | | | | | | | | * lisp/erc/erc.el (erc--check-prompt-input-for-running-process): Resolve dissonance between content of ancient `user-error' message and condition that triggered it by favoring the former because it's supported by the underlying mechanism, which revolves around the `process-not-needed' symbol property. * test/lisp/erc/erc-tests.el (erc--check-prompt-input-functions): Revise expected output for error assertion. (Bug#66073, originally from bug#54536, and included for discussion in bug#67677)
* Add erc-server-396 response handlerF. Jason Park2023-12-173-15/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-backend.el (erc-server-396, erc-server-396-functions): Define response handler for 396 numeric. For now, always display the message in the active buffer rather than bother with something like `erc-once-with-server-event' to try and suss out when this is a response to something client-initiated, like a /VHOST. Do this despite most users probably wanting the message to appear in the server buffer alone when the response is server-initiated. The `labeled-response' extension will hopefully make dealing with such matters less of a crapshoot. * lisp/erc/erc.el (erc--parse-user-regexp-pedantic): Tweak slightly to allow null groups and favor host. (erc--parse-user-regexp-legacy, erc--parse-user-regexp): Remove the first variable but preserve its value as that of the second. (erc--parse-nuh): New function. The behavior is nuanced and complex and so not easily described in a doc string. (erc-message-english-396): Define format template for 396 response. * test/lisp/erc/erc-scenarios-misc-commands.el (erc-scenarios-misc-commands--VHOST): New test. * test/lisp/erc/erc-tests.el (erc-parse-user): Move "pedantic" section to new test. (erc--parse-nuh): New test. * test/lisp/erc/resources/commands/vhost.eld: New test data file. (Bug#67677)
* Make erc-input's refoldp slot conditionally availableF. Jason Park2023-12-171-3/+4
| | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Fix entry regarding `erc-input-refoldp'. * lisp/erc/erc-common.el (erc-input): Remove `refoldp' slot, which was to be new in 5.6, in order to reduce churn in the extremely unlikely event that third-party code uses the read-syntax of these objects or ones subclassed from it for some other purpose, outside of `erc-pre-send-functions'. (erc--input-split) Add `refoldp' slot here instead. * lisp/erc/erc.el (erc-pre-send-functions): Amend doc string to stress that `refoldp' is not a real slot. (erc--input-ensure-hook-context, erc-input-refoldp): New function, an impostor accessor for the nonexistent `refoldp' slot of `erc-input', and a helper function for asserting a valid context at runtime. (erc--run-send-hooks): Don't copy over `refoldp' from the `erc--input-lines' object to the working `erc-insert' object. Check the insertion context's `erc--input-split' object instead of the hook's `erc-insert' object when deciding whether to resplit. * test/lisp/erc/erc-tests.el: Adjust test environment to satisfy assertion. (Bug#62947)
* Add utility for iterating over arrays in ERCF. Jason Park2023-12-171-0/+13
| | | | | | | | | | | | | | | | | | * lisp/erc/erc-common.el (erc--doarray): Add macro for mapping over arrays. ERC has the uncommon requirement of having to repeatedly traverse strings that contain flags for advertised server features. It doesn't make sense to translate these meanings into enums or dynamically generate variables for each flag. Hash tables and lists require additional setup and aren't as compact to inspect. * lisp/erc/erc-dcc.el (erc-dcc-handle-ctcp-send): Use `string-search' instead of `seq-contains-p' even though performance doesn't matter here. * lisp/erc/erc.el (erc--channel-mode-types): Use `erc--doarray' instead of `dolist'. (erc--process-channel-modes): Use `erc--doarray' instead of `dolist', and don't create a string from current char until needed. (erc--parse-user-modes): Use `erc--doarray' instead of `dolist'. * test/lisp/erc/erc-tests.el (erc--doarray): New test. (Bug#67677)
* Double hyphenate internal ERC 5.6 text propsF. Jason Park2023-12-1716-44/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-fill.el (erc-fill, erc-fill-static, erc-fill--wrap-continued-message-p, erc-fill-wrap, erc-fill--wrap-rejigger-region): Add second hyphen to "msg prop" text properties. Rename `erc-speaker' to `erc--speaker'. * lisp/erc/erc-goodies.el (erc--command-indicator-display): Rename `erc-msg' to `erc--msg'. * lisp/erc/erc-stamp.el (erc-stamp--current-time, erc-add-timestamp, erc-stamp-prefix-log-filter, erc-stamp--lr-date-on-pre-modify, erc-munge-invisibility-spec, erc-stamp--add-csf-on-post-modify, erc-stamp--on-clear-message, erc-echo-timestamp, erc--echo-ts-csf): Rename "msg props" with second hyphen. * lisp/erc/erc-track.el (erc-track--skipped-msgs, erc-track-modified-channels): Rename "msg prop" text properties with second hyphen. * lisp/erc/erc.el (erc--msg-props): Update doc with double-hyphenated "msg prop" names. (erc--send-action-display erc--get-inserted-msg-bounds, erc--traverse-inserted, erc-insert-line, erc-display-line, erc--ranked-properties, erc-display-message, erc--get-speaker-bounds, erc-process-ctcp-query, erc-display-msg): Update all "msg prop" names to have two hyphens. (erc--send-action-display, erc--own-property-names, erc--get-speaker-bounds, erc-format-privmessage, erc-format-my-nick, erc-ctcp-query-ACTION): Rename `erc-speaker' to `erc--speaker'. * test/lisp/erc/erc-scenarios-display-message.el (erc-scenarios-display-message--multibuf): Double hyphenate "msg prop" text properties. * test/lisp/erc/erc-scenarios-match.el (erc-scenarios-match--hide-fools/stamp-both/fill-wrap, erc-scenarios-match--hide-fools/stamp-both/fill-wrap/speak, erc-scenarios-match--stamp-both-invisible-fill-static): Update "msg prop" names. * test/lisp/erc/erc-scenarios-stamp.el (erc-scenarios-stamp--on-post-modify, erc-scenarios-stamp--left/display-margin-mode, erc-scenarios-stamp--legacy-date-stamps, erc-scenarios-stamp--on-insert-modify, erc-scenarios-stamp--date-mode/left-and-right): Add second hyphen to all "msg props". Rename `erc-speaker' to `erc--speaker'. * test/lisp/erc/erc-stamp-tests.el (erc-echo-timestamp): Rename "msg prop". * test/lisp/erc/erc-tests.el (erc--get-inserted-msg-bounds, erc--delete-inserted-message, erc--order-text-properties-from-hash, erc--route-insertion): Rename "msg props" with second hyphen. (erc-format-privmessage): Rename `erc-speaker' to `erc--speaker'. (Bug#60936) (Bug#67677) ; * test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-post-01.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-pre-01.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/monospace-01-start.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/monospace-02-right.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/monospace-03-left.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/monospace-04-reset.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/spacing-01-mono.eld: ; Add second hyphen to msg props. ; * test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: ; Add second hyphen to msg props.
* Sequester some special-variable declarations in ERCF. Jason Park2023-12-173-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-backend.el (erc-log-p): Remove declaration entirely. (erc-server-reconnect): Move declaration for `erc-reuse-buffers' here. (erc-process-sentinel-1): Move `erc-kill-server-buffer-on-quit' declaration here. (erc--conceal-prompt): Move `erc-prompt-hidden' declaration here. (erc-server-INVITE): Move `erc-invitation' declaration here. (erc-server-PART): Move `erc-kill-buffer-on-part' declaration here. (erc-server-PRIVMSG): Move declarations for `erc-minibuffer-ignored', `erc-receive-query-display', `erc-receive-query-display-defer', `erc--cmem-from-nick-function', `erc-format-nick-function', and `erc-format-query-as-channel-p' here. (erc-server-401): Move `erc-whowas-on-nosuchnick' declaration here. (erc-server-475): Move `erc--called-as-input-p' and `erc-prompt-for-channel-key' declarations here. * lisp/erc/erc-common.el (erc-log-p): Remove declaration for `erc-log-p' and replace with actual definition. (erc-log-aux): Move `erc-dbuf' declaration from top level into function body. * lisp/erc/erc-fill.el (erc-fill--wrap-continued-message-p): Note in the doc string that this function produces side effects. * lisp/erc/erc-networks.el (erc-determine-network, erc-networks--copy-server-buffer-functions): Move some variable declarations to function body. (erc-settings, erc-get): Deprecate for now and explain why in doc strings. We could deprecate them unconditionally, but they never provided usable code, and their names are short and valuable. * lisp/erc/erc.el (tabbar--local-hlf, motif-version-string, gtk-version-string): Prefer moving these single-serving declarations to function bodies, if only to make closures from this library less cluttered when debugging. This should also help avoid stray declarations. (erc-hooks, erc-timer-hook): Revise doc strings. (erc-log-p): Move definition to erc-common.el. (erc-cmd-SV): Mimic `emacs-version' and stick with `featurep', here in combination with special-variable declarations, instead of `boundp' or similar. (erc-header-line-uses-tabbar-p): Explain that this has nothing to do with `tab-bar'. (erc-update-mode-line-buffer): Only assign when bound. This has been verified to work with version 2.0 on EmacsWiki. * test/lisp/erc/erc-scenarios-base-reconnect.el: Timeouts. * test/lisp/erc/erc-scenarios-base-renick.el: Timeouts. * test/lisp/erc/resources/join/network-id/foonet-again.eld: Timeouts.
* Define ERC message-formatting templates with defvarF. Jason Park2023-12-171-0/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Mention convenience macro being preferred means of defining message templates. Mention renaming of `notify' formatting templates. * lisp/erc/erc-common.el (erc--define-catalog, erc-define-message-format-catalog): New macro and internal variant to replace `erc-define-catalog-entry'. The internal variant allows us to defer reindenting existing definitions until meaningfully edited. * lisp/erc/erc-dcc.el (erc-message-english-dcc-chat-discarded, erc-message-english-dcc-chat-ended, erc-message-english-dcc-chat-no-request, erc-message-english-dcc-chat-offered, erc-message-english-dcc-chat-offer, erc-message-english-dcc-chat-accept, erc-message-english-dcc-chat-privmsg, erc-message-english-dcc-closed, erc-message-english-dcc-command-undefined, erc-message-english-dcc-ctcp-errmsg, erc-message-english-dcc-ctcp-unknown, erc-message-english-dcc-get-bytes-received, erc-message-english-dcc-get-complete, erc-message-english-dcc-get-failed, erc-message-english-dcc-get-cmd-aborted, erc-message-english-dcc-get-file-too-long, erc-message-english-dcc-get-notfound, erc-message-english-dcc-list-head, erc-message-english-dcc-list-line, erc-message-english-dcc-list-item, erc-message-english-dcc-list-end, erc-message-english-dcc-malformed, erc-message-english-dcc-privileged-port, erc-message-english-dcc-request-bogus, erc-message-english-dcc-send-finished, erc-message-english-dcc-send-offered, erc-message-english-dcc-send-offer): Define at top level using `defvar'. * lisp/erc/erc-netsplit.el (erc-netsplit-mode, erc-netsplit-enable): Don't call `erc-netsplit-install-message-catalogs'. (erc-netsplit-install-message-catalogs): Deprecate function. (erc-message-english-netsplit, erc-message-english-netjoin, erc-message-english-netjoin-done, erc-message-english-netsplit-none, erc-message-english-netsplit-wholeft): Define at top level using `defvar'. * lisp/erc/erc-notify.el (erc-notify-install-message-catalogs): Deprecate, and rename all format templates with hyphens instead of underscores. (erc-notify-timer, erc-notify-JOIN, erc-notify-NICK, erc-notify-QUIT): Use hyphenated template names. (erc-cmd-NOTIFY): Use hyphenated template names. Load the module when necessary and emit a warning. Otherwise, people who discover this autoloaded command without being aware of the module's existence may think it's "broken". (pcomplete/erc-mode/NOTIFY): Replace top-level autoload with `require' in function body. Include `erc-notify-list' in list of completions, which makes removal easier if you don't share any channels with a person, and they're not in `erc-server-users'. A better long-term solution might be to WHOIS folks we're unsure about when they're listed in a 303. (erc-message-english-notify_current, erc-message-english-notify_list, erc-message-english-notify_on, erc-message-english-notify_off): Define at top level using `defvar'. Replace nonstandard underscores with hyphens. Alias obsolete names. * lisp/erc/erc-page.el (erc-message-english-CTCP-PAGE): Define at top level using `defvar'. * lisp/erc/erc-sasl.el (erc-message-english-s902, erc-message-english-s904, erc-message-english-s905, erc-message-english-s906, erc-message-english-s907, erc-message-english-s908): Define at top level using `defvar'. * lisp/erc/erc-sound.el (erc-message-english-CTCP-SOUND): Define using `defvar'. * lisp/erc/erc.el (erc--make-message-variable-name): New function to replace `erc-make-message-variable-name' internally, where most uses previously checked whether the returned variable was bound. This helper now does that conditionally, when asked. (erc-make-message-variable-name): Defer to internal variant, `erc--make-message-variable-name'. (erc-define-catalog-entry, erc-define-catalog): Deprecate. (erc-retrieve-catalog-entry): Refactor to favor `default-toplevel-value' of `erc-current-message-catalog' before falling back to `english'. Not doing this was arguably a bug. (erc-message-english-bad-ping-response, erc-message-english-bad-syntax, erc-message-english-incorrect-args, erc-message-english-cannot-find-file, erc-message-english-cannot-read-file, erc-message-english-connect, erc-message-english-country, erc-message-english-country-unknown, erc-message-english-ctcp-empty, erc-message-english-ctcp-request, erc-message-english-ctcp-request-to, erc-message-english-ctcp-too-many, erc-message-english-flood-ctcp-off, erc-message-english-flood-strict-mode, erc-message-english-disconnected, erc-message-english-disconnected-noreconnect, erc-message-english-reconnecting, erc-message-english-reconnect-canceled, erc-message-english-finished, erc-message-english-terminated, erc-message-english-login, erc-message-english-nick-in-use, erc-message-english-nick-too-long, erc-message-english-no-default-channel, erc-message-english-no-invitation, erc-message-english-no-target, erc-message-english-ops, erc-message-english-ops-none, erc-message-english-undefined-ctcp, erc-message-english-user-mode-redundant-add, erc-message-english-user-mode-redundant-drop, erc-message-english-variable-not-bound, erc-message-english-ACTION, erc-message-english-CTCP-CLIENTINFO, erc-message-english-CTCP-ECHO, erc-message-english-CTCP-FINGER, erc-message-english-CTCP-PING, erc-message-english-CTCP-TIME, erc-message-english-CTCP-UNKNOWN, erc-message-english-CTCP-VERSION, erc-message-english-ERROR, erc-message-english-INVITE, erc-message-english-JOIN, erc-message-english-JOIN-you, erc-message-english-KICK, erc-message-english-KICK-you, erc-message-english-KICK-by-you, erc-message-english-MODE, erc-message-english-MODE-nick, erc-message-english-NICK, erc-message-english-NICK-you, erc-message-english-PART, erc-message-english-PING, erc-message-english-PONG, erc-message-english-QUIT, erc-message-english-TOPIC, erc-message-english-WALLOPS, erc-message-english-s004, erc-message-english-s221, erc-message-english-s252, erc-message-english-s253, erc-message-english-s254, erc-message-english-s275, erc-message-english-s301, erc-message-english-s303, erc-message-english-s305, erc-message-english-s306, erc-message-english-s307, erc-message-english-s311, erc-message-english-s312, erc-message-english-s313, erc-message-english-s314, erc-message-english-s317, erc-message-english-s317-on-since, erc-message-english-s319, erc-message-english-s320, erc-message-english-s321, erc-message-english-s322, erc-message-english-s324, erc-message-english-s328, erc-message-english-s329, erc-message-english-s330, erc-message-english-s331, erc-message-english-s332, erc-message-english-s333, erc-message-english-s341, erc-message-english-s352, erc-message-english-s353, erc-message-english-s367, erc-message-english-s367-set-by, erc-message-english-s368, erc-message-english-s379, erc-message-english-s391, erc-message-english-s396, erc-message-english-s401, erc-message-english-s402, erc-message-english-s403, erc-message-english-s404, erc-message-english-s405, erc-message-english-s406, erc-message-english-s412, erc-message-english-s421, erc-message-english-s431, erc-message-english-s432, erc-message-english-s442, erc-message-english-s445, erc-message-english-s446, erc-message-english-s451, erc-message-english-s461, erc-message-english-s462, erc-message-english-s463, erc-message-english-s464, erc-message-english-s465, erc-message-english-s471, erc-message-english-s473, erc-message-english-s474, erc-message-english-s475, erc-message-english-s481, erc-message-english-s482, erc-message-english-s483, erc-message-english-s484, erc-message-english-s485, erc-message-english-s491, erc-message-english-s501, erc-message-english-s502, erc-message-english-s671): Define at top level using `defvar'. * test/lisp/erc/erc-tests.el (erc-tests--string-to-propertized-parts, erc-tests-pp-propertized-parts, erc--make-message-variable-name, erc-retrieve-catalog-entry): New tests along with utility functions and a convenience command for manipulating catalogs. (Bug#67677)
* ; Fix typosStefan Kangas2023-12-102-4/+4
|
* Restore prompt correctly when reconnecting in ERCF. Jason Park2023-11-262-5/+22
| | | | | | | | | | | | | * lisp/erc/erc.el (erc--initialize-markers): Commit 0d6c8d41ab7 "Use overlay instead of text prop to hide ERC's prompt" introduced a bug that caused the prompt to remain hidden upon reconnecting because the stashed overlay would get clobbered by ERC's major-mode setup. Binding its old value while unhiding fixes the issue. * test/lisp/erc/erc-tests.el (erc-hide-prompt): Don't permanently set the default value of `erc-hide-prompt'. * test/lisp/erc/resources/erc-scenarios-common.el (erc-scenarios-common--join-network-id): Add assertions for prompt hiding and unhiding on reconnect. (Bug#51082)
* ; Fix erc--channel-modes test on graphical displaysF. Jason Park2023-11-262-1/+49
| | | | | | | | | | | | | * lisp/erc/erc-fill.el (erc-fill--wrap-insert-merged-post): Use correct variable. * test/lisp/erc/erc-scenarios-display-message.el: Mute unrelated noisy test. * test/lisp/erc/erc-tests.el (erc--channel-modes): Bail out following first group of assertions when running on a graphical display. (erc--channel-modes/graphic-p): New test asserting different values for graphical terminals. Note that this too is tagged as :unstable. See also: d2ce30afdd2 "; Mark test for erc--update-channel-modes as :unstable".
* ; Mark test for erc--update-channel-modes as :unstableF. Jason Park2023-11-257-10/+12
| | | | | | | | | | | | | | | | | | | | | * test/lisp/erc/erc-scenarios-auth-source.el (erc-scenarios-common--auth-source): Extend timeout. * test/lisp/erc/erc-scenarios-base-buffer-display.el (erc-scenarios-base-buffer-display--count-reset-timeout): Await initial condition. * test/lisp/erc/erc-scenarios-base-renick.el (erc-scenarios-base-renick-queries-solo): Extend timeout. * test/lisp/erc/erc-scenarios-misc.el (erc-scenarios-base-flood): Extend timeout. * test/lisp/erc/erc-tests.el (erc--channel-modes): Mark test as :unstable pending further investigation. This test has been shown to be unreliable, possibly because it expects Emacs to report characters being a certain width in all environments. Thanks to Mattias EngdegÄrd for reporting this failure. * test/lisp/erc/resources/base/reuse-buffers/server/barnet.eld: Extend timeouts. * test/lisp/erc/resources/base/reuse-buffers/server/foonet.eld: Extend timeouts.
* Optionally allow substitution patterns in erc-promptF. Jason Park2023-11-241-0/+117
| | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Add entry for `erc-prompt-format'. * lisp/erc/erc-compat.el (erc-compat--defer-format-spec-in-buffer): New macro to wrap `format-spec' specification values in functions that run in the current buffer and fall back to the empty string. * lisp/erc/erc.el (erc-prompt): Add predefined Custom choice for function type in `erc-prompt-format'. (erc--prompt-format-face-example): New "pre-propertized" value for option `erc-prompt-format'. (erc-prompt-format): New companion option for `erc-prompt' choice `erc-prompt-format'. New function of the same name to perform format substitutions and serve as a Custom choice value for `erc-prompt'. Based on work and ideas originally proposed by Stefan Kangas. (erc--away-indicator, erc-away-status-indicator, erc--format-away-indicator): New formatting function and helper variables for displaying short away status. (erc--user-modes-indicator): New variable. (erc--format-user-modes): New function. (erc--format-channel-status-prefix): New function. (erc--format-modes): New function. * test/lisp/erc/erc-scenarios-prompt-format.el: New file. (Bug#51082) Co-authored-by: Stefan Kangas <stefankangas@gmail.com>
* Add merged-message indicator option for erc-fill-wrapF. Jason Park2023-11-243-3/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-fill.el (erc-fill): Use `when-let' instead of `when-let*'. (erc-fill-wrap-merge): Mention companion options in doc string. (erc-fill-wrap-merge-indicator): New option to display a distinguishing "indicator" in the form of a one-character string between messages from the same speaker. (erc-fill-wrap-mode, erc-fill-wrap-disable): Mention `erc-fill-wrap-merge-indicator' in doc string and kill related local variables. (erc-fill--wrap-merge-indicator-pre, erc-fill--wrap-merge-indicator-post): New internal variables for caching merge indicator. (erc-fill--wrap-insert-merged-post, erc-fill--wrap-insert-merged-pre): New functions for adding merge indicators either before or after a message. (erc-fill-wrap): Add logic for deferring to merge-indicator helpers when needed. * test/lisp/erc/erc-fill-tests.el (erc-fill-wrap-tests--merge-action, erc-fill-wrap--merge-action): Move body of latter test into former, a new fixture function. (erc-fill-wrap--merge-action/indicator-pre, erc-fill-wrap--merge-action/indicator-post): New tests. * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-post-01.eld: New test data file. * test/lisp/erc/resources/fill/snapshots/merge-wrap-indicator-pre-01.eld: New test data file. (Bug#60936)
* Use overlay instead of text prop to hide ERC's promptF. Jason Park2023-11-241-23/+23
| | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-backend.el (erc--hidden-prompt-overlay): New variable, a buffer-local handle for the prompt overlay. (erc--reveal-prompt): Delete overlay instead of text prop. (erc--conceal-prompt): Add overlay instead of text prop. (erc--unhide-prompt): Run `erc--refresh-prompt-hook' after revealing. (erc--hide-prompt): Run `erc--refresh-prompt-hook' after hiding. * lisp/erc/erc-stamp.el (erc-stamp--adjust-margin): Attempt a more accurate estimate of the prompt's width in columns when initially setting left-margin. (erc-stamp--skip-left-margin-prompt-p): New variable to inhibit normal behavior of displaying prompt in left margin. (erc-stamp--display-margin-mode): Allow opting out of prompt-in-left-margin behavior. (erc--reveal-prompt): Delete unneeded method implementation. (erc--conceal-prompt): Put overlay in margin. * test/lisp/erc/erc-tests.el (erc-hide-prompt): Use `get-char-property' instead of `get-text-property' in order to accommodate overlay-based prompt hiding. (Bug#51082)
* Don't inherit properties when refreshing ERC's promptF. Jason Park2023-11-241-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc.el (erc--merge-prop-behind-p): New variable to be dynamically bound around rare calls to `erc--merge-props' when the latter should append to the end of existing list-valued text properties. (erc--inhibit-prompt-display-property-p): New variable to be non-nil in buffers where an active module needs to reserve all uses of the `display' text property in the prompt region for itself. (erc--prompt-properties): Collect all common prompt properties in one place for code reuse and maintenance purposes. (erc--refresh-prompt-continue, erc--refresh-prompt-continue-request): New function and state variable for custom `erc-prompt' functions to indicate to ERC that they need the prompt to be refreshed in all buffers and not just the current one. (erc--refresh-prompt): Merge `erc-prompt-face' behind any applied by a customized `erc-prompt' function value. Crucially, don't inherit properties at the beginning of the prompt because doing so may clobber any added by a custom `erc-prompt' function. Instead, apply known properties from `erc-display-prompt' manually. Integrate `erc--refresh-prompt-continue' logic. (erc--merge-prop): Recognize flag to activate `append' behavior in which new prop values are appended to the tail of existing ones rather than consed in front. This functionality could be extended to arbitrary splices as well. (erc-display-prompt): Use common text properties defined elsewhere. * test/lisp/erc/erc-tests.el (erc--merge-prop): Add assertion for `erc--merge-prop-behind-p' non-nil behavior. (Bug#51082)
* Cache UI string for channel modes in ERCF. Jason Park2023-11-241-4/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Add entry for more expansive "%m" in header line. * lisp/erc/erc-common.el (erc--channel-mode-types): New slot `shortargs' for caching truncated mode args. * lisp/erc/erc.el (erc--mode-line-chanmodes-arg-len): New internal variable for adjusting the truncation length of channel-mode arguments as they appear in the header line. (erc--mode-line-mode-string): New variable for caching the relevant "modestring", if any, in ERC buffers. (erc--process-channel-modes): Don't associate args with group 4/D, which are all nullary modes. This fixes a bug in which arguments were associated with the wrong letters. Also, set cached mode string for channel. (erc--user-modes): Simplify slightly by removing likely useless variant for overloaded arg AS-TYPE. This function is new in ERC 5.6. (erc--channel-modes): New function. A higher-level getter for current channel mode representation to complement `erc--user-modes'. (erc--parse-user-modes): Set `erc--mode-line-mode-string in server buffers. (erc--handle-channel-mode): Change model to associate modes of type A with a running plus/minus tally of state changes since joining the channel. (erc-update-mode-line-buffer): Use cached verbose representation of channel or user modes instead of calling `erc-format-channel-modes'. * test/lisp/erc/erc-tests.el (erc--update-channel-modes): Update to reflect new running tally associations for type A modes. (erc--channel-modes): New test. (erc--user-modes): Update to reflect parameter simplification. (Bug#67220)
* Favor ISUPPORT params for MODE processing in ERCF. Jason Park2023-11-183-0/+285
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Mention shift toward CHANMODES ISUPPORT parameter for dictating MODE parsing behavior. * lisp/erc/erc-backend.el (erc--init-channel-modes, erc--update-modes, erc-set-modes, erc-update-modes): Forward declarations, the last two being removals. (erc-server-MODE, erc-server-221): Use `erc--update-modes' instead of `erc-update-modes'. (erc-server-324): Use `erc--init-channel-modes' instead of `erc-set-modes'. * lisp/erc/erc-common.el (erc--channel-mode-types): New struct for stashing processed \"CHANMODES\" data for the current server. * lisp/erc/erc.el (erc-channel-modes): Fix doc string. (erc-set-initial-user-mode): Display a local notice when requesting redundant user MODE operations. (erc-set-modes, erc-parse-modes, erc-update-modes): Deprecate for reasons explained in associated ERC-NEWS entry. (erc--update-membership-prefix): New function, a helper for specifying arguments to the rather unruly `erc-update-current-channel-member'. (erc--channel-modes): New variable to record channel-mode state in a hash table. (erc--channel-mode-types): New variable and getter to stash and retrieve server-local instance of the struct of the same name. (erc--process-channel-modes): New function to parse channel-mode changes, dispatch handlers for unary modes, and update the local variables `erc-channel-modes' and `erc--channel-modes'. (erc--user-modes): New local variable for remembering user modes per server. New function of the same name, a "getter" for the variable. (erc--parse-user-modes): New function to parse user modes only. (erc--update-user-modes): New function to update and sort `erc--user-modes'. (erc--update-channel-modes): New function to replace much of `erc-update-modes', currently a thin wrapper around `erc--process-channel-modes' to ensure it updates status prefixes. (erc--update-modes): New function to call appropriate mode-updating function for the current buffer. (erc--init-channel-modes): New function to update channel mode letters without status prefixes. (erc--handle-channel-mode): New generic function, a placeholder for an eventual API to handle specific "unary" mode letters, meaning those that specify a single parameter for setting or unsetting. (erc-update-channel-limit): Update doc string and answer question posed by ancient comment. (erc-message-english-user-mode-redundant-add, erc-message-english-user-mode-redundant-drop): New English catalog messages. * test/lisp/erc/erc-scenarios-base-chan-modes.el: New file. * test/lisp/erc/erc-tests.el (erc-parse-modes, erc--update-channel-modes, erc--update-user-modes, erc--user-modes, erc--parse-user-modes): New tests. * test/lisp/erc/resources/base/modes/chan-changed.eld: New test data file. (Bug#67220)
* Use caching variant of erc-parse-prefix internallyF. Jason Park2023-11-181-4/+62
| | | | | | | | | | | | * lisp/erc/erc-common.el (erc--parsed-prefix): New struct to help with tasks that depends on the advertised "PREFIX" parameter. * lisp/erc/erc.el (erc-parse-prefix): Rework slightly for readability. (erc--parsed-prefix): New variable and function of the same name for caching the reversed result of `erc-parse-prefix' locally per server. (erc-channel-receive-names): Use value stored in `erc--parsed-prefix'. * test/lisp/erc/erc-tests.el (erc-with-server-buffer): Only activate spy around actual test case forms. (erc--parse-prefix): New test. (Bug#67220)
* Simplify ISUPPORT-derived data wrangling in ERCF. Jason Park2023-11-181-2/+0
| | | | | | | | | | | | | | | * lisp/erc/erc-backend.el (erc--get-isupport-entry): Check server buffer for `erc-server-parameters' when (re)initializing value. This function was previously unreliable from a target buffer on cache misses. (erc--with-isupport-data): New macro for accessing and caching data derived from an ISUPPORT parameter. Late-arriving params break the cache. (erc-server-005): Rewrite pattern as `rx' form, factoring out bol/eol. * lisp/erc/erc-common.el (erc--isupport-data): New struct to be subclassed for storing cached ISUPPORT-derived data. * test/lisp/erc/erc-scenarios-display-message.el: Remove stray `require'. (Bug#67220)
* Add test for erc-cmd-SQUERYF. Jason Park2023-11-184-44/+125
| | | | | | | | | | | * lisp/erc/erc-backend.el (erc-message): Revise doc string. * test/lisp/erc/erc-scenarios-base-misc-regressions.el (erc-cmd-MOTD): Move test to another file specifically for slash commands. * test/lisp/erc/erc-scenarios-misc-commands.el: New file. * test/lisp/erc/resources/base/commands/motd.eld: Move file elsewhere. * test/lisp/erc/resources/commands/motd.eld: "New" file, moved here reusing the same Git blob from now deleted subdir base/commands. * test/lisp/erc/resources/commands/squery.eld: New file. (Bug#67209)
* ; Prepare for ERC 5.6 releaseF. Jason Park2023-11-122-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/misc/erc.texi: Minor tweak in SASL section. * etc/ERC-NEWS: Revise various sections under 5.6. * lisp/erc/erc-button.el (erc-button-alist): Remove comment. (erc-nick-popup-alist): Remove comment. * lisp/erc/erc-fill.el (erc-fill-wrap-margin-width): Remove comment. (erc-fill-wrap-margin-side): Remove comment. (erc-fill-line-spacing): Remove comment. (erc-fill-wrap-use-pixels): Remove comment. (erc-fill-wrap-visual-keys): Remove comment. (erc-fill-wrap-force-screen-line-movement): Remove comment. (erc-fill-wrap-merge): Remove comment. * lisp/erc/erc-goodies.el (erc-scrolltobottom-all): Remove comment. (erc-keep-place-indicator-style): Remove comment. (erc-keep-place-indicator-buffer-type): Remove comment. (erc-keep-place-indicator-follow): Remove comment. * lisp/erc/erc-networks.el (erc-server-alist): Remove comment. * lisp/erc/erc-nicks.el (erc-nicks): Remove comment. * lisp/erc/erc-speedbar.el (erc-speedbar-nicknames-window-width): Remove comment. (erc-speedbar-hide-mode-topic): Remove comment. (erc-speedbar-my-nick-face): Remove comment. * lisp/erc/erc-stamp.el (erc-timestamp-format-right): Remove comment. (erc-echo-timestamp-zone): Remove comment. (erc-timestamp-use-align-to): Remove comment. * lisp/erc/erc-status-sidebar.el (erc-status-sidebar-highlight-active-buffer): Remove comment. (erc-status-sidebar-style): Remove comment. (erc-status-sidebar-click-display-action): Remove comment. * lisp/erc/erc.el: Bump required Compat version to 29.1.4.3 in Package-Requires header. (erc-notice-face): Remove comment. (erc-action-face): Remove comment. (erc-interactive-display): Remove comment. (erc-auto-reconnect-display-timeout): Remove comment. (erc-reconnect-display-server-buffers): Remove comment. (erc-modules): Remove comment. * test/lisp/erc/resources/base/display-message/multibuf.eld: Remove reference to specific ERC version in QUIT command reason. * test/lisp/erc/resources/base/assoc/reconplay/foonet.eld: Timeout.
* Revive erc-command-indicator as new moduleF. Jason Park2023-11-122-1/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/misc/erc.texi: Add entry for `command-indicator' to Modules chapter. * etc/ERC-NEWS: Mention new module `command-indicator'. * lisp/erc/erc-goodies.el (erc-noncommands-list): Replace the nonexistent `erc-cmd-SMV' with function `erc-cmd-SAY'. (erc-noncommands-mode, erc-noncommands-enable, erc-noncommands-disable): Deprecate this module because it's a no-op. (erc-command-indicator-face, erc-command-indicator): Migrate from main library. (erc-command-indicator-mode, erc-command-indicator-enable, erc-command-indicator-disable): New module to take the spiritual place of `noncommands'. (erc-command-indicator): Move function here from main library, along with option namesake mentioned above. (erc-command-indicator-toggle-hidden): New command to toggle echoed command-line visibility. (erc--command-indicator-permit-insertion): New function. (erc--command-indicator-display): New function, a slightly revised version of the old `erc-display-command' from the main library. Its only call site was removed back in d1036d288de "backport: erc bugfixes". However, references were left behind to associated assets, like `erc-command-indicator', etc. The function was later commented out in 0c599ee2e2c "* lisp/erc/erc.el: Use `run-hook-with-args` for `erc-pre-send-functions`", and then removed by a63ed6f78a6 "Remove duplicate ERC prompt on reconnect". * lisp/erc/erc-match.el (erc-match-toggle-hidden-fools): Use new non-module-specific name for `erc-match--toggle-hidden'. (erc-match--toggle-hidden): Move to main library for shared use by other modules. * lisp/erc/erc.el (erc-hide-prompt): Leave note explaining updated role. (erc-command-indicator): Move option and function of same name to erc-goodies. (erc-command-indicator-face): Move to erc-goodies. (erc-modules): Remove module `noncommands' from standard value and Custom set. Add `command-indicator' to set. (erc--toggle-hidden): "New" function, a rebranded version of the utility `erc-match--toggle-hidden' from erc-match. (erc--send-input-lines): Accommodate modules wanting alternate insertion functions. (erc-load-irc-script-lines): Account for `erc-command-indicator' no longer being defined in this library. * test/lisp/erc/erc-scenarios-base-send-message.el (erc-scenarios-base-send-message--command-indicator): New test. * test/lisp/erc/erc-tests.el (erc-tests--modules): Remove deprecated module `noncommands' from manifest. (Bug#67031)
* Make nested input handling more robust in ERCF. Jason Park2023-11-122-0/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc.el (erc--send-action-function): New function-valued variable for locally advising `erc-send-action' so that built-in modules can elect to handle insertion and sending themselves. (erc-send-action): Defer to `erc--send-action-function'. (erc--send-action-perform-ctcp): Isolate the message-sending business for CTCP ACTIONs that used to reside in `erc-send-action'. (erc--send-action-display): Isolate the message-insertion business formerly residing in `erc-send-action' for more granular use. Fix a minor bug involving inserted representations of CTCP ACTIONs not having `erc-my-nick-face' applied to the speaker. (erc--send-action): Perform the same displaying and sending of CTCP ACTION messages formerly handled by `erc-send-action', but display messages before sending them. (erc--current-line-input-split): New variable bound to the post-review `erc--input-split' object for the extent of display processing. This mainly benefits slash-command handlers and the utility functions they employ, such as `erc-send-message'. (erc-cmd-SAY): Defer to `erc--send-message'. (erc--send-message-nested-function): New function-valued variable supporting an internal interface for influencing how `erc-send-message' inserts and sends prompt input. Some handlers for slash commands, like /SV, use `erc-send-message' to perform their own insertion and sending, which is normally the domain of `erc-send-current-line'. When this happens, modules can't easily leverage the normal hook-based API to do things like suppress insertion but allow sending or vice-versa. This variable provides an internal seam for modules to exert such influence. (erc-send-message): Behave specially when called by the default interactive client via `erc-send-current-line' and friends. (erc--send-message-external): New function to house the former body of `erc-send-message', for third-party code needing to apply the traditional behavior. (erc--send-message-nested): New function for turning arbitrary text, such as replacement prompt input, into outgoing message text by doing things like ensuring "send" hooks run and invariants for prompt markers are preserved. (erc--make-input-split): New helper function for creating a standard `erc--input-split' object from a string. This is arguably less confusing than adding another constructor to the struct definition. (erc-send-current-line): Bind `erc--current-line-input-split' when dispatching prompt-input handlers. Use helper `erc--make-input-split' to initialize working `erc--input-split' state object. (erc--run-send-hooks): Honor existing `refoldp' slot from `erc--input-split' object. (erc--send-input-lines): Convert to generic function to allow modules control over fundamental insertion and sending operations, which is necessary for next-generation features, like multiline messages. (erc-modes): Don't output non-modules. That is, only list actual modules created via `define-erc-module', and `quote' members of the resulting list. * test/lisp/erc/erc-scenarios-base-send-message.el: New test file. * test/lisp/erc/resources/base/send-message/noncommands.eld: New data file. (Bug#67031)
* Make ERC's error-notice formatting more consistentF. Jason Park2023-11-121-1/+1
| | | | | | | | | | | | | | | | * lisp/erc/erc-backend.el (erc--server-propagate-failed-connection): Include leading three-asterisk notice prefix when reporting process exit status, and set the `erc-msg' text property to `notice-error'. (erc-schedule-reconnect): Include leading notice prefix when inserting `reconnecting' message. * lisp/erc/erc.el (erc-process-input-line, erc-cmd-PART, erc-cmd-TOPIC): Display `no-target' messages as "error notices". (erc-message-english-disconnected, erc-message-english-disconnected-noreconnect): Hard-code standard value of `erc-notice-prefix' into message text for consistency during formatting and insertion. * test/lisp/erc/erc-tests.el (erc--refresh-prompt): Expect notice prefix before `no-target' message. (Bug#67031)
* Offer alternate pool-creation strategies in erc-nicksF. Jason Park2023-11-121-23/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-nicks.el (erc-nicks-bg-color): Expand doc string. (erc-nicks-colors): Add new choices `font-lock' and `ansi-color'. (erc-nicks--adjust-contrast): Add assertion to prevent dependency bug from resurfacing when hacking on module activation code. (erc-nicks--create-pool-function): New function-valued variable to specify a pool creation strategy. Note in doc string that this could form the basis for a possible user option should the need arise. (erc-nicks--create-coerced-pool): New function for filtering user-provided `erc-nicks-color' values. (erc-nicks--create-pool, erc-nicks--create-culled-pool): Rename former to latter. (erc-nicks--init-pool): Call `erc-nicks--create-pool-function' to actually create pool. Account for new `erc-nicks-colors' values. (erc-nicks-enable, erc-nicks-mode): Set `erc-nicks--fg-rgb' before `erc-nicks--init-pool' to prevent type error in filters that depend on that variable being initialized. This is a bug fix. (erc-nicks-refresh): Provide helpful user error instead of letting `arith-error' propagate due to an empty pool. (erc-nicks--colors-from-faces): New helper function. * test/lisp/erc/erc-nicks-tests.el (erc-nicks--create-pool, erc-nicks--create-culled-pool): Rename test from former to latter and update function invocations to reflect that. (erc-nicks--create-coerced-pool): New test. (Bug#63569)
* Align date stamps to whole days in ERCF. Jason Park2023-11-044-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-stamp.el (erc-stamp--current-time): Ditch overriding precedence of the `erc--ts' property in `:around' method because the variable `erc-stamp--current-time' fills that role well enough. (erc-stamp--current-datestamp-left): Remove unused variable. (erc-stamp--insert-date-stamp-as-phony-message): Assume `erc-timestamp-last-inserted-left' has already been assigned the updated rendered stamp for the current time. (erc-stamp--lr-date-on-pre-modify): Use the variable `erc-stamp--current-time' instead of the `erc-ts' property to convey an overriding time value for `erc-add-timestamp'. Set `erc-timestamp-last-inserted-left' instead of fiddling with another temporary variable to hack around these ill-fitting interfaces. Use day-aligned time value for the `erc-ts' property assigned to date stamps. (erc-stamp--date-mode): New internal minor mode. (erc-insert-timestamp-left-and-right): Defer to `erc-stamp--date-mode' for setting up date-stamp specific hooks. (erc-stamp--time-as-day): New function to "round" a date stamp to start of local day. (erc-stamp--setup): Defer to `erc-stamp--date-mode' for date-stamp specific teardown. (Bug#60936) * test/lisp/erc/erc-fill-tests.el (erc-fill-tests--current-time-value): Change default value to nil. (erc-stamp--current-time): New method for test cases. (erc-fill-tests--insert-privmsg): Use realistic value for `unparsed' slot. (erc-fill-tests--wrap-populate): Bind `erc-fill-tests--current-time-value' to 0. Don't mock the function `erc-stamp--current-time' because doing so inhibits normal polymorphic dispatch, which test cases rely on for delivering correct timestamp values in varied contexts. ; * test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update.
* Preserve user markers when inserting ERC date stampsF. Jason Park2023-11-041-0/+65
| | | | | | | | | | | | | | | * lisp/erc/erc-stamp.el (erc-stamp--insert-date-stamp-as-phony-message): Ensure existing user markers aren't displaced by date-stamp insertion. * lisp/erc/erc.el (erc--insert-line-function): New function-valued variable for overriding `insert'. (erc-insert-line): Call `erc--insert-line-function', when non-nil, to insert line specially. * test/lisp/erc/erc-scenarios-stamp.el (erc-scenarios-stamp--on-insert-modify): New assertion helper function. (erc-scenarios-stamp--date-mode/left-and-right): New test. (Bug#60936)
* Really fix off-by-one in erc--get-inserted-msg-boundsF. Jason Park2023-11-043-2/+51
| | | | | | | | | | * lisp/erc/erc.el (erc--get-inserted-msg-bounds): Account for `previous-single-property-change' returning a position adjacent to that with an actual changed value. The prior attempt at addressing this was insufficient. * test/lisp/erc/erc-tests.el (erc--get-inserted-msg-bounds): New test. ; * test/lisp/erc/resources/base/local-modules/second.eld: Timeout. ; * test/lisp/erc/resources/base/local-modules/third.eld: Timeout.
* ; Attempt to fix race in erc-buffer-display testF. Jason Park2023-11-019-59/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/lisp/erc/erc-fill-tests.el (erc-fill-tests--time-vals, erc-fill-tests--current-time-value): Rename former to latter and change type from function to natnum. (erc-fill-tests--wrap-populate, erc-fill-wrap--merge, erc-fill-wrap--merge-action): Use `erc-fill-tests--current-time-value' instead of function `erc-fill-tests--time-vals'. * test/lisp/erc/erc-scenarios-base-association.el (erc-scenarios-common--base-association-multi-net): Extend timeout. * test/lisp/erc/erc-scenarios-base-buffer-display.el (erc-scenarios-base-buffer-display--reconnect-common): Move some common assertions here from callers. (erc-scenarios-base-buffer-display--defwin-recbury-intbuf, erc-scenarios-base-buffer-display--count-reset-timeout): Factor out a couple common assertions. Clarify some comments. (erc-scenarios-base-buffer-display--defwino-recbury-intbuf): Factor out a couple common assertions and clarify some comments. Account for possible concurrency bug leading to intermittent test failures. * test/lisp/erc/erc-scenarios-base-misc-regressions.el (erc-scenarios-base-gapless-connect, erc-scenarios-base-channel-buffer-revival): Extend timeouts. * test/lisp/erc/resources/dcc/chat/accept.eld: Extend timeout. * test/lisp/erc/resources/base/reconnect/options-again.eld: Extend timeouts. * test/lisp/erc/resources/erc-d/erc-d.el (erc-d--m): Prevent possible wrong-type error. * test/lisp/erc/resources/erc-d/resources/dynamic-foonet.eld: Extend timeouts. * test/lisp/erc/resources/erc-scenarios-common.el (erc-scenarios-common--base-network-id-bouncer): Extend timeout.
* Tidy up ERC's internal text-property APIF. Jason Park2023-10-272-9/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-fill.el (erc-fill--spaced-commands): Remove unused internal variable originally intended for ERC 5.6. (erc-fill): Check for `erc-msg' being `msg', which carries the same meaning as `erc-cmd' being `PRIVMSG' or `NOTICE', except that inserted outgoing messages now no longer normally have an `erc-cmd' property. (erc-fill-wrap-mode, erc-fill-wrap-disable): Kill `erc-fill--wrap-last-msg'. (erc-fill--wrap-max-lull): Convert from buffer-local to normal variable. (erc-fill--wrap-continued-message-p): Rework slightly to guard against resetting the "last speaker" marker when the `erc-ephemeral' text property is present. This tells insert- and send-related hook members to pretend the current message doesn't exist when performing stateful operations. That is, modules should expect the message being inserted to possibly disappear or be replaced. Also, look for `erc-msg' being `msg' instead of `erc-cmd' being `PRIVMSG', and fix bug involving only checking `erc-ctcp' in the current message. * lisp/erc/erc-stamp.el (erc-add-timestamp): Don't insert timestamps when the `erc-ephemeral' text property is present. * lisp/erc/erc.el (erc--msg-props): Add doc string explaining the purpose of this variable and the various text properties most commonly present in its value. (erc--msg-prop-overrides): Add doc string. (erc-send-action): Don't set `erc-cmd' prop on outgoing CTCP ACTIONs. (erc-display-message): Reverse overrides to prefer items toward the front of the alist. (erc-process-ctcp-query): Include existing overrides from environs. (erc-send-current-line): Include existing overrides from environs. (erc-display-msg): Fix doc string and reverse overrides. * test/lisp/erc/erc-fill-tests.el (erc-fill-tests--insert-privmsg): Remove stray comment. (erc-fill-tests--save-p): Set value from environment variable. (erc-fill-tests--compare): Limit writing snapshots to one test at a time. (erc-fill-wrap--merge-action): Fix expected output for non-action messages that follow action messages. These were previously merged but escaped detection. * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update. (Bug#60936)
* Use marker for max pos in erc--traverse-insertedF. Jason Park2023-10-272-6/+79
| | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-stamp.el (erc-stamp--propertize-left-date-stamp): Run `erc-stamp--insert-date-hook' separately here instead of via `erc-insert-modify-hook'. (erc-stamp--insert-date-stamp-as-phony-message): Don't include value of `erc-stamp--insert-date-hook' in let-bound `erc-insert-modify-hook' because its members can run twice if buffer-local. Remove `erc-send-modify-hook' because it only runs via `erc-display-msg'. Shadow "pre" and "done" hooks because they don't expect to run in a narrowed buffer. Call getter for `erc-stamp--current-time'. (erc-stamp--lr-date-on-pre-modify, erc-insert-timestamp-left-and-right): Use function form of `erc-stamp--current-time' for determining current time stamp. * lisp/erc/erc.el (erc--get-inserted-msg-bounds): Fix off-by-one like thinko. (erc--traverse-inserted): Create temporary marker when END is a buffer position so that insertions and deletions are accounted for in the terminating condition. (erc--delete-inserted-message): New function. * test/lisp/erc/erc-tests.el (erc--delete-inserted-message): New test. (erc--update-modules/unknown): Improve readability slightly. * test/lisp/erc/resources/erc-d/erc-d-t.el (erc-d-t-make-expecter): Indicate assertion flavor in error message. (Bug#60936)
* Ignore date stamps completely in erc-trackF. Jason Park2023-10-271-1/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Mention that date stamps no longer optionally affect the mode line. Also mention but discourage new variable 'erc-stamp-prepend-date-stamps-p'. * lisp/erc/erc-stamp.el (erc-stamp-prepend-date-stamps-p): New variable, an escape hatch to allow date stamps to once again be prepended to messages. (erc-insert-timestamp-left-and-right): Don't insert stamps as independent messages when legacy support flag `erc-stamp-prepend-date-stamps-p' is non-nil. * lisp/erc/erc-track.el (erc-track--skipped-msgs): New internal variable. (erc-track-modified-channels): In previous versions, a date stamp attached to a message for an IRC command in `erc-track-exclude-types' would have no effect on the mode line. That they were able to otherwise was probably a bug. Regardless, this distinction was lost for the worse after date stamps became independent messages with c68dc7786fc "Manage some text props for ERC insertion-hook members". To sidestep this regression, the `track' module will ignore date stamps completely from now on. Thanks to Corwin Brust for spotting this. * test/lisp/erc/erc-scenarios-stamp.el (erc-scenarios-stamp--left/display-margin-mode): Remove redundant binding. (erc-scenarios-stamp--legacy-date-stamps): New test. (Bug#60936)
* ; Fix my last commitStefan Kangas2023-10-231-3/+2
| | | | | | | * test/lisp/erc/erc-tests.el (erc-tests--update-modules): Bind 'text-quoting-style' to 'grave'. (erc--update-modules/unknown): Simplify. Suggested by Mattias EngdegÄrd <mattias.engdegard@gmail.com>.
* Fix failing ERC testStefan Kangas2023-10-231-1/+3
| | | | | * test/lisp/erc/erc-tests.el (erc--update-modules/unknown): Fix test failing due to grave/curve quote.
* Prefer erc-target to erc-default-targetF. Jason Park2023-10-203-15/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Mention `erc-target' and new `erc-server-buffer-p' alias. * lisp/erc/erc-backend.el (erc-process-sentinel): Set `joined-p' slot of `erc--target-channel' object to nil when applicable. (erc-server-JOIN): Mark `erc--target-channel' object as being joined. * lisp/erc/erc-common.el (erc--target-channel): Add `joined-p' slot. Use hyphenated name so accessor function's name ends in "joined-p" rather than "joinedp". Note that this will always be nil when disconnected. (erc--target): Relocate here from erc.el. (erc-target): New public API function to return the current buffer's target as a string, even in channels that have been unjoined. * lisp/erc/erc-networks.el (erc--default-target): Remove forward declaration. (erc-networks--id-reload): Use `erc-target' instead of `erc--default-target' as predicate for visiting target buffers. * lisp/erc/erc.el (erc-remove-channel-users): Set channel "joinedness" to nil in `erc--target-channel' object, when applicable. (erc--target): Move to erc-common. (erc--default-target): Remove, replaced by new function `erc-target'. (erc-query-buffer-p): Use `erc-target'. (erc-after-connect): Revise doc string. (erc-connection-established): Revise doc string and move `erc-unhide-query-prompt' business before hook. (erc--current-buffer-joined-p): Remove comment and use new `joined-p' slot of `erc--target-channel' for determining "joinedness" of channel. (erc-kill-buffer-function): Use `erc--target-channel-p' for detecting whether the buffer is a channel buffer. * test/lisp/erc/erc-networks-tests.el (erc-networks--shrink-ids-and-buffer-names--hook-collapse-target): Remove comment. * test/lisp/erc/erc-scenarios-base-reuse-buffers.el (erc-scenarios-common--base-reuse-buffers-channel-buffers): Clarify assertion. * test/lisp/erc/erc-tests.el (erc-with-all-buffers-of-server): Replace `erc-default-recipients' with `erc--target'. (erc--target-from-string): Update expected shape of `erc--target-channel' struct with new `joined-p' slot. (erc-message): Set `erc--target' in buffer "#chan". (Bug#66578)
* Rename erc-server-buffer-pF. Jason Park2023-10-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lisp/erc/erc-log.el (erc-log-all-but-server-buffers): Use `erc--server-buffer-p' instead of `erc-server-buffer-p'. This replacement is presumed to be relatively "safe" because this function is unused in the code base and only appears in the doc string for the option `erc-enable-logging'. * lisp/erc/erc-match.el (erc-match-message): Leave comment proposing that `erc--server-buffer-p' should be preferred to `erc-server-buffer-p'. Use preferred alias for `erc-server-buffer-p'. * lisp/erc/erc-notify.el (erc-cmd-NOTIFY): Use preferred alias for `erc-server-buffer-p', and leave FIXME comment. * lisp/erc/erc-speedbar.el (erc-speedbar-buttons): Use `erc--server-buffer-p' instead of `erc-server-buffer-p'. The logic here seems simple enough to justify a change, however the absence of related bug reports is perhaps an argument against this. * lisp/erc/erc-track.el (erc-track-modified-channels): Use preferred alias for `erc-server-buffer-p' and leave comment noting possible bug. * lisp/erc/erc.el (erc-once-with-server-event): Use `erc--server-buffer-p' instead of `erc-server-buffer-p'. This change seems justified because the function sets local hooks that would otherwise be ignored outside of a server buffer. (erc-server-buffer-p, erc-server-or-unjoined-channel-buffer-p): Make the former an obsolete alias for the latter. (erc--server-buffer-p): New function to replace `erc-server-buffer-p' internally in new code. Unlike its predecessor, it returns nil in parted and kicked channels. (erc-open-server-buffer-p): Use `erc--server-buffer-p' instead of `erc-server-buffer-p'. Given the name and the doc string, breaking the odd misuse of this function in parted buffers seems justified because this is clearly a bug fix. Also, all uses in-tree conform to the intended behavior as documented. And a cursory grep of all "erc-" prefixed packages on MELPA reveals zero instances of this function. Nor is it used in erbot. (erc-get-buffer): Mention behavior in doc string regarding parted and kicked-from channels. (erc-cmd-GQUIT): Fix wrong-number-of-arguments bug in timer function. (erc-default-target): Mention behavior regarding unjoined channels. (erc-kill-query-buffers): Don't use `erc-server-buffer-p'. This replacement may break third-party code expecting to leave parted channels behind, but it seems sane when considering only the lone internal use in `erc-cmd-QUIT'. ; * test/lisp/erc/resources/join/network-id/foonet.eld: Timeouts. (Bug#66578)
* Respect user markers in erc-insert-timestamp-leftF. Jason Park2023-10-201-0/+90
| | | | | | | | | | | * lisp/erc/erc-stamp.el (erc-insert-timestamp-left): Convert to normal function, a mere wrapper that defers to existing generic variants, in order to dissuade users from adding their own methods, which could complicate troubleshooting, etc. (erc--insert-timestamp-left): Rename both methods using internal double-hyphen convention. In `erc-stamp--display-margin-mode' implementation, don't displace third-party markers. * test/lisp/erc/erc-scenarios-stamp.el: New file. (Bug#60936)
* Fix right-sided stamps commingling with erc-promptF. Jason Park2023-10-201-27/+30
| | | | | | | | | | | * lisp/erc/erc-stamp.el (erc-insert-timestamp-left-and-right): Fix bug that saw the prompt being inserted after messages but just inside the narrowed operating portion of the buffer, which meant remaining modification hooks would see it upon visiting. Thanks to Corwin Brust for catching this. * test/lisp/erc/erc-fill-tests.el (erc-fill-wrap--monospace): Use custom `erc-prompt' function to guarantee invariants asserted by `erc--assert-input-bounds' are preserved throughout. (Bug#60936)
* Restore missing metadata props in erc-display-lineF. Jason Park2023-10-2013-10/+182
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * etc/ERC-NEWS: Designate `erc-display-message' as the favored means of inserting messages. * lisp/erc/erc-fill.el (erc-fill-wrap): Skip any `unknown' `erc-msg'. * lisp/erc/erc-stamp.el (erc-stamp--current-time): Use an existing `erc-ts' text property, when present, for the current message time. * lisp/erc/erc.el (erc-display-line-1, erc-insert-line): Update doc string and declare the former an obsolete alias for the latter, `erc-insert-line'. Have `erc-log' label say `erc-display-message' even though this function is actually `erc-insert-line'. (erc-display-line): Convert to a thin wrapper around `erc-display-message', and move its existing body to a new internal function, `erc--route-insertion'. (erc--route-insertion): Adopt former body of `erc-display-line', now a convenience wrapper around `erc-display-message'. Copy `erc--msg-props' hash table when inserting a message in multiple buffers. At present, only `erc-server-QUIT' uses this facility, so such a move shouldn't impact performance in any measurable way. Also, improve readability with at most one recursive call for the fall-through case. (erc--compose-text-properties, erc--merge-text-properties-p): Rename former to latter to avoid confusion with `composition' property. (erc-display-message): Update doc string. Attempt to adapt a non-nil TYPE parameter for use as the value of the `erc-msg' text property before resorting to a value of `unknown'. But only do this when PARSED is nil, and MSG is a string. Call `erc--route-insertion' instead of `erc-display-line'. Use new name for `erc--compose-text-properties'. (erc-put-text-property): Update name of variable `erc--compose-text-properties'. * test/lisp/erc/erc-networks-tests.el (erc-networks--set-name): Mock `erc--route-insertion' instead of `erc-display-line'. * test/lisp/erc/erc-scenarios-display-message.el: New file. * test/lisp/erc/erc-tests.el (erc--route-insertion): New test. * test/lisp/erc/resources/base/display-message/multibuf.eld: New test data. ; * test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-01-start.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-02-right.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-03-left.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/monospace-04-reset.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/spacing-01-mono.eld: Update. ; * test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: Update. (Bug#60936)
* ; Mark erc-log test as :unstableF. Jason Park2023-10-205-6/+6
| | | | | | | | | * test/lisp/erc/erc-scenarios-log.el (erc-scenarios-log--truncate): Mark :unstable for now. * test/lisp/erc/resources/base/renick/queries/solo.eld: Timeouts. * test/lisp/erc/resources/base/reuse-buffers/channel/barnet.eld: Timeouts. * test/lisp/erc/resources/base/reuse-buffers/channel/foonet.eld: Timeouts. * test/lisp/erc/resources/erc-scenarios-common.el: Timeouts.
* Add command to refill buffer in erc-fill-wrap-modeF. Jason Park2023-10-131-2/+16
| | | | | | | | | | | | | * lisp/erc/erc-fill.el (erc-fill-function, erc-fill-wrap-mode): Mention new command `erc-fill-wrap-refill-buffer' in doc string. (erc-fill--wrap-rejigger-last-message): New internal variable. (erc-fill--wrap-rejigger-region, erc-fill-wrap-refill-buffer): New command and helper function for fixing alignment issues that arise, for example, from adjusting pixel-display widths of buffer text during a session. * test/lisp/erc/erc-fill-tests.el (erc-fill-tests--simulate-refill): New function for approximating `erc-fill-wrap-refill-buffer'. (erc-fill-wrap--merge): Assert refilling is idempotent. (Bug#60936)