April 29th, 2020

Trevor baby stare

conjoin: A Vim Plugin for Continuation Characters

As an avowed introvert, I took the opportunity of the new fewer-social-commitment world of coronavirus stay-home orders to do some fun programming on personal projects, like my Elizabethan curse generator. While working on bash and Tcl implementations I discovered that vim, my favorite text editor, did not automatically remove line continuation characters when performing a join command. In my case, I had copied an array of quoted strings from Python into a shell script, which doesn't need quoted strings, and wanted to realign the declaration to fit nicely in 80 columns, like so:
noun=(apple-john baggage barnacle bladder boar-pig bugbear bum-bailey \
canker-blossom clack-dish clotpole coxcomb codpiece crutch cutpurse \
death-token dewberry dogfish egg-shell flap-dragon flax-wench flirt-gill \
foot-licker fustilarian giglet gudgeon gull-catcher haggard harpy hedge-pig \
hempseed horn-beast hugger-mugger jack-a-nape jolthead lewdster lout \
maggot-pie malignancy malkin malt-worm mammet manikin measle minimus minnow \
miscreant moldwarp mumble-news nut-hook pantaloon pigeon-egg pignut puttock \
pumpion rabbit-sucker rampallion ratsbane remnant rudesby ruffian scantling \
scullion scut skainsmate snipe strumpet varlot vassal waterfly whey-face \
whipster wagtail younker)
Unfortunately, the J command in vim leaves those trailing backslashes (which mean "the command keeps going on the next line") in the middle of the combined line. After a bunch of Googling, I determined that there wasn't a vim setting to do so, and nobody had written a plugin for it either.

So of course I decided that extra home-bound free time meant it was time to learn how to write a vim plugin so that I could change the behavior of the line-joining commands. A couple coworkers mentioned that such a plugin would be even more useful if it could merge strings when joining as well (resulting in "lorem ipsum" rather than "lorem " + "ipsum"). This in turn provided a great excuse to geek out on programming language details on Wikipedia, Rosetta Code and 99-bottles-of-beer.net. And thus was born vim-conjoin, a plugin that remaps J, gJ, and :Join to handle continuation breaks and string concatenation.

This exercise was absolutely a violation of XKCD's Is It Worth the Time graph: I spent the better part of two weekends, plus a few evenings, implementing and testing this plugin (mostly testing). It will, in my lifetime, perhaps save me an hour of work. So hopefully other vim users find it useful, too.

As with any personal programming project, the time wasn't entirely wasted, of course. The next time I want to write a vim plugin I'll have a much better idea of what I'm doing. And I learned more in a couple weeks about vim than I've learned in most individual years in the last two and a half decades I've used the editor. (Though it's going to take me awhile to remember to put call before function invocations and I'm forever forgetting the l: and a: prefixes on local and argument variables.) And the Wikipedia adventures led me to finally read up on INTERCAL a famously obtuse parody language, and LOLCODE, a lolcat-inspired esoteric programming language that I wish I'd heard about in 2007 when it was announced. (LOLCODE unfortunately seems to have been abandoned; the language author hasn't responded to a 2018 proposal for array (BUKKIT) syntax.) And that gave me an idea for an esoteric language of my own that I hope to work out during the remainder of quarantine time…

You do you. And make sure you've got an unnecessarily polished tool while doing so.

This entry was originally posted at https://flwyd.dreamwidth.org/392000.html – comment over there.

Trevor baby stare

LiveJournal Crossposts Fixed

I just noticed that crossposts from my Dreamwidth account to LiveJournal (hey, remember LiveJournal?) were broken for the last year. I think LiveJournal forced a password reset (half a year after someone blew me off on a support ticket when I suggested they'd suffered an account breach) and I forgot to update it on the Dreamwidth crossposting side.

That's fixed now, and I've triggered a crosspost for everything I read in the last year. If that all showed up in your LJ friends page at once, apologies for the mess. (And also, why haven't you migrated to Dreamwidth yet?)

So, uh, in the last year:
  • I was having trouble sleeping and tried to take a relaxing vacation to Jamaica, but couldn't sleep there either.
  • Dealt with some exciting water-related homeowner problems.
  • Got some medical interventions that helped with sleep and inflammation.
  • Took my parents to Iceland to celebrate their 50th wedding anniversary.
  • Lobbied Congress to pass climate change legislation.
  • Delivered a stand-up comedy bit about passing a climate change bill through Congress.
  • Gave a talk at Ignite Boulder 40 about turning organizational charts upside down.
  • Recognized that I'd just been in go-mode for two months straight, and decided to spend the winter holiday season sitting around organizing digital photos.
  • Spent January and February feeling burned out and introspective.
  • Got periodontal surgery that I'd been putting off for most of a decade.
  • Oh hey, it's a global pandemic! Time to work from home, have video conferences, chill out, go for a walk every day, clean up the garden, and do those things I wouldn't normally get around to, like write a vim plugin and read the appendices to Lord of the Rings that I apparently skipped at age 15.

This entry was originally posted at https://flwyd.dreamwidth.org/392328.html – comment over there.