From 05f89d711d5c0fa6cc7852e23c9aded885e4a832 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Sun, 31 May 2026 19:44:26 -0700 Subject: [PATCH] Fix more missing faces on ERC margin strings * lisp/erc/erc-goodies.el (keep-place-indicator): Add `erc-keep-place-indicator-arrow' face to overlay arrow. * lisp/erc/erc-stamp.el (erc-stamp--display-prompt-in-left-margin) (erc--conceal-prompt): Add `erc-prompt-face' to entire `left-margin' string. See also 9ba65aa9 "Fix missing margin face on display prop in erc-stamp". * test/lisp/erc/erc-fill-tests.el (erc-fill--left-hand-stamps): Update expected text properties on prompt. (Bug#80693) --- lisp/erc/erc-goodies.el | 22 ++++++++++++---------- lisp/erc/erc-stamp.el | 21 +++++++++++++-------- test/lisp/erc/erc-fill-tests.el | 30 ++++++++++++++++-------------- 3 files changed, 41 insertions(+), 32 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index f1f92923ea2..e99d5f68175 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -399,16 +399,18 @@ This module is local to individual buffers." (progn (erc--restore-initialize-priors erc-keep-place-indicator-mode erc--keep-place-indicator-overlay (make-overlay 0 0)) - (when-let* (((memq erc-keep-place-indicator-style '(t arrow))) - (ov-property (if (zerop (fringe-columns 'left)) - 'after-string - 'before-string)) - (display (if (zerop (fringe-columns 'left)) - `((margin left-margin) ,overlay-arrow-string) - '(left-fringe right-triangle - erc-keep-place-indicator-arrow))) - (bef (propertize " " 'display display))) - (overlay-put erc--keep-place-indicator-overlay ov-property bef)) + (when (memq erc-keep-place-indicator-style '(t arrow)) + (overlay-put + erc--keep-place-indicator-overlay + (if (zerop (fringe-columns 'left)) 'after-string 'before-string) + (propertize " " 'display + (if (zerop (fringe-columns 'left)) + `((margin left-margin) + ,(propertize overlay-arrow-string + 'font-lock-face + 'erc-keep-place-indicator-arrow)) + '(left-fringe right-triangle + erc-keep-place-indicator-arrow))))) (when (memq erc-keep-place-indicator-style '(t face)) (overlay-put erc--keep-place-indicator-overlay 'face 'erc-keep-place-indicator-line))) diff --git a/lisp/erc/erc-stamp.el b/lisp/erc/erc-stamp.el index bf1018f58b6..fa4b829b4cf 100644 --- a/lisp/erc/erc-stamp.el +++ b/lisp/erc/erc-stamp.el @@ -478,7 +478,7 @@ and `erc-stamp--margin-left-p', before activating the mode." (defun erc-stamp--display-prompt-in-left-margin () "Show prompt in the left margin with padding." - (when (or (not erc-stamp--last-prompt) (functionp erc-prompt) + (when (or (null erc-stamp--last-prompt) (functionp erc-prompt) (> (string-width erc-stamp--last-prompt) left-margin-width)) (let ((s (buffer-substring erc-insert-marker (1- erc-input-marker)))) ;; Prevent #("abc" n m (display ((...) #("abc" p q (display...)))) @@ -489,7 +489,9 @@ and `erc-stamp--margin-left-p', before activating the mode." ;; This papers over a subtle off-by-1 bug here. (unless (equal sm s) (setq s (concat sm (substring s -1)))))) - (setq erc-stamp--last-prompt (string-pad s left-margin-width nil t)))) + (setq erc-stamp--last-prompt + (propertize (string-pad s left-margin-width nil t) + 'font-lock-face 'erc-prompt-face)))) (put-text-property erc-insert-marker (1- erc-input-marker) 'display `((margin left-margin) ,erc-stamp--last-prompt)) erc-stamp--last-prompt) @@ -505,12 +507,15 @@ and `erc-stamp--margin-left-p', before activating the mode." (&context (erc-stamp--display-margin-mode (eql t)) (erc-stamp--margin-left-p (eql t)) (erc-stamp--skip-left-margin-prompt-p null)) - (when-let* (((null erc--hidden-prompt-overlay)) - (prompt (string-pad erc-prompt-hidden left-margin-width nil 'start)) - (ov (make-overlay erc-insert-marker (1- erc-input-marker) - nil 'front-advance))) - (overlay-put ov 'display `((margin left-margin) ,prompt)) - (setq erc--hidden-prompt-overlay ov))) + (unless erc--hidden-prompt-overlay + (let ((ov (make-overlay erc-insert-marker (1- erc-input-marker) + nil 'front-advance))) + (overlay-put ov 'display + `((margin left-margin) + ,(propertize (string-pad erc-prompt-hidden + left-margin-width nil 'start) + 'font-lock-face 'erc-prompt-face))) + (setq erc--hidden-prompt-overlay ov)))) (defun erc-insert-timestamp-left (string) "Insert timestamps at the beginning of the line." diff --git a/test/lisp/erc/erc-fill-tests.el b/test/lisp/erc/erc-fill-tests.el index b06d600db66..780bec550f8 100644 --- a/test/lisp/erc/erc-fill-tests.el +++ b/test/lisp/erc/erc-fill-tests.el @@ -421,13 +421,14 @@ (pcase-let ((`((margin left-margin) ,displayed) (get-text-property erc-insert-marker 'display))) (should (equal-including-properties - displayed #(" ERC>" 4 8 - ( read-only t - front-sticky t - field erc-prompt - erc-prompt t - rear-nonsticky t - font-lock-face erc-prompt-face))))) + displayed #(" ERC>" + 0 4 (font-lock-face erc-prompt-face) + 4 8 ( read-only t + front-sticky t + field erc-prompt + erc-prompt t + rear-nonsticky t + font-lock-face erc-prompt-face))))) (erc-fill-tests--compare "stamps-left-01") (ert-info ("Shrink left margin by 1 col") @@ -437,13 +438,14 @@ (pcase-let ((`((margin left-margin) ,displayed) (get-text-property erc-insert-marker 'display))) (should (equal-including-properties - displayed #(" ERC>" 3 7 - ( read-only t - front-sticky t - field erc-prompt - erc-prompt t - rear-nonsticky t - font-lock-face erc-prompt-face)))))))))) + displayed #(" ERC>" + 0 3 (font-lock-face erc-prompt-face) + 3 7 ( read-only t + front-sticky t + field erc-prompt + erc-prompt t + rear-nonsticky t + font-lock-face erc-prompt-face)))))))))) (ert-deftest erc-fill--wrap-massage-legacy-indicator-type () (let (calls