2 " Handy functionality for using a Pyblosxom blog.
3 " Based on the work done by Jordan Sissel,
4 " http://www.semicomplete.com/blog/geekery/pyblosxom-mdate-vim-hack.html
7 autocmd BufReadPost /home/derb/blog/entries/*/*/*/*.txt call Pybloxsom_checkdate()
8 autocmd BufNewFile /home/derb/blog/entries/*/*/*/*.txt call Pybloxsom_putdate()
9 autocmd BufWritePost /home/derb/blog/entries/*/*/*/*.txt call Pybloxsom_fudgedate()
12 function Pybloxsom_checkdate()
13 " Look in the file for '#mdate foo' metadata
15 let dateline = search("^#mdate")
17 " If not found, append the mdate of the file to line 2
19 let date = system("stat -c '#mdate %Sm' " . expand("%"))
21 " Add the date to the file on line 1
26 function Pybloxsom_putdate()
27 let date=strftime("#mdate %b %e %H:%M:%S %Y")
32 function Pybloxsom_fudgedate()
37 let l=search("^#mdate")
38 let l=strpart(getline(l), 7)
39 let cmd="date -d '" . l . "' +%y%m%d%H%M"
41 let touchtime=system(cmd)
42 let touchcmd="touch -t '" . strpart(touchtime,0,strlen(touchtime)-1) . "' '" . expand("%") . "'"
46 " Reload the file (make vim notice the date change)
49 " Jump back to our old position