Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New emoji input features in Emacs 29 #199

Closed
alphapapa opened this issue Aug 10, 2023 · 9 comments
Closed

New emoji input features in Emacs 29 #199

alphapapa opened this issue Aug 10, 2023 · 9 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@alphapapa
Copy link
Owner

@phil-s posted this in the room, which seems to be a very clever solution:

(defun my-ement-room-send-common-reaction (key position)
  "Send a reaction."
  (interactive
   (list (minibuffer-with-setup-hook #'emoji-insert
           (read-string "Reaction: "))
         (point)))
  (ement-room-send-reaction key position))

The (r)ecent sub-menu seems to cater for the "commonly used" case nicely enough (although I've not yet checked whether/how that is persisted between sessions).

Using emoji-search there also works, provided that enable-recursive-minibuffers is enabled.

@alphapapa alphapapa self-assigned this Aug 10, 2023
@alphapapa alphapapa added the enhancement New feature or request label Aug 10, 2023
@alphapapa alphapapa added this to the 0.12 milestone Aug 10, 2023
@alphapapa
Copy link
Owner Author

@oantolin suggested this additional hack:

(minibuffer-with-setup-hook
    (lambda ()
      (setq-local after-change-functions
                  (list (lambda (&rest _) (exit-minibuffer)))) 
      (emoji-insert))
  (read-string "Reaction: "))

@progfolio
Copy link
Contributor

Replacing the ement-room-send-message-filter variable with a hook function run in the context of the compose buffer would allow for this and much more.
See: #200 for a WIP implementation/examples.

@oantolin
Copy link
Contributor

I have a demo implementation. It's not in a form applicable as a PR, but I could easily do that too, if there's interest. I mention it here so people can try out this UX idea and see if they like it:

  • there is a user option to pick between what command is used to choose the emoji, but
  • you can always C-g out of it and choose a different such command.

@alphapapa
Copy link
Owner Author

@oantolin That does look useful, yes. If you have time to prepare a PR or draft PR, feel free.

oantolin added a commit to oantolin/ement.el that referenced this issue Aug 11, 2023
oantolin added a commit to oantolin/ement.el that referenced this issue Aug 11, 2023
@alphapapa alphapapa modified the milestones: 0.12, 0.13 Aug 31, 2023
@alphapapa alphapapa modified the milestones: 0.13, 0.14 Oct 3, 2023
@alphapapa alphapapa modified the milestones: 0.14, 0.15 Oct 29, 2023
@phil-s
Copy link

phil-s commented Nov 11, 2023

I was playing with a little tweak to jump directly to the "Recent" menu simply by having r typed automatically:

(defun my-ement-room-send-common-reaction (key position)
  "Send a reaction."
  (interactive
   (list (minibuffer-with-setup-hook
             (lambda ()
               (activate-input-method 'emoji)
               (push ?r unread-command-events)
               (emoji-insert))
           (read-string "Reaction: "))
         (point)))
  (ement-room-send-reaction key position))

It turned out that in Emacs 29 that "Recent" sub-menu is different to the others, not only in the fact that it builds the options dynamically, but also in being separate from the rest of the transient menu such that you can't 'back out' of that sub-menu with C-g in the way that you can in the other sub-menus. That made it less useful to start in that sub-menu, as it then wouldn't be possible to reach the others.

I didn't understand transient.el enough to figure out how to fix that, but when I tested in my build of Emacs 30 I found that the problem was fixed there.

I then confirmed that emoji.el from my 30.0.50 build also worked in Emacs 29.

So if you want to, you can just copy that version of the library and then my hack works quite nicely.

@phil-s
Copy link

phil-s commented Mar 23, 2024

I noticed that I'd updated that code since then (to ensure there is an event at point to react to), so here's what I'm currently using. Notes from the previous comment still apply.

(defun my-ement-room-send-common-reaction (key position &optional event)
  "Send a reaction."
  (interactive
   (let ((event (ewoc-data (ewoc-locate ement-ewoc))))
     (unless (ement-event-p event)
       (user-error "No event at point"))
     (list (minibuffer-with-setup-hook
               (lambda ()
                 (activate-input-method 'emoji)
                 (push ?r unread-command-events)
                 (call-interactively #'emoji-insert))
             (read-string "Reaction: "))
           (point)
           event)))
  (ement-room-send-reaction key position event))

@alphapapa
Copy link
Owner Author

@phil-s Forgive me, as I haven't grokked these new features yet: Do these "hacks" of yours need to be added to Ement itself to go with Omar's patch? Or are they just for interested users to add to their configs?

@phil-s
Copy link

phil-s commented Apr 1, 2024

My snippets were independent of #201. I haven't actually tried that PR so I'm not sure how it compares, but I expect it achieves much the same goal and that no one would need my code now that the PR has been merged.

@phil-s
Copy link

phil-s commented Apr 1, 2024

I've tried it now, and the only "advantage" of my code was that it automatically jumped into the "recent" emoji listing. But (a) I'd needed the emoji.el from Emacs 30 to make that work properly (I couldn't C-g back to the root level otherwise); and (b) in the end it's only the difference between typing s r and s r r; so I don't think that's anything to worry about.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants