Highlights from the List

In the interest of sharing I will try to do write-ups of the interesting stuff from the mailing list and probably also a few of the personal replies I give while providing support for TextMate.

I am starting with half a dozen letters from the last few weeks which probably fall more in the category of frequently asked questions. The upcoming write-ups will have a more “how-to” feel over them (I actually picked a dozen letters, but putting those “how-to” sections in this post made it rather long, so I will post those over the next few days).

TmCodeBrowser 1.05 (Universal Binary)

Gerd Knops announced version 1.05 of his TmCodeBrowser plug-in, which is now a universal binary.

Jeroen van der Ham gives a tip on how to navigate TextMate’s menus using Quicksilver (be sure to read the follow-ups which have additional instructions/clarifications).

Coincidentally The Tao of Mac has a post named Making the Mouse Redundant where a screencast shows this Quicksilver plug-in used to navigate TextMate’s menus.

Sharing Bundles Between Computers

A common question is how to export bundles to another computer.

All bundles and theme customizations end up in ~/Library/Application Support/TextMate, so it is simply a matter of copying over that folder.

TextMate ensures that even if you rename bundles, bundle items, or themes inside TextMate, the filename used on disk remains the same, so it is possible to add the folder to Subversion (or similar version control system) without having to manually tell the SCM about how files were renamed.

Ned Baldessin had a nice suggestion about an infrastructure (dare I say Web 2.0) for sharing of TextMate customizations. I try not to make too many comments about the distant future, but I definitely want to isolate the current bundle editor into a “service” which can be used by other commands, and would allow others to build such a sharing system.

Back-references Versus Captures

Trevor Harmon questioned the sanity of using $1…$n for captured variables in regular expression replacements, which made me write this explanation of my preference of $1…$n over \1…\n.

ProFont and Ligatures

Quinn Comendant noted that tool tips showed ligatures (that is, fi show as the combined glyph ) when TextMate was using ProFont, which messed up results intended to be printed with fixed width fonts (like a dump of the database scheme).

TextMate uses ATSUI for normal text rendering, where it disables all such typographic features, but is not responsible for text rendering in tool tips, where such typographic features are thus not disabled. ProFont is a little strange in that it has such features, but there is a ProFontISOLatin1 variant which do not have them. Using that font will not show the problem, but will OTOH lack a few glyphs that the regular ProFont has, and the apostrophe is nicer in the regular font.

Jacob Rus noticed that tool tips also show straight single and double quotes as curly quotes. I wasn’t even aware the text system could do that automatically.

Printing in TextMate

Yeah, printing sucks in TextMate. Jeremy Wilkins took it upon himself to write a simple command to print the current document using a2ps (available e.g. via DarwinPorts).

I should add that latest version of TextMate allows commands to get the current document marked up as XML using the current language grammar (see release notes for details), and printing is possible from the HTML output of commands. So it is possible to do syntax highlighted printing based on the current language grammar and whatever pre/post-processing desired. I added a proof-of-concept command for this in the Experimental bundle quoted here:

perl -pe 's/<\/[^>]+>/<\/span>/g' \
| perl -pe 's/<([^\/.>]+)[^>]*>/<span class="$1">/g' \
| perl -pe 's/\n/<br>\n/g' \
| perl -pe 's/\t/&nbsp;&nbsp;&nbsp;/g'

Basically these four regular expression substitutions transform the XML into HTML with <span class="…"> tags, newlines converted to <br>, and tabs converted to 3 non-breaking spaces.

I left out the stylesheet which style the classes. For the records, these are: comment, constant, entity, keyword, storage, string, support, and variable.

Alternative Shift Left/Right Keys

Some (mostly european) keymaps make ⌘[ and ⌘] hard or impossible to reach.

For those there is ⌥⇥ and ⌥⇧⇥.

4 Comments

  1. 07 Apr 2006 | # Haris Skiadas wrote…

    We are indeed in deep need of such posts, keep it up.

    May I suggest changing the printing command to:

    perl -pe 's/<\/[^>]+>/<\/span>/g' \ | perl -pe 's/<([^\/.>]+)[^>]*>//g' \ | perl -pe 's/\n/\n/g' \ | perl -pe "s/\s{$TM_TAB_SIZE}/   /g" \ | perl -pe 's/\t/   /g'

    to take care of documents indented in soft-tabs mode?

  2. 07 Apr 2006 | # Haris Skiadas wrote…

    hehe, those spaces should have been &nbsp;

    You should set up some Preview Comment feature.

  3. 07 Apr 2006 | # Haris Skiadas wrote…

    Hm, actually the other lines don't look right either. I won't try again, I'm just suggesting the extra line with the $TM_TAB_SPACE, which should look like:

    | perl -pe "s/\s{$TM_TAB_SIZE}/&nbsp;&nbsp;&nbsp;/g" \

  4. 08 Apr 2006 | # Allan Odgaard wrote…

    Haris: we can also wrap the output in:

    <div style="white-space: pre; -khtml-line-break: after-white-space;"> … </div>

    And yes, preview would be a nice addition.

Comments closed, you can use the mailing list for discussion.