Subject: Re: bug#67204: 29.1; request: always echo EMOJI name while emoji-list

From: Eli Zaretskii <[email-masked]>
Date: Sat, 30 Dec 2023 11:20:59 +0200

> Cc: [email-masked], [email-masked]
> Date: Fri, 29 Dec 2023 17:44:15 +0200
> From: Eli Zaretskii <[email-masked]>
> 
> > Cc: [email-masked], [email-masked]
> > Date: Fri, 29 Dec 2023 17:38:59 +0200
> > From: Eli Zaretskii <[email-masked]>
> > 
> > I cannot reproduce this.  I get:
> > 
> >   person getting massage
> >   person getting haircut
> >   person walking
> >   person running
> >   people with bunny ears
> >   woman dancing
> 
> Sorry, this was in Emacs 29.  In Emacs 20 I indeed see what you see.
> (But the OP used Emacs 29.1.)  Will investigate.

OK, I see the issue now: it's because C-f/C-b still moves by one
character in this buffer, and we basically rely on point-adjustment to
move to the next emoji.  The cases where the echo is incorrect, point
after C-f is still on the same emoji, not on the next one, whereas
after point adjustment it is on the next emoji.

The solution to that is not to show the emoji name from the
post-command-hook, but from an idle timer.  Like this:

  (add-hook #'post-command-hook
	    (lambda ()
	      (run-with-idle-timer 0.02 nil
				   (lambda ()
				     (when-let
					 ((glyph (get-text-property (point)
								    'emoji-glyph))
					  (name (emoji--name glyph)))
				       (message "%s" name)))))
	    nil 'local)

We could have this as an optional feature, or we could leave this
alone and rely on users who want this to customize their Emacs like
above.