0

I often add a new file to a repo, make some other changes, then stage all, and commit all, forgetting that the new file is not yet tracked, so is not included in the stage all step. At least one editor (IntelliJ) has an option to auto-stage new files, which would be very helpful to me in Emacs. I guess this would be particularly helpful if it invoked --intent-to-add.

Is this feature present in magit or built-in in Emacs?

If not, I'd be interested in writing some elisp. Is there a hook run when magit sees a new untracked file, or would I have to add to the after-save-hook and query the git status?

0

Magit does not implement this and as far as I know VC/Emacs does not do so either.

Magit also does not provide a hook that is run "when it sees a new untracked" file but you could use find-file-hook, which is run when you see a untracked file. ;D

You probably want to use magit-file-tracked-p in your hook function.

4
  • Thanks. I'll take a look at writing some elisp. Is this something you'd be interested in add to magit, or do you see it as something outside of its scope? – Tom Dalziel Dec 9 '20 at 16:07
  • I don't want to add this to Magit because this is not a workflow I am comfortable promoting. – tarsius Dec 9 '20 at 16:38
  • Fair enough. Before I add this to my init.el (and maybe unwittingly degrade my workflow) would you mind explaining why it may not be desirable? I (and presumably some IntelliJ users) think it may be useful as an option at least. – Tom Dalziel Dec 9 '20 at 17:33
  • For any future readers, this is the elisp I created: gist.github.com/tomdl89/d1c68aac21a66ec656b848503188a491 – Tom Dalziel Dec 9 '20 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.