Hacker News new | ask | show | jobs
by iLemming 16 days ago
It would be nice to have some practical examples of how efficiently use its different input modes. On the surface the reasoning is straightforward - a terminal wants every keystroke. The editor also wants keystrokes for its own commands. These two desires are irreconcilable, so any editor-embedded terminal must have a way to switch "who owns the keyboard." That switch is a mode. There is no escaping it.

But like people coming to Emacs from Neovim may get confused why is nvim +term has only two modes, but this one has 5, what's the point? Without clearly understanding the problem, the knee-jerk reaction might be "this thing is an over-engineered BS", while in truth Ghostel isn't more complex because it's over-engineered - it's more complex because it solves more of the problem - the extra modes are opt-in tools for tasks nvim simply doesn't address. But it's not super clear how in practice use that leverage efficently.

1 comments

True. I'll have to update the documentation with some examples (and/or make a video?).

I know you know them but I list the 5 modes quick here for readers:

- semi-char: The default, where most keys go to the terminal but some common Emacs prefixes (M-x, C-c) go to Emacs

- char-mode: ALL keys go to the terminal. This way you can run e.g. Emacs inside Emacs.

- copy-/emacs-mode: This makes the whole buffer a pure read-only Emacs buffer and all keys go to Emacs. The difference between copy and emacs-mode is that copy freezes the terminal output (comes originally from vterm), while in emacs-mode new output keeps coming in (adopted from eat).

- line-mode: It's like `M-x shell`, everything goes to Emacs but it's not read only but you can type text on the prompt. But nothing is send to the terminal until you press return.

> why is nvim +term has only two modes, but this one has 5

I haven't used the neovim terminal, but I guess you can compare vim insert-mode with semi-char and normal-mode with copy-mode. And surely they have a char-mode as well, or can you not run nvim inside nvim (without having to press some quote key all the time)?

That would leave only line-mode as the odd one out.

> But it's not super clear how in practice use that leverage efficently

As with all Emacs things, that's highly personal.

Currently, I use semi-char mostly and switch to copy-mode to select/copy stuff.

Very rarely do I use char or line-mode.