How to unset a key binding?

Hello all,

I’ve been watching the Nyxt project for a few years now, and have decided to take the plunge. I’ve spent several hours reading the Nyxt documentation, reading up on Common Lisp, hacking with Portacle, and experimenting with Nyxt. Though I haven’t quite found my feet, I’m starting off small and trying to unset some bindings in emacs mode using my ~/.local/nyxt/init.lisp file.

I’ve noticed that M-f and M-b default to navigate forwards and backwards. I’d like to remove those bindings, just to see what happens, but the Nyxt manual only shows how to add new bindings using a custom my-keymap global list. Here’s part of a snippet to add custom bindings that I found in the manual:

(define-key *my-keymap*
  "C-f" 'nyxt/web-mode:history-forwards
  "C-b" 'nyxt/web-mode:history-backwards)

I got that working; next step is to try unsetting some of the default bindings.

Thinking it through, I’d imagine that the default bindings are stored in a global list. To remove a binding, would I just put some Common Lisp to remove an item from a list into my init.lisp file? Something like this pseudo-code?

;; LOL, I'm just making it up because I don't know much yet
(remove-item-from-a-list *global-keymap* "M-f")
(remove-item-from-a-list *global-keymap* "M-b")

How could I figure out where the key bindings are kept? I’m not at the point yet where I can get Slime to do anything useful, and I’m still having trouble finding things with C-h c|f|h|C. Does anyone have a suggestion about how to find things like a list inside a Lisp machine when you don’t know its name?

Once I know where the bindings are kept, should I just add my own Lisp code to edit the bindings list in init.lisp, or is there a better way to remove bindings? Looking forward to reading others’ thoughts on Nyxt and Lisp hacking. Thanks!

Hello!
There’s a paragraph in the manual (M-x manual), but an example would be this. The “global list” you were looking for was %slot-default%, but I don’t think you need to unset a keybinding first (I think™), the one in the config should take precedence.

EDIT: ah, my extreme-late-night brain missed that you wanted to unset them to see what happened. A kind of unset would probably be to bind the keys to nil. Not tested.

Thanks waleee-cl,

That’s a great idea. I tried setting the bindings to nil, but the M-f and M-b keys were still active after reloading the config file. However, I eventually found the noop command at the very bottom of the features page, and that did disable the keys:

(define-key *my-keymap*
  "C-f" 'nyxt/web-mode:history-forwards
  "C-b" 'nyxt/web-mode:history-backwards
  "M-f" 'noop
  "M-b" 'noop
  )

Thanks for helping guide me to the right place! It’s useful to unset some keys while my keyboard muscle memory adjusts.

1 Like