Skip to content

Commit

Permalink
Release: v0.16
Browse files Browse the repository at this point in the history
  • Loading branch information
alphapapa committed Oct 12, 2024
2 parents e120fdb + 26bf5a4 commit 2b39a87
Show file tree
Hide file tree
Showing 7 changed files with 340 additions and 137 deletions.
23 changes: 23 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,29 @@ Ement.el doesn't support encrypted rooms natively, but it can be used transparen
:TOC: :depth 0
:END:

** 0.16

*Compatibility*

+ 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]]).

*Additions*

+ 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.

*Changes*

+ 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.)

*Fixes*
+ 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.)
+ 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]].)
+ Command ~ement-disconnect~ no longer shows an error message. ([[https://github.com/alphapapa/ement.el/issues/208][#208]].)
+ 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.)
+ 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]].)
+ Customization group for options ~ement-room-mode-hook~ and ~ement-room-self-insert-mode~. (Thanks to [[https://github.com/phil-s][Phil Sainty]].)
+ Inheritance for some faces. ([[https://github.com/alphapapa/ement.el/pull/303][#303]]. Thanks to [[https://github.com/tarsius][Jonas Bernoulli]].)

** 0.15.1

*Fixes*
Expand Down
82 changes: 57 additions & 25 deletions ement-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,8 @@ e.g. `ement-room-send-org-filter')."
(when filter
(setf content (funcall filter content room)))
(when replying-to-event
(setf content (ement--add-reply content replying-to-event room)))
(setf replying-to-event (ement--original-event-for replying-to-event session)
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.
Expand Down Expand Up @@ -1363,6 +1364,15 @@ Suitable for use in completion, etc."
(format "%s/_matrix/media/r0/download/%s/%s"
uri-prefix server-name media-id)))

(defun ement--mxc-to-endpoint (uri)
"Return API endpoint for MXC URI.
Returns string suitable for the ENDPOINT argument to `ement-api'."
(string-match (rx "mxc://" (group (1+ (not (any "/"))))
"/" (group (1+ anything))) uri)
(let ((server-name (match-string 1 uri))
(media-id (match-string 2 uri)))
(format "media/download/%s/%s" server-name media-id)))

(defun ement--remove-face-property (string value)
"Remove VALUE from STRING's `face' properties.
Used to remove the `button' face from buttons, because that face
Expand Down Expand Up @@ -1632,33 +1642,34 @@ problems."
(cl-incf (ement-session-transaction-id session))
(format-time-string "%s")))

(defun ement--user-displayname-in (room user)
"Return the displayname for USER in ROOM."
(defun ement--user-displayname-in (room user &optional recalculatep)
"Return the displayname for USER in ROOM.
If RECALCULATEP, force recalculation; otherwise return a cached
name if available."
;; SPEC: <https://matrix.org/docs/spec/client_server/r0.6.1#calculating-the-display-name-for-a-user>.
;; FIXME: Add step 3 of the spec. For now we skip to step 4.

;; NOTE: Both state and timeline events must be searched. (A helpful user
;; in #matrix-dev:matrix.org, Michael (t3chguy), clarified this for me).
(if-let ((cached-name (gethash user (ement-room-displaynames room))))
cached-name
;; Put timeline events before state events, because IIUC they should be more recent.
(cl-labels ((join-displayname-event-p (event)
(and (eq user (ement-event-sender event))
(equal "m.room.member" (ement-event-type event))
(equal "join" (alist-get 'membership (ement-event-content event)))
(alist-get 'displayname (ement-event-content event)))))
;; FIXME: Should probably sort the relevant events to get the latest one.
(if-let* ((displayname (or (cl-loop for event in (ement-room-timeline room)
when (join-displayname-event-p event)
return (alist-get 'displayname (ement-event-content event)))
(cl-loop for event in (ement-room-state room)
when (join-displayname-event-p event)
return (alist-get 'displayname (ement-event-content event)))))
(calculated-name displayname))
(puthash user calculated-name (ement-room-displaynames room))
;; No membership state event: use pre-calculated displayname or ID.
(or (ement-user-displayname user)
(ement-user-id user))))))
(or (unless recalculatep
(gethash user (ement-room-displaynames room)))
(cl-labels ((event-sets-displayname (event)
(and (eq user (ement-event-sender event))
(equal "m.room.member" (ement-event-type event))
(equal "join" (alist-get 'membership (ement-event-content event)))
(alist-get 'displayname (ement-event-content event)))))
;; Search timeline events before state events, because IIUC they should be more
;; recent. Also, we assume that the timeline and state events are sorted
;; most-recent-first, so the first such event found is the one to use.
(puthash user (or (cl-loop for event in (ement-room-timeline room)
when (event-sets-displayname event)
return it)
(cl-loop for event in (ement-room-state room)
when (event-sets-displayname event)
return it)
;; FIXME: Add step 3 of the spec. For now we skip to step 4.
;; No membership state event: use pre-calculated displayname or ID.
(ement-user-displayname user)
(ement-user-id user))
(ement-room-displaynames room)))))

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

(cl-defun ement--media-request
(mxc session &key queue (then #'ignore) (else #'ement-api-error)
(as 'binary) (authenticatedp t))
"Request media from MXC URL on SESSION.
If AUTHENTICATEDP, send authenticated request. Arguments THEN,
ELSE, and AS are passed to `ement-api' for authenticated media
requests, or to `plz' for unauthenticated ones, each which see.
If QUEUE, send request on it."
(declare (indent defun))
(if authenticatedp
(ement-api session (ement--mxc-to-endpoint mxc) :version "v1"
:json-read-fn as :then then :else else :queue queue)
;; Send unauthenticated request.
(if queue
(plz-run
(plz-queue queue
'get (ement--mxc-to-url mxc session) :as as
:then then :else else :noquery t))
(plz 'get (ement--mxc-to-url mxc session) :as as
:then then :else else :noquery t))))

;;; Footer

(provide 'ement-lib)
Expand Down
8 changes: 4 additions & 4 deletions ement-room-list.el
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Set automatically when `ement-room-list-mode' is activated.")
;;;;; Persistent variables

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

;;;; Customization

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

(defface ement-room-list-invited
'((t (:inherit italic ement-room-list-name)))
'((t (:inherit (italic ement-room-list-name))))
"Invited rooms.")

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

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

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

(defface ement-room-list-unread
'((t (:inherit bold ement-room-list-name)))
'((t (:inherit (bold ement-room-list-name))))
"Unread rooms.")

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

0 comments on commit 2b39a87

Please sign in to comment.