| categories: | all | general | read | tech |
| tags: | blog code java netsurf personal photos read scrabble server tech vim webobjects writing |
|
I have been using FireFox as my primary browser for quite a while now. What held me back from switching initially were two things: 1) unacceptably poor non-native widgets, which have since improved dramatically and 2) no support for the Mac OS X Keychain, which is now available via the Keychain Services Integration extension. But eventually my desire for vim keybindings everywhere pushed me to switch despite these shortcomings. The vimperator FireFox extension allows for entirely keyboard-based browsing, using bindings similar to vim. And even better, it facilitates form field editing using vim via external editor support. So when I want to edit a form field, I type either "gi" (to enter the field) or "f#" (where # is the QuickHint mode number associated with the field; useful if there are multiple fields on the page) then hit Control-i. This creates a new tab with a buffer for that field in an existing instance of MacVim which is always running in the same Space as my browser, so it comes up almost instantaneously. I edit the contents of this buffer using all the goodness of native vim and then type ZZ. Thanks to a couple of autocommands in my .vimrc, this saves the buffer, saves a copy of its contents in a timestamped archive file, closes the buffer, and then hides MacVim, leaving FireFox active with the text I just wrote inserted in the form field ready to submit. Here are the requisite pieces of the puzzle: .vimperatorccThis is the vimperator configuration file. You need to add a line to set your external editor to the script that opens MacVim.set editor="~/bin/vimperator" shellMake a symbolic link to your mvim script so that the script can detect the context it's running in.ln -s ~/bin/mvim ~/bin/vimperator mvimThis is the mvim script that comes bundled with MacVim, moved to ~/bin and modified. Add this bit to the 'case "$name" in' statement:*vimperator) opts="$opts --remote-tab-wait-silent" gui=true ;; .vimrcNext, a couple of additions to the vim configuration file to make ZZ save the contents to an archive, close the buffer, and return FireFox to the foreground.augroup Vimperator au! BufRead vimperator-* nnoremap <buffer> ZZ :call FormFieldArchive() \| :silent write \| :bd \| :macaction hide:<CR> au BufRead vimperator-* imap <buffer> ZZ <Esc>ZZ augroup ENDFinally, here is the function that saves a copy of the form field contents to an archive file, complete with timestamp and url:
function! FormFieldArchive()
let l:contents = getbufline("%", 1, "$")
let l:filepath = expand("%")
let l:filename = expand("%:t:r")
let l:formfielddir = $HOME . "/webforms/"
let l:currentdate = TimestampText('date')
let l:entry = l:formfielddir . l:currentdate . ".txt"
let l:entryexists = filereadable(l:entry)
exec "split " . l:entry
if l:entryexists
normal Go
normal o
exec "call setline(\".\", \"" . TimestampText('time') . "\")"
else
exec "call setline(\".\", \"" . TimestampText('journal') . "\")"
exec "silent !svn add " . l:entry
endif
normal o
exec "call setline(\".\", \"" . l:filename . "\")"
normal o
exec "call setline(\".\", " . string(l:contents) . ")"
write
bd
endfunction
This will create a new file with the current date, e.g. "2010-03-15.txt", if it doesn't already exist. If it does exist, it will add the entry to the end of the file separated by a timestamp. TimestampText() is just a convenience function I wrote that returns a timestamp in various strftime() formats.
Posted by: Seth Milliken
[ 0 ] Comments During a dream last night I devised a technique to cut and paste between dreams and reality. I cleverly pasted the description of this technique on the shared dream/reality clipboard. I was thwarted by the fact that alarm clock snooze bars clear the clipboard.
Posted by: Seth Milliken
[ 2 ] Comments NetNewsWire now supports Moveable Type. This is a test of that functionality. If it works well, maybe I'll post more. On a completely unrelated note, I've been experimenting with leaving Sticky Keys turned on to see if I can improve the state of my wrists which have both taken a turn for the worse due to various combinations of foosball, swing dancing, playing guitar, and typing.
Posted by: Seth Milliken
[ 1 ] Comment ssh tunneling is a great lightweight vpn stand-in. You do need three things: an account on a externally accessible machine that is on the same internal network as the machine you're tunneling to, the IP address of the machine you're tunneling, and knowledge of what port(s) you need to forward. The syntax is: ssh <your account>@<externally accessible machine> -L <local port>:<internal target host>:<port to forward>
Posted by: Seth Milliken
[ 0 ] Comments |
Links
araxia.net blog status
del.icio.us bookmarks Facebook Profile LinkedIn Profile last.fm home résumé photos tomcat svn hg
Contact Information
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
categories:
/ |
/general/ |
/read/ |
/tech/ |
/templates/ |
html hits: 2482