I have also posted this question here on Reddit

I'm not a version control or Git expert and it is very cumbersome for me to do all the steps manually. I want to have a text editor which upon closing the file if any changes were applied, runs these commands:

checks if the file has been edited

git add <filename>

opens a popup or tab to edit the commit message

git commit -m "the commit message entered in the popup"

I would appreciate it if you could help me know if there is such an editor to have this feature built-in or via a plugin/addon. Or if it is possible to write such a plugin.

P.S.1. It doesn't really have to be git, mercurial or other versions control systems are also fine.

P.S.2. I think this should be doable in Vim script and/or emacs lisp, If I knew those languages.

P.S.3. here and here different ideas have been discussed. It is apparently possible to git commit upon closing, but I want to write the message manually.