Add: (ement-room-send-reaction) Use reaction at point

This commit is contained in:
Adam Porter 2021-08-01 05:51:58 -05:00
parent e800c04f3b
commit 82da455775
2 changed files with 10 additions and 2 deletions

View file

@ -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*

View file

@ -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)