diff options
| author | F. Jason Park | 2023-11-04 13:48:11 -0700 |
|---|---|---|
| committer | F. Jason Park | 2023-11-04 15:41:14 -0700 |
| commit | 4c8510857693812ff7ff635cd0d70f97022792db (patch) | |
| tree | 4019ef9f4b910ae706ab4882d66800fcd6fcc666 | |
| parent | 781f950edab0509f12e3ec4880690ef6541841ee (diff) | |
| download | emacs-4c8510857693812ff7ff635cd0d70f97022792db.tar.gz emacs-4c8510857693812ff7ff635cd0d70f97022792db.zip | |
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)
| -rw-r--r-- | lisp/erc/erc-stamp.el | 42 |
1 files 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." | |||
| 224 | "Non-nil means inhibit `erc-add-timestamp' completely.") | 224 | "Non-nil means inhibit `erc-add-timestamp' completely.") |
| 225 | 225 | ||
| 226 | (defvar erc-stamp--allow-unmanaged nil | 226 | (defvar erc-stamp--allow-unmanaged nil |
| 227 | "Non-nil means `erc-add-timestamp' runs unconditionally. | 227 | "Non-nil means run `erc-add-timestamp' almost unconditionally. |
| 228 | Escape hatch for third-parties using lower-level API functions, | 228 | This is an unofficial escape hatch for code wanting to use |
| 229 | such as `erc-display-line', directly.") | 229 | lower-level message-insertion functions, like `erc-insert-line', |
| 230 | directly. Third parties needing such functionality should | ||
| 231 | petition for it via \\[erc-bug].") | ||
| 232 | |||
| 233 | (defvar erc-stamp--permanent-cursor-sensor-functions nil | ||
| 234 | "Non-nil means add `cursor-sensor-functions' unconditionally. | ||
| 235 | This is an unofficial escape hatch for code wanting the text | ||
| 236 | property `cursor-sensor-functions' to always be present, | ||
| 237 | regardless of the option `erc-echo-timestamps'. Third parties | ||
| 238 | needing such pre-5.6 behavior to stick around should make that | ||
| 239 | known via \\[erc-bug].") | ||
| 230 | 240 | ||
| 231 | (defun erc-add-timestamp () | 241 | (defun erc-add-timestamp () |
| 232 | "Add timestamp and text-properties to message. | 242 | "Add timestamp and text-properties to message. |
| @@ -256,8 +266,8 @@ or `erc-send-modify-hook'." | |||
| 256 | (erc-away-time)) | 266 | (erc-away-time)) |
| 257 | (funcall erc-insert-away-timestamp-function | 267 | (funcall erc-insert-away-timestamp-function |
| 258 | (erc-format-timestamp ct erc-away-timestamp-format))) | 268 | (erc-format-timestamp ct erc-away-timestamp-format))) |
| 259 | (when erc-stamp--allow-unmanaged | 269 | (when erc-stamp--permanent-cursor-sensor-functions |
| 260 | (add-text-properties (point-min) (1- (point-max)) | 270 | (add-text-properties (point-min) (max (point-min) (1- (point-max))) |
| 261 | ;; It's important for the function to | 271 | ;; It's important for the function to |
| 262 | ;; be different on different entries (bug#22700). | 272 | ;; be different on different entries (bug#22700). |
| 263 | (list 'cursor-sensor-functions | 273 | (list 'cursor-sensor-functions |
| @@ -793,16 +803,18 @@ Return the empty string if FORMAT is nil." | |||
| 793 | (cursor-intangible-mode -1))) | 803 | (cursor-intangible-mode -1))) |
| 794 | (if erc-echo-timestamps | 804 | (if erc-echo-timestamps |
| 795 | (progn | 805 | (progn |
| 796 | (dolist (hook '(erc-insert-post-hook erc-send-post-hook)) | 806 | (unless erc-stamp--permanent-cursor-sensor-functions |
| 797 | (add-hook hook #'erc-stamp--add-csf-on-post-modify nil t)) | 807 | (dolist (hook '(erc-insert-post-hook erc-send-post-hook)) |
| 798 | (erc--restore-initialize-priors erc-stamp-mode | 808 | (add-hook hook #'erc-stamp--add-csf-on-post-modify nil t)) |
| 799 | erc-stamp--csf-props-updated-p nil) | 809 | (erc--restore-initialize-priors erc-stamp-mode |
| 800 | (unless (or erc-stamp--allow-unmanaged erc-stamp--csf-props-updated-p) | 810 | erc-stamp--csf-props-updated-p nil) |
| 801 | (setq erc-stamp--csf-props-updated-p t) | 811 | (unless erc-stamp--csf-props-updated-p |
| 802 | (let ((erc--msg-props (map-into '((erc-ts . t)) 'hash-table))) | 812 | (setq erc-stamp--csf-props-updated-p t) |
| 803 | (with-silent-modifications | 813 | (let ((erc--msg-props (map-into '((erc-ts . t)) 'hash-table))) |
| 804 | (erc--traverse-inserted (point-min) erc-insert-marker | 814 | (with-silent-modifications |
| 805 | #'erc-stamp--add-csf-on-post-modify)))) | 815 | (erc--traverse-inserted |
| 816 | (point-min) erc-insert-marker | ||
| 817 | #'erc-stamp--add-csf-on-post-modify))))) | ||
| 806 | (cursor-sensor-mode +1) ; idempotent | 818 | (cursor-sensor-mode +1) ; idempotent |
| 807 | (when (>= emacs-major-version 29) | 819 | (when (>= emacs-major-version 29) |
| 808 | (add-function :before-until (local 'clear-message-function) | 820 | (add-function :before-until (local 'clear-message-function) |