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

Allow setting `erc-split-line-length' to zero

* etc/ERC-NEWS: Mention that `erc-flood-protect' no longer affects
line splitting.
* lisp/erc/erc-backend.el (erc-split-line-length): Mention ways for
modules to suppress line splitting entirely.
(erc--split-line): Exit loop instead of asserting progress has been
made.
* lisp/erc/erc.el (erc--split-lines): Don't split input when
option `erc-split-line-length' is zero.
* test/lisp/erc/erc-tests.el (erc--split-line): Assert behavior when
`erc-split-line-length' is 0.  (Bug#62947)
This commit is contained in:
F. Jason Park 2024-01-03 02:00:45 -08:00
parent fad2d1e2ac
commit d6f9379d1c
4 changed files with 21 additions and 3 deletions

View File

@ -560,6 +560,11 @@ third-party code, the key takeaway is that more 'font-lock-face'
properties encountered in the wild may be combinations of faces rather
than lone ones.
*** 'erc-flood-protect' no longer influences input splitting.
This variable's role has been narrowed to rate limiting only. ERC
used to suppress protocol line-splitting when its value was nil, but
that's now handled by setting 'erc-split-line-length' to zero.
*** 'erc-pre-send-functions' visits prompt input post-split.
ERC now adjusts input lines to fall within allowed length limits
before showing hook members the result. For compatibility,

View File

@ -433,7 +433,11 @@ and optionally alter the attempts tally."
(defcustom erc-split-line-length 440
"The maximum length of a single message.
If a message exceeds this size, it is broken into multiple ones.
ERC normally splits chat input submitted at its prompt into
multiple messages when the initial size exceeds this value in
bytes. Modules can tell ERC to forgo splitting entirely by
setting this to zero locally or, preferably, by binding it around
a remapped `erc-send-current-line' command.
IRC allows for lines up to 512 bytes. Two of them are CR LF.
And a typical message looks like this:
@ -596,7 +600,8 @@ escape hatch for inhibiting their transmission.")
(if (= (car cmp) (point-min))
(goto-char (nth 1 cmp))
(goto-char (car cmp)))))
(cl-assert (/= (point-min) (point)))
(when (= (point-min) (point))
(goto-char (point-max)))
(push (buffer-substring-no-properties (point-min) (point)) out)
(delete-region (point-min) (point)))
(or (nreverse out) (list "")))

View File

@ -7821,7 +7821,7 @@ When all lines are empty, remove all but the first."
"Partition non-command input into lines of protocol-compliant length."
;; Prior to ERC 5.6, line splitting used to be predicated on
;; `erc-flood-protect' being non-nil.
(unless (erc--input-split-cmdp state)
(unless (or (zerop erc-split-line-length) (erc--input-split-cmdp state))
(setf (erc--input-split-lines state)
(mapcan #'erc--split-line (erc--input-split-lines state)))))

View File

@ -1298,6 +1298,14 @@
(should-not erc-debug-irc-protocol)))
(ert-deftest erc--split-line ()
(let ((erc-split-line-length 0))
(should (equal (erc--split-line "") '("")))
(should (equal (erc--split-line " ") '(" ")))
(should (equal (erc--split-line "1") '("1")))
(should (equal (erc--split-line " 1") '(" 1")))
(should (equal (erc--split-line "1 ") '("1 ")))
(should (equal (erc--split-line "abc") '("abc"))))
(let ((erc-default-recipients '("#chan"))
(erc-split-line-length 10))
(should (equal (erc--split-line "") '("")))