branch: externals/ement
commit 3d6056826077d0fc940d2db79734cc71a13d34c9
Merge: b6e41cf0ca 7ae4b3b359
Author: Adam Porter <a...@alphapapa.net>
Commit: Adam Porter <a...@alphapapa.net>

    Merge: Consider newlines in message format for wrap-prefix
---
 README.org    | 1 +
 ement-room.el | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/README.org b/README.org
index 237bbf02c1..a96dc75c75 100644
--- a/README.org
+++ b/README.org
@@ -348,6 +348,7 @@ Ement.el doesn't support encrypted rooms natively, but it 
can be used transparen
 *Fixes*
 + Toggling images to fill the window body no longer triggers unintended 
scrolling.  (Thanks to [[https://github.com/phil-s][Phil Sainty]].)
 + Recognition of mentions after a newline.  
([[https://github.com/alphapapa/ement.el/issues/267][#267]].  Thanks to 
[[https://github.com/phil-s][Phil Sainty]].)
++ Newlines in ~ement-room-message-format-spec~ are considered when calculating 
the wrap-prefix.  (Thanks to [[https://github.com/phil-s][Phil Sainty]].)
 
 ** 0.14
 
diff --git a/ement-room.el b/ement-room.el
index 90ca6ca1a7..e50ae7efb7 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -3898,11 +3898,11 @@ Format defaults to `ement-room-message-format-spec', 
which see."
       ;; Propertize margin text.
       (when ement-room--format-message-wrap-prefix
         (when-let ((wrap-prefix-end (next-single-property-change (point-min) 
'wrap-prefix-end)))
-          (let* ((prefix-width (string-width
-                                (buffer-substring-no-properties (point-min) 
wrap-prefix-end)))
+          (goto-char wrap-prefix-end)
+          (delete-char 1)
+          (let* ((prefix-width (string-width (buffer-substring-no-properties
+                                              (line-beginning-position) 
(point))))
                  (prefix (propertize " " 'display `((space :width 
,prefix-width)))))
-            (goto-char wrap-prefix-end)
-            (delete-char 1)
             ;; We apply the prefix to the entire event as `wrap-prefix', and 
to just the
             ;; body as `line-prefix'.
             (put-text-property (point-min) (point-max) 'wrap-prefix prefix)

Reply via email to