[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e3c4a648d16 31/37: Add variant for erc-match invisibility spec
From: |
F. Jason Park |
Subject: |
master e3c4a648d16 31/37: Add variant for erc-match invisibility spec |
Date: |
Sat, 8 Apr 2023 17:31:33 -0400 (EDT) |
branch: master
commit e3c4a648d166600fa507caaca3efbbc7f9a6d12f
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Add variant for erc-match invisibility spec
* lisp/erc/erc-match.el (erc-match-mode, erc-match-enable,
erc-match-disable): Arrange for possibly adding or removing
`erc-match' from `buffer-invisibility-spec'.
(erc-match--hide-fools-offset-bounds): Add new variable to serve as
switch for activating invisibility on a modified interval that's
offset toward `point-min' by one character.
(erc-hide-fools): Optionally offset start and end of invisible region
by minus one.
(erc-match--modify-invisibility-spec): New housekeeping function to
set up and tear down offset spec. (Bug#60936.)
---
lisp/erc/erc-match.el | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index 7ec9078d493..82b821503a8 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -53,8 +53,11 @@ they are hidden or highlighted. This is controlled via the
variables
you can decide whether the entire message or only the sending nick is
highlighted."
((add-hook 'erc-insert-modify-hook #'erc-match-message 'append)
+ (add-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec)
(erc--modify-local-map t "C-c C-k" #'erc-go-to-log-matches-buffer))
((remove-hook 'erc-insert-modify-hook #'erc-match-message)
+ (remove-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec)
+ (erc-match--modify-invisibility-spec)
(erc--modify-local-map nil "C-c C-k" #'erc-go-to-log-matches-buffer)))
;; Remaining customizations
@@ -649,13 +652,22 @@ See `erc-log-match-format'."
(get-buffer (car buffer-cons))))))
(switch-to-buffer buffer-name)))
+(defvar-local erc-match--hide-fools-offset-bounds nil)
+
(defun erc-hide-fools (match-type _nickuserhost _message)
"Hide foolish comments.
This function should be called from `erc-text-matched-hook'."
- (when (eq match-type 'fool)
- (erc-put-text-properties (point-min) (point-max)
- '(invisible intangible)
- (current-buffer))))
+ (when (eq match-type 'fool)
+ (if erc-match--hide-fools-offset-bounds
+ (let ((beg (point-min))
+ (end (point-max)))
+ (save-restriction
+ (widen)
+ (put-text-property (1- beg) (1- end) 'invisible 'erc-match)))
+ ;; The docs say `intangible' is deprecated, but this has been
+ ;; like this for ages. Should verify unneeded and remove if so.
+ (erc-put-text-properties (point-min) (point-max)
+ '(invisible intangible)))))
(defun erc-beep-on-match (match-type _nickuserhost _message)
"Beep when text matches.
@@ -663,6 +675,13 @@ This function is meant to be called from
`erc-text-matched-hook'."
(when (member match-type erc-beep-match-types)
(beep)))
+(defun erc-match--modify-invisibility-spec ()
+ "Add an ellipsis property to the local spec."
+ (if erc-match-mode
+ (add-to-invisibility-spec 'erc-match)
+ (erc-with-all-buffers-of-server nil nil
+ (remove-from-invisibility-spec 'erc-match))))
+
(provide 'erc-match)
;;; erc-match.el ends here
- master 1f1cd467c6a 33/37: Replace Info-goto-node with info in erc-button-alist, (continued)
- master 1f1cd467c6a 33/37: Replace Info-goto-node with info in erc-button-alist, F. Jason Park, 2023/04/08
- master e69bd59ec59 09/37: Honor arbitrary CHANTYPES in ERC, F. Jason Park, 2023/04/08
- master d5435a0d822 25/37: Refactor marker initialization in erc-open, F. Jason Park, 2023/04/08
- master 5011554529b 12/37: Don't require erc-goodies in erc.el, F. Jason Park, 2023/04/08
- master 0e4c07dc744 36/37: Allow erc-reuse-frames to favor connections, F. Jason Park, 2023/04/08
- master 89815631f24 10/37: Copy over upstream Compat macros to erc-compat, F. Jason Park, 2023/04/08
- master 9aa2806fdc3 13/37: Modify erc-mode-map in module definitions, F. Jason Park, 2023/04/08
- master 8793874616f 26/37: Adjust some old text properties in ERC buffers, F. Jason Park, 2023/04/08
- master 3d81ecf0a95 11/37: Leverage loaddefs for migrating ERC modules, F. Jason Park, 2023/04/08
- master 9f6a9cef97b 29/37: Put display properties to better use in erc-stamp, F. Jason Park, 2023/04/08
- master e3c4a648d16 31/37: Add variant for erc-match invisibility spec,
F. Jason Park <=
- master c104e90888a 35/37: Make auth-source erc-services tests more readable, F. Jason Park, 2023/04/08
- master 0c3a069ae00 30/37: Convert erc-fill minor mode into a proper module, F. Jason Park, 2023/04/08
- master 2d3ae5d5e68 03/37: Add subcommand erc-cmd-HELP handler to erc-dcc, F. Jason Park, 2023/04/08