How to make my key bindings work on the prompt buffer too?

Hi guys,

Until now, I have a humble config file for Nyxt:


;; keybindings: small Emacs experience in CUA (default binding of Nyxt)

(define-configuration buffer
  ((override-map (let ((map (make-keymap "override-map")))
                    (define-key map
                      "M-x" 'execute-command
                      "C-n" 'nyxt/web-mode:scroll-down
                      "C-p" 'nyxt/web-mode:scroll-up
                      "C-f" 'nyxt/web-mode:scroll-right
                      "C-b" 'nyxt/web-mode:scroll-left
                      "M-s->" 'nyxt/web-mode:scroll-to-bottom
                      "M-s-<" 'nyxt/web-mode:scroll-to-top
                      "C-s" 'nyxt/web-mode:search-buffer)))))

In general, it works for me. There is one point annoying me, though.

I would like to use C-n and C-p to go up and down on the prompt buffer as I choose an option. Currently, I can only do that using the arrow keys up and down.

I am craving for the UX that you have in Emacs when using the Helm package. There, you can use both arrow keys or C-n and C-p.

Is it possible to configure the prompt buffer navigation keys? [I guess so]

How can I do it?

Thanks in advance.

Seems that you have recreated the emacs bindings that exist by default, look at my config for an idea of how to do it :smiley:

1 Like

The key is this:

(default-modes (append '(emacs-mode) %slot-default%))

Yeah, I thought that extending the default binding to be exactly what I want incrementally could be an interesting exercise to understand config files better :shushing_face: (maybe it was a bad idea)

Thanks!

Now it works, I have my “Helm UX” inside Nyxt cua default binding extended :grinning_face_with_smiling_eyes:

(define-configuration buffer
  ((override-map (let ((map (make-keymap "override-map")))
                    (define-key map
                      "M-x" 'execute-command
                      "C-n" 'nyxt/web-mode:scroll-down
                      "C-p" 'nyxt/web-mode:scroll-up
                      "C-f" 'nyxt/web-mode:scroll-right
                      "C-b" 'nyxt/web-mode:scroll-left
                      "C-g" 'query-selection-in-search-engine
                      "M-s->" 'nyxt/web-mode:scroll-to-bottom
                      "M-s-<" 'nyxt/web-mode:scroll-to-top
                      "C-s" 'nyxt/web-mode:search-buffer)))))

(define-configuration (prompt-buffer)
    ((default-modes (append '(emacs-mode) %slot-default%))
     (hide-suggestion-count-p t)))