I have cutover some of my vimrc to have more python in it. We'll see how this goes. ;)
The gist of it looks like this:
" go pythonic
python << EOF
import urllib, urllib2
class Blog:
def __init__(self, title, tempfile):
self.title = title
self.tempfile = tempfile
self.url = "http://www.haller.ws/logs/"
def get(self):
f = open(self.tempfile, 'w')
for line in urllib2.urlopen(url):
f.write(line)
f.close()
def post(self):
ret = []
for line in open(self.tempfile):
ret.append(line)
urllib.urlopen(self.url,
urllib.urlencode({"title":self.title, "html": ''.join(ret) })
)
EOF
" back to vim
function! Blog(title)
" get any pre-existing post
execute 'python blog = Blog("' . a:title . '", "' . file . '")'
Switching to python from shell hacks should have a higher degree of cross-platform survivability.
We'll see how that goes tomorrow. Ah, regardless, blogging from vim feels quite good, although I'm
sure I'll hear all about this heresy from the peeps at the Pittsburgh Perl Mongers' Perl Workshop.
Cross-platform (well, cygwin) vim doesn't have vim +python by default, however a quick download
and compile with:
./configure \
--enable-multibyte \
--without-x \
--enable-gui=no \
--enable-pythoninterp \
--prefix=/usr \
--sysconfdir=/etc \
--libexecdir=/usr/sbin \
--localstatedir=/var \
--datadir=/usr/share \
--mandir=/usr/share/man \
--infodir=/usr/share/info
yielded a happy vim.exe on cygwin.