2004-04-30 |
More VIM based editing. |
I don't know how long I can go on posting the evolution of this but anyway.
def PostBlog():
import xmlrpclib
import re
nFirstLine = 0
strID = vim.current.buffer[0]
if not re.match( '^P\d+$', strID):
strID = ''
else:
nFirstLine = 1
strTitle = im.current.buffer[nFirstLine]
strText = "\n".join( vim.current.buffer[2:])
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
oPost = { 'title': strTitle,
'description': strText}
if strID == '':
strID = oPyds.metaWeblog.newPost( '', 'peter', 'wibble', oPost, 1)
else:
bSuccess = oPyds.metaWeblog.editPost( strID, 'peter', 'wibble', oPost, 1)
print "Posted entry %s" % strID
vim.command( 'set nomodified')
def ReadBlog( strID = None):
import xmlrpclib
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
if strID:
oBlog = oPyds.metaWeblog.getPost( strID, 'peter', 'wibble')
else:
oBlogs = oPyds.metaWeblog.getRecentPosts( '', 'peter', 'wibble', 1)
oBlog = oBlogs[0]
strID = oBlog['postid']
vim.current.buffer[:] = []
vim.current.buffer[0] = strID
vim.current.buffer.append( oBlog['title'])
vim.current.buffer.append( '')
for strLine in oBlog['description'].split('\n'):
vim.current.buffer.append( strLine)
|
posted at 12:50:24
#
comment []
trackback []
|
|
Smileys |
What has happened to my text smileys
This is the magic of shortcuts. Here are some I prepared earlier. Python is the language
of my dreams. Microsoft is the company of my nightmares.
|
posted at 12:26:56
#
comment []
trackback []
|
|
Scrolling preformatted text |
Something I noticed on the PYDS site is how a code snippet was in a box that
could scroll horizontally. This is useful as it stops preformatted text from
making the page grow too wide to be displayed nicely. The secret seems to be
this:
.literal-block {
overflow: auto;
}
Here is an example:
This is a very long line of stuff. It is too long to go on one line and as it is preformatted it will not word wrap. You can scroll it horizontally.
Magical. It works in Mozilla but not in IE 5.0: that just creates a very wide
web page. I'm not sure I have access to a later I.E. here at work.
Update: This makes Mozilla 1.6 on my laptop at home hang, gobbling cpu time and it doesn't work on IE6, so I ripped it out and reformatted the long lines.
|
posted at 11:57:04
#
comment []
trackback []
|
|
More VIM Editing |
I cannot leave these things alone.
def PostBlog():
import xmlrpclib
import re
nFirstLine = 0
strID = vim.current.buffer[0]
if not re.match( '^P\d+$', strID):
strID = ''
else:
nFirstLine = 1
strTitle = vim.current.buffer[nFirstLine]
strText = "\n".join( vim.current.buffer[2:])
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
oPost = { 'title': strTitle,
'description': strText}
if strID == '':
strID = oPyds.metaWeblog.newPost( '', 'peter', 'wibble', oPost, 1)
else:
bSuccess = oPyds.metaWeblog.editPost( strID, 'peter', 'wibble', oPost, 1)
print "Posted entry %s" % strID
def ReadBlog( strID):
import xmlrpclib
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
oBlog = oPyds.metaWeblog.getPost( strID, 'peter', 'wibble')
vim.current.buffer[:] = []
vim.current.buffer[0] = strID
vim.current.buffer.append( oBlog['title'])
vim.current.buffer.append( '')
for strLine in oBlog['description'].split('\n'):
vim.current.buffer.append( strLine)
It seems to work.
|
posted at 11:29:20
#
comment []
trackback []
|
|
Syntax Highlighted Entries |
If this works it will be really cool.
def HelloWorld():
print 'Hello World'
Well blow me. NOTE: two colons, case sensitive language name.
void HelloWorld() {
printf( "Hello World\n");
}
I installed the SilverCity python package and rebooted PYDS.
Does it support shitty languages?
System Message: ERROR/3 (<string>, line 20)
No SilverCity lexer found for language 'VB'.
.. code-block:: VB
Sub HelloWorld()
MsgBox "Hello World"
End Sub
That would be a No.
I edited this entry using this:
def ReadBlog( strID):
import xmlrpclib
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
oBlog = oPyds.metaWeblog.getPost( strID, 'peter', 'wibble')
vim.current.buffer[:] = []
vim.current.buffer.append( oBlog['title'])
vim.current.buffer.append( '')
for strLine in oBlog['description'].split('\n'):
vim.current.buffer.append( strLine)
def WriteBlog( strID):
import xmlrpclib
strTitle = vim.current.buffer[0]
strText = "\n".join( vim.current.buffer[2:])
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
oPost = { 'title': strTitle,
'description': strText}
strID = oPyds.metaWeblog.editPost( strID, 'peter', 'wibble', oPost, 1)
print "Posted entry %s" % strID
Good isn't it?
|
posted at 10:48:48
#
comment []
trackback []
|
|
Posting Blog Entries from VIM |
This is as easy as:
def PostBlog():
import xmlrpclib
strTitle = vim.current.buffer[0]
strText = "\n".join( vim.current.buffer[2:])
oPyds = xmlrpclib.ServerProxy( 'http://localhost:4334/RPC2')
oPost = { 'title': strTitle, 'description': strText}
strID = oPyds.metaWeblog.newPost( '', 'peter', 'wibble', oPost, 1)
print "Posted entry %s" % strID
Ok, this uses VIM with python support.
|
posted at 09:34:08
#
comment []
trackback []
|
|
|
A blog documenting Peter's dabblings with Python, Gentoo Linux and any other cool toys he comes across.
|