Prompt buffer keybindings


First of all, thanks for the awesome product.

I’m experiencing problems with setting C-y as paste keybinding to paste something into new buffer url prompt. By diving into Nyxt code a bit deeper, I’ve find the default S-Insert which works well, but it seems to be GTK platform port binding, which is another layer of abstraction. Meanwhile, other people configurations either won’t work by now (maybe because of some semi-incompatible changes between Nyxt versions, I use 2.0.0 on NixOS) or does not give any clue on what to do further.

Could you please point me into the right direction?

Are you able to bind anything in your prompt buffer? Can you please provide a paste of what you’ve tried?

Unfortunately, I’ve dropped all previous attempts code from config at the moment, but here is a pretty literal example of what I’ve tried: nixos-config/nyxt.lisp at db9a568c3e64e8945813953fa89783203e81fb98 · tmplt/nixos-config · GitHub

PS I’ve stumbled upon upon this concrete keybinding and did not go further, so there are no more things I’ve tried to bind.

I see, what is going on. In the prompt buffer you want to actually bind nyxt/prompt-buffer-mode::select-first and nyxt/prompt-buffer-mode::select-last.

That’s a little different than just scrolling the page. I hope that helps!

Seems like I’ve suddenly misguided you. I’ve retried my attempts, and here is what actually going on.

(defvar *custom-prompt-keymap* (make-keymap "custom-prompt-map"))
(define-key *custom-prompt-keymap*
  "C-y" 'minibuffer-paste)
(define-mode custom-prompt-mode ()
  ((keymap-scheme (keymap:make-scheme
                   scheme:cua *custom-prompt-keymap*
                   scheme:emacs *custom-prompt-keymap*
                   scheme:vi-normal *custom-prompt-keymap*))))

(define-configuration prompt-buffer
    ((default-modes (append '(custom-prompt-mode emacs-mode) %slot-default%))
     ;; (default-modes `(emacs-mode ,@%slot-default%))
     (hide-single-source-header-p t)))

This is the code I added.
But here is an error pops up: “Could not load the init file: unknown type specifier: LAMBDA”

The command you are looking for is 'paste, we do not refer to it as a minibuffer anymore.

Here is a full configuration to do what you want:

(define-mode custom-prompt-mode ()
  "Mode for binding my own prompt commands."
    (define-scheme "custom-prompt-mode"
       "C-y" 'nyxt/prompt-buffer-mode::paste)
       "C-y" 'nyxt/prompt-buffer-mode::paste)
       "C-y" 'nyxt/prompt-buffer-mode::paste)))))

(define-configuration prompt-buffer
    ((default-modes (append '(custom-prompt-mode emacs-mode) %slot-default%))
     (hide-single-source-header-p t)))

Anyways, thank you for the report, it made me realize a binding was missing! I’ve since fixed it here:

1 Like

Many thanks! I’m already thinking of dig Nyxt core a bit deeper and then contribute, as I did with Stumpwm a couple of years ago. =)

That would be fantastic! We would be glad to have you onboard :slight_smile:

My problem is very similar so I’m staying on this thread

Twenty years ago I installed emacs on OSX 10.2 and started learning the damn thing for real and discovered I love lisp. Like many people I’ve always bound the Meta key to Option so I can keep the Super/Alt/Command for Mac-related things. Now that I’m on NixOS I try to keep the Mac bindings as much as possible, and you can go pretty far with a WM like openbox.

So on nyxt the natural solution would seem to be something like

(defvar *qz-base-scheme*
    (define-scheme "qz-base"
   "C-q" 'noop ; 'quit
   "C-[" 'noop ; 'switch-buffer-previous
   "C-]" 'noop ; 'switch-buffer-next
   "S-[" 'switch-buffer-previous
   "S-]" 'switch-buffer-next
...  etc )))


(define-configuration nyxt:base-mode
  ((keymap-scheme (append '(*qz-base-scheme*) %slot-default%))))

but after launching nyxt (and clicking on its window)

$ nyxt &
debugger invoked on a TYPE-ERROR in thread
#<THREAD "cl-cffi-gtk main thread" RUNNING {1008612723}>:
  The value
  is not of type
  when binding KEYMAP:SCHEME

When I remove the code from init.lisp, and evaluate things from the SLY repl things seem to be fine at first.

NYXT-USER> (keymap:scheme-p *qz-base-scheme*)
NYXT-USER> (define-configuration nyxt:base-mode 
   ((keymap-scheme (append '(*qz-base-scheme*) %slot-default%))))

But I get the debugger with the same error message when I do C-h b on the nyxt window.

Now I’m stumped.

Any idea?
Thanks in advance, and keep on the good works.

I strongly suggest binding an override-map

(define-configuration buffer
  ((override-map (let ((map (make-keymap "my-override-map")))
                   (define-key map
                     "C-q" 'quit
                     "C-1" 'make-window
                     "C-2" 'delete-current-window
                     "keypadleft" 'nyxt/web-mode:history-backwards
                     "keypadright" 'nyxt/web-mode:history-forwards)

the sample provided is mine, but you can do whatever you want. The override map is provided specifically for users to have a map that is accessible everywhere, and overwritable by no one. Whenever you are in a buffer, your override map will be active.

I ended up doing the following and it seems to work so far. Thanks.

(define-configuration buffer
  ((override-map *qz-base-overrides*)
   (default-modes (append '(nyxt::emacs-mode) %slot-default%))))

(define-configuration web-buffer
  ((override-map (keymap:compose *qz-web-overrides* *qz-base-overrides*))
   (default-modes (append '(nyxt::emacs-mode) %slot-default%))))

But what about modes that can be turned on an off? Surely there’ll be a need to customize their keymaps too.

I’d like to contribute to the documentation but I don’t understand the mechanics of the thing well enough yet.

That can be done as well. If you are curious, there are many modes in the source code you can look at :slight_smile: