RCS is the simplest thing that does the job. It provides VersionControl to files on a per-file basis. You don’t have to do anything special in order to use it in Emacs. Just issue the keyboard sequence of
‘C-x v v’ to get started.
‘C-x v v’(
‘C-x v v’.
‘C-x v u’(
‘C-x v l’(
To automatically check in - out a file when saving it if the file is under RCS, put this in your .emacs:
;; automatically check-in check-out when under rcs (defun rcs-ci-co nil "check in check out the file if it is under vc with rcs with a prefix other than 1 only check-in" (when (eq (vc-backend (buffer-file-name)) 'RCS) (if (= args 1) (save-window-excursion (vc-toggle-read-only) (call-interactively 'log-edit-done) (vc-toggle-read-only)) (vc-toggle-read-only)))) (add-hook 'after-save-hook 'rcs-ci-co) (defun my-vc-diff (historic &optional not-urgent) "my vc diff, sames as vc-diff but in case of rcs, display the diffs between current version and previous one (with a prefix calls vc-diff)" (interactive (list current-prefix-arg t)) (let ((file (buffer-file-name))) (if historic (call-interactively 'vc-version-diff) (if (eq (vc-backend file) 'RCS) (vc-version-diff file (vc-previous-version (vc-workfile-version file)) (vc-workfile-version file)) (call-interactively 'vc-diff))))) (global-set-key (kbd "C-x v=") 'my-vc-diff)
Note that if a prefix is used when saving the file, the file is only checked-in allowing you to put a meaningfull message to the Changelog.
it did’nt work for me (the first defun trew errors), but this other did the trick
(defun rcs-ci-co nil "check in check out the file if it is under vc with rcs" (when (eq (vc-backend (buffer-file-name)) 'RCS) (progn (vc-checkin (list (buffer-file-name)) 'RCS nil "saved" nil) (vc-checkout (buffer-file-name) t) ))) (add-hook 'after-save-hook 'rcs-ci-co)
but it has problems anyway, for example: vc-checkin first tries to save, which is a problem when you want to create another mayor version. There is also a nice discussion here: VersionControlAlways – AlvaroMartinez
starting with Emacs 22 (in earlier versions the vc-rcs-*-switches were present, but ignored by the functions) you can also just use
(setq vc-rcs-checkin-switches "-l")
this means use “ci -l file” to checkout a locked (writable) version right after the checkin. Which should always be fine when using RCS.
Like WDired, it would be handy if you could hand edit the contents of log view (revision logs, dates, author, state, file description) and commit the changes to the RCS file. Yet another WishList item.