Skip to content

Commit 2b39a87

Browse files
committed
Release: v0.16
2 parents e120fdb + 26bf5a4 commit 2b39a87

File tree

7 files changed

+340
-137
lines changed

7 files changed

+340
-137
lines changed

README.org

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,29 @@ Ement.el doesn't support encrypted rooms natively, but it can be used transparen
297297
:TOC: :depth 0
298298
:END:
299299

300+
** 0.16
301+
302+
*Compatibility*
303+
304+
+ Use authenticated media requests (part of Matrix 1.11; see [[https://github.com/matrix-org/matrix-spec-proposals/pull/3916][MSC3916]] and [[https://matrix.org/blog/2024/06/26/sunsetting-unauthenticated-media/][matrix.org's sunsetting unauthenticated media]]).
305+
306+
*Additions*
307+
308+
+ When option ~ement-room-images~ is disabled (preventing automatic download and display of images), individual images may be shown by clicking the button in their events.
309+
310+
*Changes*
311+
312+
+ Option ~ement-room-coalesce-events~ may now be set to (and defaults to) a maximum number of events to coalesce together. (This avoids potential performance problems in rare cases. See [[https://github.com/alphapapa/ement.el/issues/247][#247]]. Thanks to [[https://github.com/viiru-][Arto Jantunen]] for reporting and [[https://github.com/sergiodj][Sergio Durigan Junior]] for testing.)
313+
314+
*Fixes*
315+
+ Replies to edited messages are correctly sent to the original event (whereas previously they were sent to the edit, which caused reactions to not be shown). ([[https://github.com/alphapapa/ement.el/issues/230][#230]], [[https://github.com/alphapapa/ement.el/issues/277][#277]]. Thanks to [[https://github.com/phil-s][Phil Sainty]] for suggesting, and to [[https://github.com/dionisos2][dionisos]] for reporting.)
316+
+ Set ~filter-buffer-substring-function~ in room buffers to prevent undesired text properties from being included in copied text. ([[https://github.com/alphapapa/ement.el/pull/278][#278]]. Thanks to [[https://github.com/phil-s][Phil Sainty]].)
317+
+ Command ~ement-disconnect~ no longer shows an error message. ([[https://github.com/alphapapa/ement.el/issues/208][#208]].)
318+
+ Retrieval of earlier events in a just-joined room. ([[https://github.com/alphapapa/ement.el/issues/148][#148]]. Thanks to [[https://github.com/MagicRB][Richard Brežák]] for reporting, and to [[https://github.com/phil-s][Phil Sainty]] for testing.)
319+
+ Cache computed displaynames in rooms (avoiding unnecessary reiteration and recalculation). ([[https://github.com/alphapapa/ement.el/issues/298][#298]]. Thanks to [[https://github.com/Rutherther][Rutherther]] for reporting and testing, and to [[https://github.com/phil-s][Phil Sainty]].)
320+
+ Customization group for options ~ement-room-mode-hook~ and ~ement-room-self-insert-mode~. (Thanks to [[https://github.com/phil-s][Phil Sainty]].)
321+
+ Inheritance for some faces. ([[https://github.com/alphapapa/ement.el/pull/303][#303]]. Thanks to [[https://github.com/tarsius][Jonas Bernoulli]].)
322+
300323
** 0.15.1
301324

302325
*Fixes*

ement-lib.el

Lines changed: 57 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,8 @@ e.g. `ement-room-send-org-filter')."
11421142
(when filter
11431143
(setf content (funcall filter content room)))
11441144
(when replying-to-event
1145-
(setf content (ement--add-reply content replying-to-event room)))
1145+
(setf replying-to-event (ement--original-event-for replying-to-event session)
1146+
content (ement--add-reply content replying-to-event room)))
11461147
(ement-api session endpoint :method 'put :data (json-encode content)
11471148
:then (apply-partially then :room room :session session
11481149
;; Data is added when calling back.
@@ -1363,6 +1364,15 @@ Suitable for use in completion, etc."
13631364
(format "%s/_matrix/media/r0/download/%s/%s"
13641365
uri-prefix server-name media-id)))
13651366

1367+
(defun ement--mxc-to-endpoint (uri)
1368+
"Return API endpoint for MXC URI.
1369+
Returns string suitable for the ENDPOINT argument to `ement-api'."
1370+
(string-match (rx "mxc://" (group (1+ (not (any "/"))))
1371+
"/" (group (1+ anything))) uri)
1372+
(let ((server-name (match-string 1 uri))
1373+
(media-id (match-string 2 uri)))
1374+
(format "media/download/%s/%s" server-name media-id)))
1375+
13661376
(defun ement--remove-face-property (string value)
13671377
"Remove VALUE from STRING's `face' properties.
13681378
Used to remove the `button' face from buttons, because that face
@@ -1632,33 +1642,34 @@ problems."
16321642
(cl-incf (ement-session-transaction-id session))
16331643
(format-time-string "%s")))
16341644

1635-
(defun ement--user-displayname-in (room user)
1636-
"Return the displayname for USER in ROOM."
1645+
(defun ement--user-displayname-in (room user &optional recalculatep)
1646+
"Return the displayname for USER in ROOM.
1647+
If RECALCULATEP, force recalculation; otherwise return a cached
1648+
name if available."
16371649
;; SPEC: <https://matrix.org/docs/spec/client_server/r0.6.1#calculating-the-display-name-for-a-user>.
1638-
;; FIXME: Add step 3 of the spec. For now we skip to step 4.
1639-
16401650
;; NOTE: Both state and timeline events must be searched. (A helpful user
16411651
;; in #matrix-dev:matrix.org, Michael (t3chguy), clarified this for me).
1642-
(if-let ((cached-name (gethash user (ement-room-displaynames room))))
1643-
cached-name
1644-
;; Put timeline events before state events, because IIUC they should be more recent.
1645-
(cl-labels ((join-displayname-event-p (event)
1646-
(and (eq user (ement-event-sender event))
1647-
(equal "m.room.member" (ement-event-type event))
1648-
(equal "join" (alist-get 'membership (ement-event-content event)))
1649-
(alist-get 'displayname (ement-event-content event)))))
1650-
;; FIXME: Should probably sort the relevant events to get the latest one.
1651-
(if-let* ((displayname (or (cl-loop for event in (ement-room-timeline room)
1652-
when (join-displayname-event-p event)
1653-
return (alist-get 'displayname (ement-event-content event)))
1654-
(cl-loop for event in (ement-room-state room)
1655-
when (join-displayname-event-p event)
1656-
return (alist-get 'displayname (ement-event-content event)))))
1657-
(calculated-name displayname))
1658-
(puthash user calculated-name (ement-room-displaynames room))
1659-
;; No membership state event: use pre-calculated displayname or ID.
1660-
(or (ement-user-displayname user)
1661-
(ement-user-id user))))))
1652+
(or (unless recalculatep
1653+
(gethash user (ement-room-displaynames room)))
1654+
(cl-labels ((event-sets-displayname (event)
1655+
(and (eq user (ement-event-sender event))
1656+
(equal "m.room.member" (ement-event-type event))
1657+
(equal "join" (alist-get 'membership (ement-event-content event)))
1658+
(alist-get 'displayname (ement-event-content event)))))
1659+
;; Search timeline events before state events, because IIUC they should be more
1660+
;; recent. Also, we assume that the timeline and state events are sorted
1661+
;; most-recent-first, so the first such event found is the one to use.
1662+
(puthash user (or (cl-loop for event in (ement-room-timeline room)
1663+
when (event-sets-displayname event)
1664+
return it)
1665+
(cl-loop for event in (ement-room-state room)
1666+
when (event-sets-displayname event)
1667+
return it)
1668+
;; FIXME: Add step 3 of the spec. For now we skip to step 4.
1669+
;; No membership state event: use pre-calculated displayname or ID.
1670+
(ement-user-displayname user)
1671+
(ement-user-id user))
1672+
(ement-room-displaynames room)))))
16621673

16631674
(defun ement--xml-escape-string (string)
16641675
"Return STRING having been escaped with `xml-escape-string'.
@@ -1791,6 +1802,27 @@ seconds, etc."
17911802
choices)))
17921803
(read-multiple-choice prompt choices (format help-format help-choices))))
17931804

1805+
(cl-defun ement--media-request
1806+
(mxc session &key queue (then #'ignore) (else #'ement-api-error)
1807+
(as 'binary) (authenticatedp t))
1808+
"Request media from MXC URL on SESSION.
1809+
If AUTHENTICATEDP, send authenticated request. Arguments THEN,
1810+
ELSE, and AS are passed to `ement-api' for authenticated media
1811+
requests, or to `plz' for unauthenticated ones, each which see.
1812+
If QUEUE, send request on it."
1813+
(declare (indent defun))
1814+
(if authenticatedp
1815+
(ement-api session (ement--mxc-to-endpoint mxc) :version "v1"
1816+
:json-read-fn as :then then :else else :queue queue)
1817+
;; Send unauthenticated request.
1818+
(if queue
1819+
(plz-run
1820+
(plz-queue queue
1821+
'get (ement--mxc-to-url mxc session) :as as
1822+
:then then :else else :noquery t))
1823+
(plz 'get (ement--mxc-to-url mxc session) :as as
1824+
:then then :else else :noquery t))))
1825+
17941826
;;; Footer
17951827

17961828
(provide 'ement-lib)

ement-room-list.el

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ Set automatically when `ement-room-list-mode' is activated.")
123123
;;;;; Persistent variables
124124

125125
(persist-defvar ement-room-list-visibility-cache nil
126-
"Applied to `magit-section-visibility-cache', which see.")
126+
"Applied to `magit-section-visibility-cache', which see.")
127127

128128
;;;; Customization
129129

@@ -162,7 +162,7 @@ Set automatically when `ement-room-list-mode' is activated.")
162162
"Favourite rooms.")
163163

164164
(defface ement-room-list-invited
165-
'((t (:inherit italic ement-room-list-name)))
165+
'((t (:inherit (italic ement-room-list-name))))
166166
"Invited rooms.")
167167

168168
(defface ement-room-list-left
@@ -173,15 +173,15 @@ Set automatically when `ement-room-list-mode' is activated.")
173173
"Low-priority rooms.")
174174

175175
(defface ement-room-list-name
176-
'((t (:inherit font-lock-function-name-face button)))
176+
'((t (:inherit (font-lock-function-name-face button))))
177177
"Non-direct rooms.")
178178

179179
(defface ement-room-list-space '((t (:inherit (font-lock-regexp-grouping-backslash ement-room-list-name))))
180180
"Space rooms."
181181
:group 'ement-room-list)
182182

183183
(defface ement-room-list-unread
184-
'((t (:inherit bold ement-room-list-name)))
184+
'((t (:inherit (bold ement-room-list-name))))
185185
"Unread rooms.")
186186

187187
(defface ement-room-list-recent '((t (:inherit font-lock-warning-face)))

0 commit comments

Comments
 (0)