esvn.el: a minor mode for editing Ethan's journal
I keep my journal in my home directory in ~/writing/journal. But I'm obsessed with keeping records and history. Every time I make another entry, I enclose it in start and end times, like this:
I wanted to keep sleeping, but the sun was shining right into my eye, so I got up instead.
Sometimes when writing short stories in my journal, I copy and paste the thing five or six times, with each copy having an extra iteration of proofreading. This is obnoxious as well as foolish; if you want history, keep your stuff in a version control system.
But svn requires commit messages for every commit!
And I usually don't have anything worth saying about the commit -- I added another thought. Or completed an old thought. The changes don't merit description, and looking at the change is usually enough to explain the change itself. Besides, I write my journal in emacs, and I don't want to have to keep a terminal open to type "svn commit -m 'blah'" every now and then. No, what would be nice is if emacs would commit for me.
There's a solution!
I spent one Saturday writing this minor mode. Basically it only has one feature -- if you type C-c C-c it commits. It will even prompt you for a commit message or accept defaults. If given a prefix argument, it will "autocommit", taking a message from an appropriate default and committing without user intervention.
In the future, perhaps there will be other features, such as calling
svn diff, but I wouldn't bet on it.
Isn't this a completely nonstandard and possibly dysfunctional way to use SVN or any other version control system?
Yes. Ohhhh, yes.
What's the low-down?
esvn.el is some 150 lines of emacs-lisp. Be warned; I don't actually know emacs-lisp, so there are probably a number of horrible, awful mistakes and indiscretions sprinkled liberally throughout. If you have any comments, feel free to email me.
It won't commit directories which contain the files it wants to commit.
It rebinds a key starting with the prefix key C-c. Naughty, naughty!
I don't care. If
python-modecan do it, so can I.
It doesn't use
define-minor-mode, but instead writes its own function.
I did this because I wanted to use the modeline indicator "E", but when I did this and turned on
esvn-mode, I was helpfully informed that "Esvn modE enabled".
0.1.3, 2007 April 29: Display only the last line of SVN output, and always save on commit.
0.1.2, 2007 April 29: Might work with GNUmacs, but at least doesn't break on startup. Also, save before checking status.
0.1.0, 2007 April 28: Does most of what I want it to do.
0.0.1, 2007 April 28: An actual minor mode.
How do you use it?
I put esvn.el in my
.xemacs directory and add the following to my
(require 'esvn) (define-derived-mode journal-mode text-mode "Journal" "Major mode for editing Ethan's diary." (setq esvn-default-commit-message "Entry.") (setq esvn-default-autocommit-message "autocommit") (setq esvn-default-add-message "New day.") (esvn-mode) (local-set-key [?\C-x ?\C-s] 'esvn-save-or-autocommit)) (setq auto-mode-alist (append '( ("\\.mdwn$" . mdwn-mode) ; completely unrelated ("writing/journal/" . journal-mode) ; see  ) auto-mode-alist))
Now, whenever I open a file in
writing/journal/, emacs will fill in some default commit messages. Note also that I rebind C-x C-s to autocommit by default! Of course, if I want to provide a commit message, I can do so using C-c C-c.
This is how I use esvn.el. I have no idea how you might use esvn.el. It is possible that esvn.el might have some use besides editing my journal, but I doubt it.
 I know that this matches any
writing/journal/ directory, including
invisible_writing/journal/, etc., but there's only one directory called anything like that in my home directory, and when I was testing this it was useful to mess around in another directory (
Why didn't you use emacs's built in VC-mode?
I looked at emacs's built in VC a couple of years ago and it didn't seem like what I wanted. Of course, I wasn't as expert in emacs-fu as I have become over the course of writing esvn.el, so I might have been able to hack VC up.
On the Saturday that I wrote esvn.el, I looked at emacs's VC again, and saw immediately that it supported "SCCS, RCS, and CVS", and was so horrified that I decided to ditch.
Why didn't you use psvn.el?
psvn is too heavyweight. psvn takes a project-based view to svn use -- you have a command that pulls up a magic svn buffer, which you can then use to mark up particular files for committing or not committing or adding or deleting. I wanted something where I could press a key and commit the file I was working on. psvn doesn't do that, it does something else. So I wrote my own.
What are the core assumptions of esvn.el?
Each file is committed "by itself", after possibly adding it to version control. No two files are committed together. In other words, changing one file is assumed not to necessitate changing another file.
It is assumed that no files are ever removed from version control, but files are added.
In my .emacs snippet, I assume that all files in a particular directory are going to be placed in version control.
It is assumed that changes are going to be frequent, small, and self-explanatory.
esvn.el is unlikely to be useful for any programming work, but for plaintext it may be handy.
Aren't you going to have a huge SVN repo with zillions of transactions?
The KDE SVN repo has over 260,000 revisions. I do like to whine at great length in my journal, but even so, I don't expect to have that many.
Where can I get it?