"Return the bounds of a message in an ERC buffer.
Return ONLY one side when the first arg is `end' or `beg'. With
POINT, search from POINT instead of `point'."
+ ;; TODO add edebug spec.
`(let* ((point ,(or point '(point)))
(at-start-p (get-text-property point 'erc-msg)))
(and-let*
- (,@(and (member only '(nil 'beg))
+ (,@(and (member only '(nil beg 'beg))
'((b (or (and at-start-p point)
(and-let*
((p (previous-single-property-change point
'erc-msg)))
- (if (= p (1- point)) p (1- p)))))))
- ,@(and (member only '(nil 'end))
+ (if (= p (1- point))
+ (if (get-text-property p 'erc-msg) p (1- p))
+ (1- p)))))))
+ ,@(and (member only '(nil end 'end))
'((e (1- (next-single-property-change
(if at-start-p (1+ point) point)
'erc-msg nil erc-insert-marker))))))
(should-not calls))))))
+(ert-deftest erc--get-inserted-msg-bounds ()
+ (erc-mode)
+ (erc--initialize-markers (point) nil)
+ (let ((parsed (make-erc-response :unparsed ":bob PRIVMSG #chan :hi"
+ :sender "bob"
+ :command "PRIVMSG"
+ :command-args (list "#chan" "hi")
+ :contents "hi"))
+ (erc--msg-prop-overrides '((erc-ts . 0))))
+ (erc-display-message parsed nil (current-buffer)
+ (erc-format-privmessage "bob" "hi" nil t)))
+ (goto-char 3)
+ (should (looking-at "<bob> hi"))
+ (goto-char 11)
+ (should (looking-back "<bob> hi"))
+
+ (ert-info ("Parameter `only' being `beg'")
+ (dolist (i (number-sequence 3 11))
+ (goto-char i)
+ (ert-info ((format "At %d (%c)" i (char-after i)))
+ (should (= 3 (erc--get-inserted-msg-bounds 'beg)))))
+
+ (ert-info ("Parameter `point'")
+ (dolist (i (number-sequence 3 11))
+ (ert-info ((format "At %d (%c)" i (char-after i)))
+ (should (= 3 (erc--get-inserted-msg-bounds 'beg i)))))))
+
+ (ert-info ("Parameter `only' being `end'")
+ (dolist (i (number-sequence 3 11))
+ (goto-char i)
+ (ert-info ((format "At %d (%c)" i (char-after i)))
+ (should (= 11 (erc--get-inserted-msg-bounds 'end)))))
+
+ (ert-info ("Parameter `point'")
+ (dolist (i (number-sequence 3 11))
+ (ert-info ((format "At %d (%c)" i (char-after i)))
+ (should (= 11 (erc--get-inserted-msg-bounds 'end i)))))))
+
+ (ert-info ("Parameter `only' being nil")
+ (dolist (i (number-sequence 3 11))
+ (goto-char i)
+ (ert-info ((format "At %d (%c)" i (char-after i)))
+ (should (equal '(3 . 11) (erc--get-inserted-msg-bounds nil)))))
+
+ (ert-info ("Parameter `point'")
+ (dolist (i (number-sequence 3 11))
+ (ert-info ((format "At %d (%c)" i (char-after i)))
+ (should (equal '(3 . 11) (erc--get-inserted-msg-bounds nil i))))))))
+
(ert-deftest erc--delete-inserted-message ()
(erc-mode)
(erc--initialize-markers (point) nil)
(0.00 ":alice!~u@2fzfcku68ehqa.irc PRIVMSG #chan :bob: No remedy, my lord, when walls are so wilful to hear without warning.")
(0.01 ":bob!~u@2fzfcku68ehqa.irc PRIVMSG #chan :alice: Let our reciprocal vows be remembered. You have many opportunities to cut him off; if your will want not, time and place will be fruitfully offered. There is nothing done if he return the conqueror; then am I the prisoner, and his bed my gaol; from the loathed warmth whereof deliver me, and supply the place for your labor."))
-((quit 1 "QUIT :\2ERC\2")
+((quit 10 "QUIT :\2ERC\2")
(0.03 ":tester`!~u@u9iqi96sfwk9s.irc QUIT :Quit"))
((drop 0 DROP))