1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-12 09:28:24 +00:00

Fix right-sided stamps commingling with erc-prompt

* lisp/erc/erc-stamp.el (erc-insert-timestamp-left-and-right): Fix bug
that saw the prompt being inserted after messages but just inside the
narrowed operating portion of the buffer, which meant remaining
modification hooks would see it upon visiting.  Thanks to Corwin Brust
for catching this.
* test/lisp/erc/erc-fill-tests.el (erc-fill-wrap--monospace): Use
custom `erc-prompt' function to guarantee invariants asserted by
`erc--assert-input-bounds' are preserved throughout.  (Bug#60936)
This commit is contained in:
F. Jason Park 2023-10-18 23:20:07 -07:00
parent 7ffc79690a
commit 47612514a9
2 changed files with 34 additions and 29 deletions

View File

@ -704,10 +704,12 @@ left-sided stamps and date stamps inserted by this function."
(unless erc-stamp--date-format-end
(add-hook 'erc-insert-pre-hook #'erc-stamp--lr-date-on-pre-modify -95 t)
(add-hook 'erc-send-pre-functions #'erc-stamp--lr-date-on-pre-modify -95 t)
(let ((erc--insert-marker (point-min-marker)))
(let ((erc--insert-marker (point-min-marker))
(end-marker (point-max-marker)))
(set-marker-insertion-type erc--insert-marker t)
(erc-stamp--lr-date-on-pre-modify nil)
(narrow-to-region erc--insert-marker (point-max))
(narrow-to-region erc--insert-marker end-marker)
(set-marker end-marker nil)
(set-marker erc--insert-marker nil)))
(let* ((ct (or erc-stamp--current-time (erc-stamp--current-time)))
(ts-right (with-suppressed-warnings

View File

@ -203,36 +203,39 @@
(unless (>= emacs-major-version 29)
(ert-skip "Emacs version too low, missing `buffer-text-pixel-size'"))
(erc-fill-tests--wrap-populate
(let ((erc-prompt (lambda () "ABC>")))
(erc-fill-tests--wrap-populate
(lambda ()
(should (= erc-fill--wrap-value 27))
(erc-fill-tests--wrap-check-prefixes "*** " "<alice> " "<bob> ")
(erc-fill-tests--compare "monospace-01-start")
(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"))
(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))
(lambda ()
(should (= erc-fill--wrap-value 27))
(erc-fill-tests--wrap-check-prefixes "*** " "<alice> " "<bob> ")
(erc-fill-tests--compare "monospace-04-reset")))))
(erc-fill-tests--compare "monospace-01-start")
(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"))
(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)))))
(defun erc-fill-tests--simulate-refill ()
;; Simulate `erc-fill-wrap-refill-buffer' synchronously and without