From: F. Jason Park Date: Thu, 28 Dec 2023 02:44:29 +0000 (-0800) Subject: Sideline implied invisible-intangible coupling in ERC X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=775bd4b631e9303c20e4ebddd179960276065448;p=emacs.git Sideline implied invisible-intangible coupling in ERC * etc/ERC-NEWS: Add entry explaining removal of automatic `intangible' propertizing of t-valued `invisible' messages. * lisp/erc/erc.el (erc--insert-invisible-as-intangible-p): New flag variable, a temporary escape hatch to regain pre-5.6 behavior involving the modification of certain `invisible' messages. (erc--insert-line): Gate unfavorable behavior behind `erc--insert-invisible-as-intangible-p' flag. Add comment clarifying deferred initialization of `insert-position', which was part of the many changes introduced as part of bug#60936. --- diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS index c883f575c15..6dc8af3c514 100644 --- a/etc/ERC-NEWS +++ b/etc/ERC-NEWS @@ -438,6 +438,17 @@ those folded onto the next line. Such inconsistency made stamp detection overly complex and produced uneven results when toggling stamp visibility. +*** Invisible message insertions not automatically made 'intangible'. +Previously, when 'erc-display-message' and friends spotted the +'invisible' text property with a value of t anywhere in text to be +inserted, it would apply that property to the entire message, along +with a t-valued 'intangible' property. Beginning with ERC 5.6, users +expecting this behavior will have to instead perform the treatment +themselves. To help with the transition, a temporary escape hatch has +been made available to regain this behavior, but its existence is only +guaranteed for this one minor version alone. See source code in the +vicinity of 'erc-insert-line' for more. + *** Date stamps have become independent messages. ERC now inserts "date stamps" generated from the option 'erc-timestamp-format-left' as separate, standalone messages. This diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 02bfda143bc..f6962910da0 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -3282,6 +3282,21 @@ If END is a marker, possibly update its position." (unless (eq end erc-insert-marker) (set-marker end nil))) +(defvar erc--insert-invisible-as-intangible-p nil + "When non-nil, ensure certain invisible messages are also intangible. +That is, single out any message inserted via `erc-insert-line' +that lacks a trailing newline but has a t-valued `invisible' +property anywhere along its length, and ensure it's both +`invisible' t and `intangible' t throughout. Note that this is +merely an escape hatch for accessing aberrant pre-5.6 behavior +that ERC considers a bug because it applies a practice described +as obsolete in the manual, and it does so heavy-handedly. That +the old behavior only acted when the input lacked a trailing +newline was likely accidental but is ultimately incidental. See +info node `(elisp) Special Properties' for specifics. Beware +that this flag and the behavior it restores may disappear at any +time, so if you need them, please let ERC know with \\[erc-bug].") + (defvar erc--insert-line-function nil "When non-nil, an alterntive to `insert' for inserting messages.") @@ -3310,13 +3325,15 @@ preformatted or anticipated by third-party members of the various modification hooks)." (when string (with-current-buffer (or buffer (process-buffer erc-server-process)) - (let ((insert-position (marker-position erc-insert-marker))) - (let ((string string) ;; FIXME! Can this be removed? - (buffer-undo-list t) + (let (insert-position) + ;; Initialize ^ below to thwart rogue `erc-insert-pre-hook' + ;; members that dare to modify the buffer's length. + (let ((buffer-undo-list t) (inhibit-read-only t)) - (unless (string-match "\n$" string) + (unless (string-suffix-p "\n" string) (setq string (concat string "\n")) - (when (erc-string-invisible-p string) + (when (and erc--insert-invisible-as-intangible-p + (erc-string-invisible-p string)) (erc-put-text-properties 0 (length string) '(invisible intangible) string))) (erc-log (concat "erc-display-message: " string