Posts

Showing posts from January, 2012

Hiding a regex with vim (aka making C comments disappear)

Image
I use the mighty vim editor for most of my coding. I have a heavily customized setup which has evolved over quite a few years. However, it is by no means a static setup as I keep finding new scripts and tricks (and of course Bram keeps on adding extra goodness with each release). Recently, I was hacking through a lot of C code containing lots of debug cruft (log function calls, commented out bits and pieces, etc). The problem was I couldn't get a feel for the code as all the debug was too distracting. The question popped into my head, "can I hide all this stuff?" A number of folk have come up with ways to "hide" the data you don't want to see in Vim using folds (" :help fold " in Vim). However, that wasn't what I wanted as folds also introduce their own "visual noise". I just wanted this stuff gone . What I came up with is a complete hack, but it suited my purpose rather well: I changed the colour of the regex's matching the

making uzbl-tabbed open a link in a new tab (not a new window)

If like me you gravitate towards minimal applications, check out the uzbl web browser. It's based on webkit , supports Java, Flash, CSS, Javascript, etc and has full keyboard control. Added to this, it is fully configurable - it has a standard ASCII config file. This page shows the default keybindings. uzbl is a godsend to those of us who are too lazy (or busy) to take their hands away from the keyboard to reach for the pesky mouse. To install: sudo apt-get install uzbl I'm running uzbl-tabbed (which comes as part of the uzbl package). As the name suggests, this supports tabs. However, I was scratching my head trying to work out how to open a new link in a new tab , rather than a new window . The answer is simplicity itself (once you know of course :-). Fire up your favourite editor and point it at ~/.config/uzbl/config . Then, make sure you have an entry like this: @on_event NEW_WINDOW event NEW_TAB %s Now, any request to open a new window actually ge

Converting troff tables to ASCII

One particularly useful piece of information I've been wanting to add to the Upstart Cookbook for a while now is the upstart-events(7) manual page. This page shows a summary of the "well-known" Upstart events that are provided on an Ubuntu system.  However, as show in the link, formatting this data is tricky due to the number and complexity of the tables. I wondered about converting the troff source to some other format (maybe DocBook) and using that source to generate both the man page and the same data in a format suitable for inclusion in the Upstart Cookbook. However, DocBook seemed a bit heavy weight and I'm not convinced it could handle it (tell me if I'm wrong!) My preference actually is to keep the source as troff since: troff+tbl is a very rich language which provides a lot of control. I want full control over the width of the tables The man page may look a little "cramped". I could have padded it out and made it a little easier