atlas-engineer / nyxt

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

Keys missing in Emacs key mode #3411

Open impaktor opened 2 weeks ago

impaktor commented 2 weeks ago

I did my annual "let's give Nyxt another try" the other day, and as I'm coming into the browser with new and fresh eyes, I thought my feedback might be of interest to the project. I find many basic Emacsy-keys missing which interferes with my muscle memory. I propose adding to the default Emacs key mode:

sort order in buffer list?

In Emacs, buffer list is sorted on latest visited. I.e.

which-key functionality

As I understand it search is "C-s s", rather than just Emacsy "C-s", due to Nyxt search having more search options? It would help with a which key functionality, i.e. after a second, a half completed key sequence (like "C-s" in Nyxt) opens up mini buffer and shows the possible completing second half. This would help transitioning to (and long term use) of a keyboard driven browser, I think.

Below, in Emacs (with "which-key"), pressing C-h shows I could for instance complete the sequence with i for info, or k for describe-key.

2024-06-09-104621_1536x960_scrot

I'm sure I could give more feedback, but I did not get further for now.

aadcg commented 1 week ago

@impaktor thank you for taking the time sharing your experience.

  • PgUp -> BKSPC (symmetric with SPC for PgDn). I.e. not just C-v / M-v for PgDn/PgUp in input buffers. In Emacs buffers like Info-pages (any many other places, one would expect SPC & BKSPC to also navigate).

I doubt it would be a good default. Note that SPC and Shift+SPC correspond to PgDn (C-v) and PgUp (M-v), respectively. Backspace is often used as a "Back" command in most web browsers.

  • C-h i -> index / table of content of manual if possible (C-h t, and C-h k in Nyxt already mirror Emacs behavior)

Note that C-h r in Nyxt is bound to bringing up the manual (just like in Emacs); and there's no analog of Emacs' C-h i in Nyxt. So it seems we're being consistent.

  • ESC (abort) -> C-g This was a major pain point for me, and I tried to figure out how to re-bind it, but interestingly, to see what is bound to ESC: "C-h k ESC" does not work, nor C-h b and searching for "esc", "escape", "abort" in list of all bound keys)

It seems that you may have missed something here. We have the nothing command and it is bound to C-g by default. For instance, if you invoke the prompt buffer (via M-x) followed by C-g, it will abort it.

C-h k ESC won't show anything because the Escape key isn't bound to any command (in the context of document-mode), meaning that it is being forwarded directly to the renderer. I believe that the overall UI/UX of C-h k is very poor, and there are other issues related to it too (see #2997). Patches are welcome :)

  • F5 (reload buffer) -> g (like many popular Emacs major modes like magit, notmuch, elfeed)

The command reload-current-buffer is bound to C-r when emacs-mode is enabled. F5 is enabled when the default CUA keybindings are enabled.

We could bind it to g. Historically, however, we have always avoided binding keys that are inherently modal in emacs-mode (in other words, keys without modifier keys as prefixes). g would then mean "insert the g character" or reload-current-buffer depending on what kind of HTML element has the focus. Personally, I disagree with the chosen path since navigating the web is inherently modal. In other words, emacs-mode should be populated with keybindings that don't have modifier keys as prefixes.

To sum up, while this change won't probably happen, it would easy for the user to add this keybinding in their config.

  • Possibly remove C-SPC all together (I see there's code in the manual for doing this on per-config basis, I'm merely suggesting having it removed by default in "Emacs mode" of Nyxt.)

I can't think of any good reason that would prompt for such a change.

  • "C-x b RET" would switch to penultimate visited buffer,

I agree 100%. The reason why it doesn't exhibit that behavior is because the current buffer suggestion at the prompt buffer sets the main buffer. In other words, it would be jarring for switch-buffer to immediately change the buffer view. See commit c61c17ddd023b6690ca2af672878d40f1f69538f. I find the current iteration a bit clumsy though. In my view, a better default would be to list the last visited buffer at the top of the prompt buffer; and disable having the main buffer follow the prompt buffer's current buffer suggestion. But we'd need to discuss it with @jmercouris.

which-key functionality

I think this kind of functionality doesn't belong to Nyxt's core, just like it doesn't belong to Emacs' core. I have tried which-key in Emacs and quickly realized that it doesn't provide enough value in my experience. Obviously, others may disagree. But that's precisely the point - that kind of functionality is better suited as an a Nyxt extension.

impaktor commented 4 days ago

Thanks for reply.

I doubt it would be a good default. (...) Backspace is often used as a "Back" command in most web browsers.

Possibly so, however, if a user chooses "Emacs mode", they'd expect it to better conform with Emacs muscle memory, rather than what "normal" browsers do as default, I would argue.

My annual "let's try Nyxt", that I mentioned in my top post, was triggered this time by startpage.com (my main search engine for many years) stopped working in conkeror (I do wonder if I'm the last user of that browser, but stuff like #2972 is so nice), my solution to the broken site is to use LibreY, such that I can stick to conkeror for a wee bit longer.