(require 'transient) (defun emoji-pick-read-affixation (names) (mapcar (lambda (name) (list name (char-to-string (char-from-name (concat "EMOJI MODIFIER FITZPATRICK TYPE-" name))))) names)) (defun emoji-pick-read-tone (prompt initial-input history) (let* ((names '("1-2" "3" "4" "5" "6")) (str (completing-read prompt (lambda (string pred action) (if (eq action 'metadata) `(metadata (affixation-function . ,'emoji-pick-read-affixation)) (complete-with-action action names string pred))) nil t initial-input history))) (char-to-string (char-from-name (concat "EMOJI MODIFIER FITZPATRICK TYPE-" str))))) (transient-define-infix emoji-pick:--skin-tone () :description "Skin tone" :class 'transient-option :shortarg "-s" :argument "" :prompt "Skin tone: " :reader 'emoji-pick-read-tone) (transient-define-prefix emoji-pick () ["Variations" (emoji-pick:--skin-tone)] [["Emoji" ("s" "🤷" emoji-shrug) ("y" "👍" emoji-yes)]] (interactive) (transient-setup 'emoji-pick)) (defun emoji-shrug (&optional variation) (interactive (transient-args 'emoji-pick)) (insert (concat "🤷" variation))) (defun emoji-yes (&optional variation) (interactive (transient-args 'emoji-pick)) (insert (concat "👍" variation)))