mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
Add text props for CTCP messages and speakers in ERC
* etc/ERC-NEWS: Mention reduction in boldness of `erc-notice-face' and `erc-action-face'. * lisp/erc/erc-fill.el (erc-fill-spaced-commands, erc-fill--spaced-commands): Rename former to latter and demote from user option to internal variable. (erc-fill): Change `erc-fill-spaced-commands' to `erc-fill--spaced-commands'. (erc-fill--wrap-continued-message-p): Use more precise `erc-ctcp' text prop instead of face-based heuristic to detect CTCP ACTION message. (erc-fill--wrap-action-dedent-p): New variable to toggle whether `line-prefix' is applied to CTCP ACTION messages. This exists less to accommodate user preferences and more for third-party code that assumes the first non-whitespace span in every message is a nick. (erc-fill-wrap): Look for `erc-speaker' property before falling back on word at point. Use `erc-ctcp' to detect CTCP ACTION messages. * lisp/erc/erc.el (erc-notice-face, erc-action-face): Prefer weight of `semi-bold' when available so that buttonization is at least somewhat perceptible in notices and action messages. (erc-send-action): Ensure nickname passed to `erc-display-message' has `erc-speaker' property and `erc-ctcp' ACTION property. (erc--own-property-names): Add `erc-speaker' to lineup. (erc-format-privmessage): Don't clobber `erc-nick-prefix-face'. That is, retain face applied to a leading stretch of characters in the `nick' parameter, but continue to discard trailing faces. (erc-format-my-nick, erc-ctcp-query-ACTION): Add new text property `erc-speaker' to the nick portion of the formatted speaker label. Do this to assist modules, like `button' and `match', that currently re-parse speakers in inserted messages. (erc-process-ctcp-query): Add `erc-ctcp' property to entire message before insertion hooks see it. * test/lisp/erc/erc-fill-tests.el (erc-fill-tests--compare): Warn about certain unreliable comparisons if generalizing helper for use by other modules. * test/lisp/erc/erc-tests.el (erc-tests--equal-including-properties): New helper compat macro. (erc-format-privmessage): New test. (Bug#64301)
This commit is contained in:
parent
4f3d036957
commit
6a96b86268
5 changed files with 102 additions and 18 deletions
|
|
@ -153,7 +153,10 @@
|
|||
(with-temp-file expect-file
|
||||
(insert repr))
|
||||
(if (file-exists-p expect-file)
|
||||
;; Compare set-equal over intervals
|
||||
;; Compare set-equal over intervals. This comparison is
|
||||
;; less useful for messages treated by other modules because
|
||||
;; it doesn't compare "nested" props belonging to
|
||||
;; string-valued properties, like timestamps.
|
||||
(should (equal-including-properties
|
||||
(read repr)
|
||||
(read (with-temp-buffer
|
||||
|
|
|
|||
|
|
@ -1443,6 +1443,49 @@
|
|||
(kill-buffer "ExampleNet")
|
||||
(kill-buffer "#chan")))
|
||||
|
||||
(defmacro erc-tests--equal-including-properties (a b)
|
||||
(list (if (< emacs-major-version 29)
|
||||
'ert-equal-including-properties
|
||||
'equal-including-properties)
|
||||
a b))
|
||||
|
||||
(ert-deftest erc-format-privmessage ()
|
||||
;; Basic PRIVMSG
|
||||
(should (erc-tests--equal-including-properties
|
||||
(erc-format-privmessage (copy-sequence "bob")
|
||||
(copy-sequence "oh my")
|
||||
nil 'msgp)
|
||||
#("<bob> oh my"
|
||||
0 1 (font-lock-face erc-default-face)
|
||||
1 4 (erc-speaker "bob" font-lock-face erc-nick-default-face)
|
||||
4 11 (font-lock-face erc-default-face))))
|
||||
|
||||
;; Basic NOTICE
|
||||
(should (erc-tests--equal-including-properties
|
||||
(erc-format-privmessage (copy-sequence "bob")
|
||||
(copy-sequence "oh my")
|
||||
nil nil)
|
||||
#("-bob- oh my"
|
||||
0 1 (font-lock-face erc-default-face)
|
||||
1 4 (erc-speaker "bob" font-lock-face erc-nick-default-face)
|
||||
4 11 (font-lock-face erc-default-face))))
|
||||
|
||||
;; Prefixed PRIVMSG
|
||||
(let* ((user (make-erc-server-user :nickname (copy-sequence "Bob")))
|
||||
(cuser (make-erc-channel-user :op t))
|
||||
(erc-channel-users (make-hash-table :test #'equal)))
|
||||
(puthash "bob" (cons user cuser) erc-channel-users)
|
||||
|
||||
(should (erc-tests--equal-including-properties
|
||||
(erc-format-privmessage (erc-format-@nick user cuser)
|
||||
(copy-sequence "oh my")
|
||||
nil 'msgp)
|
||||
#("<@Bob> oh my"
|
||||
0 1 (font-lock-face erc-default-face)
|
||||
1 2 (font-lock-face erc-nick-prefix-face help-echo "operator")
|
||||
2 5 (erc-speaker "Bob" font-lock-face erc-nick-default-face)
|
||||
5 12 (font-lock-face erc-default-face))))))
|
||||
|
||||
(defvar erc-tests--ipv6-examples
|
||||
'("1:2:3:4:5:6:7:8"
|
||||
"::ffff:10.0.0.1" "::ffff:1.2.3.4" "::ffff:0.0.0.0"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue