reddit / emacs
What is the best possible solution for file history?
inquisitive-user_ · 2022-09-01 20:00
I need to have file history feature for changes I make in org files (daily notes). I don't want to make a manual commit every time I close a file after editing. However, making commit after source code changes is absolutely fine for me.
orzechod · 2022-09-01 20:35
try fiddling with the value of `recentf-keep`:
> List of regexps and predicates for filenames kept in the recent list.
Regexps and predicates are tried in the specified order.
When nil all filenames are kept in the recent list.
When a filename matches any of the regexps or satisfies any of the
predicates it is kept in the recent list.
The default is to keep readable files. Remote files are checked
for readability only in case a connection is established to that
remote system, otherwise they are kept in the recent list without
checking their readability.
A predicate is a function that is passed a filename to check and that
must return non-nil to keep it.
orzechod · 2022-09-01 20:36
oh, sorry, I just saw the Doom flair attached to your question. I don't use Doom so I'm not sure if it uses `recentf-mode` or not.
inquisitive-user_ · 2022-09-01 21:03
>recentf-keep
Thanks for the response. I have started with doom emacs as I have been using for about a week and found it easier to use. I am also building my own config in vanilla as I am learning day by day. So, there is no existing solution for my problem.
arthurno1 · 2022-09-01 22:01
> I need to have file history feature for all the changes I make in org files (daily notes) I don't want to commit every time I close a file after editing.
It is a bit contradictory. If you want history of *every* change (you say all changes), than you have to commit, after every save. You can save it elsewhere, in some backup file, but if you already use git, why? Just use git, that is what git is for :).
You don't have to do it manually. Configure your Emacs to commit in the backround with some appropriate autocommit message and put it in after-save-hook, and/or some other place. You can also configure Emacs to auto save your file after certain time interval (if there are changes) so everything gets automated.
inquisitive-user_ · 2022-09-01 22:12
>Congure your Emacs to commit in the backround and make some appropriateautocommit message and put it on some appropriate hook. After-save-hookis probably a good place, and/or some other place.
Yes, I want to do that, but I am a noob in Emacs world. That's why I am looking for existing solutions.
walseb · 2022-09-02 00:13
Helm-backup and git-backup-ivy does what you describe.
https://github.com/antham/helm-backup
https://github.com/walseb/git-backup-ivy
gepardcv · 2022-09-02 04:42
Use git-auto-commit-mode: https://github.com/ryuslash/git-auto-commit-mode
inquisitive-user_ · 2022-09-02 09:20
Yes, something like this.
organic-bookworm · 2022-09-02 10:44
If you use [`magit`](https://github.com/magit/magit), it has [`magit-wip-mode`](https://magit.vc/manual/magit/Wip-Modes.html) to automatically commit changes made to working (only *tracked* files) and index trees into wip refs per branch.
inquisitive-user_ · 2022-09-02 12:39
Thanks I will try to do it.
thiscarhasfourtires · 2022-09-05 14:08
You can use the package [git-auto-commit](https://github.com/ryuslash/git-auto-commit-mode) for timed automatic commits (or a git command periodically ran by `cron`, for a non-Emacs solution). If you use Doom Emacs, as is indicated next to your username, you can enable the module `vc` which contains the package `git-timemachine`. This package has a command that allows you to easily browse through and visualize all your commits. If you're not using Doom, you can just install and configure [git-timemachine](https://github.com/emacsmirror/git-timemachine) by itself for the same effect.
If you're not using `magit` already, I recommend the above since for what you want `magit` would be overkill IMHO.