aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorF. Jason Park2023-01-27 05:34:56 -0800
committerF. Jason Park2023-04-08 14:23:51 -0700
commite3c4a648d166600fa507caaca3efbbc7f9a6d12f (patch)
treef9166590e0dff2306b200031ce2cd1faeb13f017
parent0c3a069ae0051148f2f35f542ce4ef573e5f5468 (diff)
downloademacs-e3c4a648d166600fa507caaca3efbbc7f9a6d12f.tar.gz
emacs-e3c4a648d166600fa507caaca3efbbc7f9a6d12f.zip
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.)
-rw-r--r--lisp/erc/erc-match.el27
1 files 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
53you can decide whether the entire message or only the sending nick is 53you can decide whether the entire message or only the sending nick is
54highlighted." 54highlighted."
55 ((add-hook 'erc-insert-modify-hook #'erc-match-message 'append) 55 ((add-hook 'erc-insert-modify-hook #'erc-match-message 'append)
56 (add-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec)
56 (erc--modify-local-map t "C-c C-k" #'erc-go-to-log-matches-buffer)) 57 (erc--modify-local-map t "C-c C-k" #'erc-go-to-log-matches-buffer))
57 ((remove-hook 'erc-insert-modify-hook #'erc-match-message) 58 ((remove-hook 'erc-insert-modify-hook #'erc-match-message)
59 (remove-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec)
60 (erc-match--modify-invisibility-spec)
58 (erc--modify-local-map nil "C-c C-k" #'erc-go-to-log-matches-buffer))) 61 (erc--modify-local-map nil "C-c C-k" #'erc-go-to-log-matches-buffer)))
59 62
60;; Remaining customizations 63;; Remaining customizations
@@ -649,13 +652,22 @@ See `erc-log-match-format'."
649 (get-buffer (car buffer-cons)))))) 652 (get-buffer (car buffer-cons))))))
650 (switch-to-buffer buffer-name))) 653 (switch-to-buffer buffer-name)))
651 654
655(defvar-local erc-match--hide-fools-offset-bounds nil)
656
652(defun erc-hide-fools (match-type _nickuserhost _message) 657(defun erc-hide-fools (match-type _nickuserhost _message)
653 "Hide foolish comments. 658 "Hide foolish comments.
654This function should be called from `erc-text-matched-hook'." 659This function should be called from `erc-text-matched-hook'."
655 (when (eq match-type 'fool) 660 (when (eq match-type 'fool)
656 (erc-put-text-properties (point-min) (point-max) 661 (if erc-match--hide-fools-offset-bounds
657 '(invisible intangible) 662 (let ((beg (point-min))
658 (current-buffer)))) 663 (end (point-max)))
664 (save-restriction
665 (widen)
666 (put-text-property (1- beg) (1- end) 'invisible 'erc-match)))
667 ;; The docs say `intangible' is deprecated, but this has been
668 ;; like this for ages. Should verify unneeded and remove if so.
669 (erc-put-text-properties (point-min) (point-max)
670 '(invisible intangible)))))
659 671
660(defun erc-beep-on-match (match-type _nickuserhost _message) 672(defun erc-beep-on-match (match-type _nickuserhost _message)
661 "Beep when text matches. 673 "Beep when text matches.
@@ -663,6 +675,13 @@ This function is meant to be called from `erc-text-matched-hook'."
663 (when (member match-type erc-beep-match-types) 675 (when (member match-type erc-beep-match-types)
664 (beep))) 676 (beep)))
665 677
678(defun erc-match--modify-invisibility-spec ()
679 "Add an ellipsis property to the local spec."
680 (if erc-match-mode
681 (add-to-invisibility-spec 'erc-match)
682 (erc-with-all-buffers-of-server nil nil
683 (remove-from-invisibility-spec 'erc-match))))
684
666(provide 'erc-match) 685(provide 'erc-match)
667 686
668;;; erc-match.el ends here 687;;; erc-match.el ends here