diff options
| author | F. Jason Park | 2023-09-02 13:43:22 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-10-27 13:09:29 -0700 |
| commit | 9acd8c8e530dda326ae5bf852c2437fdcde4e8cc (patch) | |
| tree | e20478f3f0a2c638505b010b3252cbb2f82bcdd3 /test | |
| parent | 5c4a9b73031f1607e4f793c5c0ef27004cc258db (diff) | |
| download | emacs-9acd8c8e530dda326ae5bf852c2437fdcde4e8cc.tar.gz emacs-9acd8c8e530dda326ae5bf852c2437fdcde4e8cc.zip | |
Tidy up ERC's internal text-property API
* lisp/erc/erc-fill.el (erc-fill--spaced-commands): Remove unused
internal variable originally intended for ERC 5.6.
(erc-fill): Check for `erc-msg' being `msg', which carries the same
meaning as `erc-cmd' being `PRIVMSG' or `NOTICE', except that inserted
outgoing messages now no longer normally have an `erc-cmd' property.
(erc-fill-wrap-mode, erc-fill-wrap-disable): Kill
`erc-fill--wrap-last-msg'.
(erc-fill--wrap-max-lull): Convert from buffer-local to normal
variable.
(erc-fill--wrap-continued-message-p): Rework slightly to guard against
resetting the "last speaker" marker when the `erc-ephemeral' text
property is present. This tells insert- and send-related hook members
to pretend the current message doesn't exist when performing stateful
operations. That is, modules should expect the message being inserted
to possibly disappear or be replaced. Also, look for `erc-msg' being
`msg' instead of `erc-cmd' being `PRIVMSG', and fix bug involving only
checking `erc-ctcp' in the current message.
* lisp/erc/erc-stamp.el (erc-add-timestamp): Don't insert timestamps
when the `erc-ephemeral' text property is present.
* lisp/erc/erc.el (erc--msg-props): Add doc string explaining the
purpose of this variable and the various text properties most commonly
present in its value.
(erc--msg-prop-overrides): Add doc string.
(erc-send-action): Don't set `erc-cmd' prop on outgoing CTCP ACTIONs.
(erc-display-message): Reverse overrides to prefer items toward the
front of the alist.
(erc-process-ctcp-query): Include existing overrides from environs.
(erc-send-current-line): Include existing overrides from environs.
(erc-display-msg): Fix doc string and reverse overrides.
* test/lisp/erc/erc-fill-tests.el (erc-fill-tests--insert-privmsg):
Remove stray comment.
(erc-fill-tests--save-p): Set value from environment variable.
(erc-fill-tests--compare): Limit writing snapshots to one test at a
time.
(erc-fill-wrap--merge-action): Fix expected output for non-action
messages that follow action messages. These were previously merged
but escaped detection.
* test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld: Update.
(Bug#60936)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-fill-tests.el | 23 | ||||
| -rw-r--r-- | test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld | 2 |
2 files changed, 16 insertions, 9 deletions
diff --git a/test/lisp/erc/erc-fill-tests.el b/test/lisp/erc/erc-fill-tests.el index 80f5fd22ac6..92424d1e556 100644 --- a/test/lisp/erc/erc-fill-tests.el +++ b/test/lisp/erc/erc-fill-tests.el | |||
| @@ -33,7 +33,6 @@ | |||
| 33 | (declare (indent 1)) | 33 | (declare (indent 1)) |
| 34 | (let* ((msg (erc-format-privmessage speaker | 34 | (let* ((msg (erc-format-privmessage speaker |
| 35 | (apply #'concat msg-parts) nil t)) | 35 | (apply #'concat msg-parts) nil t)) |
| 36 | ;; (erc--msg-prop-overrides '((erc-msg . msg) (erc-cmd . PRIVMSG))) | ||
| 37 | (parsed (make-erc-response :unparsed msg :sender speaker | 36 | (parsed (make-erc-response :unparsed msg :sender speaker |
| 38 | :command "PRIVMSG" | 37 | :command "PRIVMSG" |
| 39 | :command-args (list "#chan" msg) | 38 | :command-args (list "#chan" msg) |
| @@ -129,10 +128,10 @@ | |||
| 129 | (should (equal (get-text-property (1- (pos-eol)) 'wrap-prefix) | 128 | (should (equal (get-text-property (1- (pos-eol)) 'wrap-prefix) |
| 130 | '(space :width erc-fill--wrap-value)))))) | 129 | '(space :width erc-fill--wrap-value)))))) |
| 131 | 130 | ||
| 132 | ;; Set this variable to t to generate new snapshots after carefully | 131 | ;; Use this variable to generate new snapshots after carefully |
| 133 | ;; reviewing the output of *each* snapshot (not just first and last). | 132 | ;; reviewing the output of *each* snapshot (not just first and last). |
| 134 | ;; Obviously, only run one test at a time. | 133 | ;; Obviously, only run one test at a time. |
| 135 | (defvar erc-fill-tests--save-p nil) | 134 | (defvar erc-fill-tests--save-p (getenv "ERC_TESTS_FILL_SAVE")) |
| 136 | 135 | ||
| 137 | ;; On graphical displays, echo .graphic >> .git/info/exclude | 136 | ;; On graphical displays, echo .graphic >> .git/info/exclude |
| 138 | (defvar erc-fill-tests--graphic-dir "fill/snapshots/.graphic") | 137 | (defvar erc-fill-tests--graphic-dir "fill/snapshots/.graphic") |
| @@ -162,8 +161,12 @@ | |||
| 162 | (insert (setq got (read repr)))) | 161 | (insert (setq got (read repr)))) |
| 163 | (erc-mode)) | 162 | (erc-mode)) |
| 164 | (if erc-fill-tests--save-p | 163 | (if erc-fill-tests--save-p |
| 165 | (with-temp-file expect-file | 164 | (let (inhibit-message) |
| 166 | (insert repr)) | 165 | (with-temp-file expect-file |
| 166 | (insert repr)) | ||
| 167 | ;; Limit writing snapshots to one test at a time. | ||
| 168 | (setq erc-fill-tests--save-p nil) | ||
| 169 | (message "erc-fill-tests--compare: wrote %S" expect-file)) | ||
| 167 | (if (file-exists-p expect-file) | 170 | (if (file-exists-p expect-file) |
| 168 | ;; Ensure string-valued properties, like timestamps, aren't | 171 | ;; Ensure string-valued properties, like timestamps, aren't |
| 169 | ;; recursive (signals `max-lisp-eval-depth' exceeded). | 172 | ;; recursive (signals `max-lisp-eval-depth' exceeded). |
| @@ -297,16 +300,20 @@ | |||
| 297 | ;; Set this here so that the first few messages are from 1970 | 300 | ;; Set this here so that the first few messages are from 1970 |
| 298 | (let ((erc-fill-tests--time-vals (lambda () 1680332400))) | 301 | (let ((erc-fill-tests--time-vals (lambda () 1680332400))) |
| 299 | (erc-fill-tests--insert-privmsg "bob" "zero.") | 302 | (erc-fill-tests--insert-privmsg "bob" "zero.") |
| 303 | (erc-fill-tests--insert-privmsg "bob" "0.5") | ||
| 300 | 304 | ||
| 301 | (erc-process-ctcp-query | 305 | (erc-process-ctcp-query |
| 302 | erc-server-process | 306 | erc-server-process |
| 303 | (make-erc-response | 307 | (make-erc-response |
| 304 | :unparsed ":bob!~u@fake PRIVMSG #chan :\1ACTION one\1" | 308 | :unparsed ":bob!~u@fake PRIVMSG #chan :\1ACTION one.\1" |
| 305 | :sender "bob!~u@fake" :command "PRIVMSG" | 309 | :sender "bob!~u@fake" |
| 306 | :command-args '("#chan" "\1ACTION one\1") :contents "\1ACTION one\1") | 310 | :command "PRIVMSG" |
| 311 | :command-args '("#chan" "\1ACTION one.\1") | ||
| 312 | :contents "\1ACTION one.\1") | ||
| 307 | "bob" "~u" "fake") | 313 | "bob" "~u" "fake") |
| 308 | 314 | ||
| 309 | (erc-fill-tests--insert-privmsg "bob" "two.") | 315 | (erc-fill-tests--insert-privmsg "bob" "two.") |
| 316 | (erc-fill-tests--insert-privmsg "bob" "2.5") | ||
| 310 | 317 | ||
| 311 | ;; Compat switch to opt out of overhanging speaker. | 318 | ;; Compat switch to opt out of overhanging speaker. |
| 312 | (let (erc-fill--wrap-action-dedent-p) | 319 | (let (erc-fill--wrap-action-dedent-p) |
diff --git a/test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld b/test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld index 82c6d52cf7c..f966daeed1f 100644 --- a/test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld +++ b/test/lisp/erc/resources/fill/snapshots/merge-wrap-01.eld | |||
| @@ -1 +1 @@ | |||
| #("\n\n\n[Thu Jan 1 1970]\n*** 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.[00:00]\n<alice> bob: come, you are a tedious fool: to the purpose. What was done to Elbow's wife, that he hath cause to complain of? Come me to what was done to her.\n<bob> alice: Either your unparagoned mistress is dead, or she's outprized by a trifle.\n\n[Sat Apr 1 2023]\n<bob> zero.[07:00]\n* bob one\n<bob> two.\n* bob three\n<bob> four.\n" 2 3 (erc-msg datestamp erc-ts 0 field erc-timestamp) 3 20 (field erc-timestamp wrap-prefix #1=(space :width 27) line-prefix (space :width (- 27 (18)))) 21 22 (erc-msg notice erc-ts 0 wrap-prefix #1# line-prefix #2=(space :width (- 27 (4)))) 22 183 (wrap-prefix #1# line-prefix #2#) 183 190 (field erc-timestamp wrap-prefix #1# line-prefix #2# display (#6=(margin right-margin) #("[00:00]" 0 7 (invisible timestamp)))) 191 192 (erc-msg msg erc-ts 0 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #3=(space :width (- 27 (8)))) 192 197 (wrap-prefix #1# line-prefix #3#) 197 199 (wrap-prefix #1# line-prefix #3#) 199 202 (wrap-prefix #1# line-prefix #3#) 202 315 (wrap-prefix #1# line-prefix #3#) 316 348 (wrap-prefix #1# line-prefix #3#) 349 350 (erc-msg msg erc-ts 0 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #4=(space :width (- 27 (6)))) 350 353 (wrap-prefix #1# line-prefix #4#) 353 355 (wrap-prefix #1# line-prefix #4#) 355 360 (wrap-prefix #1# line-prefix #4#) 360 435 (wrap-prefix #1# line-prefix #4#) 436 437 (erc-msg datestamp erc-ts 1680332400 field erc-timestamp) 437 454 (field erc-timestamp wrap-prefix #1# line-prefix (space :width (- 27 (18)))) 455 456 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #5=(space :width (- 27 (6)))) 456 459 (wrap-prefix #1# line-prefix #5#) 459 466 (wrap-prefix #1# line-prefix #5#) 466 473 (field erc-timestamp wrap-prefix #1# line-prefix #5# display (#6# #("[07:00]" 0 7 (invisible timestamp)))) 474 475 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG erc-ctcp ACTION wrap-prefix #1# line-prefix #7=(space :width (- 27 (6)))) 475 476 (wrap-prefix #1# line-prefix #7#) 476 479 (wrap-prefix #1# line-prefix #7#) 479 483 (wrap-prefix #1# line-prefix #7#) 484 485 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #8=(space :width (- 27 0)) display #9="") 485 488 (wrap-prefix #1# line-prefix #8# display #9#) 488 490 (wrap-prefix #1# line-prefix #8# display #9#) 490 494 (wrap-prefix #1# line-prefix #8#) 495 496 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG erc-ctcp ACTION wrap-prefix #1# line-prefix #10=(space :width (- 27 (2)))) 496 497 (wrap-prefix #1# line-prefix #10#) 497 500 (wrap-prefix #1# line-prefix #10#) 500 506 (wrap-prefix #1# line-prefix #10#) 507 508 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #11=(space :width (- 27 0)) display #9#) 508 511 (wrap-prefix #1# line-prefix #11# display #9#) 511 513 (wrap-prefix #1# line-prefix #11# display #9#) 513 518 (wrap-prefix #1# line-prefix #11#)) | #("\n\n\n[Thu Jan 1 1970]\n*** 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.[00:00]\n<alice> bob: come, you are a tedious fool: to the purpose. What was done to Elbow's wife, that he hath cause to complain of? Come me to what was done to her.\n<bob> alice: Either your unparagoned mistress is dead, or she's outprized by a trifle.\n\n[Sat Apr 1 2023]\n<bob> zero.[07:00]\n<bob> 0.5\n* bob one.\n<bob> two.\n<bob> 2.5\n* bob three\n<bob> four.\n" 2 3 (erc-msg datestamp erc-ts 0 field erc-timestamp) 3 20 (field erc-timestamp wrap-prefix #1=(space :width 27) line-prefix (space :width (- 27 (18)))) 21 22 (erc-msg notice erc-ts 0 wrap-prefix #1# line-prefix #2=(space :width (- 27 (4)))) 22 183 (wrap-prefix #1# line-prefix #2#) 183 190 (field erc-timestamp wrap-prefix #1# line-prefix #2# display (#5=(margin right-margin) #("[00:00]" 0 7 (invisible timestamp)))) 191 192 (erc-msg msg erc-ts 0 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #3=(space :width (- 27 (8)))) 192 197 (wrap-prefix #1# line-prefix #3#) 197 199 (wrap-prefix #1# line-prefix #3#) 199 202 (wrap-prefix #1# line-prefix #3#) 202 315 (wrap-prefix #1# line-prefix #3#) 316 348 (wrap-prefix #1# line-prefix #3#) 349 350 (erc-msg msg erc-ts 0 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #4=(space :width (- 27 (6)))) 350 353 (wrap-prefix #1# line-prefix #4#) 353 355 (wrap-prefix #1# line-prefix #4#) 355 360 (wrap-prefix #1# line-prefix #4#) 360 435 (wrap-prefix #1# line-prefix #4#) 436 437 (erc-msg datestamp erc-ts 1680332400 field erc-timestamp) 437 454 (field erc-timestamp wrap-prefix #1# line-prefix (space :width (- 27 (18)))) 455 456 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #6=(space :width (- 27 (6)))) 456 459 (wrap-prefix #1# line-prefix #6#) 459 466 (wrap-prefix #1# line-prefix #6#) 466 473 (field erc-timestamp wrap-prefix #1# line-prefix #6# display (#5# #("[07:00]" 0 7 (invisible timestamp)))) 474 475 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #7=(space :width (- 27 0)) display #8="") 475 478 (wrap-prefix #1# line-prefix #7# display #8#) 478 480 (wrap-prefix #1# line-prefix #7# display #8#) 480 483 (wrap-prefix #1# line-prefix #7#) 484 485 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG erc-ctcp ACTION wrap-prefix #1# line-prefix #9=(space :width (- 27 (6)))) 485 486 (wrap-prefix #1# line-prefix #9#) 486 489 (wrap-prefix #1# line-prefix #9#) 489 494 (wrap-prefix #1# line-prefix #9#) 495 496 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #10=(space :width (- 27 (6)))) 496 499 (wrap-prefix #1# line-prefix #10#) 499 505 (wrap-prefix #1# line-prefix #10#) 506 507 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #11=(space :width (- 27 0)) display #8#) 507 510 (wrap-prefix #1# line-prefix #11# display #8#) 510 512 (wrap-prefix #1# line-prefix #11# display #8#) 512 515 (wrap-prefix #1# line-prefix #11#) 516 517 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG erc-ctcp ACTION wrap-prefix #1# line-prefix #12=(space :width (- 27 (2)))) 517 518 (wrap-prefix #1# line-prefix #12#) 518 521 (wrap-prefix #1# line-prefix #12#) 521 527 (wrap-prefix #1# line-prefix #12#) 528 529 (erc-msg msg erc-ts 1680332400 erc-cmd PRIVMSG wrap-prefix #1# line-prefix #13=(space :width (- 27 (6)))) 529 532 (wrap-prefix #1# line-prefix #13#) 532 539 (wrap-prefix #1# line-prefix #13#)) \ No newline at end of file | ||