Skip to content

Commit

Permalink
Change: Make reaction function customisable
Browse files Browse the repository at this point in the history
  • Loading branch information
Visuwesh committed May 8, 2022
1 parent e54ad99 commit bf707b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ement-room.el
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ In that case, sender names are aligned to the margin edge.")
(defvar ement-sessions)
(defvar ement-users)
(defvar ement-notify-limit-room-name-width)
(defvar ement-read-reaction)

;;;; Customization

Expand Down Expand Up @@ -1402,8 +1403,8 @@ reaction string, e.g. \"👍\"."
(lambda () (face-at-point-p 'ement-room-reactions-key)))))))
(list
(or (key-at (point))
(char-to-string (read-char-by-name "Reaction (prepend \"*\" for substring search): ")))
(point))))
(funcall ement-read-reaction)
(point)))))
;; 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))
Expand Down
11 changes: 11 additions & 0 deletions ement.el
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ Alist mapping user IDs to a list of room aliases/IDs to open buffers for."
:type '(alist :key-type (string :tag "Local user ID")
:value-type (repeat (string :tag "Room alias/ID"))))

(defcustom ement-read-reaction #'ement-read-reaction
"Function that prompts the user for reaction string.
The function is called with no arguments and should return a
string to be used as the reaction."
:type '(choice (const :tag "Default function" #'ement-read-reaction)
(const :tag "Custom function" function)))

;;;; Commands

;;;###autoload
Expand Down Expand Up @@ -1384,6 +1391,10 @@ To be called after initial sync."
(when-let ((child-room (cl-find child-id rooms :key #'ement-room-id :test #'equal)))
(cl-pushnew parent-id (alist-get 'parents (ement-room-local child-room)) :test #'equal))))))))

(defun ement-read-reaction ()
"Prompt user for reaction and return it."
(char-to-string (read-char-by-name "Reaction (prepend \"*\" for substring search): ")))

;;;; Footer

(provide 'ement)
Expand Down

0 comments on commit bf707b0

Please sign in to comment.