meow icon indicating copy to clipboard operation
meow copied to clipboard

What is `<remap>` in minibuffer?

Open Esnos33 opened this issue 9 months ago • 3 comments

Hi, what does <remap> key mean in minibuffer? I can't find any information about it outside this issue https://github.com/meow-edit/meow/issues/481 image

Esnos33 avatar May 06 '24 18:05 Esnos33

Have you found something out meanwhile?

zikajk avatar Jul 28 '24 15:07 zikajk

@zikajk I didn't find anything in meow github, but in emacs you can encounter when you are reading keymap. For example, when you run M-x describe-keymap ENTER meow-keymap, the new buffer will open with i formation <remap> <describe-key> meow-describe-key meaning if I would press key that normaly runs "describe-key" command, you will run "meow-describe-key" command.

Esnos33 avatar Aug 01 '24 20:08 Esnos33

I found this pretty annoying as well, since it persists across all meow-keypads.

The issue might be related to the function meow--keypad-get-keymap-for-describe (note that in meow-keymap.el, meow-keymap is initialized to a keymap which creates a keybinding for [remap describe-key], but modifying the definition to initialize an empty keymap didn't fix the issue). Indeed, evaluating (meow--keypad-get-keymap-for-describe) returns a keymap definition which includes (remap keymap (self-insert-command . undefined)).

It doesn't look like <remap> actually does anything useful, so the code base could probably be updated to directly remove any call to remap. But just in case it's there for some under-the-hood reason, a simple and safe solution is to just remove it from the keypad just before it's displayed:

(defun advice-remove-meow-remap (orig-fun &rest args)
  "Advice to remove the remap entry from the keymap returned by foo."
  (let ((keymap (apply orig-fun args)))
    (if-let ((remap (assq 'remap keymap)))
        (delq remap keymap)
      keymap)))

(advice-add #'meow--keypad-get-keymap-for-describe :around #'advice-remove-meow-remap)

ahan98 avatar Aug 16 '24 21:08 ahan98