popper icon indicating copy to clipboard operation
popper copied to clipboard

Assign keybindings to popper buffers

Open Qkessler opened this issue 3 years ago • 7 comments

Hi there, Thank you so much for your work, I use popper daily! Rather than an issue, this is more of a question that I'm sure will not take much of your time. Maybe I missed something in the README, but I was wondering about assigning keybindings to popper buffers. I have tried assigning to buffers with popper-mode activated, without success, as popper-mode is enabled for all buffers, if enabled at startup. Does anybody have any ideas on how to assign keybindings to only buffers on the "popup state"? Thanks in advance! Best, Enrique.

Qkessler avatar Jan 02 '22 09:01 Qkessler

@Qkessler I don't understand what you mean by "assign keybindings to only buffers on the popup state". Can you give me an example of a specific action you would like to take?

karthink avatar Jan 03 '22 00:01 karthink

Hey there,

Sure, no problem. The use case that I have in mind is defining the cycle and toggle-type functions only for buffers that are considered popups.

Thanks for the response, Enrique.

On 2022-01-02, 16:06 -0800, karthink @.***> wrote:

@Qkessler I don't understand what you mean by "assign keybindings to only buffers on the popup state". Can you give me an example of a specific action you would like to take?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

-- Enrique Kessler Martínez

Qkessler avatar Jan 03 '22 08:01 Qkessler

Isn't this already the case? The cycle and toggle actions only apply to popup buffers.

On Mon, Jan 3, 2022, 12:17 AM Enrique Kessler Martínez < @.***> wrote:

Hey there,

Sure, no problem. The use case that I have in mind is defining the cycle and toggle-type functions only for buffers that are considered popups.

Thanks for the response, Enrique.

On 2022-01-02, 16:06 -0800, karthink @.***> wrote:

@Qkessler I don't understand what you mean by "assign keybindings to only buffers on the popup state". Can you give me an example of a specific action you would like to take?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

-- Enrique Kessler Martínez

— Reply to this email directly, view it on GitHub https://github.com/karthink/popper/issues/20#issuecomment-1003929801, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACBVOLGWYBUN434D4GYQZPTUUFLS7ANCNFSM5LDPI5OQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you commented.Message ID: @.***>

karthink avatar Jan 03 '22 17:01 karthink

Sure! I was trying to assign the keys for only buffers in that state, not on every buffer but only applied in a popup buffer. Another example that comes to mind is using N for example to cycle when on a popup buffer (I use evil). Thanks again, Best, Enrique.

On Mon, Jan 3, 2022 at 18:25 karthink @.***> wrote:

Isn't this already the case? The cycle and toggle actions only apply to popup buffers.

On Mon, Jan 3, 2022, 12:17 AM Enrique Kessler Martínez < @.***> wrote:

Hey there,

Sure, no problem. The use case that I have in mind is defining the cycle and toggle-type functions only for buffers that are considered popups.

Thanks for the response, Enrique.

On 2022-01-02, 16:06 -0800, karthink @.***> wrote:

@Qkessler I don't understand what you mean by "assign keybindings to only buffers on the popup state". Can you give me an example of a specific action you would like to take?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.

-- Enrique Kessler Martínez

— Reply to this email directly, view it on GitHub https://github.com/karthink/popper/issues/20#issuecomment-1003929801, or unsubscribe < https://github.com/notifications/unsubscribe-auth/ACBVOLGWYBUN434D4GYQZPTUUFLS7ANCNFSM5LDPI5OQ

. Triage notifications on the go with GitHub Mobile for iOS < https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675

or Android < https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .

You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/karthink/popper/issues/20#issuecomment-1004241119, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALN7QXE2BKENHOKF5Q2V35LUUHLXLANCNFSM5LDPI5OQ . You are receiving this because you were mentioned.Message ID: @.***>

-- Enrique Kessler Martínez. c/ Jiménez de la espada, Cartagena, España.

Qkessler avatar Jan 03 '22 18:01 Qkessler

I'm still confused about what you're looking for. I see different interpretations:

  1. Assign custom keybindings for existing popup commands, such as popper-cycle.
  2. Define new commands to act only on popup buffers.
  3. Define a command that does something in a popup but nothing in a regular buffer.

For 1 you can just do (evil-define-key 'normal global-map (kbd "N") #'popper-cycle). 2 is more complicated, I can help if you provide a concrete example of something you want.

For 3 you can define a command as usual but use the check (popper-popup-p (current-buffer)) in a conditional.

karthink avatar Jan 03 '22 18:01 karthink

I'm interested in (3) above: concretely I would like to assign something like Q in popups to close them. Doing that via popper-popup-p seems convoluted compared to having a popper keymap in popups. What do you think?

indigoviolet avatar May 11 '22 23:05 indigoviolet

Doing that via popper-popup-p seems convoluted compared to having a popper keymap in popups. What do you think?

Popper is a global minor mode, so it's possible but not idiomatic to define buffer-specific keymaps. I would like to avoid adding this feature. Using a general command with the popper-popup-p is the most straightforward way to do it.

However, if you're specifically looking to close popups, there are a couple of built-in options. You can use popper-kill-latest-popup to kill the popup buffer, or just popper-toggle-latest to just close the window. If you're using popper-echo-mode, you can enable popper-echo-dispatch-actions and then kill any popup with k followed by the popup key. In this example, you can kill the 4th popup with k M-4:

mpv-shot0001

karthink avatar Sep 19 '22 01:09 karthink