Subject: Re: bug#65993: 29.1; emoji-insert show nothing without font settings

From: [email-masked]
Date: Sun, 17 Sep 2023 18:37:02 +0900

Eli Zaretskii <[email-masked]> writes:

>> >> And once emoji-insert is called before font setting,
>> >> emoji-insert does not show emoji items after they are made visible in
>> >> emacs buffer with font settings.
>> >
>> > This is not a bug: you need to clear the font cache to get Emacs to
>> > react to newly-installed fonts without restarting Emacs.  Like this:
>> >
>> >   M-: (clear-font-cache) RET
>> 
>> Evaluating (clear-font-cache) have no effect on emoji-insert.
>> Perhaps menu items are cached in another place.
>
> Maybe.  You can also try clear-composition-cache.  If that doesn't
> help either, just restart the session.  Installing new fonts and
> reconfiguring fontsets while running Emacs is not fully supported, due
> to many caches we have for fonts and compositions.

The definition of emoji-insert is as below:
  (defun emoji-insert ()
    "Choose and insert an emoji glyph."
    (interactive "*")
    (emoji--init)
    (unless (fboundp 'emoji--command-Emoji)
      (emoji--define-transient))
    (funcall (intern "emoji--command-Emoji")))

The function emoji--init evaluates (require 'emoji-labels).
In the file emoji-labels.el, the variable emoji--labels is defined.
Its value is a hierarchical alist of emoji menu.
Then, inside the function emoji--init, non-displayable emojis in
emoji--labels are removed from alist.
After the function emoji--init, many functions are automatically
generated. Each of them corresponds to one item of emoji menu,
from which non-displayable emojis are already removed.
Finally emoji-insert calls the function of the top menu.

To change the emoji menu, I need to evaluate:
  (progn (load emoji-labels) (emoji--init))
This form resets emoji--labels and redefines menu functions.

I think the removal of non-displayable emojis is unnecessary.
If hex numbers are displayed, users can notice there are more emojis
than displayable. If it is difficult to find displayable emojis among
many non-displayable emojis, the menu classification is not
appropriate. Too many emojis in one menu node make user unable to find
the purpose emoji.