Configuration ignored?

Hi,

I am realtively new to Nyxt but love the concept.
As I am trying to learn the basics I have setup a basic config file, following the manual, and I am simply trying to get C-space to toggle-mark mode

(define-configuration buffer
  ((default-modes (append '(emacs-mode) %slot-default%)))
  ((override-map (let ((map (make-keymap "override-map")))
                   (define-key map
                     "C-space" 'toggle-mark
                     "M-x" 'execute-command)))))

but I get no reaction, C-space still behave as execute command.

I have had the same problem with others commands I have tried to override…
any idea what I am doing wrong?

Thanks!

You have too many brackets. Try this:

(define-configuration buffer
  ((default-modes (append '(emacs-mode) %slot-default%))
   (override-map (let ((map (make-keymap "override-map")))
                   (define-key map
                     "C-space" 'toggle-mark
                     "M-x" 'execute-command)))))
1 Like

Thanks! No change however. C-space still will fire execute command instead of toggle-mark

I have tried with map C-o to execute-command - just to try a test, but it keeps opening files… so nope, I don’t see what I am doing wrong…

Where is your configuration file located? Is it located in ~/.config/nyxt/init.lisp?

For the record, I did get the following to work overriding “C-o” as you’ve mentioned:

(define-configuration buffer
  ((default-modes (append '(emacs-mode) %slot-default%))
   (override-map (let ((map (make-keymap "my-override-map")))
                   (define-key map
                     "C-o" 'execute-command
                     "C-q" 'quit
                     "C-1" 'make-window
                     "C-2" 'delete-current-window
                     "keypadleft" 'nyxt/web-mode:history-backwards
                     "keypadright" 'nyxt/web-mode:history-forwards)
                   map))))

Also, if you don’t mind, could you please paste the full contents of your configuration file?

Sorry, mistake in my snippet: we need to return the map from the let form:

(define-configuration buffer
  ((default-modes (append '(emacs-mode) %slot-default%))
   (override-map (let ((map (make-keymap "override-map")))
                   (define-key map
                     "C-space" 'toggle-mark
                     "M-x" 'execute-command)
                     map))))

Maybe better to take @jmercouris snippet as a model :wink:

No worries :slight_smile:

All help is appreciated!

yes the file is located in ~/.config/nyxt/init.lisp and I see in the log that nyxt is actually loading the file.

Current full config is :

(define-configuration buffer
  ((default-modes (append '(emacs-mode) %slot-default%)))
  ((override-map (let ((map (make-keymap "override-map")))
                   (define-key map
                     "C-o" 'execute-command
                     "M-x" 'execute-command)))))

;; Replace reddit.com with old-reddit
(defun old-reddit-handler (request-data)
  (let ((url (url request-data)))
    (setf (url request-data)
          (if (search "reddit.com" (quri:uri-host url))
              (progn
                (setf (quri:uri-host url) "old.reddit.com")
                (log:info "Switching to old Reddit: ~s" (render-url url))
                url)
              url)))
  request-data)

(define-configuration web-buffer
  ((request-resource-hook
    (hooks:add-hook %slot-default% (make-handler-resource #'old-reddit-handler)))))

I will replace the first block with yours, hopefully will work better.

Edit: I replaced it with your snippet and indeed it works! Great! Thanks!

Note that toggle-mark is not a command in the nyxt-user package. It’s in nyxt/prompt-buffer-mode however, so you need to write it as 'nyxt/prompt-buffer-mode:toggle-mark.

1 Like