Emacs File Change History

Is there an emacs extension that accepts periodic snapshots (once per minute, each time x keystrokes, no matter which file) during editing, similar to the history of changes in Eclipse or the history of changes in Google Docs and other programs?

I hope for something that will allow me to easily move on to the changes that I have made day after day. Is there something like this already written?

Edit

I have to be more specific - I'm not looking for VCS. I am looking for a minor mode or something similar, I can just turn it on and have hard copies of the revisions on disk.

+4
source share
4 answers

There is a built-in function called autosave that saves after N keystrokes (and maybe after M seconds, I'm not sure). I usually use this if Emacs fails, and not to see what changes I made; it’s better to cancel it. Here is my configuration:

(setq autosave-dir (concat user-emacs-directory "autosaves/") auto-save-list-file-prefix (concat emacs-persistence-directory "autosave-list")) (if (not (file-exists-p autosave-dir)) (make-directory autosave-dir t)) (add-to-list 'auto-save-file-name-transforms `("\\`/?\\([^/]*/\\)*\\([^/]*\\)\\'" ,(concat autosave-dir "\\2") t)) ;; tramp autosaves (setq tramp-auto-save-directory (concat user-emacs-directory "tramp-autosaves/")) (if (not (file-exists-p tramp-auto-save-directory)) (make-directory tramp-auto-save-directory)) 

There is also a backup system that creates a copy after each save (rather than autosave). I use this for what I think you are asking for β€” looking at the story since my last VCS. Here is my configuration:

 (setq make-backup-files t vc-make-backup-files t version-control t kept-new-versions 256 kept-old-versions 0 delete-old-versions t backup-by-copying t) (setq backup-dir (concat user-emacs-directory "backup/")) (if (not (file-exists-p backup-dir)) (make-directory backup-dir)) (add-to-list 'backup-directory-alist `(".*" . ,backup-dir)) (defun force-backup-of-buffer () (setq buffer-backed-up nil)) (add-hook 'before-save-hook 'force-backup-of-buffer) ;; this is what tramp uses (setq tramp-backup-directory-alist backup-directory-alist) (add-to-path "backup-walker") (autoload 'backup-walker-start "backup-walker" "start walking with the latest backup" t) 

I use an excellent backup-walker to navigate through backups.

+5
source

If you really appreciate saving your changes, I highly recommend starting using git. It will work for your windows and Linux coding environment. I use it to change ports from code back and forth. It does a great job of fixing all the small lines and merging the changes.

If you really want to keep the old versions, emacs can create a new backup every time you save it. It just creates another file next to your current one. This way you can control how often it creates a new backup (each time it is saved).

Here is a good page that talks about options:

ftp://ftp.gnu.org/pub/old-gnu/Manuals/emacs-20.7/html_chapter/emacs_18.html#SEC109

+4
source

The best solution I have found for this is undo-tree , which is equivalent to Emacs for gundo for vim: it allows you to visualize the undo / redo tree, view changes and switch between different versions.

undo-tree can be installed using ELPA; once it is installed, add the following to .emacs :

 (require 'undo-tree) (global-undo-tree-mode) 

You can then display the undo tree using Ctrl - x u ( undo-tree-visualize ). Various β€œversions” can be implemented using the arrow keys in a very intuitive way.

History can also be made permanent using undo-tree-save-history .

+3
source

Try http://www.emacswiki.org/emacs/BackupEachSave

He saved me several times, allowing me to retreat.

+1
source

Source: https://habr.com/ru/post/1411885/


All Articles