Subject: Re: bug#63731: [PATCH] Support Emoji Variation Sequence 16 (FE0F) where appropriate

From: Robert Pluim <[email-masked]>
Date: Sun, 28 May 2023 13:57:49 +0200

>>>>> On Fri, 26 May 2023 20:27:26 +0300, Eli Zaretskii <[email-masked]> said:
    >> 
    >> Itʼs a change to the VS-16 entry. We did discuss it before, and
    >> decided to put it aside because the solutions all involved adding
    >> composition-function-table entries for 0-9 or similar. I donʼt
    >> remember why we didnʼt consider adding to VS-16ʼs entry.
    >> 
    >> Iʼll do some more testing, and post a final version hopefully this
    >> weekend sometime.

    Eli> OK, thanks.

Eli, if the 20e3 changes are too much for emacs-29, I can put them in
master.

Iʼll put some notes in admin/notes/unicode as well.

diff --git c/admin/unidata/emoji-zwj.awk i/admin/unidata/emoji-zwj.awk
index 7d2ff6cb900..0b6f1267205 100644
--- c/admin/unidata/emoji-zwj.awk
+++ i/admin/unidata/emoji-zwj.awk
@@ -82,6 +82,7 @@ END {
      trigger_codepoints[11] = "1F574"
      trigger_codepoints[12] = "1F575"
      trigger_codepoints[13] = "1F590"
+     trigger_codepoints[14] = "20E3"
 
      printf "(setq auto-composition-emoji-eligible-codepoints\n"
      printf "'("
diff --git c/lisp/composite.el i/lisp/composite.el
index fb8b76114f4..acba4e73c17 100644
--- c/lisp/composite.el
+++ i/lisp/composite.el
@@ -762,6 +762,23 @@ compose-gstring-for-dotted-circle
 	 (if (memq val '(Mn Mc Me))
 	     (set-char-table-range composition-function-table key elt)))
      unicode-category-table))
+  ;; for Emoji presentation selector
+  ;; We don't want the generic nil 0 entry because it causes display
+  ;; of an extra box for FE0F.  (Bug#63731)
+  ;; This also covers the fully-qualified enclosing keycap case.
+  (set-char-table-range
+   composition-function-table
+   #xFE0E
+   `([,(purecopy "\\c.\ufe0e") 1 compose-gstring-for-graphic]))
+  (set-char-table-range
+   composition-function-table
+   #xFE0F
+   `([,(purecopy "\\c.\ufe0f\u20e3?") 1 compose-gstring-for-graphic]))
+  ;; for unqualified enclosing keycap
+  (set-char-table-range
+   composition-function-table
+   #x20E3
+   `([,(purecopy "[#*0-9]\u20e3") 1 compose-gstring-for-graphic]))
   ;; for dotted-circle
   (aset composition-function-table #x25CC
 	`([,(purecopy ".\\c^") 0 compose-gstring-for-dotted-circle]))
@@ -857,11 +874,10 @@ compose-gstring-for-variation-glyph
 ;; taken care of by font_range in font.c, which will check for an
 ;; emoji font for codepoints used in compositions even if they're not
 ;; emoji themselves, and thus choose the Emoji presentation for them
-;; when followed by VS-16.  VS-15 *is* handled here, because if it's
-;; handled in font_range, we end up choosing the Emoji presentation
-;; rather than the Text presentation.
+;; when followed by VS-16.  VS-15 is handled by the setup around
+;; unicode-category-table above.
 (let ((elt '([".." 1 compose-gstring-for-variation-glyph])))
-  (set-char-table-range composition-function-table '(#xFE00 . #xFE0E) elt)
+  (set-char-table-range composition-function-table '(#xFE00 . #xFE0D) elt)
   (set-char-table-range composition-function-table '(#xE0100 . #xE01EF) elt))
 
 (defun auto-compose-chars (func from to font-object string direction)

Robert
--