>From 41e15143e16a842fc4ae072d28a647f25c58fdb8 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Sat, 24 Jun 2023 18:33:20 -0700 Subject: [PATCH] [5.6] Don't clobber erc-nick-prefix-face * lisp/erc/erc-fill.el (erc-fill-wrap): Look for `erc-speaker' property before falling back on word at point. * lisp/erc/erc.el (erc-send-action): Ensure nickname passed to `erc-display-message' has `erc-speaker' property. (erc--own-property-names): Add `erc-speaker'. (erc-format-privmessage): Retain face applied to a leading stretch of characters in the `nick' parameter. But continue to discard any trailing faces. (erc-format-privmessage, erc-format-my-nick, erc-ctcp-query-ACTION): Add a new text property, `erc-speaker', to the nick portion of the formatted speaker label. Do this to assist modules, like `button' and `match', that re-parse speakers in inserted messages. --- lisp/erc/erc-fill.el | 10 +++++++++- lisp/erc/erc.el | 22 ++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lisp/erc/erc-fill.el b/lisp/erc/erc-fill.el index 5115e45210d..acc07e7a6af 100644 --- a/lisp/erc/erc-fill.el +++ b/lisp/erc/erc-fill.el @@ -428,8 +428,16 @@ erc-fill-wrap (let ((len (or (and erc-fill--wrap-length-function (funcall erc-fill--wrap-length-function)) (progn + (when-let ((b (next-single-property-change + (point) 'erc-speaker nil (pos-eol))) + ((not (= (pos-eol) b))) + ;; String vals `eq' along same stretch + (e (text-property-not-all + b (pos-eol) 'erc-speaker + (get-text-property b 'erc-speaker)))) + (goto-char e)) (skip-syntax-forward "^-") - (forward-char) + (skip-syntax-forward "-") ;; Using the `invisible' property might make more ;; sense, but that would require coordination ;; with other modules, like `erc-match'. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 70adbb15b5f..c7720221115 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -2724,9 +2724,11 @@ erc-send-action (let ((erc-insert-pre-hook (cons (lambda (s) ; Leave newline be. (put-text-property 0 (1- (length s)) 'erc-command 'PRIVMSG s)) - erc-insert-pre-hook))) + erc-insert-pre-hook)) + (nick (erc-current-nick))) + (setq nick (propertize nick 'erc-speaker nick)) (erc-display-message nil 'input (current-buffer) - 'ACTION ?n (erc-current-nick) ?a str ?u "" ?h ""))) + 'ACTION ?n nick ?a str ?u "" ?h ""))) ;; Display interface @@ -4532,7 +4534,7 @@ erc-ensure-channel-name (concat "#" channel))) (defvar erc--own-property-names - '( tags erc-parsed display ; core + '( tags erc-speaker erc-parsed display ; core ;; `erc-display-prompt' rear-nonsticky erc-prompt field front-sticky read-only ;; stamp @@ -5037,11 +5039,18 @@ erc-format-privmessage (mark-e (if msgp (if privp "*" ">") "-")) (str (format "%s%s%s %s" mark-s nick mark-e msg)) (nick-face (if privp 'erc-nick-msg-face 'erc-nick-default-face)) + (nick-prefix-face (get-text-property 0 'font-lock-face nick)) + (prefix-len (or (text-property-not-all 0 (length nick) 'font-lock-face + nick-prefix-face nick) + 0)) (msg-face (if privp 'erc-direct-msg-face 'erc-default-face))) ;; add text properties to text before the nick, the nick and after the nick (erc-put-text-property 0 (length mark-s) 'font-lock-face msg-face str) - (erc-put-text-property (length mark-s) (+ (length mark-s) (length nick)) - 'font-lock-face nick-face str) + (erc-put-text-properties (+ (length mark-s) prefix-len) + (+ (length mark-s) (length nick)) + '(font-lock-face erc-speaker) str + (list nick-face + (substring-no-properties nick prefix-len))) (erc-put-text-property (+ (length mark-s) (length nick)) (length str) 'font-lock-face msg-face str) str)) @@ -5093,7 +5102,7 @@ erc-format-my-nick (concat (propertize open 'font-lock-face 'erc-default-face) (propertize mode 'font-lock-face 'erc-my-nick-prefix-face) - (propertize nick 'font-lock-face 'erc-my-nick-face) + (propertize nick 'font-lock-face 'erc-my-nick-face 'erc-speaker nick) (propertize close 'font-lock-face 'erc-default-face))) (let ((prefix "> ")) (propertize prefix 'font-lock-face 'erc-default-face)))) @@ -5366,6 +5375,7 @@ erc-ctcp-query-ACTION (buf (or (erc-get-buffer to proc) (erc-get-buffer nick proc) (process-buffer proc)))) + (setq nick (propertize nick 'erc-speaker nick)) (erc-display-message parsed 'action buf 'ACTION ?n nick ?u login ?h host ?a s)))) -- 2.40.1