Skip to content

Commit

Permalink
Fix: (ement-room-send-reaction) Bail out early when there's no event …
Browse files Browse the repository at this point in the history
…at point
  • Loading branch information
Phil Sainty committed Dec 2, 2023
1 parent 7b78c13 commit 72bbb28
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -1776,17 +1776,22 @@ Interactively, to event at point."
(replying-to-event (ement--original-event-for event ement-session)))
(ement-room-send-message room session :body body :replying-to-event replying-to-event)))))

(defun ement-room-send-reaction (key position)
(defun ement-room-send-reaction (key position &optional event)
"Send reaction of KEY to event at POSITION.
Interactively, send reaction to event at point. KEY should be a
reaction string, e.g. \"👍\"."
(interactive
(list (char-to-string (read-char-by-name "Reaction (prepend \"*\" for substring search): "))
(point)))
(let ((event (ewoc-data (ewoc-locate ement-ewoc))))
(unless (ement-event-p event)
(user-error "No event at point"))
(list (char-to-string (read-char-by-name "Reaction (prepend \"*\" for substring search): "))
(point)
event)))
;; SPEC: MSC2677 <https://github.com/matrix-org/matrix-doc/pull/2677>
;; HACK: We could simplify this by storing the key in a text property...
(ement-room-with-highlighted-event-at position
(pcase-let* ((event (or (ewoc-data (ewoc-locate ement-ewoc position))
(pcase-let* ((event (or event
(ewoc-data (ewoc-locate ement-ewoc position))
(user-error "No event at point")))
;; NOTE: Sadly, `face-at-point' doesn't work here because, e.g. if
;; hl-line-mode is enabled, it only returns the hl-line face.
Expand Down

0 comments on commit 72bbb28

Please sign in to comment.