atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.77k stars 409 forks source link

Unable to apply multiple default modes and two usability questions #3221

Closed TLINDEN closed 10 months ago

TLINDEN commented 10 months ago

Describe the bug

Precise recipe to reproduce the issue

Information

ASDF version: 3.3.1 ASDF registries: (NYXT-SOURCE-REGISTRY ENVIRONMENT-SOURCE-REGISTRY) Critical dependencies: (/run/build/nyxt/_build/cl-cffi-gtk/gtk/cl-cffi-gtk.asd /run/build/nyxt/_build/cl-gobject-introspection/cl-gobject-introspection.asd /run/build/nyxt/_build/cl-webkit/webkit2/cl-webkit2.asd)


I am trying to apply multiple default modes. This is the only variant that works so far (so, only a single default mode for me currently):

(define-configuration web-buffer ((default-modes (append '(dark-mode) %slot-default%))))


In some issue someone posted this:

(define-configuration (buffer web-buffer) ((default-modes (append %slot-default% '(noscript-mode) '(noimage-mode) '(nosound-mode) '(nowebgl-mode)))))

This doesn't work, nyxt starts up, prints no errors but runs with the default configuration, it seems to ignore the whole config.

I also tried this:

(define-configuration web-buffer ((default-modes (append '(dark-mode) %slot-default%)) (default-modes (append '(noscript-mode) %slot-default%)) (default-modes (append '(reduce-tracking-mode) %slot-default%)) (default-modes (append '(blocker-mode) %slot-default%)) (default-modes (append '(nosound-mode) %slot-default%)) (default-modes (append '(nowebgl-mode) %slot-default%))))

with the same effect (none, that is)

Then I tried:

(define-configuration buffer ((default-modes (pushnew 'nyxt/mode/emacs:emacs-mode %slot-value%) (pushnew 'nyxt/mode/style:dark-mode %slot-value%))))

But this leads to an error:

Warning: malformed property list: ((PUSHNEW 'NYXT/MODE/STYLE:DARK-MODE %SLOT-VALUE%)).

[18:38:47] Warning: Error on separate thread: The value 'NYXT/MODE/STYLE:DARK-MODE is not of type SYMBOL ``` And finally I tried what I believe to be the lastest variant required to do this: ``` (defmethod customize-instance ((buffer buffer) &key) (setf (slot-value buffer 'default-modes) '(nyxt/mode/autofill:autofill-mode nyxt/mode/emacs:emacs-mode nyxt/mode/style:dark-mode base-mode)) (setf (slot-value buffer 'zoom-ratio-default) 1.3)) ``` with the same result: it ignores the configuration completely. In the log it only says: ``` Nyxt version 3.9.0 [19:49:54] Source location: #P"/app/share/nyxt/" [19:49:54] Loading Lisp file #P"/home/scip/.config/nyxt/config.lisp". [19:49:54] Listening to socket: #P"/run/user/1000/nyxt/nyxt.socket" [19:49:54] Restarting with ("nyxt" "--failsafe"). [19:49:54] Deleting socket #P"/run/user/1000/nyxt/nyxt.socket". ``` I googled for other configuration examples and found some, but none are working. While I'm at it, two questions arised during testing nyxt: 1) I am using the emacs key bindings. If I hit `C-l` then multiple suggestions are listed like new url query, history, buffer list. What is the keybinding to switch diretly to another list (say from new url to history)? 2) Also using `c-l` when I enter a url without protocol like `blog.fefe.de` nyxt doesn't try to open it but instead opens a websearch which even doesn't find the site. How can I disable this behavior? Thanks in advance, Tom
TLINDEN commented 10 months ago

PS: I found the function common-settings which allowed me to setup default modes. This is what has been generated in auto-config.3.lisp:

(defmethod customize-instance ((buffer buffer) &key)
  (setf (slot-value buffer 'default-modes)
          '(nyxt/mode/force-https:force-https-mode
            nyxt/mode/reduce-tracking:reduce-tracking-mode
            nyxt/mode/emacs:emacs-mode nyxt/mode/no-script:no-script-mode
            nyxt/mode/no-webgl:no-webgl-mode nyxt/mode/no-sound:no-sound-mode
            nyxt/mode/bookmark-frequent-visits:bookmark-frequent-visits-mode
            nyxt/mode/buffer-listing:buffer-listing-mode
            nyxt/mode/bookmarklets:bookmarklets-mode
            nyxt/mode/blocker:blocker-mode
            nyxt/mode/certificate-exception:certificate-exception-mode
            nyxt/mode/annotate:annotate-mode nyxt/mode/bookmark:bookmark-mode
            nyxt/mode/history:history-mode nyxt/mode/password:password-mode
            nyxt/mode/hint:hint-mode nyxt/mode/document:document-mode
            nyxt/mode/search-buffer:search-buffer-mode
            nyxt/mode/autofill:autofill-mode
            nyxt/mode/spell-check:spell-check-mode base-mode)))

But again it runs in failsafe mode, no errors are being logged, the config is being ignored.

aartaka commented 10 months ago

The simplest ans safest option here is to replace %slot-default% with %slot-value% in the config you posted initially. This way, the changes will accumulate on top of defaults, instead of overriding defaults every time.

customize-instance is a powerful thing that should rather be avoided until a case so complex that define-configuration couldn't handle it.

aartaka commented 10 months ago

While I'm at it, two questions arised during testing nyxt:

1) I am using the emacs key bindings. If I hit C-l then multiple suggestions are listed like new url query, history, buffer list. What is the keybinding to switch diretly to another list (say from new url to history)?

I use C-[ and C-]. There are others, probably. You can C-h m to see the description of the current prompt buffer and C-h b to list and run prompt-related commands.

2) Also using c-l when I enter a url without protocol like blog.fefe.de nyxt doesn't try to open it but instead opens a websearch which even doesn't find the site. How can I disable this behavior?

Nyxt appends https:// to the URLs, but it does so asynchronously and thus not instantaneously. If you wait for a fraction of second, the scheme will be appended and you'd be able to open the website directly.

aadcg commented 10 months ago

@TLINDEN You're having trouble configuring Nyxt because you're lacking pre-requisite knowledge in Common Lisp. I'll not go into details but the Lisp forms you've shared to configure default-modes aren't valid. Follow the sample below:

(define-configuration web-buffer
  ((default-modes (append '(nyxt/mode/blocker:blocker-mode
                            nyxt/mode/force-https:force-https-mode)
                          %slot-value%))))

Nyxt is being started in failsafe mode due to the mistakes in your config. Please delete /home/scip/.config/nyxt/config.lisp or the offending contents.


What is the keybinding to switch diretly to another list (say from new url to history)?

Shift-down/up works for any keyscheme. If you're using the Emacs keyscheme, M-n/p and M-[/] are also bound.

Run f1 b to get a list of available prompt buffer commands.


Also using c-l when I enter a url without protocol like blog.fefe.de nyxt doesn't try to open it but instead opens a websearch which even doesn't find the site. How can I disable this behavior?

I find that to be unintuitive as well, despite the advice @aartaka gave you. I'd suggest opening an issue mentioning that particular quirk.

aadcg commented 10 months ago

Closing. Feel free to ask more questions @TLINDEN. There's also a forum at https://discourse.atlas.engineer/.