[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master d6f9379d1c7 4/6: Allow setting `erc-split-line-length' to zero
From: |
F. Jason Park |
Subject: |
master d6f9379d1c7 4/6: Allow setting `erc-split-line-length' to zero |
Date: |
Sun, 7 Jan 2024 18:17:15 -0500 (EST) |
branch: master
commit d6f9379d1c708dddc0543bf7242ba1ec6aee9746
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
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)
---
etc/ERC-NEWS | 5 +++++
lisp/erc/erc-backend.el | 9 +++++++--
lisp/erc/erc.el | 2 +-
test/lisp/erc/erc-tests.el | 8 ++++++++
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index c51b6f05458..6cfa704d995 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -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,
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 4162df00595..95207e56fd1 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -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 "")))
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index b73e80cedde..d0c43134f9d 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -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)))))
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index 2cd47ec3f89..a9aa255718d 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -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 "") '("")))
- master updated (18de131222e -> 50f430ebcd8), F. Jason Park, 2024/01/07
- master 50f430ebcd8 6/6: Clarify purpose of module aliases in ERC, F. Jason Park, 2024/01/07
- master 94f760163e2 1/6: ; doc/misc/erc.texi: Improve SASL intro., F. Jason Park, 2024/01/07
- master fad2d1e2acc 3/6: Use global window hook for erc-keep-place-indicator, F. Jason Park, 2024/01/07
- master d6f9379d1c7 4/6: Allow setting `erc-split-line-length' to zero,
F. Jason Park <=
- master 37e87bc3eeb 5/6: Make ERC's format catalogs more extensible, F. Jason Park, 2024/01/07
- master 74f022b2797 2/6: ; Make erc--send-input-lines a normal function again, F. Jason Park, 2024/01/07