Compose Emoji in GNU Emacs


Modern emojis are composable - you can compose multiple emojis into a new one. Most commonly, this is done using Zero-Width Joiner or ZWJ character (#200D). Though not all combinations are valid. The valid combinations are defined by the font. e.g. you can combine as follows:

  • Person + rocket = Astronaut
  • Person + manual wheelchair = Person on wheelchair

Following function will help you insert ZWJ in between selected text.

(defun emoji-compose ()
  "Compose emoji from components."
  (unless (region-active-p)
    (error "Select a sequence of emoji components"))
  (let* ((start (1+ (region-beginning)))
     (len (- (region-end) start)))
    (goto-char start)
    (dotimes (i len)
      (insert #x200D)

For auto-completion, you can use company-emoji.




Popular posts from this blog

Formula Editor in GNU Emacs

GNU Emacs: A configurable browser

Draw and Scribble Notes in GNU Emacs