aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Zaretskii2023-07-03 19:04:13 +0300
committerEli Zaretskii2023-07-03 19:04:13 +0300
commit0b060faf2e34b24cc550580e2e86ebcb16dc9cdf (patch)
treea936c53da74957d928606ef3853d9e83b8cb7fb6
parent997b2c90efc28163f70ab018086173dec9864b34 (diff)
parentd0325e23099823f9f6e2575ef52940a69e8a6549 (diff)
downloademacs-0b060faf2e34b24cc550580e2e86ebcb16dc9cdf.tar.gz
emacs-0b060faf2e34b24cc550580e2e86ebcb16dc9cdf.zip
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
-rw-r--r--etc/ERC-NEWS2
-rw-r--r--lisp/erc/erc-match.el36
-rw-r--r--lisp/erc/erc-stamp.el4
-rw-r--r--test/lisp/erc/erc-scenarios-match.el11
-rw-r--r--test/lisp/erc/erc-tests.el4
5 files changed, 22 insertions, 35 deletions
diff --git a/etc/ERC-NEWS b/etc/ERC-NEWS
index 2f465e247d7..5665b760ea9 100644
--- a/etc/ERC-NEWS
+++ b/etc/ERC-NEWS
@@ -183,7 +183,7 @@ Luckily, ERC now leverages a feature introduced in Emacs 27, "hook
183depth," to secure the positions of a few key members of 183depth," to secure the positions of a few key members of
184'erc-insert-modify-hook' and 'erc-send-modify-hook'. So far, this 184'erc-insert-modify-hook' and 'erc-send-modify-hook'. So far, this
185includes the functions 'erc-button-add-buttons', 'erc-fill', 185includes the functions 'erc-button-add-buttons', 'erc-fill',
186'erc-add-timestamp', and 'erc-match-message', which now appear in that 186'erc-match-message', and 'erc-add-timestamp', which now appear in that
187order, when present, at depths beginning at 20 and ending below 80. 187order, when present, at depths beginning at 20 and ending below 80.
188Of most interest to module authors is the new relative positioning of 188Of most interest to module authors is the new relative positioning of
189the first two, 'erc-button-add-buttons' and 'erc-fill', which have 189the first two, 'erc-button-add-buttons' and 'erc-fill', which have
diff --git a/lisp/erc/erc-match.el b/lisp/erc/erc-match.el
index 204bf14a1cf..2b7fff87ff0 100644
--- a/lisp/erc/erc-match.el
+++ b/lisp/erc/erc-match.el
@@ -52,7 +52,7 @@ they are hidden or highlighted. This is controlled via the variables
52`erc-current-nick-highlight-type'. For all these highlighting types, 52`erc-current-nick-highlight-type'. For all these highlighting types,
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 60) 55 ((add-hook 'erc-insert-modify-hook #'erc-match-message 50)
56 (add-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec) 56 (add-hook 'erc-mode-hook #'erc-match--modify-invisibility-spec)
57 (unless erc--updating-modules-p 57 (unless erc--updating-modules-p
58 (erc-buffer-do #'erc-match--modify-invisibility-spec)) 58 (erc-buffer-do #'erc-match--modify-invisibility-spec))
@@ -237,10 +237,7 @@ for beeping to work."
237ERC calls members with the arguments (MATCH-TYPE NUH MESSAGE), 237ERC calls members with the arguments (MATCH-TYPE NUH MESSAGE),
238where MATCH-TYPE is one of the symbols `current-nick', `keyword', 238where MATCH-TYPE is one of the symbols `current-nick', `keyword',
239`pal', `dangerous-host', `fool', and NUH is an `erc-response' 239`pal', `dangerous-host', `fool', and NUH is an `erc-response'
240sender, like bob!~bob@example.org. Users should keep in mind 240sender, like bob!~bob@example.org."
241that MESSAGE may not include decorations, such as white space or
242time stamps, preceding the same text as inserted in the narrowed
243buffer."
244 :options '(erc-log-matches erc-hide-fools erc-beep-on-match) 241 :options '(erc-log-matches erc-hide-fools erc-beep-on-match)
245 :type 'hook) 242 :type 'hook)
246 243
@@ -462,19 +459,8 @@ In any of the following situations, MSG is directed at an entry FOOL:
462 (erc-list-match fools-end msg)))) 459 (erc-list-match fools-end msg))))
463 460
464(defun erc-match-message () 461(defun erc-match-message ()
465 "Add faces to matching text in inserted message." 462 "Mark certain keywords in a region.
466 ;; Exclude leading whitespace, stamps, etc. 463Use this defun with `erc-insert-modify-hook'."
467 (let ((omin (point-min))
468 (beg (or (and (not (get-text-property (point-min) 'erc-command))
469 (next-single-property-change (point-min) 'erc-command))
470 (point-min))))
471 ;; FIXME when ERC no longer supports 28, use `with-restriction'
472 ;; with `:label' here instead of passing `omin'.
473 (save-restriction
474 (narrow-to-region beg (point-max))
475 (erc-match--message omin))))
476
477(defun erc-match--message (unrestricted-point-min)
478 ;; This needs some refactoring. 464 ;; This needs some refactoring.
479 (goto-char (point-min)) 465 (goto-char (point-min))
480 (let* ((to-match-nick-dep '("pal" "fool" "dangerous-host")) 466 (let* ((to-match-nick-dep '("pal" "fool" "dangerous-host"))
@@ -576,14 +562,12 @@ In any of the following situations, MSG is directed at an entry FOOL:
576 'font-lock-face match-face))) 562 'font-lock-face match-face)))
577 ;; Else twiddle your thumbs. 563 ;; Else twiddle your thumbs.
578 (t nil)) 564 (t nil))
579 ;; FIXME use `without-restriction' after dropping 28. 565 (run-hook-with-args
580 (save-restriction 566 'erc-text-matched-hook
581 (narrow-to-region unrestricted-point-min (point-max)) 567 (intern match-type)
582 (run-hook-with-args 568 (or nickuserhost
583 'erc-text-matched-hook (intern match-type) 569 (concat "Server:" (erc-get-parsed-vector-type vector)))
584 (or nickuserhost 570 message))))
585 (concat "Server:" (erc-get-parsed-vector-type vector)))
586 message)))))
587 (if nickuserhost 571 (if nickuserhost
588 (append to-match-nick-dep to-match-nick-indep) 572 (append to-match-nick-dep to-match-nick-indep)
589 to-match-nick-indep))))) 573 to-match-nick-indep)))))
diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el
index aac51135a07..5035e60a87d 100644
--- a/lisp/erc/erc-stamp.el
+++ b/lisp/erc/erc-stamp.el
@@ -163,8 +163,8 @@ from entering them and instead jump over them."
163(define-erc-module stamp timestamp 163(define-erc-module stamp timestamp
164 "This mode timestamps messages in the channel buffers." 164 "This mode timestamps messages in the channel buffers."
165 ((add-hook 'erc-mode-hook #'erc-munge-invisibility-spec) 165 ((add-hook 'erc-mode-hook #'erc-munge-invisibility-spec)
166 (add-hook 'erc-insert-modify-hook #'erc-add-timestamp 50) 166 (add-hook 'erc-insert-modify-hook #'erc-add-timestamp 60)
167 (add-hook 'erc-send-modify-hook #'erc-add-timestamp 50) 167 (add-hook 'erc-send-modify-hook #'erc-add-timestamp 60)
168 (add-hook 'erc-mode-hook #'erc-stamp--recover-on-reconnect) 168 (add-hook 'erc-mode-hook #'erc-stamp--recover-on-reconnect)
169 (add-hook 'erc--pre-clear-functions #'erc-stamp--reset-on-clear) 169 (add-hook 'erc--pre-clear-functions #'erc-stamp--reset-on-clear)
170 (unless erc--updating-modules-p 170 (unless erc--updating-modules-p
diff --git a/test/lisp/erc/erc-scenarios-match.el b/test/lisp/erc/erc-scenarios-match.el
index 49e6a3370fc..782907bfc30 100644
--- a/test/lisp/erc/erc-scenarios-match.el
+++ b/test/lisp/erc/erc-scenarios-match.el
@@ -49,8 +49,9 @@
49 :port port 49 :port port
50 :full-name "tester" 50 :full-name "tester"
51 :nick "tester") 51 :nick "tester")
52 (should (memq 'erc-match-message 52 ;; Module `timestamp' follows `match' in insertion hooks.
53 (memq 'erc-add-timestamp erc-insert-modify-hook))) 53 (should (memq 'erc-add-timestamp
54 (memq 'erc-match-message erc-insert-modify-hook)))
54 ;; The "match type" is `current-nick'. 55 ;; The "match type" is `current-nick'.
55 (funcall expect 5 "tester") 56 (funcall expect 5 "tester")
56 (should (eq (get-text-property (1- (point)) 'font-lock-face) 57 (should (eq (get-text-property (1- (point)) 'font-lock-face)
@@ -60,6 +61,7 @@
60;; some non-nil invisibility property spans the entire message. 61;; some non-nil invisibility property spans the entire message.
61(ert-deftest erc-scenarios-match--stamp-left-fools-invisible () 62(ert-deftest erc-scenarios-match--stamp-left-fools-invisible ()
62 :tags '(:expensive-test) 63 :tags '(:expensive-test)
64 (ert-skip "WIP: fix included in bug#64301")
63 (erc-scenarios-common-with-cleanup 65 (erc-scenarios-common-with-cleanup
64 ((erc-scenarios-common-dialog "join/legacy") 66 ((erc-scenarios-common-dialog "join/legacy")
65 (dumb-server (erc-d-run "localhost" t 'foonet)) 67 (dumb-server (erc-d-run "localhost" t 'foonet))
@@ -84,8 +86,9 @@
84 :full-name "tester" 86 :full-name "tester"
85 :password "changeme" 87 :password "changeme"
86 :nick "tester") 88 :nick "tester")
87 (should (memq 'erc-match-message 89 ;; Module `timestamp' follows `match' in insertion hooks.
88 (memq 'erc-add-timestamp erc-insert-modify-hook))) 90 (should (memq 'erc-add-timestamp
91 (memq 'erc-match-message erc-insert-modify-hook)))
89 (funcall expect 5 "This server is in debug mode"))) 92 (funcall expect 5 "This server is in debug mode")))
90 93
91 (ert-info ("Ensure lines featuring \"bob\" are invisible") 94 (ert-info ("Ensure lines featuring \"bob\" are invisible")
diff --git a/test/lisp/erc/erc-tests.el b/test/lisp/erc/erc-tests.el
index b751ef50520..80c7c708fc5 100644
--- a/test/lisp/erc/erc-tests.el
+++ b/test/lisp/erc/erc-tests.el
@@ -1851,8 +1851,8 @@
1851 '( :erc-insert-modify-hook (erc-controls-highlight ; 0 1851 '( :erc-insert-modify-hook (erc-controls-highlight ; 0
1852 erc-button-add-buttons ; 30 1852 erc-button-add-buttons ; 30
1853 erc-fill ; 40 1853 erc-fill ; 40
1854 erc-add-timestamp ; 50 1854 erc-match-message ; 50
1855 erc-match-message) ; 60 1855 erc-add-timestamp) ; 60
1856 1856
1857 :erc-send-modify-hook ( erc-controls-highlight ; 0 1857 :erc-send-modify-hook ( erc-controls-highlight ; 0
1858 erc-button-add-buttons ; 30 1858 erc-button-add-buttons ; 30