How to overwrite default keybindings?

I’m looking for a way to paste from different sources without having to dig through the menu.

I dug through the scheme files to find the procedure that does it. I wanted to map C-S-V V to paste text verbatim, C-S-V L to paste from LaTex, and so on. I added this to my init scheme file which has other keybindings that work.

(kbd-map
  ("C-S-V v" (clipboard-paste-import "verbatim" "primary"))
)

The above code didn’t work. I assumed that since C-S-V is already used by texmacs, it’s not possible to remap it, even with extensions such as C-S-V P that are not used. My first question is, is it not possible to remap default keybindings?

I further dug through the scheme files and found /usr/share/TeXmacs/progs/generic/generic-kbd.scm. It seems that the way to do it is with code below. The pastefrom implies C-S-V. While this is not intuitive, at least there’s a way to do it. So, my next move was to take the code below and put it inside my init scheme file. For some reason that I cannot understand, it doesn’t work. The only way the the code below runs is when it is inside /usr/share/TeXmacs/progs/generic/generic-kbd.scm., which requires su privileges and can be overwritten by a new version. Any ideas why this code cannot run from inside my init scheme file?

(kbd-map
  ("pastefrom v" (clipboard-paste-import "verbatim" "primary"))
)

What happens if you replace “paste from v” with “std V v” ? Does it works? It could be that for some reason late keybindings do not get processed like the standard ones. However in prefix-kbd.scm you see what “pastefrom” translates to in each system.

That didn’t work, unfortunately. At the moment, I have added the keybindings to /usr/share/TeXmacs/progs/generic/generic-kbd.scm file, but this will get overwritten during an update.

Is it possible that “pastefrom” is not yet defined when my-init-texxmacs.scm is run? Did you try to delay the mapping? You can search the forum for “kbd-map” and/or “delayed” for examples.

(delayed
  (lazy-keyboard-force)
  (kbd-map
    ("pastefrom v" (clipboard-paste-import "verbatim" "primary"))
    ))

:slight_smile:

3 Likes