[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4c851085769 4/5: Decouple disparate escape-hatch concerns in erc-
From: |
F. Jason Park |
Subject: |
master 4c851085769 4/5: Decouple disparate escape-hatch concerns in erc-stamp |
Date: |
Sat, 4 Nov 2023 18:43:41 -0400 (EDT) |
branch: master
commit 4c8510857693812ff7ff635cd0d70f97022792db
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Decouple disparate escape-hatch concerns in erc-stamp
* lisp/erc/erc-stamp.el (erc-stamp--allow-unmanaged): Improve doc
string.
(erc-stamp--permanent-cursor-sensor-functions): New variable to take
over the formerly provided `cursor-sensor-functions' aspect of the
flag `erc-stamp--allow-unmanaged'.
(erc-add-timestamp): Use
`erc-stamp--permanent-cursor-sensor-functions' instead of
`erc-stamp--allow-unmanaged' in guard condition.
(erc-munge-invisibility-spec): Use dedicated compatibility flag
`erc-stamp--permanent-cursor-sensor-functions' and forgo unnecessary
setup when it's non-nil. (Bug#60936)
---
lisp/erc/erc-stamp.el | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index b65c7adf676..71036a9a853 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -224,9 +224,19 @@ This becomes the message's `erc-ts' text property."
"Non-nil means inhibit `erc-add-timestamp' completely.")
(defvar erc-stamp--allow-unmanaged nil
- "Non-nil means `erc-add-timestamp' runs unconditionally.
-Escape hatch for third-parties using lower-level API functions,
-such as `erc-display-line', directly.")
+ "Non-nil means run `erc-add-timestamp' almost unconditionally.
+This is an unofficial escape hatch for code wanting to use
+lower-level message-insertion functions, like `erc-insert-line',
+directly. Third parties needing such functionality should
+petition for it via \\[erc-bug].")
+
+(defvar erc-stamp--permanent-cursor-sensor-functions nil
+ "Non-nil means add `cursor-sensor-functions' unconditionally.
+This is an unofficial escape hatch for code wanting the text
+property `cursor-sensor-functions' to always be present,
+regardless of the option `erc-echo-timestamps'. Third parties
+needing such pre-5.6 behavior to stick around should make that
+known via \\[erc-bug].")
(defun erc-add-timestamp ()
"Add timestamp and text-properties to message.
@@ -256,8 +266,8 @@ or `erc-send-modify-hook'."
(erc-away-time))
(funcall erc-insert-away-timestamp-function
(erc-format-timestamp ct erc-away-timestamp-format)))
- (when erc-stamp--allow-unmanaged
- (add-text-properties (point-min) (1- (point-max))
+ (when erc-stamp--permanent-cursor-sensor-functions
+ (add-text-properties (point-min) (max (point-min) (1- (point-max)))
;; It's important for the function to
;; be different on different entries (bug#22700).
(list 'cursor-sensor-functions
@@ -793,16 +803,18 @@ Return the empty string if FORMAT is nil."
(cursor-intangible-mode -1)))
(if erc-echo-timestamps
(progn
- (dolist (hook '(erc-insert-post-hook erc-send-post-hook))
- (add-hook hook #'erc-stamp--add-csf-on-post-modify nil t))
- (erc--restore-initialize-priors erc-stamp-mode
- erc-stamp--csf-props-updated-p nil)
- (unless (or erc-stamp--allow-unmanaged erc-stamp--csf-props-updated-p)
- (setq erc-stamp--csf-props-updated-p t)
- (let ((erc--msg-props (map-into '((erc-ts . t)) 'hash-table)))
- (with-silent-modifications
- (erc--traverse-inserted (point-min) erc-insert-marker
- #'erc-stamp--add-csf-on-post-modify))))
+ (unless erc-stamp--permanent-cursor-sensor-functions
+ (dolist (hook '(erc-insert-post-hook erc-send-post-hook))
+ (add-hook hook #'erc-stamp--add-csf-on-post-modify nil t))
+ (erc--restore-initialize-priors erc-stamp-mode
+ erc-stamp--csf-props-updated-p nil)
+ (unless erc-stamp--csf-props-updated-p
+ (setq erc-stamp--csf-props-updated-p t)
+ (let ((erc--msg-props (map-into '((erc-ts . t)) 'hash-table)))
+ (with-silent-modifications
+ (erc--traverse-inserted
+ (point-min) erc-insert-marker
+ #'erc-stamp--add-csf-on-post-modify)))))
(cursor-sensor-mode +1) ; idempotent
(when (>= emacs-major-version 29)
(add-function :before-until (local 'clear-message-function)