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

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

[elpa] externals-release/ement d3154cabb8 07/12: Fix: (ement-room-send-r


From: ELPA Syncer
Subject: [elpa] externals-release/ement d3154cabb8 07/12: Fix: (ement-room-send-reaction) Bail out early when there's no event at point
Date: Thu, 25 Jan 2024 21:57:58 -0500 (EST)

branch: externals-release/ement
commit d3154cabb84ffdede17f34afb1b1869bf3531e42
Author: Phil Sainty <phil@catalyst.net.nz>
Commit: Adam Porter <adam@alphapapa.net>

    Fix: (ement-room-send-reaction) Bail out early when there's no event at 
point
---
 ement-room.el | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/ement-room.el b/ement-room.el
index 51792b914f..423551dd56 100644
--- a/ement-room.el
+++ b/ement-room.el
@@ -1783,17 +1783,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.



reply via email to

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