2023-01-13 00:00:56 -08:00
|
|
|
;;; erc-fill-tests.el --- Tests for erc-fill -*- lexical-binding:t -*-
|
|
|
|
|
2024-01-02 10:30:05 +08:00
|
|
|
;; Copyright (C) 2023-2024 Free Software Foundation, Inc.
|
2023-01-13 00:00:56 -08:00
|
|
|
|
|
|
|
;; This file is part of GNU Emacs.
|
|
|
|
;;
|
|
|
|
;; GNU Emacs is free software: you can redistribute it and/or modify
|
|
|
|
;; it under the terms of the GNU General Public License as published
|
|
|
|
;; by the Free Software Foundation, either version 3 of the License,
|
|
|
|
;; or (at your option) any later version.
|
|
|
|
;;
|
|
|
|
;; GNU Emacs is distributed in the hope that it will be useful, but
|
|
|
|
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
;; General Public License for more details.
|
|
|
|
;;
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
|
|
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
|
|
;; FIXME these tests are brittle and error prone. Replace with
|
|
|
|
;; scenarios.
|
|
|
|
|
|
|
|
;;; Code:
|
2024-02-08 19:19:53 -08:00
|
|
|
(require 'erc-fill)
|
|
|
|
|
2023-01-13 00:00:56 -08:00
|
|
|
(require 'ert-x)
|
Move ERC test utilities to common file
* lisp/erc/erc-common.el (erc--define-catalog): Update name of
reference to convenience command now located in `erc-tests-common'.
* test/lisp/erc/erc-button-tests.el: Require common test-util library
`erc-tests-common', located under test/lisp/erc/resources.
; (erc-button-alist--url,
; erc-button-tests--erc-button-alist--function-as-form,
; erc-button-tests--erc-button-alist--nil-form,
; erc-button--display-error-notice-with-keys): Use common helper
; `erc-tests-common-init-server-proc' from test-utils library.
* test/lisp/erc/erc-fill-tests.el: Require `erc-tests-common'.
(erc-fill-tests--wrap-populate): Use helper
`erc-tests-common-init-server-proc'.
(erc-fill-tests--save-p): Remove. See replacement
`erc-tests-common-snapshot-save-p' in erc-tests-common.
(erc-fill-tests--graphic-dir): Add trailing slash.
(erc-fill-tests--compare): Move body to generalized utility
`erc-tests-common-snapshot-compare' in erc-tests-common.
* test/lisp/erc/erc-goodies-tests.el: Require `erc-tests-common'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move here from erc-tests.el.
* test/lisp/erc/erc-networks-tests.el: Load `erc-tests-common'.
(erc-networks-tests--create-live-proc): Defer to
`erc-tests-common-init-server-proc' and drop optional buffer param.
(erc-networks-tests--clean-bufs): Defer to
`erc-tests-common-kill-buffers'.
(erc-networks--rename-server-buffer--existing--live): Call
`erc-networks-tests--create-live-proc' in server buffer.
* test/lisp/erc/erc-scenarios-internal.el: Load `erc-tests-common'.
(erc-scenarios-internal--run-graphical-all): Use
`erc-tests-common-create-subprocess' to create process.
* test/lisp/erc/erc-scenarios-sasl.el
(erc-scenarios-sasl--plain-fail): Silence error message.
* test/lisp/erc/erc-stamp-tests.el: Require `erc-tests-common'.
(erc-stamp-tests--insert-right, erc-timestamp-intangible--left): Use
`erc-tests-common-init-server-proc'.
(erc-tests--assert-get-inserted-msg/stamp,
erc-stamp-tests--assert-get-inserted-msg/stamp): Move from
erc-tests.el, renaming to latter.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move here from
erc-tests.el.
* test/lisp/erc/erc-tests.el: Require `erc-tests-common'.
(erc-with-server-buffer): Use renamed test-helper utility
`erc-tests-common-init-server-proc'.
(erc-tests--send-prep, erc-tests--set-fake-server-process): Move to
`erc-tests-common' library and rename to
`erc-tests-common-prep-for-insertion' and
`erc-tests-common-init-server-proc', respectively.
; (erc-hide-prompt, erc--refresh-prompt,
; erc-setup-buffer--custom-action, erc--parsed-prefix,
; erc--update-channel-modes, erc--channel-modes,
; erc--channel-modes/graphic-p, erc-ring-previous-command): Use
; `erc-tests-common-prep-for-insertion' instead of
; `erc-tests--send-prep', and use `erc-tests-common-init-server-proc'
; instead of `erc-tests--set-fake-server-process'.
(erc-tests--with-process-input-spy): Move to `erc-tests-common' and
rename `erc-tests-common-with-process-input-spy'.
; (erc--check-prompt-input-functions, erc-send-current-line,
; erc--check-prompt-input-for-multiline-blanks,
; erc-send-whitespace-lines): Use renamed
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
; (erc-process-input-line): Use renamed
; `erc-tests-common-init-server-proc'.
(erc-tests--get-inserted-msg-setup,
erc-tests--assert-get-inserted-msg,
erc-tests--assert-get-inserted-msg/basic,
erc-tests--assert-get-inserted-msg-readonly-with): Move to
`erc-tests-common' and rename with "common" prefix, using single
instead of double hyphen.
(erc-tests--assert-get-inserted-msg/stamp): Move to `erc-stamp-tests'
and rename with "stamp" prefix.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move to
`erc-stamp-tests'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move to `erc-goodies-tests'.
; (erc--get-inserted-msg-beg/basic,
; erc--get-inserted-msg-end/basic,
; erc--get-inserted-msg-bounds/basic): Use common helpers.
; (erc--route-insertion): Use renamed helper functions
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
(erc-tests--make-server-buf): Move to `erc-common-tests' and rename
with "common" prefix.
(erc-tests--make-client-buf): Remove unused function without supplying
replacement.
; (erc-handle-irc-url): Use renamed `erc-tests-common-make-server-buf'
; utility function.
; (erc-tests--assert-printed-in-subprocess): Use helper from common lib
; `erc-tests-common-create-subprocess code' to do the heavy lifting.
(erc-tests--string-to-propertized-parts,
erc-tests-pp-propertized-parts): Move to `erc-tests-common' and rename
with "common" prefix.
* test/lisp/erc/resources/erc-tests-common.el: New file containing
helper utilities and fixtures used by multiple files in test/lisp/erc.
2023-12-24 12:21:49 -08:00
|
|
|
(eval-and-compile
|
|
|
|
(let ((load-path (cons (ert-resource-directory) load-path)))
|
|
|
|
(require 'erc-tests-common)))
|
|
|
|
|
2023-01-13 00:00:56 -08:00
|
|
|
(defvar erc-fill-tests--buffers nil)
|
2023-11-02 17:05:48 -07:00
|
|
|
(defvar erc-fill-tests--current-time-value nil)
|
|
|
|
|
|
|
|
(cl-defmethod erc-stamp--current-time
|
|
|
|
(&context (erc-fill-tests--current-time-value integer))
|
|
|
|
erc-fill-tests--current-time-value)
|
2023-01-13 00:00:56 -08:00
|
|
|
|
|
|
|
(defun erc-fill-tests--insert-privmsg (speaker &rest msg-parts)
|
|
|
|
(declare (indent 1))
|
2023-12-04 22:13:02 -08:00
|
|
|
(let* ((erc--msg-prop-overrides `((erc--msg . msg)))
|
|
|
|
(msg (erc-format-privmessage speaker
|
Manage some text props for ERC insertion-hook members
* etc/ERC-NEWS: Mention that ERC only adds the text property
`cursor-sensor-functions' when `erc-echo-timestamps' is enabled. Also
mention that date stamps are now inserted as separate messages.
* lisp/erc/erc-fill.el (erc-fill): Look for text prop `erc-cmd'
instead of `erc-command' and use helper utility to do so.
(erc-fill-static): Skip date stamps because this fill style leaves
them flush left.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Don't hook on the soon-to-be-removed function interface
`erc-stamp--insert-date-function' because date stamps are now separate
messages.
(erc-fill--wrap-continued-message-p): Restore accidentally discarded
doc string. Derive context about current message from text props at
`point-min', and use updated property names and utility functions.
Abort when previous message is now hidden.
(erc-fill--wrap-stamp-insert-prefixed-date): Remove unused function,
originally meant to be new in ERC 5.6, and move logic for date-stamp
measuring portion directly to `erc-fill-wrap' itself.
(erc-fill--wrap-measure): New helper function.
(erc-fill-wrap): Use helper `erc-fill--wrap-measure' and incorporate
date-stamp detection and width measuring from removed helper. Don't
dedent first word for messages of unknown origin, such as those
inserted by `erc-display-line' alone without prior preparation from
`erc-display-message'.
* lisp/erc/erc-goodies.el (erc-readonly-mode, erc-readonly-enable):
Set hook depth explicitly to 70.
* lisp/erc/erc-stamp.el (erc-timestamp-format-left): Mention that a
trailing newline is implicit if not provided and that users who don't
want date stamps should use `erc-timestamp-format-right' instead.
(erc-stamp-mode, erc-stamp-enable): Call `erc-stamp--setup' instead
of `erc-munge-invisibility-spec', and bump hook depth for
`erc-add-timestamp' to 70.
(erc-stamp--current-time): Use `erc-ts' instead of `erc-timestamp'
text property in doc string.
(erc-stamp--skip): New internal variable.
(erc-stamp--allow-unmanaged): New variable for legacy code to force
`erc-add-timestamps' to run when `erc--msg-props' is nil.
(erc-add-timestamp): Always run when `erc-stamp--allow-unmanaged' is
non-nil unless `erc-stamp--skip' is as well because the latter takes
precedence. Don't add `erc-ts' text prop directly unless
`erc-stamp--allow-unmanaged is non-nil. Instead, use the new
`erc--msg-props' facility to defer until after modification hooks.
Likewise, don't add `cursor-senor-functions' directly either unless
the same compatibility flag is enabled. Instead, expect the latter to
be handled by a post-modify hook conditioned on the option
`erc-echo-timestamps'.
(erc-timestamp-last-inserted-left): Mention that the final trailing
newline specified in the format string no longer appears in the
recorded value.
(erc-stamp-prefix-log-filter): Use updated name for timestamp
property as well as helper utility for accessing it.
(erc-stamp--inherited-props): Add doc string.
(erc-insert-timestamp-right): Fix bug involving object cycle where
the time-stamp string would appear in its own `display' property.
(erc-stamp--insert-date-function, erc-stamp--insert-date-hook): Remove
unused internal function-valued interface variable and replace with
the latter, a normal hook.
(erc-stamp--date-format-end, erc-stamp--propertize-left-date-stamp):
New function and auxiliary variable to apply date stamp properties at
the post-modify stage. Add text property `erc-stamp-type' to inserted
date stamps to help folks distinguish between them and other
left-sided stamps.
(erc-stamp--current-datestamp-left,
erc-stamp--format-date-stamp,
erc-stamp--insert-date-stamp-as-phony-message,
erc-stamp--lr-date-on-pre-modify): New functions and state variable to
help ERC treat date stamps as separate messages while working within
the established mechanism for processing inserted messages. Shadow
`erc-stamp--invisible-property' when calling `erc-format-timestamp' in
order to prevent date stamps from inheriting other `invisible' props.
These date stamps are special in that they have no business being
hidden along with the current message.
(erc-insert-timestamp-left-and-right): On initial run in any buffer,
remember whether the date stamp needed newline massaging on insertion.
Move all business for inserting date stamps to post-modify hooks, but
run them forcibly if this is the very first date stamp in the current
buffer. Also mention some specifics related to relevant text props in
the doc string.
(erc-format-timestamp): Don't add `invisible' prop to stamp unless
`erc-stamp--invisible-property' is non-nil.
(erc-stamp--csf-props-updated-p): New local variable.
(erc-munge-invisibility-spec): Restore `cursor-sensor-functions' text
property for existing messages when a user enables the option
mid-session. Add and remove hooks for use with automatic timestamp
echoing.
(erc-stamp--add-csf-on-post-modify): New function to add
`cursor-sensor-functions' property on post-modify hooks.
(erc-stamp--setup): Perform some additional teardown.
(erc-stamp--on-clear-message): Look for text property `erc-ts' instead
of `erc-timestamp'.
(erc-echo-timestamp, erc--echo-ts-csf): Use utility to find time-stamp
text prop in current message.
(erc-stamp--update-saved-position, erc-stamp--reset-on-clear): Use
hook `erc-stamp--insert-date-hook' instead of excised function-valued
variable interface `erc-stamp--insert-date-function'.
* lisp/erc/erc-truncate.el (erc-truncate-buffer-to-size): Use internal
utility to find beginning of message.
* lisp/erc/erc.el (erc--msg-props, erc--msg-props-overrides): New
internal variables for initializing and conveying metadata-oriented
text properties among insert and send hooks.
(erc-insert-modify-hook): Mention reserved depth ranges for built-in
members in doc string.
(erc-send-action): Use convenience variable to modifying text props
instead of awkwardly overriding `erc-insert-pre-hook'.
(erc--check-msg-prop, erc--get-inserted-msg-bounds,
erc--get-inserted-msg-prop, erc--with-inserted-msg,
erc--traverse-inserted): New utility functions and macros to help
modules find metadata and message-delimiting text props.
(erc-display-line-1): Ensure the first character of every message in
an ERC buffer has the `erc-msg' property, as well as any other props
in `erc--msg-props', when populated.
(erc--hide-message): Don't bother offsetting start of first message in
a buffer.
(erc--ranked-properties, erc--order-text-properties-from-hash): New
variable and function to convert `erc--msg-props' into a plist
suitable for `add-text-properties'.
(erc-display-message): Make doc string more informative. Bind and
initialize `erc--msg-props' for use by all hooks. Respect
`erc--msg-prop-overrides' when non-nil. Don't add `erc-command'
property. Instead, ensure `erc--msg-props' contains an `erc-cmd' item
when the parameter PARSED is non-nil.
(erc--own-property-names): Add `erc-stamp-type'.
(erc--get-speaker-bounds): Use helper to find message start.
(erc-process-ctcp-query, erc-send-current-line): Use convenience
variable to leverage framework for manipulating message metadata
instead of overriding `erc-insert-pre-hook'.
(erc-display-msg): Bind `erc--msg-props' for use by all send-related
hooks. Add text props from table after `erc-send-post-hook'.
(erc-restore-text-properties): Improve doc string.
(erc--get-eq-comparable-cmd): Use `if-let' instead of `if-let*'.
* test/lisp/erc/erc-fill-tests.el (erc-fill-tests--insert-privmsg):
Make phony message more realistic.
(erc-fill-tests--wrap-populate): Shorten overlong line.
(erc-fill-tests--wrap-check-prefixes): Make test utility more vigilant
in asserting no gaps exist in `line-prefix' property interval.
(erc-fill-tests--compare): Compare text props on text-prop values that
are themselves strings.
* test/lisp/erc/erc-scenarios-log.el (erc-scenarios-log--clear-stamp):
Ensure `erc-stamp' is loaded.
* test/lisp/erc/erc-scenarios-match.el
(erc-scenarios-match--stamp-left-current-nick,
erc-scenarios-match--invisible-stamp): Use `default-value' for
`erc-insert-modify-hook' in ordering assertion.
(erc-scenarios-match--find-bol, erc-scenarios-match--find-eol): Remove
unused assertion helper functions.
(erc-scenarios-match--stamp-right-fools-invisible): Remove misplaced
ERT tag from function and use utility to find message bounds.
(erc-scenarios-match--stamp-right-fools-invisible): Use real utility
from main library to find message end.
(erc-scenarios-match--fill-wrap-stamp-dedented-p): New assertion
utility function.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap) New test.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap/speak): New
test.
(erc-scenarios-match--stamp-both-invisible-fill-static): Expect
`erc-cmd' at beginning of inserted message's filled line, even if the
line starts with white space. Also, add new function parameter
`assert-ds', a callback to run when visiting the second date stamp,
which is followed by a hidden message. In the test of the same name,
expect the date stamp's invisibility interval to begin at the newline
after the previous message and to not contain any existing
invisibility props, namely, those belonging to the subsequent hidden
"fools" message. Also use shortened "metadata" text prop names.
(erc-scenarios-match--stamp-both-invisible-fill-static--nooffset):
Expect the date stamp's invisibility interval to match its field's
instead of starting and ending sooner.
* test/lisp/erc/erc-stamp-tests.el: Put well-known metadata prop at
the start of the message.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt): Prevent modules
from mutating hooks.
(erc--order-text-properties-from-hash, erc--check-msg-prop): New
tests.
* test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update
test data.
* test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update
test data.
* 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.
* test/lisp/erc/resources/match/fools/fill-wrap.eld: New file.
(Bug#60936)
2023-09-21 23:54:31 -07:00
|
|
|
(apply #'concat msg-parts) nil t))
|
2023-11-02 17:05:48 -07:00
|
|
|
(parsed (make-erc-response :unparsed (format ":%s PRIVMSG #chan :%s"
|
|
|
|
speaker msg)
|
|
|
|
:sender speaker
|
Manage some text props for ERC insertion-hook members
* etc/ERC-NEWS: Mention that ERC only adds the text property
`cursor-sensor-functions' when `erc-echo-timestamps' is enabled. Also
mention that date stamps are now inserted as separate messages.
* lisp/erc/erc-fill.el (erc-fill): Look for text prop `erc-cmd'
instead of `erc-command' and use helper utility to do so.
(erc-fill-static): Skip date stamps because this fill style leaves
them flush left.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Don't hook on the soon-to-be-removed function interface
`erc-stamp--insert-date-function' because date stamps are now separate
messages.
(erc-fill--wrap-continued-message-p): Restore accidentally discarded
doc string. Derive context about current message from text props at
`point-min', and use updated property names and utility functions.
Abort when previous message is now hidden.
(erc-fill--wrap-stamp-insert-prefixed-date): Remove unused function,
originally meant to be new in ERC 5.6, and move logic for date-stamp
measuring portion directly to `erc-fill-wrap' itself.
(erc-fill--wrap-measure): New helper function.
(erc-fill-wrap): Use helper `erc-fill--wrap-measure' and incorporate
date-stamp detection and width measuring from removed helper. Don't
dedent first word for messages of unknown origin, such as those
inserted by `erc-display-line' alone without prior preparation from
`erc-display-message'.
* lisp/erc/erc-goodies.el (erc-readonly-mode, erc-readonly-enable):
Set hook depth explicitly to 70.
* lisp/erc/erc-stamp.el (erc-timestamp-format-left): Mention that a
trailing newline is implicit if not provided and that users who don't
want date stamps should use `erc-timestamp-format-right' instead.
(erc-stamp-mode, erc-stamp-enable): Call `erc-stamp--setup' instead
of `erc-munge-invisibility-spec', and bump hook depth for
`erc-add-timestamp' to 70.
(erc-stamp--current-time): Use `erc-ts' instead of `erc-timestamp'
text property in doc string.
(erc-stamp--skip): New internal variable.
(erc-stamp--allow-unmanaged): New variable for legacy code to force
`erc-add-timestamps' to run when `erc--msg-props' is nil.
(erc-add-timestamp): Always run when `erc-stamp--allow-unmanaged' is
non-nil unless `erc-stamp--skip' is as well because the latter takes
precedence. Don't add `erc-ts' text prop directly unless
`erc-stamp--allow-unmanaged is non-nil. Instead, use the new
`erc--msg-props' facility to defer until after modification hooks.
Likewise, don't add `cursor-senor-functions' directly either unless
the same compatibility flag is enabled. Instead, expect the latter to
be handled by a post-modify hook conditioned on the option
`erc-echo-timestamps'.
(erc-timestamp-last-inserted-left): Mention that the final trailing
newline specified in the format string no longer appears in the
recorded value.
(erc-stamp-prefix-log-filter): Use updated name for timestamp
property as well as helper utility for accessing it.
(erc-stamp--inherited-props): Add doc string.
(erc-insert-timestamp-right): Fix bug involving object cycle where
the time-stamp string would appear in its own `display' property.
(erc-stamp--insert-date-function, erc-stamp--insert-date-hook): Remove
unused internal function-valued interface variable and replace with
the latter, a normal hook.
(erc-stamp--date-format-end, erc-stamp--propertize-left-date-stamp):
New function and auxiliary variable to apply date stamp properties at
the post-modify stage. Add text property `erc-stamp-type' to inserted
date stamps to help folks distinguish between them and other
left-sided stamps.
(erc-stamp--current-datestamp-left,
erc-stamp--format-date-stamp,
erc-stamp--insert-date-stamp-as-phony-message,
erc-stamp--lr-date-on-pre-modify): New functions and state variable to
help ERC treat date stamps as separate messages while working within
the established mechanism for processing inserted messages. Shadow
`erc-stamp--invisible-property' when calling `erc-format-timestamp' in
order to prevent date stamps from inheriting other `invisible' props.
These date stamps are special in that they have no business being
hidden along with the current message.
(erc-insert-timestamp-left-and-right): On initial run in any buffer,
remember whether the date stamp needed newline massaging on insertion.
Move all business for inserting date stamps to post-modify hooks, but
run them forcibly if this is the very first date stamp in the current
buffer. Also mention some specifics related to relevant text props in
the doc string.
(erc-format-timestamp): Don't add `invisible' prop to stamp unless
`erc-stamp--invisible-property' is non-nil.
(erc-stamp--csf-props-updated-p): New local variable.
(erc-munge-invisibility-spec): Restore `cursor-sensor-functions' text
property for existing messages when a user enables the option
mid-session. Add and remove hooks for use with automatic timestamp
echoing.
(erc-stamp--add-csf-on-post-modify): New function to add
`cursor-sensor-functions' property on post-modify hooks.
(erc-stamp--setup): Perform some additional teardown.
(erc-stamp--on-clear-message): Look for text property `erc-ts' instead
of `erc-timestamp'.
(erc-echo-timestamp, erc--echo-ts-csf): Use utility to find time-stamp
text prop in current message.
(erc-stamp--update-saved-position, erc-stamp--reset-on-clear): Use
hook `erc-stamp--insert-date-hook' instead of excised function-valued
variable interface `erc-stamp--insert-date-function'.
* lisp/erc/erc-truncate.el (erc-truncate-buffer-to-size): Use internal
utility to find beginning of message.
* lisp/erc/erc.el (erc--msg-props, erc--msg-props-overrides): New
internal variables for initializing and conveying metadata-oriented
text properties among insert and send hooks.
(erc-insert-modify-hook): Mention reserved depth ranges for built-in
members in doc string.
(erc-send-action): Use convenience variable to modifying text props
instead of awkwardly overriding `erc-insert-pre-hook'.
(erc--check-msg-prop, erc--get-inserted-msg-bounds,
erc--get-inserted-msg-prop, erc--with-inserted-msg,
erc--traverse-inserted): New utility functions and macros to help
modules find metadata and message-delimiting text props.
(erc-display-line-1): Ensure the first character of every message in
an ERC buffer has the `erc-msg' property, as well as any other props
in `erc--msg-props', when populated.
(erc--hide-message): Don't bother offsetting start of first message in
a buffer.
(erc--ranked-properties, erc--order-text-properties-from-hash): New
variable and function to convert `erc--msg-props' into a plist
suitable for `add-text-properties'.
(erc-display-message): Make doc string more informative. Bind and
initialize `erc--msg-props' for use by all hooks. Respect
`erc--msg-prop-overrides' when non-nil. Don't add `erc-command'
property. Instead, ensure `erc--msg-props' contains an `erc-cmd' item
when the parameter PARSED is non-nil.
(erc--own-property-names): Add `erc-stamp-type'.
(erc--get-speaker-bounds): Use helper to find message start.
(erc-process-ctcp-query, erc-send-current-line): Use convenience
variable to leverage framework for manipulating message metadata
instead of overriding `erc-insert-pre-hook'.
(erc-display-msg): Bind `erc--msg-props' for use by all send-related
hooks. Add text props from table after `erc-send-post-hook'.
(erc-restore-text-properties): Improve doc string.
(erc--get-eq-comparable-cmd): Use `if-let' instead of `if-let*'.
* test/lisp/erc/erc-fill-tests.el (erc-fill-tests--insert-privmsg):
Make phony message more realistic.
(erc-fill-tests--wrap-populate): Shorten overlong line.
(erc-fill-tests--wrap-check-prefixes): Make test utility more vigilant
in asserting no gaps exist in `line-prefix' property interval.
(erc-fill-tests--compare): Compare text props on text-prop values that
are themselves strings.
* test/lisp/erc/erc-scenarios-log.el (erc-scenarios-log--clear-stamp):
Ensure `erc-stamp' is loaded.
* test/lisp/erc/erc-scenarios-match.el
(erc-scenarios-match--stamp-left-current-nick,
erc-scenarios-match--invisible-stamp): Use `default-value' for
`erc-insert-modify-hook' in ordering assertion.
(erc-scenarios-match--find-bol, erc-scenarios-match--find-eol): Remove
unused assertion helper functions.
(erc-scenarios-match--stamp-right-fools-invisible): Remove misplaced
ERT tag from function and use utility to find message bounds.
(erc-scenarios-match--stamp-right-fools-invisible): Use real utility
from main library to find message end.
(erc-scenarios-match--fill-wrap-stamp-dedented-p): New assertion
utility function.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap) New test.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap/speak): New
test.
(erc-scenarios-match--stamp-both-invisible-fill-static): Expect
`erc-cmd' at beginning of inserted message's filled line, even if the
line starts with white space. Also, add new function parameter
`assert-ds', a callback to run when visiting the second date stamp,
which is followed by a hidden message. In the test of the same name,
expect the date stamp's invisibility interval to begin at the newline
after the previous message and to not contain any existing
invisibility props, namely, those belonging to the subsequent hidden
"fools" message. Also use shortened "metadata" text prop names.
(erc-scenarios-match--stamp-both-invisible-fill-static--nooffset):
Expect the date stamp's invisibility interval to match its field's
instead of starting and ending sooner.
* test/lisp/erc/erc-stamp-tests.el: Put well-known metadata prop at
the start of the message.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt): Prevent modules
from mutating hooks.
(erc--order-text-properties-from-hash, erc--check-msg-prop): New
tests.
* test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update
test data.
* test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update
test data.
* 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.
* test/lisp/erc/resources/match/fools/fill-wrap.eld: New file.
(Bug#60936)
2023-09-21 23:54:31 -07:00
|
|
|
:command "PRIVMSG"
|
|
|
|
:command-args (list "#chan" msg)
|
|
|
|
:contents msg)))
|
2024-04-08 14:21:43 -07:00
|
|
|
(erc-tests-common-display-message parsed nil (current-buffer) msg)))
|
2023-01-13 00:00:56 -08:00
|
|
|
|
|
|
|
(defun erc-fill-tests--wrap-populate (test)
|
|
|
|
(let ((original-window-buffer (window-buffer (selected-window)))
|
2023-11-13 12:07:36 -08:00
|
|
|
(erc--fill-wrap-scrolltobottom-exempt-p t)
|
2023-01-13 00:00:56 -08:00
|
|
|
(erc-stamp--tz t)
|
|
|
|
(erc-fill-function 'erc-fill-wrap)
|
|
|
|
(pre-command-hook pre-command-hook)
|
|
|
|
(inhibit-message noninteractive)
|
2023-11-02 17:05:48 -07:00
|
|
|
(erc-fill-tests--current-time-value 0)
|
2023-01-13 00:00:56 -08:00
|
|
|
erc-insert-post-hook
|
|
|
|
extended-command-history
|
|
|
|
erc-kill-channel-hook erc-kill-server-hook erc-kill-buffer-hook)
|
2023-11-02 17:05:48 -07:00
|
|
|
(cl-letf (((symbol-function 'erc-server-connect)
|
2023-01-13 00:00:56 -08:00
|
|
|
(lambda (&rest _)
|
Move ERC test utilities to common file
* lisp/erc/erc-common.el (erc--define-catalog): Update name of
reference to convenience command now located in `erc-tests-common'.
* test/lisp/erc/erc-button-tests.el: Require common test-util library
`erc-tests-common', located under test/lisp/erc/resources.
; (erc-button-alist--url,
; erc-button-tests--erc-button-alist--function-as-form,
; erc-button-tests--erc-button-alist--nil-form,
; erc-button--display-error-notice-with-keys): Use common helper
; `erc-tests-common-init-server-proc' from test-utils library.
* test/lisp/erc/erc-fill-tests.el: Require `erc-tests-common'.
(erc-fill-tests--wrap-populate): Use helper
`erc-tests-common-init-server-proc'.
(erc-fill-tests--save-p): Remove. See replacement
`erc-tests-common-snapshot-save-p' in erc-tests-common.
(erc-fill-tests--graphic-dir): Add trailing slash.
(erc-fill-tests--compare): Move body to generalized utility
`erc-tests-common-snapshot-compare' in erc-tests-common.
* test/lisp/erc/erc-goodies-tests.el: Require `erc-tests-common'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move here from erc-tests.el.
* test/lisp/erc/erc-networks-tests.el: Load `erc-tests-common'.
(erc-networks-tests--create-live-proc): Defer to
`erc-tests-common-init-server-proc' and drop optional buffer param.
(erc-networks-tests--clean-bufs): Defer to
`erc-tests-common-kill-buffers'.
(erc-networks--rename-server-buffer--existing--live): Call
`erc-networks-tests--create-live-proc' in server buffer.
* test/lisp/erc/erc-scenarios-internal.el: Load `erc-tests-common'.
(erc-scenarios-internal--run-graphical-all): Use
`erc-tests-common-create-subprocess' to create process.
* test/lisp/erc/erc-scenarios-sasl.el
(erc-scenarios-sasl--plain-fail): Silence error message.
* test/lisp/erc/erc-stamp-tests.el: Require `erc-tests-common'.
(erc-stamp-tests--insert-right, erc-timestamp-intangible--left): Use
`erc-tests-common-init-server-proc'.
(erc-tests--assert-get-inserted-msg/stamp,
erc-stamp-tests--assert-get-inserted-msg/stamp): Move from
erc-tests.el, renaming to latter.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move here from
erc-tests.el.
* test/lisp/erc/erc-tests.el: Require `erc-tests-common'.
(erc-with-server-buffer): Use renamed test-helper utility
`erc-tests-common-init-server-proc'.
(erc-tests--send-prep, erc-tests--set-fake-server-process): Move to
`erc-tests-common' library and rename to
`erc-tests-common-prep-for-insertion' and
`erc-tests-common-init-server-proc', respectively.
; (erc-hide-prompt, erc--refresh-prompt,
; erc-setup-buffer--custom-action, erc--parsed-prefix,
; erc--update-channel-modes, erc--channel-modes,
; erc--channel-modes/graphic-p, erc-ring-previous-command): Use
; `erc-tests-common-prep-for-insertion' instead of
; `erc-tests--send-prep', and use `erc-tests-common-init-server-proc'
; instead of `erc-tests--set-fake-server-process'.
(erc-tests--with-process-input-spy): Move to `erc-tests-common' and
rename `erc-tests-common-with-process-input-spy'.
; (erc--check-prompt-input-functions, erc-send-current-line,
; erc--check-prompt-input-for-multiline-blanks,
; erc-send-whitespace-lines): Use renamed
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
; (erc-process-input-line): Use renamed
; `erc-tests-common-init-server-proc'.
(erc-tests--get-inserted-msg-setup,
erc-tests--assert-get-inserted-msg,
erc-tests--assert-get-inserted-msg/basic,
erc-tests--assert-get-inserted-msg-readonly-with): Move to
`erc-tests-common' and rename with "common" prefix, using single
instead of double hyphen.
(erc-tests--assert-get-inserted-msg/stamp): Move to `erc-stamp-tests'
and rename with "stamp" prefix.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move to
`erc-stamp-tests'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move to `erc-goodies-tests'.
; (erc--get-inserted-msg-beg/basic,
; erc--get-inserted-msg-end/basic,
; erc--get-inserted-msg-bounds/basic): Use common helpers.
; (erc--route-insertion): Use renamed helper functions
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
(erc-tests--make-server-buf): Move to `erc-common-tests' and rename
with "common" prefix.
(erc-tests--make-client-buf): Remove unused function without supplying
replacement.
; (erc-handle-irc-url): Use renamed `erc-tests-common-make-server-buf'
; utility function.
; (erc-tests--assert-printed-in-subprocess): Use helper from common lib
; `erc-tests-common-create-subprocess code' to do the heavy lifting.
(erc-tests--string-to-propertized-parts,
erc-tests-pp-propertized-parts): Move to `erc-tests-common' and rename
with "common" prefix.
* test/lisp/erc/resources/erc-tests-common.el: New file containing
helper utilities and fixtures used by multiple files in test/lisp/erc.
2023-12-24 12:21:49 -08:00
|
|
|
(erc-tests-common-init-server-proc "sleep" "1"))))
|
2023-01-13 00:00:56 -08:00
|
|
|
(with-current-buffer
|
|
|
|
(car (push (erc-open "localhost" 6667 "tester" "Tester" 'connect
|
|
|
|
nil nil nil nil nil "tester" 'foonet)
|
|
|
|
erc-fill-tests--buffers))
|
|
|
|
(setq erc-network 'foonet
|
|
|
|
erc-server-connected t)
|
|
|
|
(with-current-buffer (erc--open-target "#chan")
|
|
|
|
(set-window-buffer (selected-window) (current-buffer))
|
|
|
|
|
|
|
|
(erc-update-channel-member
|
|
|
|
"#chan" "alice" "alice" t nil nil nil nil nil "fake" "~u" nil nil t)
|
|
|
|
|
|
|
|
(erc-update-channel-member
|
|
|
|
"#chan" "bob" "bob" t nil nil nil nil nil "fake" "~u" nil nil t)
|
|
|
|
|
2024-04-08 14:21:43 -07:00
|
|
|
(erc-tests-common-display-message
|
2023-01-13 00:00:56 -08:00
|
|
|
nil 'notice (current-buffer)
|
|
|
|
(concat "This server is in debug mode and is logging all user I/O. "
|
|
|
|
"If you do not wish for everything you send to be readable "
|
|
|
|
"by the server owner(s), please disconnect."))
|
|
|
|
|
|
|
|
(erc-fill-tests--insert-privmsg "alice"
|
|
|
|
"bob: come, you are a tedious fool: to the purpose. "
|
Manage some text props for ERC insertion-hook members
* etc/ERC-NEWS: Mention that ERC only adds the text property
`cursor-sensor-functions' when `erc-echo-timestamps' is enabled. Also
mention that date stamps are now inserted as separate messages.
* lisp/erc/erc-fill.el (erc-fill): Look for text prop `erc-cmd'
instead of `erc-command' and use helper utility to do so.
(erc-fill-static): Skip date stamps because this fill style leaves
them flush left.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Don't hook on the soon-to-be-removed function interface
`erc-stamp--insert-date-function' because date stamps are now separate
messages.
(erc-fill--wrap-continued-message-p): Restore accidentally discarded
doc string. Derive context about current message from text props at
`point-min', and use updated property names and utility functions.
Abort when previous message is now hidden.
(erc-fill--wrap-stamp-insert-prefixed-date): Remove unused function,
originally meant to be new in ERC 5.6, and move logic for date-stamp
measuring portion directly to `erc-fill-wrap' itself.
(erc-fill--wrap-measure): New helper function.
(erc-fill-wrap): Use helper `erc-fill--wrap-measure' and incorporate
date-stamp detection and width measuring from removed helper. Don't
dedent first word for messages of unknown origin, such as those
inserted by `erc-display-line' alone without prior preparation from
`erc-display-message'.
* lisp/erc/erc-goodies.el (erc-readonly-mode, erc-readonly-enable):
Set hook depth explicitly to 70.
* lisp/erc/erc-stamp.el (erc-timestamp-format-left): Mention that a
trailing newline is implicit if not provided and that users who don't
want date stamps should use `erc-timestamp-format-right' instead.
(erc-stamp-mode, erc-stamp-enable): Call `erc-stamp--setup' instead
of `erc-munge-invisibility-spec', and bump hook depth for
`erc-add-timestamp' to 70.
(erc-stamp--current-time): Use `erc-ts' instead of `erc-timestamp'
text property in doc string.
(erc-stamp--skip): New internal variable.
(erc-stamp--allow-unmanaged): New variable for legacy code to force
`erc-add-timestamps' to run when `erc--msg-props' is nil.
(erc-add-timestamp): Always run when `erc-stamp--allow-unmanaged' is
non-nil unless `erc-stamp--skip' is as well because the latter takes
precedence. Don't add `erc-ts' text prop directly unless
`erc-stamp--allow-unmanaged is non-nil. Instead, use the new
`erc--msg-props' facility to defer until after modification hooks.
Likewise, don't add `cursor-senor-functions' directly either unless
the same compatibility flag is enabled. Instead, expect the latter to
be handled by a post-modify hook conditioned on the option
`erc-echo-timestamps'.
(erc-timestamp-last-inserted-left): Mention that the final trailing
newline specified in the format string no longer appears in the
recorded value.
(erc-stamp-prefix-log-filter): Use updated name for timestamp
property as well as helper utility for accessing it.
(erc-stamp--inherited-props): Add doc string.
(erc-insert-timestamp-right): Fix bug involving object cycle where
the time-stamp string would appear in its own `display' property.
(erc-stamp--insert-date-function, erc-stamp--insert-date-hook): Remove
unused internal function-valued interface variable and replace with
the latter, a normal hook.
(erc-stamp--date-format-end, erc-stamp--propertize-left-date-stamp):
New function and auxiliary variable to apply date stamp properties at
the post-modify stage. Add text property `erc-stamp-type' to inserted
date stamps to help folks distinguish between them and other
left-sided stamps.
(erc-stamp--current-datestamp-left,
erc-stamp--format-date-stamp,
erc-stamp--insert-date-stamp-as-phony-message,
erc-stamp--lr-date-on-pre-modify): New functions and state variable to
help ERC treat date stamps as separate messages while working within
the established mechanism for processing inserted messages. Shadow
`erc-stamp--invisible-property' when calling `erc-format-timestamp' in
order to prevent date stamps from inheriting other `invisible' props.
These date stamps are special in that they have no business being
hidden along with the current message.
(erc-insert-timestamp-left-and-right): On initial run in any buffer,
remember whether the date stamp needed newline massaging on insertion.
Move all business for inserting date stamps to post-modify hooks, but
run them forcibly if this is the very first date stamp in the current
buffer. Also mention some specifics related to relevant text props in
the doc string.
(erc-format-timestamp): Don't add `invisible' prop to stamp unless
`erc-stamp--invisible-property' is non-nil.
(erc-stamp--csf-props-updated-p): New local variable.
(erc-munge-invisibility-spec): Restore `cursor-sensor-functions' text
property for existing messages when a user enables the option
mid-session. Add and remove hooks for use with automatic timestamp
echoing.
(erc-stamp--add-csf-on-post-modify): New function to add
`cursor-sensor-functions' property on post-modify hooks.
(erc-stamp--setup): Perform some additional teardown.
(erc-stamp--on-clear-message): Look for text property `erc-ts' instead
of `erc-timestamp'.
(erc-echo-timestamp, erc--echo-ts-csf): Use utility to find time-stamp
text prop in current message.
(erc-stamp--update-saved-position, erc-stamp--reset-on-clear): Use
hook `erc-stamp--insert-date-hook' instead of excised function-valued
variable interface `erc-stamp--insert-date-function'.
* lisp/erc/erc-truncate.el (erc-truncate-buffer-to-size): Use internal
utility to find beginning of message.
* lisp/erc/erc.el (erc--msg-props, erc--msg-props-overrides): New
internal variables for initializing and conveying metadata-oriented
text properties among insert and send hooks.
(erc-insert-modify-hook): Mention reserved depth ranges for built-in
members in doc string.
(erc-send-action): Use convenience variable to modifying text props
instead of awkwardly overriding `erc-insert-pre-hook'.
(erc--check-msg-prop, erc--get-inserted-msg-bounds,
erc--get-inserted-msg-prop, erc--with-inserted-msg,
erc--traverse-inserted): New utility functions and macros to help
modules find metadata and message-delimiting text props.
(erc-display-line-1): Ensure the first character of every message in
an ERC buffer has the `erc-msg' property, as well as any other props
in `erc--msg-props', when populated.
(erc--hide-message): Don't bother offsetting start of first message in
a buffer.
(erc--ranked-properties, erc--order-text-properties-from-hash): New
variable and function to convert `erc--msg-props' into a plist
suitable for `add-text-properties'.
(erc-display-message): Make doc string more informative. Bind and
initialize `erc--msg-props' for use by all hooks. Respect
`erc--msg-prop-overrides' when non-nil. Don't add `erc-command'
property. Instead, ensure `erc--msg-props' contains an `erc-cmd' item
when the parameter PARSED is non-nil.
(erc--own-property-names): Add `erc-stamp-type'.
(erc--get-speaker-bounds): Use helper to find message start.
(erc-process-ctcp-query, erc-send-current-line): Use convenience
variable to leverage framework for manipulating message metadata
instead of overriding `erc-insert-pre-hook'.
(erc-display-msg): Bind `erc--msg-props' for use by all send-related
hooks. Add text props from table after `erc-send-post-hook'.
(erc-restore-text-properties): Improve doc string.
(erc--get-eq-comparable-cmd): Use `if-let' instead of `if-let*'.
* test/lisp/erc/erc-fill-tests.el (erc-fill-tests--insert-privmsg):
Make phony message more realistic.
(erc-fill-tests--wrap-populate): Shorten overlong line.
(erc-fill-tests--wrap-check-prefixes): Make test utility more vigilant
in asserting no gaps exist in `line-prefix' property interval.
(erc-fill-tests--compare): Compare text props on text-prop values that
are themselves strings.
* test/lisp/erc/erc-scenarios-log.el (erc-scenarios-log--clear-stamp):
Ensure `erc-stamp' is loaded.
* test/lisp/erc/erc-scenarios-match.el
(erc-scenarios-match--stamp-left-current-nick,
erc-scenarios-match--invisible-stamp): Use `default-value' for
`erc-insert-modify-hook' in ordering assertion.
(erc-scenarios-match--find-bol, erc-scenarios-match--find-eol): Remove
unused assertion helper functions.
(erc-scenarios-match--stamp-right-fools-invisible): Remove misplaced
ERT tag from function and use utility to find message bounds.
(erc-scenarios-match--stamp-right-fools-invisible): Use real utility
from main library to find message end.
(erc-scenarios-match--fill-wrap-stamp-dedented-p): New assertion
utility function.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap) New test.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap/speak): New
test.
(erc-scenarios-match--stamp-both-invisible-fill-static): Expect
`erc-cmd' at beginning of inserted message's filled line, even if the
line starts with white space. Also, add new function parameter
`assert-ds', a callback to run when visiting the second date stamp,
which is followed by a hidden message. In the test of the same name,
expect the date stamp's invisibility interval to begin at the newline
after the previous message and to not contain any existing
invisibility props, namely, those belonging to the subsequent hidden
"fools" message. Also use shortened "metadata" text prop names.
(erc-scenarios-match--stamp-both-invisible-fill-static--nooffset):
Expect the date stamp's invisibility interval to match its field's
instead of starting and ending sooner.
* test/lisp/erc/erc-stamp-tests.el: Put well-known metadata prop at
the start of the message.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt): Prevent modules
from mutating hooks.
(erc--order-text-properties-from-hash, erc--check-msg-prop): New
tests.
* test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update
test data.
* test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update
test data.
* 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.
* test/lisp/erc/resources/match/fools/fill-wrap.eld: New file.
(Bug#60936)
2023-09-21 23:54:31 -07:00
|
|
|
"What was done to Elbow's wife, that he hath cause to complain of?"
|
|
|
|
" Come me to what was done to her.")
|
2023-01-13 00:00:56 -08:00
|
|
|
|
|
|
|
;; Introduce an artificial gap in properties `line-prefix' and
|
|
|
|
;; `wrap-prefix' and later ensure they're not incremented twice.
|
|
|
|
(save-excursion
|
|
|
|
(forward-line -1)
|
|
|
|
(search-forward "? ")
|
|
|
|
(with-silent-modifications
|
|
|
|
(remove-text-properties (1- (point)) (point)
|
|
|
|
'(line-prefix t wrap-prefix t))))
|
|
|
|
|
|
|
|
(erc-fill-tests--insert-privmsg "bob"
|
|
|
|
"alice: Either your unparagoned mistress is dead, "
|
|
|
|
"or she's outprized by a trifle.")
|
|
|
|
|
|
|
|
;; Defend against non-local exits from `ert-skip'
|
|
|
|
(unwind-protect
|
|
|
|
(funcall test)
|
2023-04-10 17:58:05 -07:00
|
|
|
(when set-transient-map-timer
|
|
|
|
(timer-event-handler set-transient-map-timer))
|
2023-01-13 00:00:56 -08:00
|
|
|
(set-window-buffer (selected-window) original-window-buffer)
|
Move ERC test utilities to common file
* lisp/erc/erc-common.el (erc--define-catalog): Update name of
reference to convenience command now located in `erc-tests-common'.
* test/lisp/erc/erc-button-tests.el: Require common test-util library
`erc-tests-common', located under test/lisp/erc/resources.
; (erc-button-alist--url,
; erc-button-tests--erc-button-alist--function-as-form,
; erc-button-tests--erc-button-alist--nil-form,
; erc-button--display-error-notice-with-keys): Use common helper
; `erc-tests-common-init-server-proc' from test-utils library.
* test/lisp/erc/erc-fill-tests.el: Require `erc-tests-common'.
(erc-fill-tests--wrap-populate): Use helper
`erc-tests-common-init-server-proc'.
(erc-fill-tests--save-p): Remove. See replacement
`erc-tests-common-snapshot-save-p' in erc-tests-common.
(erc-fill-tests--graphic-dir): Add trailing slash.
(erc-fill-tests--compare): Move body to generalized utility
`erc-tests-common-snapshot-compare' in erc-tests-common.
* test/lisp/erc/erc-goodies-tests.el: Require `erc-tests-common'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move here from erc-tests.el.
* test/lisp/erc/erc-networks-tests.el: Load `erc-tests-common'.
(erc-networks-tests--create-live-proc): Defer to
`erc-tests-common-init-server-proc' and drop optional buffer param.
(erc-networks-tests--clean-bufs): Defer to
`erc-tests-common-kill-buffers'.
(erc-networks--rename-server-buffer--existing--live): Call
`erc-networks-tests--create-live-proc' in server buffer.
* test/lisp/erc/erc-scenarios-internal.el: Load `erc-tests-common'.
(erc-scenarios-internal--run-graphical-all): Use
`erc-tests-common-create-subprocess' to create process.
* test/lisp/erc/erc-scenarios-sasl.el
(erc-scenarios-sasl--plain-fail): Silence error message.
* test/lisp/erc/erc-stamp-tests.el: Require `erc-tests-common'.
(erc-stamp-tests--insert-right, erc-timestamp-intangible--left): Use
`erc-tests-common-init-server-proc'.
(erc-tests--assert-get-inserted-msg/stamp,
erc-stamp-tests--assert-get-inserted-msg/stamp): Move from
erc-tests.el, renaming to latter.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move here from
erc-tests.el.
* test/lisp/erc/erc-tests.el: Require `erc-tests-common'.
(erc-with-server-buffer): Use renamed test-helper utility
`erc-tests-common-init-server-proc'.
(erc-tests--send-prep, erc-tests--set-fake-server-process): Move to
`erc-tests-common' library and rename to
`erc-tests-common-prep-for-insertion' and
`erc-tests-common-init-server-proc', respectively.
; (erc-hide-prompt, erc--refresh-prompt,
; erc-setup-buffer--custom-action, erc--parsed-prefix,
; erc--update-channel-modes, erc--channel-modes,
; erc--channel-modes/graphic-p, erc-ring-previous-command): Use
; `erc-tests-common-prep-for-insertion' instead of
; `erc-tests--send-prep', and use `erc-tests-common-init-server-proc'
; instead of `erc-tests--set-fake-server-process'.
(erc-tests--with-process-input-spy): Move to `erc-tests-common' and
rename `erc-tests-common-with-process-input-spy'.
; (erc--check-prompt-input-functions, erc-send-current-line,
; erc--check-prompt-input-for-multiline-blanks,
; erc-send-whitespace-lines): Use renamed
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
; (erc-process-input-line): Use renamed
; `erc-tests-common-init-server-proc'.
(erc-tests--get-inserted-msg-setup,
erc-tests--assert-get-inserted-msg,
erc-tests--assert-get-inserted-msg/basic,
erc-tests--assert-get-inserted-msg-readonly-with): Move to
`erc-tests-common' and rename with "common" prefix, using single
instead of double hyphen.
(erc-tests--assert-get-inserted-msg/stamp): Move to `erc-stamp-tests'
and rename with "stamp" prefix.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move to
`erc-stamp-tests'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move to `erc-goodies-tests'.
; (erc--get-inserted-msg-beg/basic,
; erc--get-inserted-msg-end/basic,
; erc--get-inserted-msg-bounds/basic): Use common helpers.
; (erc--route-insertion): Use renamed helper functions
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
(erc-tests--make-server-buf): Move to `erc-common-tests' and rename
with "common" prefix.
(erc-tests--make-client-buf): Remove unused function without supplying
replacement.
; (erc-handle-irc-url): Use renamed `erc-tests-common-make-server-buf'
; utility function.
; (erc-tests--assert-printed-in-subprocess): Use helper from common lib
; `erc-tests-common-create-subprocess code' to do the heavy lifting.
(erc-tests--string-to-propertized-parts,
erc-tests-pp-propertized-parts): Move to `erc-tests-common' and rename
with "common" prefix.
* test/lisp/erc/resources/erc-tests-common.el: New file containing
helper utilities and fixtures used by multiple files in test/lisp/erc.
2023-12-24 12:21:49 -08:00
|
|
|
(when (or noninteractive (getenv "ERC_TESTS_GRAPHICAL"))
|
|
|
|
(erc-tests-common-kill-buffers erc-fill-tests--buffers)
|
|
|
|
(setq erc-fill-tests--buffers nil))))))))
|
2023-01-13 00:00:56 -08:00
|
|
|
|
|
|
|
(defun erc-fill-tests--wrap-check-prefixes (&rest prefixes)
|
|
|
|
;; Check that prefix props are applied over correct intervals.
|
|
|
|
(save-excursion
|
|
|
|
(goto-char (point-min))
|
|
|
|
(dolist (prefix prefixes)
|
|
|
|
(should (search-forward prefix nil t))
|
|
|
|
(should (get-text-property (pos-bol) 'line-prefix))
|
2023-06-05 02:35:53 -07:00
|
|
|
(should (get-text-property (1- (pos-eol)) 'line-prefix))
|
|
|
|
(should-not (get-text-property (pos-eol) 'line-prefix))
|
Manage some text props for ERC insertion-hook members
* etc/ERC-NEWS: Mention that ERC only adds the text property
`cursor-sensor-functions' when `erc-echo-timestamps' is enabled. Also
mention that date stamps are now inserted as separate messages.
* lisp/erc/erc-fill.el (erc-fill): Look for text prop `erc-cmd'
instead of `erc-command' and use helper utility to do so.
(erc-fill-static): Skip date stamps because this fill style leaves
them flush left.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Don't hook on the soon-to-be-removed function interface
`erc-stamp--insert-date-function' because date stamps are now separate
messages.
(erc-fill--wrap-continued-message-p): Restore accidentally discarded
doc string. Derive context about current message from text props at
`point-min', and use updated property names and utility functions.
Abort when previous message is now hidden.
(erc-fill--wrap-stamp-insert-prefixed-date): Remove unused function,
originally meant to be new in ERC 5.6, and move logic for date-stamp
measuring portion directly to `erc-fill-wrap' itself.
(erc-fill--wrap-measure): New helper function.
(erc-fill-wrap): Use helper `erc-fill--wrap-measure' and incorporate
date-stamp detection and width measuring from removed helper. Don't
dedent first word for messages of unknown origin, such as those
inserted by `erc-display-line' alone without prior preparation from
`erc-display-message'.
* lisp/erc/erc-goodies.el (erc-readonly-mode, erc-readonly-enable):
Set hook depth explicitly to 70.
* lisp/erc/erc-stamp.el (erc-timestamp-format-left): Mention that a
trailing newline is implicit if not provided and that users who don't
want date stamps should use `erc-timestamp-format-right' instead.
(erc-stamp-mode, erc-stamp-enable): Call `erc-stamp--setup' instead
of `erc-munge-invisibility-spec', and bump hook depth for
`erc-add-timestamp' to 70.
(erc-stamp--current-time): Use `erc-ts' instead of `erc-timestamp'
text property in doc string.
(erc-stamp--skip): New internal variable.
(erc-stamp--allow-unmanaged): New variable for legacy code to force
`erc-add-timestamps' to run when `erc--msg-props' is nil.
(erc-add-timestamp): Always run when `erc-stamp--allow-unmanaged' is
non-nil unless `erc-stamp--skip' is as well because the latter takes
precedence. Don't add `erc-ts' text prop directly unless
`erc-stamp--allow-unmanaged is non-nil. Instead, use the new
`erc--msg-props' facility to defer until after modification hooks.
Likewise, don't add `cursor-senor-functions' directly either unless
the same compatibility flag is enabled. Instead, expect the latter to
be handled by a post-modify hook conditioned on the option
`erc-echo-timestamps'.
(erc-timestamp-last-inserted-left): Mention that the final trailing
newline specified in the format string no longer appears in the
recorded value.
(erc-stamp-prefix-log-filter): Use updated name for timestamp
property as well as helper utility for accessing it.
(erc-stamp--inherited-props): Add doc string.
(erc-insert-timestamp-right): Fix bug involving object cycle where
the time-stamp string would appear in its own `display' property.
(erc-stamp--insert-date-function, erc-stamp--insert-date-hook): Remove
unused internal function-valued interface variable and replace with
the latter, a normal hook.
(erc-stamp--date-format-end, erc-stamp--propertize-left-date-stamp):
New function and auxiliary variable to apply date stamp properties at
the post-modify stage. Add text property `erc-stamp-type' to inserted
date stamps to help folks distinguish between them and other
left-sided stamps.
(erc-stamp--current-datestamp-left,
erc-stamp--format-date-stamp,
erc-stamp--insert-date-stamp-as-phony-message,
erc-stamp--lr-date-on-pre-modify): New functions and state variable to
help ERC treat date stamps as separate messages while working within
the established mechanism for processing inserted messages. Shadow
`erc-stamp--invisible-property' when calling `erc-format-timestamp' in
order to prevent date stamps from inheriting other `invisible' props.
These date stamps are special in that they have no business being
hidden along with the current message.
(erc-insert-timestamp-left-and-right): On initial run in any buffer,
remember whether the date stamp needed newline massaging on insertion.
Move all business for inserting date stamps to post-modify hooks, but
run them forcibly if this is the very first date stamp in the current
buffer. Also mention some specifics related to relevant text props in
the doc string.
(erc-format-timestamp): Don't add `invisible' prop to stamp unless
`erc-stamp--invisible-property' is non-nil.
(erc-stamp--csf-props-updated-p): New local variable.
(erc-munge-invisibility-spec): Restore `cursor-sensor-functions' text
property for existing messages when a user enables the option
mid-session. Add and remove hooks for use with automatic timestamp
echoing.
(erc-stamp--add-csf-on-post-modify): New function to add
`cursor-sensor-functions' property on post-modify hooks.
(erc-stamp--setup): Perform some additional teardown.
(erc-stamp--on-clear-message): Look for text property `erc-ts' instead
of `erc-timestamp'.
(erc-echo-timestamp, erc--echo-ts-csf): Use utility to find time-stamp
text prop in current message.
(erc-stamp--update-saved-position, erc-stamp--reset-on-clear): Use
hook `erc-stamp--insert-date-hook' instead of excised function-valued
variable interface `erc-stamp--insert-date-function'.
* lisp/erc/erc-truncate.el (erc-truncate-buffer-to-size): Use internal
utility to find beginning of message.
* lisp/erc/erc.el (erc--msg-props, erc--msg-props-overrides): New
internal variables for initializing and conveying metadata-oriented
text properties among insert and send hooks.
(erc-insert-modify-hook): Mention reserved depth ranges for built-in
members in doc string.
(erc-send-action): Use convenience variable to modifying text props
instead of awkwardly overriding `erc-insert-pre-hook'.
(erc--check-msg-prop, erc--get-inserted-msg-bounds,
erc--get-inserted-msg-prop, erc--with-inserted-msg,
erc--traverse-inserted): New utility functions and macros to help
modules find metadata and message-delimiting text props.
(erc-display-line-1): Ensure the first character of every message in
an ERC buffer has the `erc-msg' property, as well as any other props
in `erc--msg-props', when populated.
(erc--hide-message): Don't bother offsetting start of first message in
a buffer.
(erc--ranked-properties, erc--order-text-properties-from-hash): New
variable and function to convert `erc--msg-props' into a plist
suitable for `add-text-properties'.
(erc-display-message): Make doc string more informative. Bind and
initialize `erc--msg-props' for use by all hooks. Respect
`erc--msg-prop-overrides' when non-nil. Don't add `erc-command'
property. Instead, ensure `erc--msg-props' contains an `erc-cmd' item
when the parameter PARSED is non-nil.
(erc--own-property-names): Add `erc-stamp-type'.
(erc--get-speaker-bounds): Use helper to find message start.
(erc-process-ctcp-query, erc-send-current-line): Use convenience
variable to leverage framework for manipulating message metadata
instead of overriding `erc-insert-pre-hook'.
(erc-display-msg): Bind `erc--msg-props' for use by all send-related
hooks. Add text props from table after `erc-send-post-hook'.
(erc-restore-text-properties): Improve doc string.
(erc--get-eq-comparable-cmd): Use `if-let' instead of `if-let*'.
* test/lisp/erc/erc-fill-tests.el (erc-fill-tests--insert-privmsg):
Make phony message more realistic.
(erc-fill-tests--wrap-populate): Shorten overlong line.
(erc-fill-tests--wrap-check-prefixes): Make test utility more vigilant
in asserting no gaps exist in `line-prefix' property interval.
(erc-fill-tests--compare): Compare text props on text-prop values that
are themselves strings.
* test/lisp/erc/erc-scenarios-log.el (erc-scenarios-log--clear-stamp):
Ensure `erc-stamp' is loaded.
* test/lisp/erc/erc-scenarios-match.el
(erc-scenarios-match--stamp-left-current-nick,
erc-scenarios-match--invisible-stamp): Use `default-value' for
`erc-insert-modify-hook' in ordering assertion.
(erc-scenarios-match--find-bol, erc-scenarios-match--find-eol): Remove
unused assertion helper functions.
(erc-scenarios-match--stamp-right-fools-invisible): Remove misplaced
ERT tag from function and use utility to find message bounds.
(erc-scenarios-match--stamp-right-fools-invisible): Use real utility
from main library to find message end.
(erc-scenarios-match--fill-wrap-stamp-dedented-p): New assertion
utility function.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap) New test.
(erc-scenarios-match--hide-fools/stamp-both/fill-wrap/speak): New
test.
(erc-scenarios-match--stamp-both-invisible-fill-static): Expect
`erc-cmd' at beginning of inserted message's filled line, even if the
line starts with white space. Also, add new function parameter
`assert-ds', a callback to run when visiting the second date stamp,
which is followed by a hidden message. In the test of the same name,
expect the date stamp's invisibility interval to begin at the newline
after the previous message and to not contain any existing
invisibility props, namely, those belonging to the subsequent hidden
"fools" message. Also use shortened "metadata" text prop names.
(erc-scenarios-match--stamp-both-invisible-fill-static--nooffset):
Expect the date stamp's invisibility interval to match its field's
instead of starting and ending sooner.
* test/lisp/erc/erc-stamp-tests.el: Put well-known metadata prop at
the start of the message.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt): Prevent modules
from mutating hooks.
(erc--order-text-properties-from-hash, erc--check-msg-prop): New
tests.
* test/lisp/erc/resources/fill/snapshots/merge-01-start.eld: Update
test data.
* test/lisp/erc/resources/fill/snapshots/merge-02-right.eld: Update
test data.
* 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.
* test/lisp/erc/resources/match/fools/fill-wrap.eld: New file.
(Bug#60936)
2023-09-21 23:54:31 -07:00
|
|
|
;; Spans entire line uninterrupted.
|
|
|
|
(let* ((val (get-text-property (pos-bol) 'line-prefix))
|
|
|
|
(end (text-property-not-all (pos-bol) (point-max)
|
|
|
|
'line-prefix val)))
|
|
|
|
(when (and (/= end (pos-eol)) (= ?? (char-before end)))
|
|
|
|
(setq end (text-property-not-all (1+ end) (point-max)
|
|
|
|
'line-prefix val)))
|
|
|
|
(should (eq end (pos-eol))))
|
2023-01-13 00:00:56 -08:00
|
|
|
(should (equal (get-text-property (pos-bol) 'wrap-prefix)
|
|
|
|
'(space :width erc-fill--wrap-value)))
|
2023-06-05 02:35:53 -07:00
|
|
|
(should-not (get-text-property (pos-eol) 'wrap-prefix))
|
|
|
|
(should (equal (get-text-property (1- (pos-eol)) 'wrap-prefix)
|
2023-01-13 00:00:56 -08:00
|
|
|
'(space :width erc-fill--wrap-value))))))
|
|
|
|
|
2023-05-07 07:28:56 -07:00
|
|
|
;; On graphical displays, echo .graphic >> .git/info/exclude
|
Move ERC test utilities to common file
* lisp/erc/erc-common.el (erc--define-catalog): Update name of
reference to convenience command now located in `erc-tests-common'.
* test/lisp/erc/erc-button-tests.el: Require common test-util library
`erc-tests-common', located under test/lisp/erc/resources.
; (erc-button-alist--url,
; erc-button-tests--erc-button-alist--function-as-form,
; erc-button-tests--erc-button-alist--nil-form,
; erc-button--display-error-notice-with-keys): Use common helper
; `erc-tests-common-init-server-proc' from test-utils library.
* test/lisp/erc/erc-fill-tests.el: Require `erc-tests-common'.
(erc-fill-tests--wrap-populate): Use helper
`erc-tests-common-init-server-proc'.
(erc-fill-tests--save-p): Remove. See replacement
`erc-tests-common-snapshot-save-p' in erc-tests-common.
(erc-fill-tests--graphic-dir): Add trailing slash.
(erc-fill-tests--compare): Move body to generalized utility
`erc-tests-common-snapshot-compare' in erc-tests-common.
* test/lisp/erc/erc-goodies-tests.el: Require `erc-tests-common'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move here from erc-tests.el.
* test/lisp/erc/erc-networks-tests.el: Load `erc-tests-common'.
(erc-networks-tests--create-live-proc): Defer to
`erc-tests-common-init-server-proc' and drop optional buffer param.
(erc-networks-tests--clean-bufs): Defer to
`erc-tests-common-kill-buffers'.
(erc-networks--rename-server-buffer--existing--live): Call
`erc-networks-tests--create-live-proc' in server buffer.
* test/lisp/erc/erc-scenarios-internal.el: Load `erc-tests-common'.
(erc-scenarios-internal--run-graphical-all): Use
`erc-tests-common-create-subprocess' to create process.
* test/lisp/erc/erc-scenarios-sasl.el
(erc-scenarios-sasl--plain-fail): Silence error message.
* test/lisp/erc/erc-stamp-tests.el: Require `erc-tests-common'.
(erc-stamp-tests--insert-right, erc-timestamp-intangible--left): Use
`erc-tests-common-init-server-proc'.
(erc-tests--assert-get-inserted-msg/stamp,
erc-stamp-tests--assert-get-inserted-msg/stamp): Move from
erc-tests.el, renaming to latter.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move here from
erc-tests.el.
* test/lisp/erc/erc-tests.el: Require `erc-tests-common'.
(erc-with-server-buffer): Use renamed test-helper utility
`erc-tests-common-init-server-proc'.
(erc-tests--send-prep, erc-tests--set-fake-server-process): Move to
`erc-tests-common' library and rename to
`erc-tests-common-prep-for-insertion' and
`erc-tests-common-init-server-proc', respectively.
; (erc-hide-prompt, erc--refresh-prompt,
; erc-setup-buffer--custom-action, erc--parsed-prefix,
; erc--update-channel-modes, erc--channel-modes,
; erc--channel-modes/graphic-p, erc-ring-previous-command): Use
; `erc-tests-common-prep-for-insertion' instead of
; `erc-tests--send-prep', and use `erc-tests-common-init-server-proc'
; instead of `erc-tests--set-fake-server-process'.
(erc-tests--with-process-input-spy): Move to `erc-tests-common' and
rename `erc-tests-common-with-process-input-spy'.
; (erc--check-prompt-input-functions, erc-send-current-line,
; erc--check-prompt-input-for-multiline-blanks,
; erc-send-whitespace-lines): Use renamed
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
; (erc-process-input-line): Use renamed
; `erc-tests-common-init-server-proc'.
(erc-tests--get-inserted-msg-setup,
erc-tests--assert-get-inserted-msg,
erc-tests--assert-get-inserted-msg/basic,
erc-tests--assert-get-inserted-msg-readonly-with): Move to
`erc-tests-common' and rename with "common" prefix, using single
instead of double hyphen.
(erc-tests--assert-get-inserted-msg/stamp): Move to `erc-stamp-tests'
and rename with "stamp" prefix.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move to
`erc-stamp-tests'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move to `erc-goodies-tests'.
; (erc--get-inserted-msg-beg/basic,
; erc--get-inserted-msg-end/basic,
; erc--get-inserted-msg-bounds/basic): Use common helpers.
; (erc--route-insertion): Use renamed helper functions
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
(erc-tests--make-server-buf): Move to `erc-common-tests' and rename
with "common" prefix.
(erc-tests--make-client-buf): Remove unused function without supplying
replacement.
; (erc-handle-irc-url): Use renamed `erc-tests-common-make-server-buf'
; utility function.
; (erc-tests--assert-printed-in-subprocess): Use helper from common lib
; `erc-tests-common-create-subprocess code' to do the heavy lifting.
(erc-tests--string-to-propertized-parts,
erc-tests-pp-propertized-parts): Move to `erc-tests-common' and rename
with "common" prefix.
* test/lisp/erc/resources/erc-tests-common.el: New file containing
helper utilities and fixtures used by multiple files in test/lisp/erc.
2023-12-24 12:21:49 -08:00
|
|
|
(defvar erc-fill-tests--graphic-dir "fill/snapshots/.graphic/")
|
2023-05-07 07:28:56 -07:00
|
|
|
|
2023-01-13 00:00:56 -08:00
|
|
|
(defun erc-fill-tests--compare (name)
|
Move ERC test utilities to common file
* lisp/erc/erc-common.el (erc--define-catalog): Update name of
reference to convenience command now located in `erc-tests-common'.
* test/lisp/erc/erc-button-tests.el: Require common test-util library
`erc-tests-common', located under test/lisp/erc/resources.
; (erc-button-alist--url,
; erc-button-tests--erc-button-alist--function-as-form,
; erc-button-tests--erc-button-alist--nil-form,
; erc-button--display-error-notice-with-keys): Use common helper
; `erc-tests-common-init-server-proc' from test-utils library.
* test/lisp/erc/erc-fill-tests.el: Require `erc-tests-common'.
(erc-fill-tests--wrap-populate): Use helper
`erc-tests-common-init-server-proc'.
(erc-fill-tests--save-p): Remove. See replacement
`erc-tests-common-snapshot-save-p' in erc-tests-common.
(erc-fill-tests--graphic-dir): Add trailing slash.
(erc-fill-tests--compare): Move body to generalized utility
`erc-tests-common-snapshot-compare' in erc-tests-common.
* test/lisp/erc/erc-goodies-tests.el: Require `erc-tests-common'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move here from erc-tests.el.
* test/lisp/erc/erc-networks-tests.el: Load `erc-tests-common'.
(erc-networks-tests--create-live-proc): Defer to
`erc-tests-common-init-server-proc' and drop optional buffer param.
(erc-networks-tests--clean-bufs): Defer to
`erc-tests-common-kill-buffers'.
(erc-networks--rename-server-buffer--existing--live): Call
`erc-networks-tests--create-live-proc' in server buffer.
* test/lisp/erc/erc-scenarios-internal.el: Load `erc-tests-common'.
(erc-scenarios-internal--run-graphical-all): Use
`erc-tests-common-create-subprocess' to create process.
* test/lisp/erc/erc-scenarios-sasl.el
(erc-scenarios-sasl--plain-fail): Silence error message.
* test/lisp/erc/erc-stamp-tests.el: Require `erc-tests-common'.
(erc-stamp-tests--insert-right, erc-timestamp-intangible--left): Use
`erc-tests-common-init-server-proc'.
(erc-tests--assert-get-inserted-msg/stamp,
erc-stamp-tests--assert-get-inserted-msg/stamp): Move from
erc-tests.el, renaming to latter.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move here from
erc-tests.el.
* test/lisp/erc/erc-tests.el: Require `erc-tests-common'.
(erc-with-server-buffer): Use renamed test-helper utility
`erc-tests-common-init-server-proc'.
(erc-tests--send-prep, erc-tests--set-fake-server-process): Move to
`erc-tests-common' library and rename to
`erc-tests-common-prep-for-insertion' and
`erc-tests-common-init-server-proc', respectively.
; (erc-hide-prompt, erc--refresh-prompt,
; erc-setup-buffer--custom-action, erc--parsed-prefix,
; erc--update-channel-modes, erc--channel-modes,
; erc--channel-modes/graphic-p, erc-ring-previous-command): Use
; `erc-tests-common-prep-for-insertion' instead of
; `erc-tests--send-prep', and use `erc-tests-common-init-server-proc'
; instead of `erc-tests--set-fake-server-process'.
(erc-tests--with-process-input-spy): Move to `erc-tests-common' and
rename `erc-tests-common-with-process-input-spy'.
; (erc--check-prompt-input-functions, erc-send-current-line,
; erc--check-prompt-input-for-multiline-blanks,
; erc-send-whitespace-lines): Use renamed
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
; (erc-process-input-line): Use renamed
; `erc-tests-common-init-server-proc'.
(erc-tests--get-inserted-msg-setup,
erc-tests--assert-get-inserted-msg,
erc-tests--assert-get-inserted-msg/basic,
erc-tests--assert-get-inserted-msg-readonly-with): Move to
`erc-tests-common' and rename with "common" prefix, using single
instead of double hyphen.
(erc-tests--assert-get-inserted-msg/stamp): Move to `erc-stamp-tests'
and rename with "stamp" prefix.
(erc--get-inserted-msg-beg/stamp,
erc--get-inserted-msg-beg/readonly/stamp,
erc--get-inserted-msg-end/stamp,
erc--get-inserted-msg-end/readonly/stamp,
erc--get-inserted-msg-bounds/stamp,
erc--get-inserted-msg-bounds/readonly/stamp): Move to
`erc-stamp-tests'.
(erc--get-inserted-msg-beg/readonly,
erc--get-inserted-msg-end/readonly,
erc--get-inserted-msg-bounds/readonly): Move to `erc-goodies-tests'.
; (erc--get-inserted-msg-beg/basic,
; erc--get-inserted-msg-end/basic,
; erc--get-inserted-msg-bounds/basic): Use common helpers.
; (erc--route-insertion): Use renamed helper functions
; `erc-tests-common-with-process-input-spy' and
; `erc-tests-common-init-server-proc'.
(erc-tests--make-server-buf): Move to `erc-common-tests' and rename
with "common" prefix.
(erc-tests--make-client-buf): Remove unused function without supplying
replacement.
; (erc-handle-irc-url): Use renamed `erc-tests-common-make-server-buf'
; utility function.
; (erc-tests--assert-printed-in-subprocess): Use helper from common lib
; `erc-tests-common-create-subprocess code' to do the heavy lifting.
(erc-tests--string-to-propertized-parts,
erc-tests-pp-propertized-parts): Move to `erc-tests-common' and rename
with "common" prefix.
* test/lisp/erc/resources/erc-tests-common.el: New file containing
helper utilities and fixtures used by multiple files in test/lisp/erc.
2023-12-24 12:21:49 -08:00
|
|
|
(let ((dir (expand-file-name (if (display-graphic-p)
|
|
|
|
erc-fill-tests--graphic-dir
|
|
|
|
"fill/snapshots/" )
|
|
|
|
(ert-resource-directory)))
|
|
|
|
(transform-fn (lambda (got)
|
|
|
|
(string-replace "erc-fill--wrap-value"
|
|
|
|
(number-to-string erc-fill--wrap-value)
|
|
|
|
got)))
|
|
|
|
(buffer-setup-fn (lambda ()
|
|
|
|
(push (current-buffer) erc-fill-tests--buffers))))
|
|
|
|
(erc-tests-common-snapshot-compare name dir transform-fn buffer-setup-fn)))
|
2023-01-13 00:00:56 -08:00
|
|
|
|
|
|
|
;; To inspect variable pitch, set `erc-mode-hook' to
|
|
|
|
;;
|
|
|
|
;; (lambda () (face-remap-add-relative 'default :family "Sans Serif"))
|
|
|
|
;;
|
|
|
|
;; or similar.
|
|
|
|
|
|
|
|
(ert-deftest erc-fill-wrap--monospace ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
2023-01-13 00:00:56 -08:00
|
|
|
(unless (>= emacs-major-version 29)
|
|
|
|
(ert-skip "Emacs version too low, missing `buffer-text-pixel-size'"))
|
|
|
|
|
2023-10-18 23:20:07 -07:00
|
|
|
(let ((erc-prompt (lambda () "ABC>")))
|
|
|
|
(erc-fill-tests--wrap-populate
|
2023-01-13 00:00:56 -08:00
|
|
|
|
2023-10-18 23:20:07 -07:00
|
|
|
(lambda ()
|
|
|
|
(should (= erc-fill--wrap-value 27))
|
2023-01-13 00:00:56 -08:00
|
|
|
(erc-fill-tests--wrap-check-prefixes "*** " "<alice> " "<bob> ")
|
2023-10-18 23:20:07 -07:00
|
|
|
(erc-fill-tests--compare "monospace-01-start")
|
2023-01-13 00:00:56 -08:00
|
|
|
|
2023-10-18 23:20:07 -07:00
|
|
|
(ert-info ("Shift right by one (plus)")
|
|
|
|
;; Args are all `erc-fill-wrap-nudge' +1 because interactive "p"
|
|
|
|
(ert-with-message-capture messages
|
|
|
|
;; M-x erc-fill-wrap-nudge RET =
|
|
|
|
(ert-simulate-command '(erc-fill-wrap-nudge 2))
|
|
|
|
(should (string-match (rx "for further adjustment") messages)))
|
|
|
|
(should (= erc-fill--wrap-value 29))
|
|
|
|
(erc-fill-tests--wrap-check-prefixes "*** " "<alice> " "<bob> ")
|
|
|
|
(erc-fill-tests--compare "monospace-02-right"))
|
2023-01-13 00:00:56 -08:00
|
|
|
|
2023-10-18 23:20:07 -07:00
|
|
|
(ert-info ("Shift left by five")
|
|
|
|
;; "M-x erc-fill-wrap-nudge RET -----"
|
|
|
|
(ert-simulate-command '(erc-fill-wrap-nudge -4))
|
|
|
|
(should (= erc-fill--wrap-value 25))
|
|
|
|
(erc-fill-tests--wrap-check-prefixes "*** " "<alice> " "<bob> ")
|
|
|
|
(erc-fill-tests--compare "monospace-03-left"))
|
|
|
|
|
|
|
|
(ert-info ("Reset")
|
|
|
|
;; M-x erc-fill-wrap-nudge RET 0
|
|
|
|
(ert-simulate-command '(erc-fill-wrap-nudge 0))
|
|
|
|
(should (= erc-fill--wrap-value 27))
|
|
|
|
(erc-fill-tests--wrap-check-prefixes "*** " "<alice> " "<bob> ")
|
|
|
|
(erc-fill-tests--compare "monospace-04-reset"))
|
|
|
|
|
|
|
|
(erc--assert-input-bounds)))))
|
2023-01-13 00:00:56 -08:00
|
|
|
|
2023-09-21 06:54:27 -07:00
|
|
|
(defun erc-fill-tests--simulate-refill ()
|
|
|
|
;; Simulate `erc-fill-wrap-refill-buffer' synchronously and without
|
|
|
|
;; a progress reporter.
|
|
|
|
(save-excursion
|
|
|
|
(with-silent-modifications
|
|
|
|
(erc-fill--wrap-rejigger-region (point-min) erc-insert-marker nil nil))))
|
|
|
|
|
2023-01-13 00:00:56 -08:00
|
|
|
(ert-deftest erc-fill-wrap--merge ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
2023-01-13 00:00:56 -08:00
|
|
|
(unless (>= emacs-major-version 29)
|
|
|
|
(ert-skip "Emacs version too low, missing `buffer-text-pixel-size'"))
|
|
|
|
|
|
|
|
(erc-fill-tests--wrap-populate
|
|
|
|
|
|
|
|
(lambda ()
|
2023-04-28 07:01:14 -07:00
|
|
|
(erc-update-channel-member
|
|
|
|
"#chan" "Dummy" "Dummy" t nil nil nil nil nil "fake" "~u" nil nil t)
|
|
|
|
|
2023-09-21 06:54:27 -07:00
|
|
|
;; Set this here so that the first few messages are from 1970.
|
|
|
|
;; Following the current date stamp, the speaker isn't merged
|
|
|
|
;; even though it's continued: "<bob> zero."
|
2023-10-30 23:36:54 -07:00
|
|
|
(let ((erc-fill-tests--current-time-value 1680332400))
|
2023-01-13 00:00:56 -08:00
|
|
|
(erc-fill-tests--insert-privmsg "bob" "zero.")
|
|
|
|
(erc-fill-tests--insert-privmsg "alice" "one.")
|
|
|
|
(erc-fill-tests--insert-privmsg "alice" "two.")
|
|
|
|
(erc-fill-tests--insert-privmsg "bob" "three.")
|
2023-04-28 07:01:14 -07:00
|
|
|
(erc-fill-tests--insert-privmsg "bob" "four.")
|
|
|
|
(erc-fill-tests--insert-privmsg "Dummy" "five.")
|
|
|
|
(erc-fill-tests--insert-privmsg "Dummy" "six."))
|
2023-01-13 00:00:56 -08:00
|
|
|
|
|
|
|
(should (= erc-fill--wrap-value 27))
|
|
|
|
(erc-fill-tests--wrap-check-prefixes
|
|
|
|
"*** " "<alice> " "<bob> "
|
2023-04-28 07:01:14 -07:00
|
|
|
"<bob> " "<alice> " "<alice> " "<bob> " "<bob> " "<Dummy> " "<Dummy> ")
|
2023-01-13 00:00:56 -08:00
|
|
|
(erc-fill-tests--compare "merge-01-start")
|
|
|
|
|
|
|
|
(ert-info ("Shift right by one (plus)")
|
|
|
|
(ert-simulate-command '(erc-fill-wrap-nudge 2))
|
|
|
|
(should (= erc-fill--wrap-value 29))
|
|
|
|
(erc-fill-tests--wrap-check-prefixes
|
|
|
|
"*** " "<alice> " "<bob> "
|
2023-04-28 07:01:14 -07:00
|
|
|
"<bob> " "<alice> " "<alice> " "<bob> " "<bob> " "<Dummy> " "<Dummy> ")
|
2023-09-21 06:54:27 -07:00
|
|
|
(erc-fill-tests--compare "merge-02-right")
|
|
|
|
|
|
|
|
(ert-info ("Command `erc-fill-wrap-refill-buffer' is idempotent")
|
|
|
|
(kill-buffer (pop erc-fill-tests--buffers))
|
|
|
|
(erc-fill-tests--simulate-refill) ; idempotent
|
|
|
|
(erc-fill-tests--compare "merge-02-right"))))))
|
2023-01-13 00:00:56 -08:00
|
|
|
|
2023-11-19 17:18:29 -08:00
|
|
|
(defun erc-fill-wrap-tests--merge-action (compare-file)
|
2023-07-22 14:07:38 -07:00
|
|
|
(unless (>= emacs-major-version 29)
|
|
|
|
(ert-skip "Emacs version too low, missing `buffer-text-pixel-size'"))
|
|
|
|
|
|
|
|
(erc-fill-tests--wrap-populate
|
|
|
|
|
|
|
|
(lambda ()
|
2023-10-30 23:36:54 -07:00
|
|
|
;; Allow prior messages to be from 1970.
|
|
|
|
(let ((erc-fill-tests--current-time-value 1680332400))
|
2023-07-22 14:07:38 -07:00
|
|
|
(erc-fill-tests--insert-privmsg "bob" "zero.")
|
2023-09-02 13:43:22 -07:00
|
|
|
(erc-fill-tests--insert-privmsg "bob" "0.5")
|
2023-07-22 14:07:38 -07:00
|
|
|
|
2024-04-08 14:21:43 -07:00
|
|
|
(erc-tests-common-with-date-aware-display-message
|
|
|
|
(erc-process-ctcp-query
|
|
|
|
erc-server-process
|
|
|
|
(make-erc-response
|
|
|
|
:unparsed ":bob!~u@fake PRIVMSG #chan :\1ACTION one.\1"
|
|
|
|
:sender "bob!~u@fake"
|
|
|
|
:command "PRIVMSG"
|
|
|
|
:command-args '("#chan" "\1ACTION one.\1")
|
|
|
|
:contents "\1ACTION one.\1")
|
|
|
|
"bob" "~u" "fake"))
|
2023-07-22 14:07:38 -07:00
|
|
|
|
|
|
|
(erc-fill-tests--insert-privmsg "bob" "two.")
|
2023-09-02 13:43:22 -07:00
|
|
|
(erc-fill-tests--insert-privmsg "bob" "2.5")
|
2023-07-22 14:07:38 -07:00
|
|
|
|
|
|
|
;; Compat switch to opt out of overhanging speaker.
|
2024-04-08 14:21:43 -07:00
|
|
|
(erc-tests-common-with-date-aware-display-message
|
|
|
|
(let (erc-fill--wrap-action-dedent-p)
|
|
|
|
(erc-process-ctcp-query
|
|
|
|
erc-server-process
|
|
|
|
(make-erc-response
|
|
|
|
:unparsed ":bob!~u@fake PRIVMSG #chan :\1ACTION three\1"
|
|
|
|
:sender "bob!~u@fake" :command "PRIVMSG"
|
|
|
|
:command-args '("#chan" "\1ACTION three\1")
|
|
|
|
:contents "\1ACTION three\1")
|
|
|
|
"bob" "~u" "fake")))
|
2023-07-22 14:07:38 -07:00
|
|
|
|
|
|
|
(erc-fill-tests--insert-privmsg "bob" "four."))
|
|
|
|
|
|
|
|
(should (= erc-fill--wrap-value 27))
|
|
|
|
(erc-fill-tests--wrap-check-prefixes
|
|
|
|
"*** " "<alice> " "<bob> " "<bob> " "* bob " "<bob> " "* " "<bob> ")
|
2023-11-19 17:18:29 -08:00
|
|
|
(erc-fill-tests--compare compare-file))))
|
|
|
|
|
|
|
|
(ert-deftest erc-fill-wrap--merge-action ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
2023-11-19 17:18:29 -08:00
|
|
|
(erc-fill-wrap-tests--merge-action "merge-wrap-01"))
|
|
|
|
|
|
|
|
(ert-deftest erc-fill-wrap--merge-action/indicator-pre ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
2024-04-12 00:04:50 -07:00
|
|
|
(let ((erc-fill-wrap-merge-indicator '(?> . shadow)))
|
2023-11-19 17:18:29 -08:00
|
|
|
(erc-fill-wrap-tests--merge-action "merge-wrap-indicator-pre-01")))
|
|
|
|
|
2023-05-07 07:28:56 -07:00
|
|
|
(ert-deftest erc-fill-line-spacing ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
2023-05-07 07:28:56 -07:00
|
|
|
(unless (>= emacs-major-version 29)
|
|
|
|
(ert-skip "Emacs version too low, missing `buffer-text-pixel-size'"))
|
|
|
|
|
|
|
|
(let ((erc-fill-line-spacing 0.5))
|
|
|
|
(erc-fill-tests--wrap-populate
|
|
|
|
(lambda ()
|
|
|
|
(erc-fill-tests--insert-privmsg "bob" "This buffer is for text.")
|
2024-04-08 14:21:43 -07:00
|
|
|
(erc-tests-common-display-message nil 'notice
|
|
|
|
(current-buffer) "one two three")
|
|
|
|
(erc-tests-common-display-message nil 'notice
|
|
|
|
(current-buffer) "four five six")
|
2023-05-07 07:28:56 -07:00
|
|
|
(erc-fill-tests--insert-privmsg "bob" "Somebody stop me")
|
|
|
|
(erc-fill-tests--compare "spacing-01-mono")))))
|
|
|
|
|
2023-01-13 00:00:56 -08:00
|
|
|
(ert-deftest erc-fill-wrap-visual-keys--body ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
2023-01-13 00:00:56 -08:00
|
|
|
(erc-fill-tests--wrap-populate
|
|
|
|
|
|
|
|
(lambda ()
|
|
|
|
(ert-info ("Value: non-input")
|
|
|
|
(should (eq erc-fill--wrap-visual-keys 'non-input))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(should (search-forward "that he hath" nil t))
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(should-not (looking-at (rx "<alice> ")))
|
|
|
|
(execute-kbd-macro "\C-e")
|
|
|
|
(should (search-backward "tedious fool" nil t))
|
|
|
|
(should-not (looking-back "done to her\\."))
|
|
|
|
(forward-char)
|
|
|
|
(execute-kbd-macro "\C-e")
|
|
|
|
(should (search-forward "done to her." nil t)))
|
|
|
|
|
|
|
|
(ert-info ("Value: nil")
|
|
|
|
(execute-kbd-macro "\C-ca")
|
|
|
|
(should-not erc-fill--wrap-visual-keys)
|
|
|
|
(goto-char (point-min))
|
|
|
|
(should (search-forward "in debug mode" nil t))
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(should (looking-at (rx "*** ")))
|
|
|
|
(execute-kbd-macro "\C-e")
|
|
|
|
(should (eql ?\] (char-before (point)))))
|
|
|
|
|
|
|
|
(ert-info ("Value: t")
|
|
|
|
(execute-kbd-macro "\C-ca")
|
|
|
|
(should (eq erc-fill--wrap-visual-keys t))
|
|
|
|
(goto-char (point-min))
|
|
|
|
(should (search-forward "that he hath" nil t))
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(should-not (looking-at (rx "<alice> ")))
|
|
|
|
(should (search-backward "tedious fool" nil t))
|
|
|
|
(execute-kbd-macro "\C-e")
|
|
|
|
(should-not (looking-back (rx "done to her\\.")))
|
|
|
|
(should (search-forward "done to her." nil t))
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(should-not (looking-at (rx "<alice> ")))))))
|
|
|
|
|
|
|
|
(ert-deftest erc-fill-wrap-visual-keys--prompt ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
2023-01-13 00:00:56 -08:00
|
|
|
(erc-fill-tests--wrap-populate
|
|
|
|
|
|
|
|
(lambda ()
|
|
|
|
(set-window-buffer (selected-window) (current-buffer))
|
|
|
|
(goto-char erc-input-marker)
|
|
|
|
(insert "This buffer is for text that is not saved, and for Lisp "
|
|
|
|
"evaluation. To create a file, visit it with C-x C-f and "
|
|
|
|
"enter text in its buffer.")
|
|
|
|
|
|
|
|
(ert-info ("Value: non-input")
|
|
|
|
(should (eq erc-fill--wrap-visual-keys 'non-input))
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(should (looking-at "This buffer"))
|
|
|
|
(execute-kbd-macro "\C-e")
|
|
|
|
(should (looking-back "its buffer\\."))
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(execute-kbd-macro "\C-k")
|
|
|
|
(should (eobp)))
|
|
|
|
|
|
|
|
(ert-info ("Value: nil") ; same
|
|
|
|
(execute-kbd-macro "\C-ca")
|
|
|
|
(should-not erc-fill--wrap-visual-keys)
|
|
|
|
(execute-kbd-macro "\C-y")
|
|
|
|
(should (looking-back "its buffer\\."))
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(should (looking-at "This buffer"))
|
|
|
|
(execute-kbd-macro "\C-k")
|
|
|
|
(should (eobp)))
|
|
|
|
|
|
|
|
(ert-info ("Value: non-input")
|
|
|
|
(execute-kbd-macro "\C-ca")
|
|
|
|
(should (eq erc-fill--wrap-visual-keys t))
|
|
|
|
(execute-kbd-macro "\C-y")
|
|
|
|
(execute-kbd-macro "\C-a")
|
|
|
|
(should-not (looking-at "This buffer"))
|
|
|
|
(execute-kbd-macro "\C-p")
|
|
|
|
(should-not (looking-back "its buffer\\."))
|
|
|
|
(should (search-forward "its buffer." nil t))
|
|
|
|
(should (search-backward "ERC> " nil t))
|
|
|
|
(execute-kbd-macro "\C-a")))))
|
|
|
|
|
Make erc-fill-wrap work with left-sided stamps
* etc/ERC-NEWS: Remove all mention of option `erc-timestamp-align-to'
supporting a value of `margin', which has been abandoned. Do mention
leading white space before stamps now having stamp-related properties.
* lisp/erc/erc-backend.el (erc--reveal-prompt, erc--conceal-prompt):
New generic functions with default implementations factored out from
`erc--unhide-prompt' and `erc--hide-prompt'.
(erc--prompt-hidden-p): New internal predicate function.
(erc--unhide-prompt): Defer to `erc--reveal-prompt', and set
`erc-prompt' text property to t.
(erc--hide-prompt): Defer to `erc--conceal-prompt', and set
`erc-prompt' text property to `hidden'.
* lisp/erc/erc-compat.el (erc-compat--29-browse-url-irc): Don't
use `function-equal'.
* lisp/erc/erc-fill.el (erc-fill-wrap-margin-width,
erc-fill-wrap-margin-side): New options to control side and initial
width of `fill-wrap' margin.
(erc-fill--wrap-beginning-of-line): Fix bug involving non-string
valued `display' props.
(erc-fill-wrap-toggle-truncate-lines): New command to re-enable
`visual-line-mode' when toggling off `truncate-lines'.
(erc-fill-wrap-mode-map): Remap `toggle-truncate-lines' to
`erc-fill-wrap-toggle-truncate-lines'.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Update doc string, persist a few local vars, and conditionally set
`erc-stamp--margin-left-p'. When deactivating, disable
`visual-line-mode' first.
(erc-fill--wrap-continued-message-p): Use `erc-speaker' instead of
heuristics when comparing nicks between consecutive messages.
(erc-fill-wrap-nudge): Update doc string and account for left-sided
stamps.
(erc-timestamp-offset): Add comment regarding conditional guard based
on function-valued option.
* lisp/erc/erc-stamp.el (erc-timestamp-use-align-to): Remove value
variant `margin', which was originally intended to be new in ERC 5.6.
This functionality was all but useless without the internal minor mode
`erc-stamp--display-margin-mode' active.
(erc-stamp-right-margin-width): Remove unused option new in 5.6.
(erc-stamp--display-margin-force): Remove unused function.
(erc-stamp--margin-width, erc-stamp--margin-left-p): New internal
variables.
(erc-stamp--init-margins-on-connect): New function for initializing
mode-managed margin after connecting.
(erc-stamp--adjust-right-margin, erc-stamp--adjust-margin): Rename
function to latter and accommodate left-hand stamps.
(erc-stamp--inherited-props): Move definition higher up in same file.
(erc-stamp--display-margin-mode): Update function name, and adjust
setup and teardown to accommodate left-handed stamps. Don't add
advice around `erc-insert-timestamp-function'.
(erc-stamp--last-prompt, erc-stamp--display-prompt-in-left-margin):
New function and helper var to convert a normal inserted prompt so
that it appears in the left margin.
(erc-stamp--refresh-left-margin-prompt): Helper for other modules to
quickly refresh prompt outside of insert hooks.
(erc--reveal-prompt, erc--conceal-prompt): New implementations for
when `erc-stamp--display-margin-mode' is active.
(erc-insert-timestamp-left): Convert to generic function and provide
implementation for `erc-stamp--display-margin-mode'.
(erc-stamp--omit-properties-on-folded-lines): New variable, an escape
hatch for propertizing white space before right-side stamps folded
over onto another line.
(erc-insert-timestamp-right): Don't expect `erc-timestamp-align-to' to
ever be the symbol `margin'. Move handling for that case to one
contingent on the internal minor mode `erc-stamp--display-margin-mode'
being active. Add text properties preceding stamps that occupy a line
by their lonesome. See related news entry for rationale. This is
arguably a breaking change.
* lisp/erc/erc.el (erc--refresh-prompt-hook): New hook variable for
modules to adjust prompt properties whenever it's refreshed.
(erc--refresh-prompt): Fix bug in which user-defined prompt functions
failed to hide when quitting in server buffers. Run new hook
`erc--refresh-prompt-hook'.
(erc-display-prompt): Add comment noting that the text property
`erc-prompt' now actually matters: it's t while a session is running
and `hidden' when disconnected.
* test/lisp/erc/erc-fill-tests.el (erc-fill--left-hand-stamps): New
test.
* test/lisp/erc/erc-stamp-tests.el
(erc-stamp-tests--use-align-to--nil,
erc-stamp-tests--use-align-to--t): New functions forged from old test
bodies to allow optionally asserting pre-5.6 behavior regarding
leading white space on right-hand stamps that exist on their own line.
(erc-timestamp-use-align-to--nil, erc-timestamp-use-align-to--t):
Parameterize with compatibility flag.
(erc-timestamp-use-align-to--margin,
erc-stamp--display-margin-mode--right): Rename test to latter.
* test/lisp/erc/erc-tests.el (erc-hide-prompt): Add some assertions
for new possible value of `erc-prompt' text property.
* test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: New test
data file. (Bug#60936)
2023-07-14 06:12:30 -07:00
|
|
|
(ert-deftest erc-fill--left-hand-stamps ()
|
2023-12-23 15:23:44 -08:00
|
|
|
:tags `(:unstable
|
|
|
|
,@(and (getenv "ERC_TESTS_GRAPHICAL") '(:erc--graphical)))
|
Make erc-fill-wrap work with left-sided stamps
* etc/ERC-NEWS: Remove all mention of option `erc-timestamp-align-to'
supporting a value of `margin', which has been abandoned. Do mention
leading white space before stamps now having stamp-related properties.
* lisp/erc/erc-backend.el (erc--reveal-prompt, erc--conceal-prompt):
New generic functions with default implementations factored out from
`erc--unhide-prompt' and `erc--hide-prompt'.
(erc--prompt-hidden-p): New internal predicate function.
(erc--unhide-prompt): Defer to `erc--reveal-prompt', and set
`erc-prompt' text property to t.
(erc--hide-prompt): Defer to `erc--conceal-prompt', and set
`erc-prompt' text property to `hidden'.
* lisp/erc/erc-compat.el (erc-compat--29-browse-url-irc): Don't
use `function-equal'.
* lisp/erc/erc-fill.el (erc-fill-wrap-margin-width,
erc-fill-wrap-margin-side): New options to control side and initial
width of `fill-wrap' margin.
(erc-fill--wrap-beginning-of-line): Fix bug involving non-string
valued `display' props.
(erc-fill-wrap-toggle-truncate-lines): New command to re-enable
`visual-line-mode' when toggling off `truncate-lines'.
(erc-fill-wrap-mode-map): Remap `toggle-truncate-lines' to
`erc-fill-wrap-toggle-truncate-lines'.
(erc-fill-wrap-mode, erc-fill-wrap-enable, erc-fill-wrap-disable):
Update doc string, persist a few local vars, and conditionally set
`erc-stamp--margin-left-p'. When deactivating, disable
`visual-line-mode' first.
(erc-fill--wrap-continued-message-p): Use `erc-speaker' instead of
heuristics when comparing nicks between consecutive messages.
(erc-fill-wrap-nudge): Update doc string and account for left-sided
stamps.
(erc-timestamp-offset): Add comment regarding conditional guard based
on function-valued option.
* lisp/erc/erc-stamp.el (erc-timestamp-use-align-to): Remove value
variant `margin', which was originally intended to be new in ERC 5.6.
This functionality was all but useless without the internal minor mode
`erc-stamp--display-margin-mode' active.
(erc-stamp-right-margin-width): Remove unused option new in 5.6.
(erc-stamp--display-margin-force): Remove unused function.
(erc-stamp--margin-width, erc-stamp--margin-left-p): New internal
variables.
(erc-stamp--init-margins-on-connect): New function for initializing
mode-managed margin after connecting.
(erc-stamp--adjust-right-margin, erc-stamp--adjust-margin): Rename
function to latter and accommodate left-hand stamps.
(erc-stamp--inherited-props): Move definition higher up in same file.
(erc-stamp--display-margin-mode): Update function name, and adjust
setup and teardown to accommodate left-handed stamps. Don't add
advice around `erc-insert-timestamp-function'.
(erc-stamp--last-prompt, erc-stamp--display-prompt-in-left-margin):
New function and helper var to convert a normal inserted prompt so
that it appears in the left margin.
(erc-stamp--refresh-left-margin-prompt): Helper for other modules to
quickly refresh prompt outside of insert hooks.
(erc--reveal-prompt, erc--conceal-prompt): New implementations for
when `erc-stamp--display-margin-mode' is active.
(erc-insert-timestamp-left): Convert to generic function and provide
implementation for `erc-stamp--display-margin-mode'.
(erc-stamp--omit-properties-on-folded-lines): New variable, an escape
hatch for propertizing white space before right-side stamps folded
over onto another line.
(erc-insert-timestamp-right): Don't expect `erc-timestamp-align-to' to
ever be the symbol `margin'. Move handling for that case to one
contingent on the internal minor mode `erc-stamp--display-margin-mode'
being active. Add text properties preceding stamps that occupy a line
by their lonesome. See related news entry for rationale. This is
arguably a breaking change.
* lisp/erc/erc.el (erc--refresh-prompt-hook): New hook variable for
modules to adjust prompt properties whenever it's refreshed.
(erc--refresh-prompt): Fix bug in which user-defined prompt functions
failed to hide when quitting in server buffers. Run new hook
`erc--refresh-prompt-hook'.
(erc-display-prompt): Add comment noting that the text property
`erc-prompt' now actually matters: it's t while a session is running
and `hidden' when disconnected.
* test/lisp/erc/erc-fill-tests.el (erc-fill--left-hand-stamps): New
test.
* test/lisp/erc/erc-stamp-tests.el
(erc-stamp-tests--use-align-to--nil,
erc-stamp-tests--use-align-to--t): New functions forged from old test
bodies to allow optionally asserting pre-5.6 behavior regarding
leading white space on right-hand stamps that exist on their own line.
(erc-timestamp-use-align-to--nil, erc-timestamp-use-align-to--t):
Parameterize with compatibility flag.
(erc-timestamp-use-align-to--margin,
erc-stamp--display-margin-mode--right): Rename test to latter.
* test/lisp/erc/erc-tests.el (erc-hide-prompt): Add some assertions
for new possible value of `erc-prompt' text property.
* test/lisp/erc/resources/fill/snapshots/stamps-left-01.eld: New test
data file. (Bug#60936)
2023-07-14 06:12:30 -07:00
|
|
|
(unless (>= emacs-major-version 29)
|
|
|
|
(ert-skip "Emacs version too low, missing `buffer-text-pixel-size'"))
|
|
|
|
|
|
|
|
(let ((erc-timestamp-only-if-changed-flag nil)
|
|
|
|
(erc-insert-timestamp-function #'erc-insert-timestamp-left))
|
|
|
|
(erc-fill-tests--wrap-populate
|
|
|
|
(lambda ()
|
|
|
|
(should (= 8 left-margin-width))
|
|
|
|
(pcase-let ((`((margin left-margin) ,displayed)
|
|
|
|
(get-text-property erc-insert-marker 'display)))
|
|
|
|
(should (equal-including-properties
|
|
|
|
displayed #(" ERC>" 4 8
|
|
|
|
( read-only t
|
|
|
|
front-sticky t
|
|
|
|
field erc-prompt
|
|
|
|
erc-prompt t
|
|
|
|
rear-nonsticky t
|
|
|
|
font-lock-face erc-prompt-face)))))
|
|
|
|
(erc-fill-tests--compare "stamps-left-01")
|
|
|
|
|
|
|
|
(ert-info ("Shrink left margin by 1 col")
|
|
|
|
(erc-stamp--adjust-margin -1)
|
|
|
|
(with-silent-modifications (erc--refresh-prompt))
|
|
|
|
(should (= 7 left-margin-width))
|
|
|
|
(pcase-let ((`((margin left-margin) ,displayed)
|
|
|
|
(get-text-property erc-insert-marker 'display)))
|
|
|
|
(should (equal-including-properties
|
|
|
|
displayed #(" ERC>" 3 7
|
|
|
|
( read-only t
|
|
|
|
front-sticky t
|
|
|
|
field erc-prompt
|
|
|
|
erc-prompt t
|
|
|
|
rear-nonsticky t
|
|
|
|
font-lock-face erc-prompt-face))))))))))
|
|
|
|
|
2024-04-12 00:04:50 -07:00
|
|
|
(ert-deftest erc-fill--wrap-massage-legacy-indicator-type ()
|
|
|
|
(let (calls
|
|
|
|
erc-fill-wrap-merge-indicator)
|
|
|
|
(cl-letf (((symbol-function 'erc--warn-once-before-connect)
|
|
|
|
(lambda (_ &rest args) (push args calls))))
|
|
|
|
;; List of (pre CHAR FACE) becomes (CHAR . FACE).
|
|
|
|
(let ((erc-fill-wrap-merge-indicator
|
|
|
|
'(pre #xb7 erc-fill-wrap-merge-indicator-face)))
|
|
|
|
(erc-fill--wrap-massage-legacy-indicator-type)
|
|
|
|
(should (equal erc-fill-wrap-merge-indicator
|
|
|
|
'(#xb7 . erc-fill-wrap-merge-indicator-face)))
|
|
|
|
(should (string-search "(pre CHAR FACE)" (nth 1 (pop calls)))))
|
|
|
|
|
|
|
|
;; Cons of (CHAR . STRING) becomes STRING.
|
|
|
|
(let ((erc-fill-wrap-merge-indicator '(pre . "\u00b7")))
|
|
|
|
(erc-fill--wrap-massage-legacy-indicator-type)
|
|
|
|
(should (equal erc-fill-wrap-merge-indicator "\u00b7"))
|
|
|
|
(should (string-search "(pre . STRING)" (nth 1 (pop calls)))))
|
|
|
|
|
|
|
|
;; Anything with a CAR of `post' becomes nil.
|
|
|
|
(let ((erc-fill-wrap-merge-indicator
|
|
|
|
'(post #xb6 erc-fill-wrap-merge-indicator-face)))
|
|
|
|
(erc-fill--wrap-massage-legacy-indicator-type)
|
|
|
|
(should-not erc-fill-wrap-merge-indicator)
|
|
|
|
(should (string-search "no longer available" (nth 1 (pop calls)))))
|
|
|
|
(let ((erc-fill-wrap-merge-indicator '(post . "\u00b7")))
|
|
|
|
(erc-fill--wrap-massage-legacy-indicator-type)
|
|
|
|
(should-not erc-fill-wrap-merge-indicator)
|
|
|
|
(should (string-search "no longer available" (nth 1 (pop calls))))))))
|
|
|
|
|
2023-01-13 00:00:56 -08:00
|
|
|
;;; erc-fill-tests.el ends here
|