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

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

[elpa] externals-release/ement 2078ad4605 04/12: Merge: Support for m.au


From: ELPA Syncer
Subject: [elpa] externals-release/ement 2078ad4605 04/12: Merge: Support for m.audio events
Date: Thu, 25 Jan 2024 21:57:56 -0500 (EST)

branch: externals-release/ement
commit 2078ad46058bfb3f87ae08424a45f1543da1b854
Merge: d55751927f a3cbeeade1
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Merge: Support for m.audio events
    
    See <https://github.com/alphapapa/ement.el/pull/231>.
---
 README.org    |  1 +
 ement-room.el | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/README.org b/README.org
index bb7bcdc658..a8fbb068f4 100644
--- a/README.org
+++ b/README.org
@@ -297,6 +297,7 @@ Ement.el doesn't support encrypted rooms natively, but it 
can be used transparen
 
 *Additions*
 
++ Audio events are rendered as a link to the audio file.  (Thanks to 
[[https://github.com/viiru-][Arto Jantunen]].)
 + Customization group ~ement-room-list~.
 + Option ~ement-room-list-space-prefix~ is applied to space names in the room 
list (e.g. set to empty string for cleaner appearance).
 + Option ~ement-room-reaction-names-limit~ sets how many senders of a reaction 
are shown in the buffer (more than that many are shown in the tooltip).
diff --git a/ement-room.el b/ement-room.el
index ce1088825f..8379819b86 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -3508,6 +3508,7 @@ If FORMATTED-P, return the formatted body content, when 
available."
                            ("m.image" (ement-room--format-m.image event))
                            ("m.file" (ement-room--format-m.file event))
                            ("m.video" (ement-room--format-m.video event))
+                           ("m.audio" (ement-room--format-m.audio event))
                            (_ (if (or local-redacted-by unsigned-redacted-by)
                                   nil
                                 (format "[unsupported msgtype: %s]" msgtype 
))))))
@@ -4307,6 +4308,31 @@ Then invalidate EVENT's node to show the image."
             (propertize " "
                         'display '(space :relative-height 1.5)))))
 
+(defun ement-room--format-m.audio (event)
+  "Return \"m.audio\" EVENT formatted as a string."
+  (pcase-let* (((cl-struct ement-event
+                           (content (map body
+                                         ('info (map mimetype duration size))
+                                         ('url mxc-url))))
+                event)
+               (url (when mxc-url
+                      (ement--mxc-to-url mxc-url ement-session)))
+               (human-size (file-size-human-readable size))
+               (human-duration (format-seconds "%m:%s" (/ duration 1000)))
+               (string (format "[audio: %s (%s) (%s) (%s)]" body mimetype 
human-duration human-size)))
+    (concat (propertize string
+                        'action #'browse-url
+                        'button t
+                        'button-data url
+                        'category t
+                        'face 'button
+                        'follow-link t
+                        'help-echo url
+                        'keymap button-map
+                        'mouse-face 'highlight)
+            (propertize " "
+                        'display '(space :relative-height 1.5)))))
+
 ;;;;; Org format sending
 
 ;; Some of these declarations may need updating as Org changes.



reply via email to

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