Skip to content

Commit

Permalink
Change: Always send rich replies, remove ement-room-send-rich-replies
Browse files Browse the repository at this point in the history
* ement-room.el (ement-room-send-rich-replies):
* ement-lib.el (ement-room-send-rich-replies, ement-send-message):
Always send rich replies.
  • Loading branch information
Visuwesh committed Apr 18, 2024
1 parent e1b02bc commit 6ec7d31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
11 changes: 4 additions & 7 deletions ement-lib.el
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
(defvar ement-room-buffer-name-prefix)
(defvar ement-room-buffer-name-suffix)
(defvar ement-room-leave-kill-buffer)
(defvar ement-room-send-rich-replies)
(defvar ement-room-prism)
(defvar ement-room-prism-color-adjustment)
(defvar ement-room-prism-minimum-contrast)
Expand Down Expand Up @@ -1113,15 +1112,14 @@ suggested room."
(alist-get selected-name name-to-room-session nil nil #'string=)))

(cl-defun ement-send-message (room session
&key body formatted-body replying-to-event rich-reply filter then)
&key body formatted-body replying-to-event filter then)
"Send message to ROOM on SESSION with BODY and FORMATTED-BODY.
THEN may be a function to call after the event is sent
successfully. It is called with keyword arguments for ROOM,
SESSION, CONTENT, and DATA.
REPLYING-TO-EVENT may be an event the message is
in reply to; the message will reference it appropriately.
If RICH-REPLY is non-nil, then a rich-reply is sent instead.
FILTER may be a function through which to pass the message's
content object before sending (see,
Expand All @@ -1144,10 +1142,9 @@ e.g. `ement-room-send-org-filter')."
(when filter
(setf content (funcall filter content room)))
(when replying-to-event
(when ement-room-send-rich-replies
;; TODO: Submit a patch to Emacs to enable `map-nested-elt' to work as a generalized variable.
(setf (map-elt (map-elt (map-elt content 'm.relates_to) 'm.in_reply_to) 'event_id)
(ement-event-id replying-to-event)))
;; TODO: Submit a patch to Emacs to enable `map-nested-elt' to work as a generalized variable.
(setf (map-elt (map-elt (map-elt content 'm.relates_to) 'm.in_reply_to) 'event_id)
(ement-event-id 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
Expand Down
8 changes: 0 additions & 8 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -710,14 +710,6 @@ When using a light theme, it may be necessary to use a negative
number (to darken rather than lighten)."
:type 'integer)

(defcustom ement-room-send-rich-replies nil
;; TODO: Switch this default to non-nil in the future, and eventually remove the option.
"Whether to send rich replies when replying to messages.
When non-nil, \"rich replies\" are sent, which encode the
relationship between messages in their metadata."
:type 'boolean
:link '(url-link "https://spec.matrix.org/v1.3/client-server-api/#rich-replies"))

;;;; Macros

(defmacro ement-room-with-highlighted-event-at (position &rest body)
Expand Down

0 comments on commit 6ec7d31

Please sign in to comment.