It frustrates me endlessly that this one simple, almost self-evident piece of Emacs wisdom failed to gain traction almost everywhere else. Even the venerable Vim drops the ball hard here, with the various "widgets" it uses in its interface which have slightly different semantics and behaviours.
Every time I get a shitty modal with some text I can't copy paste, every time I have a crappy edit box lacking basic editing capabilities, every time I get some large text dump I can't search through with normal editing commands, every single time that happens I pray to the altar of RMS for him to smite the heathens and bring us to the age of enlightenment.
> It frustrates me endlessly that this one simple, almost self-evident piece of Emacs wisdom failed to gain traction almost everywhere else. Even the venerable Vim drops the ball hard here, with the various "widgets" it uses in its interface which have slightly different semantics and behaviours.
Perhaps I don't understand emacs well enough, but I know that every file loaded in vim can be accessed via its buffer number. How it's displayed depends on the window and tab layout. Quickfix, help, and terminal buffers behave differently, but the vast majority of buffers are just associated with open files.
Basically menus, project trees, terminal tabs, etc. Are all just text buffers. So you can navigate them like they were a file opened in a regular text buffer.
Vim is not the worst offender by any mean, but it's definitely a lot less uniform than Emacs.
:redir "a :messages :redir END
Then, you can just paste from that register using "ap.
Two especially laborious operations are `git add -p` and `git rebase -i`. Try them out on magit, you'll see the difference.
In Magit you visit the file you changed, hit `C-x g' and see all diffs. Now you can review and select hunks by hitting „s“ (stage), go to the next relevant hunk and hit „s“ again to mark for staging. And when you‘re done selecting all changes that are relevant for one ticket, you hit „c“ twice to write a commit message. And off to the modifications/ hunks regarding second ticket.
So how‘d you do this in command line?
I'm sure it's not nearly as nice as Magit's UI, but I've been a happy user of this feature for a while.
[0]: https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging
$ git add -p path/to/the/file
?
Combine this with your favorite tool for command line auto-completion of paths (and, maybe, a git alias to avoid typing `git add -p` all the time) and it's extremely fast.
And then I navigate with j/k (down/up).
Yes, it does the job. Matter of preference.
But if you worked eagerly on three / four different topics and try next to create several different commits by getting a visual overview of all hunks with the abilitiy to selectively stage is a little more comfortable.
You can also hit "s" to split a hunk to only commit a part of a hunk of if you want fine grained control you can hit "e" to edit just that hunk in your $EDITOR to only select a specific line or whatever you want.
Personally I tried fugitive and other git clients in the past and always come back to git add -p on the command line. It just feels the most natural and it also forces you to look at the hunks, so there's really no chance you'll accidentally forget to add something.
When using GUIs with sidebars showing what files changed, etc. it's easy to forget to add something because you skim it without really paying attention to what was changed.
Or fugitive in Vim.
The difference is like that between using Ed and Vi. Seeing things as you do them is valuable.
(when (string-match "code" default-directory)
(magit-status)
(delete-other-windows))
(with-eval-after-load 'magit
(define-key magit-status-mode-map (kbd "q") 'save-buffers-kill-terminal))
These days I mostly use VSCode due to great language server integration (Pylance, gopls, rust-analyzer, etc.), but I still rely on Emacs with Magit for almost all my git interactions. This is not helped by VSCode's shitty commit message box, which after five years is still this ~250x20px by default input field with some after-the-fact validation tossed in. The great thing about Emacs is that everything is a buffer, you get the full editing power afforded by a buffer, not some second-class input field, especially for something as important as commit messages.