branch: externals/ement
commit 7ae4b3b359afee57486925bb6e067fc879737a76
Author: Phil Sainty <p...@catalyst.net.nz>
Commit: Adam Porter <a...@alphapapa.net>

    Fix: (ement-room--format-message) %W considers only the current line
    
    When the format contains newlines, only the line containing %W is used
    to establish the width of the wrap-prefix.  Previously the widths of
    any preceding lines were included as well.
    
    Closes #182.
---
 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