emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ement 2ea81a0057: Fix: Message format filter when writi


From: ELPA Syncer
Subject: [elpa] externals/ement 2ea81a0057: Fix: Message format filter when writing replies
Date: Fri, 31 Mar 2023 03:58:10 -0400 (EDT)

branch: externals/ement
commit 2ea81a00572e96b4878f73f20abd841db07f6ed4
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Fix: Message format filter when writing replies
    
    This fix is in two parts:
    
    * ement-lib.el (ement-send-message): Apply the message filter before
    adding reply content.
    
    * ement-room.el (ement-room-send-org-filter): Use (setf (alist-get
    ...)) instead of (push ...), because the latter can duplicate the keys
    in the alist (which json-encode dutifully passes on to the Matrix
    server, and who knows which one it may choose).
    
    Fixes #30.  Thanks to @Wibjarm for reporting and @jeffbowman for
    investigating.
---
 README.org    | 1 +
 ement-lib.el  | 4 ++--
 ement-room.el | 4 ++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/README.org b/README.org
index d91bfd8d16..f7c08aa002 100644
--- a/README.org
+++ b/README.org
@@ -310,6 +310,7 @@ Note that, while ~matrix-client~ remains usable, and 
probably will for some time
 
 *Fixes*
 
++ Message format filter works properly when writing replies.
 + Improve insertion of sender name headers when using the "Elemental" message 
format.
 + Prompts in commands ~ement-leave-room~ and ~ement-forget-room~.
 
diff --git a/ement-lib.el b/ement-lib.el
index c04eb8bf11..ebf21190f1 100644
--- a/ement-lib.el
+++ b/ement-lib.el
@@ -1082,10 +1082,10 @@ e.g. `ement-room-send-org-filter')."
                             (push (cons "formatted_body" formatted-body) it)
                             (push (cons "format" "org.matrix.custom.html") 
it))))
                (then (or then #'ignore)))
-    (when replying-to-event
-      (setf content (ement--add-reply content replying-to-event room)))
     (when filter
       (setf content (funcall filter content room)))
+    (when replying-to-event
+      (setf content (ement--add-reply content replying-to-event room)))
     (ement-api session endpoint :method 'put :data (json-encode content)
       :then (apply-partially then :room room :session session
                              ;; Data is added when calling back.
diff --git a/ement-room.el b/ement-room.el
index 4bd4f6f409..35ba8524c9 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -4161,8 +4161,8 @@ compatibility), and the result is added to the CONTENT as
                     (with-current-buffer "*Org HTML Export*"
                       (prog1 (string-trim (buffer-string))
                         (kill-buffer)))))))
-    (push (cons "formatted_body" formatted-body) content)
-    (push (cons "format" "org.matrix.custom.html") content)
+    (setf (alist-get "formatted_body" content nil nil #'equal) formatted-body
+          (alist-get "format" content nil nil #'equal) 
"org.matrix.custom.html")
     content))
 
 (defun ement-room--org-html-src-block (src-block _contents info)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]