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

How do I capture keys in a popup-tip? #68

Open
stsquad opened this issue Mar 25, 2014 · 2 comments
Open

How do I capture keys in a popup-tip? #68

stsquad opened this issue Mar 25, 2014 · 2 comments

Comments

@stsquad
Copy link

stsquad commented Mar 25, 2014

I was looking at enhancing git-messenger to copy the commit for a given commit to the kill-ring if a certain key was pressed. It seems hard to do this with the popup-tip and using the menu machinery seems excessive given I don't want to loose the info in the tip. Any tips?

@syohex
Copy link
Contributor

syohex commented Mar 30, 2014

Sorry too late reply.
There is no way to capture key now.

But you can archive it by hook of git-messenger and global-map as below.

(defvar my/git-messenger-last-message nil)

(defun my/git-messenger-hook (message)
  (setq my/git-messenger-last-message message))

(add-hook 'git-messenger:before-popup-hook 'my/git-messenger-hook)

(defun my/git-messenger-copy-message ()
  (interactive)
  (with-temp-buffer
    (if (not my/git-messenger-last-message)
        (message "no message")
      (insert my/git-messenger-last-message)
      (copy-region-as-kill (point-min) (point-max)))))

(global-set-key (kbd "C-c C-q") 'my/git-messenger-copy-message)

@stsquad
Copy link
Author

stsquad commented Mar 31, 2014

That's doable but using the global-map is sub-optimal as you need to ensure you have cleared bindings after the message has been displayed. It would really be useful to have some way of capturing keys only while the popup is active.

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

No branches or pull requests

2 participants