From 82da4557752245ff5c7c864c551de7bf01efc5ff Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 1 Aug 2021 05:51:58 -0500 Subject: [PATCH] Add: (ement-room-send-reaction) Use reaction at point --- README.org | 2 +- ement-room.el | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index 76c5637..1538f4e 100644 --- a/README.org +++ b/README.org @@ -107,7 +107,7 @@ If you want to install it manually, it's simple enough, but you should know what + Write new message: ~RET~ + Write reply to event at point (when region is active, only quote marked text) : ~S-RET~ -+ Send reaction (a type of annotation) to event at point: ~a~ ++ Send reaction (a type of annotation) to event at point, or send same reaction at point: ~a~ *Viewing rooms* diff --git a/ement-room.el b/ement-room.el index e686520..35c5e97 100644 --- a/ement-room.el +++ b/ement-room.el @@ -732,7 +732,15 @@ The message must be one sent by the local user." (interactive) (pcase-let* ((event (or (ewoc-data (ewoc-locate ement-ewoc)) (user-error "No event at point"))) - (key (char-to-string (read-char-by-name "Reaction (prepend \"*\" for substring search): "))) + ;; 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. + (face-at-point (get-text-property (point) 'face)) + ;; FIXME: Doesn't seem that `cl-typecase' can handle this, but maybe `pcase' in Emacs 27/28? + (key (if (or (eq 'ement-room-reactions-key face-at-point) + (and (listp face-at-point) + (member 'ement-room-reactions-key face-at-point))) + (char-to-string (char-after (point))) + (char-to-string (read-char-by-name "Reaction (prepend \"*\" for substring search): ")))) ((cl-struct ement-event (id event-id)) event) ((cl-struct ement-session server token) ement-session) ((cl-struct ement-room (id room-id)) ement-room)