auto-complete / popup-el

Visual Popup Interface Library for Emacs
GNU General Public License v3.0
445 stars 96 forks source link

Keymap doesn't work with popup-menu* #142

Closed doomchild closed 6 months ago

doomchild commented 8 months ago

I'm trying to figure out exactly how to interact with popups, and I'm getting a result I don't expect. Specifically, if I pass a keymap to popup-menu*, it appears to render all key presses void except for "C-g". Here's what I'm doing:

(defun temp-select (popup i)
  (message "popup %s" popup))

(setq temp-keymap
      (let ((keymap (make-sparse-keymap)))
        (set-keymap-parent keymap popup-menu-keymap)
        (define-key keymap [return] 'temp-select)
       keymap))

(popup-menu* '("Thing" "Other")
             :width 30
             :keymap temp-keymap
             :margin-left 2
             :margin-right 2
             :scroll-bar t)

When I evaluate the above, the popup shows up like I expect but the only key sequence that has any effect at all is "C-g", which cancels everything and hides the popup. I thought that making a sparse keymap with the popup-menu-keymap as the parent meant that any keys I didn't override would use what's already in popup-menu-keymap, and that my temp-select function would print a message to the *Messages* buffer, but instead nothing happens at all until I cancel.

Are my expectations wrong, or am I doing something incorrect, or what?

doomchild commented 6 months ago

In case some other doomed soul happens upon this, the problem was that the function attached to temp-keymap needed to be an interactive function.