Native Emacs “versioning” - backups, etc.

TODO: more notes


from my .emacs:

;; Put autosave files (ie #foo#) in one place, *not*
;; scattered all over the file system!
(defvar autosave-dir "~/autosaves/")

(make-directory autosave-dir t)

(defun auto-save-file-name-p (filename)
  (string-match "^#.*#$" (file-name-nondirectory filename)))

(defun make-auto-save-file-name ()
  (concat autosave-dir
   (if buffer-file-name
      (concat "#" (file-name-nondirectory buffer-file-name) "#")
     (concat "#%" (buffer-name) "#")))))

;; Put backup files (ie foo~) in one place too. (The backup-directory-alist
;; list contains regexp=>directory mappings; filenames matching a regexp are
;; backed up in the corresponding directory. Emacs will mkdir it if necessary.)
(defvar backup-dir "~/backups/")
(setq backup-directory-alist (list (cons "." backup-dir)))



Using CVS inside of Emacs

Using CVS inside emacs
out-of-date Emacs PCL-CVS info


Getting Started with PCV-CVS




Using RCS in GNU Emacs
rcs under Emacs


I had issues with RCS under my WinXP EmacsW32 set-up. Usually it wouldn’t work; sometimes it would. It would always work from the command-line (cmd-shell outside of Emacs). Finally, I found some some other installation of ci.exe (etc.) that had a higher-priority in my path. Or at least the Emacs path. I re-orged my PATH environment-variable to put the RCS/bin directory much earlier than it was. But if that were the problem/solution, it never would have worked from the command-shell in the first place. Hunh. My other thought was that Cygwin was interfering, somehow -- but that isn’t even in the path. So, I am left with RCS working, but no definitive answer for how I fixed it. Aaaargh. cargo-cult programming, once again....



If anybody asks “why on earth use RCS when, since you have a local server installed, you could use CVS?”, I would respond that I prefer using CVS for projects, but RCS is handier for one-off files here and there. Or so it seems to me.


Using RCS in GNU Emacs

(adapted from


Emacs has integrated support for RCS (and other version control systems). Emacs looks for RCS comma-v (,v) files in the current directory or in an RCS subdirectory.
Version Control Commands in Emacs


Commands are located in the menu system in Tools...Version Control. The keyboard command prefix for all version control commands is C-x v.


Starting a File in RCS with Emacs

To check in a new file to RCS - Register command (keyboard sequence C-x v i or C-x v v.


Interpretering the Emacs Mode Line

Files that are using RCS will have the following status line:


--1-:%%-F1 strntok.c (C RCS-1.2)--L1--Top-------


The %% indicates the buffer is read-only. The RCS-1.2 indicates that this file is under RCS control, and you are viewing revision 1.2.


Checking Out and Editing File

To checkout and be able to edit the file - Check In/Out command C-x v v The status line will now be:


--1-:---F1 strntok.c (C RCS:1.2)--L1--Top------


The missing %% means the file is writeable, and the semicolon (: after RCS, resulting in RCS:, means the file is locked.


Viewing the Changes with rcsdiff

To compare the current version of the file you’re editing with the last version in RCS - Compare to Last Version C-v =, which opens a buffer with the output of the rcsdiff command.


Checking in Changes

To check in files use the same command as check out - Register command C-x v v


Checking in files results in Emacs asking to save the buffer it hasn’t been saved, and creates a window (buffer *VC-log*)to enter a change comment. Emacs tells you to type C-c C-c when done.


Reverting to Undo Changes

To undo all the changes to a file - Revert to Last Version C-x v u


Viewing the Revision Log

The meta revision information of a file - Show History C-x v l


Viewing Another Revision

View another revision of a file in another window - Show Other Version C-x v ~



Mercurial integration

Stack Overflow: best Emacs mode for Mercurial


I used Mercurial (from Emacs, mostly) for a few months at work. Ultimately, I ran afoul of case-sensitivity issues. Windows is not case-sensitive, Mercurial is. And since it allowed me to enter the same file in different casings (eg myFile.txt and MyFile.txt) - case-sensitive M Ercurial? insisted they were different files, yet part of the same archive-file (however it internally works) and wouldn’t let me retrieve anything. Several weeks of commits lost to a case issue. Aaaaargh. I found a reference to somebody facing the same problem, who got around it by patching and recompiling the source. I lost the reference, and didn’t attempt it, either. :::sigh:



Log files

the logfile will never go away


The problem is that the relation between version control software and ChangeLog files isn't automatic enough as it should be. [....] In Emacs, ChangeLog support is quite successful.



See Also

Programming.Version Control




Emacs VersionControl



Comment Page  

  danny   - 13.06.2020 - 22:43    

<p>thank you for sharing<a href=“ sites)”>!</a></p>

  Danny   - 13.06.2020 - 14:10    

<p>Thanks for sharing<a href=“ sites)”>!</a></p>



Add Comment

 Your Message
 Enter value ← Have you entered the code number?