(Solved) Issue remapping keybind for `search-buffer` and `visual-mode`

Hello. I dont understand why I have issue remapping these functions: search-buffer and visual-mode.

(define-configuration buffer
  ;;If you want to reuse the default map,
  ;;you can use %slot-default instead of (make-keymap ...)
  ((override-map (define-key %slot-default%
                   "S-x" 'execute-command
		   "M-c" 'delete-buffer
		   "M-v" 'visual-mode
		   "M-s" 'search-buffer
                   "C-w" 'delete-current-buffer))))

Why is "M-c" 'delete-buffer works but not "M-v" 'visual-mode nor "M-s" 'search-buffer?

That’s the output I get:

$ nyxt
nyxt
<INFO> [06:43:51] Listening to socket "/run/user/1000/nyxt/nyxt.socket".
Nyxt version 2.2.3
<INFO> [06:43:51] Loading Lisp file "/home/danrobi/.config/nyxt/init.lisp".
<WARN> [06:43:52] Warning: Error on GTK thread: The value
                       VISUAL-MODE
                     is not of type
                       NYXT::NYXT-KEYMAP-VALUE
  C-c C-c^C<INFO> [06:44:15] Deleting socket "/run/user/1000/nyxt/nyxt.socket".
danrobi@Emacs-MX-Lappy:~
$ nyxt
nyxt
<INFO> [06:46:00] Listening to socket "/run/user/1000/nyxt/nyxt.socket".
Nyxt version 2.2.3
<INFO> [06:46:01] Loading Lisp file "/home/danrobi/.config/nyxt/init.lisp".
<WARN> [06:46:01] Warning: Error on GTK thread: The value
                       SEARCH-BUFFER
                     is not of type
                       NYXT::NYXT-KEYMAP-VALUE
  C-c C-c^C<INFO> [06:46:13] Deleting socket "/run/user/1000/nyxt/nyxt.socket".

Indeed, this one is often a source of confusion.

We have Lisp packages (think C++ namespaces) to cleanly encapsulate modes and their commands and prevent pollution of nyxt-user namespace. That’s why, when you bind keys to commands, you need to use proper package prefixes.

In case of visual-mode, the prefix is predictable: nyxt/visual-mode:. It’s basically the mode name prefixed by nyxt/.

In case of search-buffer it’s less obvious. The prefix is nyxt/web-mode, as search-buffer is part of web-mode.

delete-buffer belongs to base-mode, the mode all the commands from which are exported to nyxt-user, that’s why you can use it unprefixed.

The procedure to find the proper prefix is:

  • Call execute-command (C-space in CUA, M-x in Emacs, : in VI).
  • Type in the name of command you want to bind.
  • Look at the “Mode” column. This column will have something like web-mode or auto-mode.
  • Prefix the mode name with nyxt/. You’ve got a package name.
  • Add a command name after the package name, and separate those by a colon.
  • You’ve got a full name of the command, like nyxt/visual-mode:visual-mode or nyxt/web-mode:search-buffer!
1 Like

This bind keys to commands explanation should find his way into the Documentation. Very, very well explaned. Thank you much @aartaka works like a charm :slight_smile: