When commenting on sites, I have sometimes, seen that the commenting system just swallows the comment, or there is a browser crash, or a system one. In these cases it would be great if you can recover it somehow, particularly when you typed quite a bit.
There are plugins for firefox and other browsers for this. But since I use Pentadactyl(site), I thought not to use any external plugin but write one for dactyl. But then, I realized a plugin may not be needed.
Following is what I use:
#!/bin/zsh
file="$@"
dat=$(date +%s)
ln -f $file ~/.pentadactyl/tmp/pentadactyl-$dat.txt
urxvt -name dactyle -e /usr/bin/vim '+set ft=mail' '+set foldminlines=2' "$file"
cp "$HOME/.pentadactyl/tmp/pentadactyl-$dat.txt" ~/.pentadactyl/data/${file:t}-$dat
rm ~/.pentadactyl/tmp/pentadactyl-$dat.txt
EDIT: I didn’t explicitly mention this earlier but you need to set the above script as editor with ‘set editor=pvim’ (in pentadactylrc).
With this, whenever I switch to external editor mode (which is vim in may case), the existing comment is copied (this is done by dactyl itself) and then after I exit the editor, a copy of the comment is saved in my home directory. Note that, the linking is necessary there, otherwise the temporary file gets deleted after urxvt returns. Also, the window name is used there to provide hint to my window manager (xmonad) on how maintain the window. The ‘ft=mail’ is used so I can use the same vim file mode that is used while replying to mails (in mutt).
In addition to have protection against crash (note that vim also maintains swap files), it is also nice to have an archive of all your comments. I just did a count in my comment directory and I see about 946 comments! The files are also named based on date and so on, so I can refer earlier comments easily.
Note that, while this approach works with most of the sites, with some commenting systems like disqus I have had issues (I actually lost one of my comments on disqus today morning). That is one of the reasons I use a plugin like Pentadactyl since it allows for KISS solutions like these. I have written plugins (mostly trivial) for other issues like using extended hints to invoke an external player on an URL.