diff options
| author | F. Jason Park | 2023-06-10 00:17:44 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-06-11 20:14:08 -0700 |
| commit | 2daa71f93294240f899fa94e3f7a87900bd64e3f (patch) | |
| tree | 7a1c59630cbd40e45569eca30e42ebba84f1dddd /test | |
| parent | d880a08f9592e51ada5749d10b472396683fb6ee (diff) | |
| download | emacs-2daa71f93294240f899fa94e3f7a87900bd64e3f.tar.gz emacs-2daa71f93294240f899fa94e3f7a87900bd64e3f.zip | |
Don't insert prompt input before markers in ERC
* etc/ERC-NEWS: Update entry in 5.6 section announcing a persistent
prompt.
* lisp/erc/erc-dcc.el (erc-dcc-chat-setup): Use helper
`erc--initialize-markers' to set up prompt.
* lisp/erc/erc.el (erc--initialize-markers): Change
`erc-insert-marker' type to t. Do this to spare modules that want to
remember the current message location from resorting to workarounds,
like leaving a marker one char before the end of a message, which is
not foolproof.
(erc--refresh-prompt): Temporarily change type of `erc-insert-marker'
when inserting prompt.
(erc-display-line-1): Insert incoming message normally instead of
forcing before markers, thus respecting markers left by third parties.
Strictly speaking, this is a breaking change.
(erc-display-msg): Insert normally instead of calling
`insert-before-markers', which was a regression introduced by 05f6fdb9
"Preserve ERC prompt and its bounding markers".
* test/lisp/erc/erc-dcc-tests.el
(erc-dcc-tests--dcc-handle-ctcp-send,
erc-dcc-tests--erc-dcc-do-GET-command): Use helper to initialize
prompt and markers.
* test/lisp/erc/erc-networks-tests.el
(erc-networks--ensure-announced,
erc-networks--rename-server-buffer--existing--reuse,
erc-networks--rename-server-buffer--existing--noreuse,
erc-networks--rename-server-buffer--reconnecting,
erc-networks--rename-server-buffer--id,
erc-networks--rename-server-buffer--existing--live,
erc-networks--rename-server-buffer--local-match,
erc-networks--rename-server-buffer--local-nomatch): Use helper to
initialize prompt and bounding markers.
* test/lisp/erc/erc-stamp-tests.el (erc-stamp-tests--insert-right):
Use `erc--initialize-markers' for setting up prompt.
* test/lisp/erc/erc-tests.el (erc--refresh-prompt): Adjust assertions
for expected prompt content. (Bug#60936)
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/erc/erc-dcc-tests.el | 10 | ||||
| -rw-r--r-- | test/lisp/erc/erc-networks-tests.el | 24 | ||||
| -rw-r--r-- | test/lisp/erc/erc-stamp-tests.el | 7 | ||||
| -rw-r--r-- | test/lisp/erc/erc-tests.el | 47 |
4 files changed, 39 insertions, 49 deletions
diff --git a/test/lisp/erc/erc-dcc-tests.el b/test/lisp/erc/erc-dcc-tests.el index 7fb5f82e784..f02ddf228a2 100644 --- a/test/lisp/erc/erc-dcc-tests.el +++ b/test/lisp/erc/erc-dcc-tests.el | |||
| @@ -57,11 +57,8 @@ | |||
| 57 | (erc-mode) | 57 | (erc-mode) |
| 58 | (setq erc-server-process | 58 | (setq erc-server-process |
| 59 | (start-process "fake" (current-buffer) "sleep" "10") | 59 | (start-process "fake" (current-buffer) "sleep" "10") |
| 60 | erc-input-marker (make-marker) | ||
| 61 | erc-insert-marker (make-marker) | ||
| 62 | erc-server-current-nick "dummy") | 60 | erc-server-current-nick "dummy") |
| 63 | (erc-display-prompt) | 61 | (erc--initialize-markers (point) nil) |
| 64 | (set-marker erc-insert-marker (pos-bol)) | ||
| 65 | (set-process-query-on-exit-flag erc-server-process nil) | 62 | (set-process-query-on-exit-flag erc-server-process nil) |
| 66 | (should-not erc-dcc-list) | 63 | (should-not erc-dcc-list) |
| 67 | (erc-ctcp-query-DCC erc-server-process | 64 | (erc-ctcp-query-DCC erc-server-process |
| @@ -121,17 +118,14 @@ | |||
| 121 | calls) | 118 | calls) |
| 122 | (erc-mode) | 119 | (erc-mode) |
| 123 | (setq erc-server-process proc | 120 | (setq erc-server-process proc |
| 124 | erc-input-marker (make-marker) | ||
| 125 | erc-insert-marker (make-marker) | ||
| 126 | erc-server-current-nick "dummy") | 121 | erc-server-current-nick "dummy") |
| 122 | (erc--initialize-markers (point) nil) | ||
| 127 | (set-process-query-on-exit-flag proc nil) | 123 | (set-process-query-on-exit-flag proc nil) |
| 128 | (cl-letf (((symbol-function 'read-file-name) | 124 | (cl-letf (((symbol-function 'read-file-name) |
| 129 | (lambda (&rest _) file)) | 125 | (lambda (&rest _) file)) |
| 130 | ((symbol-function 'erc-dcc-get-file) | 126 | ((symbol-function 'erc-dcc-get-file) |
| 131 | (lambda (&rest r) (push r calls)))) | 127 | (lambda (&rest r) (push r calls)))) |
| 132 | (goto-char (point-max)) | 128 | (goto-char (point-max)) |
| 133 | (set-marker erc-insert-marker (point-max)) | ||
| 134 | (erc-display-prompt) | ||
| 135 | 129 | ||
| 136 | (ert-info ("No turbo") | 130 | (ert-info ("No turbo") |
| 137 | (should-not (plist-member elt :turbo)) | 131 | (should-not (plist-member elt :turbo)) |
diff --git a/test/lisp/erc/erc-networks-tests.el b/test/lisp/erc/erc-networks-tests.el index b9d216f217b..f0fcbbc81c6 100644 --- a/test/lisp/erc/erc-networks-tests.el +++ b/test/lisp/erc/erc-networks-tests.el | |||
| @@ -1233,10 +1233,7 @@ | |||
| 1233 | :contents "MOTD File is missing"))) | 1233 | :contents "MOTD File is missing"))) |
| 1234 | 1234 | ||
| 1235 | (erc-mode) ; boilerplate displayable start (needs `erc-server-process') | 1235 | (erc-mode) ; boilerplate displayable start (needs `erc-server-process') |
| 1236 | (insert "\n\n") | 1236 | (erc--initialize-markers (point) nil) |
| 1237 | (setq erc-input-marker (make-marker) erc-insert-marker (make-marker)) | ||
| 1238 | (set-marker erc-insert-marker (point-max)) | ||
| 1239 | (erc-display-prompt) ; boilerplate displayable end | ||
| 1240 | 1237 | ||
| 1241 | (erc-networks--ensure-announced erc-server-process parsed) | 1238 | (erc-networks--ensure-announced erc-server-process parsed) |
| 1242 | (goto-char (point-min)) | 1239 | (goto-char (point-min)) |
| @@ -1277,9 +1274,9 @@ | |||
| 1277 | (with-current-buffer old-buf | 1274 | (with-current-buffer old-buf |
| 1278 | (erc-mode) | 1275 | (erc-mode) |
| 1279 | (insert "*** Old buf") | 1276 | (insert "*** Old buf") |
| 1277 | (erc--initialize-markers (point) nil) | ||
| 1280 | (setq erc-network 'FooNet | 1278 | (setq erc-network 'FooNet |
| 1281 | erc-server-current-nick "tester" | 1279 | erc-server-current-nick "tester" |
| 1282 | erc-insert-marker (set-marker (make-marker) (point-max)) | ||
| 1283 | erc-server-process old-proc | 1280 | erc-server-process old-proc |
| 1284 | erc-networks--id (erc-networks--id-create nil))) | 1281 | erc-networks--id (erc-networks--id-create nil))) |
| 1285 | 1282 | ||
| @@ -1328,10 +1325,10 @@ | |||
| 1328 | erc-reuse-buffers) | 1325 | erc-reuse-buffers) |
| 1329 | (with-current-buffer old-buf | 1326 | (with-current-buffer old-buf |
| 1330 | (erc-mode) | 1327 | (erc-mode) |
| 1328 | (erc--initialize-markers (point) nil) | ||
| 1331 | (insert "*** Old buf") | 1329 | (insert "*** Old buf") |
| 1332 | (setq erc-network 'FooNet | 1330 | (setq erc-network 'FooNet |
| 1333 | erc-server-current-nick "tester" | 1331 | erc-server-current-nick "tester" |
| 1334 | erc-insert-marker (set-marker (make-marker) (point-max)) | ||
| 1335 | erc-server-process old-proc | 1332 | erc-server-process old-proc |
| 1336 | erc-networks--id (erc-networks--id-create nil))) | 1333 | erc-networks--id (erc-networks--id-create nil))) |
| 1337 | (with-current-buffer (get-buffer-create "#chan") | 1334 | (with-current-buffer (get-buffer-create "#chan") |
| @@ -1377,10 +1374,10 @@ | |||
| 1377 | 1374 | ||
| 1378 | (with-current-buffer old-buf | 1375 | (with-current-buffer old-buf |
| 1379 | (erc-mode) | 1376 | (erc-mode) |
| 1377 | (erc--initialize-markers (point) nil) | ||
| 1380 | (insert "*** Old buf") | 1378 | (insert "*** Old buf") |
| 1381 | (setq erc-network 'FooNet | 1379 | (setq erc-network 'FooNet |
| 1382 | erc-server-current-nick "tester" | 1380 | erc-server-current-nick "tester" |
| 1383 | erc-insert-marker (set-marker (make-marker) (point-max)) | ||
| 1384 | erc-server-process old-proc | 1381 | erc-server-process old-proc |
| 1385 | erc-networks--id (erc-networks--id-create nil))) | 1382 | erc-networks--id (erc-networks--id-create nil))) |
| 1386 | 1383 | ||
| @@ -1415,10 +1412,10 @@ | |||
| 1415 | 1412 | ||
| 1416 | (with-current-buffer old-buf | 1413 | (with-current-buffer old-buf |
| 1417 | (erc-mode) | 1414 | (erc-mode) |
| 1415 | (erc--initialize-markers (point) nil) | ||
| 1418 | (insert "*** Old buf") | 1416 | (insert "*** Old buf") |
| 1419 | (setq erc-network 'FooNet | 1417 | (setq erc-network 'FooNet |
| 1420 | erc-networks--id (erc-networks--id-create 'MySession) | 1418 | erc-networks--id (erc-networks--id-create 'MySession) |
| 1421 | erc-insert-marker (set-marker (make-marker) (point-max)) | ||
| 1422 | erc-server-process old-proc)) | 1419 | erc-server-process old-proc)) |
| 1423 | 1420 | ||
| 1424 | (with-current-buffer (get-buffer-create "#chan") | 1421 | (with-current-buffer (get-buffer-create "#chan") |
| @@ -1454,10 +1451,10 @@ | |||
| 1454 | 1451 | ||
| 1455 | (with-current-buffer old-buf | 1452 | (with-current-buffer old-buf |
| 1456 | (erc-mode) | 1453 | (erc-mode) |
| 1454 | (erc--initialize-markers (point) nil) | ||
| 1457 | (insert "*** Old buf") | 1455 | (insert "*** Old buf") |
| 1458 | (setq erc-network 'FooNet | 1456 | (setq erc-network 'FooNet |
| 1459 | erc-server-current-nick "tester" | 1457 | erc-server-current-nick "tester" |
| 1460 | erc-insert-marker (set-marker (make-marker) (point-max)) | ||
| 1461 | erc-server-process old-proc | 1458 | erc-server-process old-proc |
| 1462 | erc-networks--id (erc-networks--id-create nil)) | 1459 | erc-networks--id (erc-networks--id-create nil)) |
| 1463 | (should (erc-server-process-alive))) | 1460 | (should (erc-server-process-alive))) |
| @@ -1473,15 +1470,12 @@ | |||
| 1473 | (ert-info ("New buffer rejected, abandoned, not killed") | 1470 | (ert-info ("New buffer rejected, abandoned, not killed") |
| 1474 | (with-current-buffer (get-buffer-create "irc.foonet.org") | 1471 | (with-current-buffer (get-buffer-create "irc.foonet.org") |
| 1475 | (erc-mode) | 1472 | (erc-mode) |
| 1473 | (erc--initialize-markers (point) nil) | ||
| 1476 | (setq erc-network 'FooNet | 1474 | (setq erc-network 'FooNet |
| 1477 | erc-server-current-nick "tester" | 1475 | erc-server-current-nick "tester" |
| 1478 | erc-insert-marker (make-marker) | ||
| 1479 | erc-input-marker (make-marker) | ||
| 1480 | erc-server-process (erc-networks-tests--create-live-proc) | 1476 | erc-server-process (erc-networks-tests--create-live-proc) |
| 1481 | erc-networks--id (erc-networks--id-create nil)) | 1477 | erc-networks--id (erc-networks--id-create nil)) |
| 1482 | (set-process-sentinel erc-server-process #'ignore) | 1478 | (set-process-sentinel erc-server-process #'ignore) |
| 1483 | (erc-display-prompt nil (point-max)) | ||
| 1484 | (set-marker erc-insert-marker (pos-bol)) | ||
| 1485 | (erc-display-message nil 'notice (current-buffer) "notice") | 1479 | (erc-display-message nil 'notice (current-buffer) "notice") |
| 1486 | (with-silent-modifications | 1480 | (with-silent-modifications |
| 1487 | (should-not (erc-networks--rename-server-buffer erc-server-process))) | 1481 | (should-not (erc-networks--rename-server-buffer erc-server-process))) |
| @@ -1514,10 +1508,10 @@ | |||
| 1514 | (with-current-buffer old-buf | 1508 | (with-current-buffer old-buf |
| 1515 | (erc-mode) | 1509 | (erc-mode) |
| 1516 | (insert "*** Old buf") | 1510 | (insert "*** Old buf") |
| 1511 | (erc--initialize-markers (point) nil) | ||
| 1517 | (setq erc-network 'FooNet | 1512 | (setq erc-network 'FooNet |
| 1518 | erc-server-current-nick "tester" | 1513 | erc-server-current-nick "tester" |
| 1519 | erc-server-announced-name "us-east.foonet.org" | 1514 | erc-server-announced-name "us-east.foonet.org" |
| 1520 | erc-insert-marker (set-marker (make-marker) (point-max)) | ||
| 1521 | erc-server-process old-proc | 1515 | erc-server-process old-proc |
| 1522 | erc--isupport-params (make-hash-table) | 1516 | erc--isupport-params (make-hash-table) |
| 1523 | erc-networks--id (erc-networks--id-create nil)) | 1517 | erc-networks--id (erc-networks--id-create nil)) |
| @@ -1566,10 +1560,10 @@ | |||
| 1566 | (with-current-buffer old-buf | 1560 | (with-current-buffer old-buf |
| 1567 | (erc-mode) | 1561 | (erc-mode) |
| 1568 | (insert "*** Old buf") | 1562 | (insert "*** Old buf") |
| 1563 | (erc--initialize-markers (point) nil) | ||
| 1569 | (setq erc-network 'FooNet | 1564 | (setq erc-network 'FooNet |
| 1570 | erc-server-current-nick "tester" | 1565 | erc-server-current-nick "tester" |
| 1571 | erc-server-announced-name "us-west.foonet.org" | 1566 | erc-server-announced-name "us-west.foonet.org" |
| 1572 | erc-insert-marker (set-marker (make-marker) (point-max)) | ||
| 1573 | erc-server-process old-proc | 1567 | erc-server-process old-proc |
| 1574 | erc--isupport-params (make-hash-table) | 1568 | erc--isupport-params (make-hash-table) |
| 1575 | erc-networks--id (erc-networks--id-create nil)) | 1569 | erc-networks--id (erc-networks--id-create nil)) |
diff --git a/test/lisp/erc/erc-stamp-tests.el b/test/lisp/erc/erc-stamp-tests.el index 01e71e348e0..6da7ed4503d 100644 --- a/test/lisp/erc/erc-stamp-tests.el +++ b/test/lisp/erc/erc-stamp-tests.el | |||
| @@ -43,13 +43,10 @@ | |||
| 43 | (with-current-buffer (get-buffer-create "*erc-stamp-tests--insert-right*") | 43 | (with-current-buffer (get-buffer-create "*erc-stamp-tests--insert-right*") |
| 44 | (erc-mode) | 44 | (erc-mode) |
| 45 | (erc-munge-invisibility-spec) | 45 | (erc-munge-invisibility-spec) |
| 46 | (erc--initialize-markers (point) nil) | ||
| 46 | (setq erc-server-process (start-process "p" (current-buffer) | 47 | (setq erc-server-process (start-process "p" (current-buffer) |
| 47 | "sleep" "1") | 48 | "sleep" "1")) |
| 48 | erc-input-marker (make-marker) | ||
| 49 | erc-insert-marker (make-marker)) | ||
| 50 | (set-process-query-on-exit-flag erc-server-process nil) | 49 | (set-process-query-on-exit-flag erc-server-process nil) |
| 51 | (set-marker erc-insert-marker (point-max)) | ||
| 52 | (erc-display-prompt) | ||
| 53 | 50 | ||
| 54 | (funcall test) | 51 | (funcall test) |
| 55 | 52 | ||
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el index 7d1e20132e1..f3489a16386 100644 --- a/test/lisp/erc/erc-tests.el +++ b/test/lisp/erc/erc-tests.el | |||
| @@ -294,16 +294,19 @@ | |||
| 294 | (set-process-query-on-exit-flag erc-server-process nil) | 294 | (set-process-query-on-exit-flag erc-server-process nil) |
| 295 | ;; Incoming message redraws prompt | 295 | ;; Incoming message redraws prompt |
| 296 | (erc-display-message nil 'notice nil "Welcome") | 296 | (erc-display-message nil 'notice nil "Welcome") |
| 297 | (should (looking-at-p (rx "*** Welcome"))) | ||
| 298 | (forward-line) | ||
| 297 | (should (looking-at-p "ServNet 4>")) | 299 | (should (looking-at-p "ServNet 4>")) |
| 298 | ;; Say something | 300 | ;; Say something |
| 299 | (save-excursion (goto-char erc-input-marker) | 301 | (goto-char erc-input-marker) |
| 300 | (insert "Howdy") | 302 | (insert "Howdy") |
| 301 | (erc-send-current-line) | 303 | (erc-send-current-line) |
| 302 | (forward-line -1) | 304 | (save-excursion (forward-line -1) |
| 303 | (should (looking-at "No target")) | 305 | (should (looking-at "No target")) |
| 304 | (forward-line -1) | 306 | (forward-line -1) |
| 305 | (should (looking-at "<tester> Howdy"))) | 307 | (should (looking-at "<tester> Howdy"))) |
| 306 | (should (looking-at-p "ServNet 6>")) | 308 | (should (looking-back "ServNet 6> ")) |
| 309 | (should (= erc-input-marker (point))) | ||
| 307 | ;; Space after prompt is unpropertized | 310 | ;; Space after prompt is unpropertized |
| 308 | (should (get-text-property (1- erc-input-marker) 'erc-prompt)) | 311 | (should (get-text-property (1- erc-input-marker) 'erc-prompt)) |
| 309 | (should-not (get-text-property erc-input-marker 'erc-prompt)) | 312 | (should-not (get-text-property erc-input-marker 'erc-prompt)) |
| @@ -317,6 +320,7 @@ | |||
| 317 | (erc-tests--send-prep) | 320 | (erc-tests--send-prep) |
| 318 | (goto-char erc-insert-marker) | 321 | (goto-char erc-insert-marker) |
| 319 | (should (looking-at-p "#chan 9>")) | 322 | (should (looking-at-p "#chan 9>")) |
| 323 | (goto-char erc-input-marker) | ||
| 320 | (setq erc-server-process (buffer-local-value 'erc-server-process | 324 | (setq erc-server-process (buffer-local-value 'erc-server-process |
| 321 | (get-buffer "ServNet")) | 325 | (get-buffer "ServNet")) |
| 322 | erc-networks--id (erc-with-server-buffer erc-networks--id) | 326 | erc-networks--id (erc-with-server-buffer erc-networks--id) |
| @@ -328,18 +332,18 @@ | |||
| 328 | (erc-update-current-channel-member "tester" "tester") | 332 | (erc-update-current-channel-member "tester" "tester") |
| 329 | (erc-display-message nil nil (current-buffer) | 333 | (erc-display-message nil nil (current-buffer) |
| 330 | (erc-format-privmessage "alice" "Hi" nil t)) | 334 | (erc-format-privmessage "alice" "Hi" nil t)) |
| 331 | (should (looking-at-p "#chan@ServNet 10>")) | 335 | (should (looking-back "#chan@ServNet 10> ")) |
| 332 | (save-excursion (goto-char erc-input-marker) | 336 | (goto-char erc-input-marker) |
| 333 | (insert "Howdy") | 337 | (insert "Howdy") |
| 334 | (erc-send-current-line) | 338 | (erc-send-current-line) |
| 335 | (forward-line -1) | 339 | (save-excursion (forward-line -1) |
| 336 | (should (looking-at "<tester> Howdy"))) | 340 | (should (looking-at "<tester> Howdy"))) |
| 337 | (should (looking-at-p "#chan@ServNet 11>")) | 341 | (should (looking-back "#chan@ServNet 11> ")) |
| 338 | (save-excursion (goto-char erc-input-marker) | 342 | (should (= (point) erc-input-marker)) |
| 339 | (insert "/query bob") | 343 | (insert "/query bob") |
| 340 | (erc-send-current-line)) | 344 | (erc-send-current-line) |
| 341 | ;; Query does not redraw (nor /help, only message input) | 345 | ;; Query does not redraw (nor /help, only message input) |
| 342 | (should (looking-at-p "#chan@ServNet 11>")) | 346 | (should (looking-back "#chan@ServNet 11> ")) |
| 343 | ;; No sign of old prompts | 347 | ;; No sign of old prompts |
| 344 | (save-excursion | 348 | (save-excursion |
| 345 | (goto-char (point-min)) | 349 | (goto-char (point-min)) |
| @@ -349,15 +353,16 @@ | |||
| 349 | (with-current-buffer (get-buffer "bob") | 353 | (with-current-buffer (get-buffer "bob") |
| 350 | (goto-char erc-insert-marker) | 354 | (goto-char erc-insert-marker) |
| 351 | (should (looking-at-p "bob@ServNet 14>")) | 355 | (should (looking-at-p "bob@ServNet 14>")) |
| 356 | (goto-char erc-input-marker) | ||
| 352 | (erc-display-message nil nil (current-buffer) | 357 | (erc-display-message nil nil (current-buffer) |
| 353 | (erc-format-privmessage "bob" "Hi" nil t)) | 358 | (erc-format-privmessage "bob" "Hi" nil t)) |
| 354 | (should (looking-at-p "bob@ServNet 15>")) | 359 | (should (looking-back "bob@ServNet 15> ")) |
| 355 | (save-excursion (goto-char erc-input-marker) | 360 | (goto-char erc-input-marker) |
| 356 | (insert "Howdy") | 361 | (insert "Howdy") |
| 357 | (erc-send-current-line) | 362 | (erc-send-current-line) |
| 358 | (forward-line -1) | 363 | (save-excursion (forward-line -1) |
| 359 | (should (looking-at "<tester> Howdy"))) | 364 | (should (looking-at "<tester> Howdy"))) |
| 360 | (should (looking-at-p "bob@ServNet 16>")) | 365 | (should (looking-back "bob@ServNet 16> ")) |
| 361 | ;; No sign of old prompts | 366 | ;; No sign of old prompts |
| 362 | (save-excursion | 367 | (save-excursion |
| 363 | (goto-char (point-min)) | 368 | (goto-char (point-min)) |