Skip to content

Commit 835ce50

Browse files
committed
Check emoji commands exist before offering them
1 parent a9f06e9 commit 835ce50

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

ement-room.el

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,12 @@ Used to, e.g. call `ement-room-compose-org'.")
188188
(defvar ement-room-reaction-map
189189
(let ((map (make-sparse-keymap)))
190190
(define-key map "c" #'insert-char)
191-
(define-key map "i" 'emoji-insert)
192-
(define-key map "s" 'emoji-search)
193-
(define-key map "m" #'ement-room-select-emoji-input-method)
191+
(when (commandp 'emoji-insert)
192+
(define-key map "i" 'emoji-insert))
193+
(when (commandp 'emoji-search)
194+
(define-key map "s" 'emoji-search))
195+
(when (assoc "emoji" input-method-alist)
196+
(define-key map "m" #'ement-room-use-emoji-input-method))
194197
map)
195198
"Keymap used in `ement-room-send-reaction'.")
196199

@@ -405,12 +408,15 @@ emoji and inserts it into the current buffer. In Emacs 29
405408
reasonable choices include `emoji-insert' which uses a transient
406409
interface, and `emoji-search' which uses `completing-read'. If
407410
those are not available, one can use `insert-char'."
408-
:type '(choice
411+
:type `(choice
409412
(const :tag "Complete unicode character name" insert-char)
410-
(const :tag "Complete emoji name" emoji-search)
411-
(const :tag "Transient emoji menu" emoji-insert)
412-
(const :tag "Emoji input method"
413-
ement-room-select-emoji-input-method)
413+
,@(when (commandp 'emoji-insert)
414+
'((const :tag "Transient emoji menu" emoji-insert)))
415+
,@(when (commandp 'emoji-search)
416+
'((const :tag "Complete emoji name" emoji-search)))
417+
,@(when (assoc "emoji" input-method-alist)
418+
'((const :tag "Emoji input method"
419+
ement-room-use-emoji-input-method)))
414420
(const :tag "Type an emoji without assistance" ignore)
415421
(function :tag "Use other command")))
416422

@@ -1739,10 +1745,11 @@ The message must be one sent by the local user."
17391745
(ement-room-read-string prompt nil nil nil 'inherit-input-method))))
17401746
(ement-room-send-message room session :body body :replying-to-event event))))
17411747

1742-
(defun ement-room-select-emoji-input-method ()
1743-
"Activate the emoji input method in the current buffer."
1744-
(interactive)
1745-
(set-input-method "emoji"))
1748+
(when (assoc "emoji" input-method-alist)
1749+
(defun ement-room-use-emoji-input-method ()
1750+
"Activate the emoji input method in the current buffer."
1751+
(interactive)
1752+
(set-input-method "emoji")))
17461753

17471754
(defun ement-room-send-reaction (key position)
17481755
"Send reaction of KEY to event at POSITION.

0 commit comments

Comments
 (0)