<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>TextMate Blog</title>
	<atom:link href="http://blog.macromates.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.macromates.com</link>
	<description>TextMate and OS X</description>
	<lastBuildDate>Fri, 29 Mar 2013 11:21:20 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Nightly Build not Updating</title>
		<link>http://blog.macromates.com/2013/nightly-build-not-updating/</link>
		<comments>http://blog.macromates.com/2013/nightly-build-not-updating/#comments</comments>
		<pubDate>Fri, 29 Mar 2013 11:21:20 +0000</pubDate>
		<dc:creator>Michael Sheets</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=348</guid>
		<description><![CDATA[For those that live on the cutting edge by watching the nightly builds of the 2.0 alpha you have been cutoff from automatic updates by an unfortunate bug introduced in a recent build (a9401). You can update by opening preferences (<abbr title="Command-Comma">⌘,</abbr>) and switching to the Software Update tab (<abbr title="Command-5">⌘5</abbr>). Here you will notice that the [...]]]></description>
				<content:encoded><![CDATA[<p>For those that live on the cutting edge by watching the nightly builds of the 2.0 alpha you have been cutoff from automatic updates by an unfortunate bug introduced in a recent build (a9401). You can update by opening preferences (<code><abbr title="Command-Comma">⌘,</abbr></code>) and switching to the Software Update tab (<code><abbr title="Command-5">⌘5</abbr></code>). Here you will notice that the last check was a while ago and can manually check for an update by clicking &#034;Check Now&#034;. After updating to a9409 or newer it will again check automatically for updates.</p>

<p>If you are using the &#034;Normal Releases&#034; option in this tab this bug does not affect you.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2013/nightly-build-not-updating/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple Events &amp; 10.8.2</title>
		<link>http://blog.macromates.com/2012/apple-events-10-8-2/</link>
		<comments>http://blog.macromates.com/2012/apple-events-10-8-2/#comments</comments>
		<pubDate>Wed, 17 Oct 2012 07:02:05 +0000</pubDate>
		<dc:creator>Michael Sheets</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=345</guid>
		<description><![CDATA[Recently we have been getting reports of some issues with Transmit, QuickCursor and other applications that use Apple events to communicate with TextMate. Thanks to Brian Webster and Michael Tsai this has been tracked down to a bug in the appleeventsd process in 10.8.2, hopefully this will be fixed quickly by Apple. A workaround for [...]]]></description>
				<content:encoded><![CDATA[<p>Recently we have been getting reports of some issues with <a href="http://panic.com/transmit/" title="Panic - Transmit">Transmit</a>, <a href="http://www.hogbaysoftware.com/products/quickcursor" title="QuickCursor — Your text editor anywhere for Mac.">QuickCursor</a> and other applications that use <a href="http://en.wikipedia.org/wiki/Apple_events" title="Apple events - Wikipedia">Apple events</a> to communicate with TextMate. Thanks to <a href="http://brian-webster.tumblr.com/post/32830692042/a-workaround-for-aesendmessage-hanging-on-os-x-10-8-2" title="A workaround for AESendMessage() hanging on OS X 10.8.2">Brian Webster</a> and <a href="http://mjtsai.com/blog/2012/10/04/aesendmessage-bug-in-mac-os-x-10-8-2/" title="AESendMessage Bug in Mac OS X 10.8.2">Michael Tsai</a> this has been tracked down to a bug in the <code>appleeventsd</code> process in 10.8.2, hopefully this will be fixed quickly by Apple.</p>

<p>A workaround for Transmit would be to mount the server as a hard drive and open the files from there as it would bypass the bug, this would also work in other file transfer programs that have this feature. You can get more information and alternative workarounds at the their respective posts linked above.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/apple-events-10-8-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nested Replacements</title>
		<link>http://blog.macromates.com/2012/nested-replacements/</link>
		<comments>http://blog.macromates.com/2012/nested-replacements/#comments</comments>
		<pubDate>Tue, 25 Sep 2012 12:01:15 +0000</pubDate>
		<dc:creator>Allan Odgaard</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=342</guid>
		<description><![CDATA[While updating the TextMate source to use ARC I needed to update the following code: NSAutoreleasePool* pool = [NSAutoreleasePool new]; … [pool drain]; To use the new autorelease blocks: @autoreleasepool { … } Searching We can find all the autorelease constructs using a regular expression like the following: NSAutoreleasePool.*(?m)(.*?)\[pool \w+\]; I made the assumption here [...]]]></description>
				<content:encoded><![CDATA[<p>While updating the TextMate source to use ARC I needed to update the following code:</p>

<pre><code>NSAutoreleasePool* pool = [NSAutoreleasePool new];
…
[pool drain];
</code></pre>

<p>To use the new autorelease blocks:</p>

<pre><code>@autoreleasepool {
    …
}
</code></pre>

<p><span id="more-342"></span></p>

<h2>Searching</h2>

<p>We can find all the autorelease constructs using a regular expression like the following:</p>

<pre><code>NSAutoreleasePool.*(?m)(.*?)\[pool \w+\];
</code></pre>

<p>I made the assumption here that our autorelease pool variable is always named <code>pool</code>. If that is not the case, one could use a back-reference.</p>

<p>As for the pattern: The <code>(?m)</code> syntax enables “multiline matching”, meaning that the “any” operator (<code>.</code>) matches newlines. This isn’t enabled until the second use of <code>.</code>, so the first <code>.*</code> will only match the first line (excluding its newline).</p>

<p>The code between declaring the pool and draining/releasing it is matched by <code>.*?</code> wrapped in parentheses to capture it. As we are in multiline mode, we make it a non-greedy match by using the non-greedy modifier (<code>?</code>), i.e. using <code>.*?</code> instead of just <code>.*</code>.</p>

<p>Had we not made it non-greedy, and a file contained more than one use of an autorelease pool, we would have gotten just one match from that file, which would encompass all of the pools.</p>

<h2>Replacing</h2>

<p>A naive replacement string would be:</p>

<pre><code>@autoreleasepool {$1}
</code></pre>

<p>If however you enter this after having done the find, you’ll get a replacement preview and notice that this isn’t satisfying:</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/09/autorelease_replacement_preview.png" alt="Autorelease Replacement Preview" /></p>

<p>The problem is that the capture (<code>$1</code>) should be indented. Fortunately TextMate offers you its powerful <a href="http://blog.macromates.com/2011/format-strings/">format string syntax</a> in the replacement field, which means we can perform further replacements on the capture. In particular we wish to increase the indent by one tab, which can be done using:</p>

<pre><code>${1/^/\t/g}
</code></pre>

<p>What we do is match “begin of line” using <code>^</code> and then replacing that with a single tab (<code>\t</code>), specifying <code>g</code> as option to make it repeat (global). Looking at the preview though this isn’t entirely right either:</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/09/indented_autorelease_replacement_preview.png" alt="Indented Autorelease Replacement Preview" /></p>

<p>The problem is that the first and last lines are indented. What we really want is to only add a tab to lines which are non-empty. This can be done using the following replacement:</p>

<pre><code>${1/^\t*(?=\S)/$0\t/g}
</code></pre>

<p>Here we match begin of line followed by zero or more tab characters and then <strong>not</strong> followed by whitespace. <code>\S</code> matches non-whitespace characters, where newline counts as whitespace, and wrapping it in <code>(?=…)</code> makes it a “look-ahead assertion” meaning that it is not part of the actual match, we just ensure the match is followed by this.</p>

<p>The entire replacement string now becomes:</p>

<pre><code>@autoreleasepool {${1/^\t*(?=\S)/$0\t/g}}
</code></pre>

<p>Which gives us the desired replacement:</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/09/final_autorelease_replacement_preview.png" alt="Final Autorelease Replacement Preview" /></p>

<h2>Addendum</h2>

<p>The ability to process captures when doing search and replace is not limited to regular expression transformations, TextMate offers conditional insertions, case transformations, and even an asciify conversion.</p>

<p>You can find the full range of options in Help → TextMate Help → Format String Syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/nested-replacements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Beyond Document Scopes</title>
		<link>http://blog.macromates.com/2012/beyond-document-scopes/</link>
		<comments>http://blog.macromates.com/2012/beyond-document-scopes/#comments</comments>
		<pubDate>Wed, 22 Aug 2012 22:30:27 +0000</pubDate>
		<dc:creator>Allan Odgaard</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=333</guid>
		<description><![CDATA[The way to specialize things in TextMate is via the venerable scope selector matched against the current scope. TextMate 1 created the scope by parsing the document’s content using a language grammar. Though sometimes, more context information is needed than what can be provided by the document’s content, which is why TextMate 2 has extended [...]]]></description>
				<content:encoded><![CDATA[<p>The way to specialize things in TextMate is via the venerable <a href="http://manual.macromates.com/en/scope_selectors">scope selector</a> matched against the current scope.</p>

<p>TextMate 1 created the scope by parsing the document’s content using a language grammar. Though sometimes, more context information is needed than what can be provided by the document’s content, which is why TextMate 2 has extended the information stored in a scope.</p>

<p><span id="more-333"></span></p>

<p>Two examples of where there is a lot of choice (and thus bundles) are build systems and revision control.</p>

<p>For this reason, we introduced scopes for these two things. If you have the TextMate source checked out and press <abbr title="Control-Shift-P">⌃⇧P</abbr> (Show Scope) with <a href="https://github.com/textmate/textmate/blob/master/README.md">README.md</a> open then you should see something like:</p>

<pre><code>text.html.markdown
attr.rev-path.md.README.TextMate.Projects.duff.Users
attr.os-version.10.8.0
attr.scm.git
attr.project.ninja
attr.scm.branch.master
attr.scm.status.H
</code></pre>

<p>The relevant scopes are <code>attr.scm.git</code> and <code>attr.project.ninja</code>. By having a scope for the SCM system we have been able to make all the SCM bundles use <abbr title="Command-Y">⌘Y</abbr> as key equivalent (hint <abbr title="Shift-Command-Y">⇧⌘Y</abbr> is the key for showing “SCM Status” in the file browser). Likewise, by having <code>attr.project.ninja</code> we can scope the <a href="https://github.com/textmate/ninja.tmbundle">Ninja bundle’s</a> Build command to <abbr title="Command-B">⌘B</abbr>, even though this key is also used by Make, Xcode Build, and similar.</p>

<p>As for the latter key though, <abbr title="Command-B">⌘B</abbr> is also bound to “Bold” in many markup languages so we have a conflict. The Build command “wins” because the attribute scopes are more specific than the content scopes which means that if we press <abbr title="Command-B">⌘B</abbr> in our <a href="https://github.com/textmate/textmate/blob/master/README.md">README.md</a> then we will build the project rather than make a word bold.</p>

<p>If we select a word, as we would normally do before bolding it, and show the scope, we see that TextMate 2 has another nice new thing in the scope:</p>

<pre><code>text.html.markdown
⋮
dyn.selection.continuous
</code></pre>

<p>The new <code>dyn.selection</code> scope allows us to override keys only when there is a selection, for example I have rebound the <code>{</code> key (no modifiers, but requires a selection) to wrap and indent the selection in a pair of braces, likewise <code>}</code> will unwrap and unindent the selection (a feature that goes well together with <abbr title="Shift-Command-B">⇧⌘B</abbr> to first select the braces/block).</p>

<p>In the case of our Build command, I ended up scoping it like this:</p>

<pre><code>attr.project.ninja - (text dyn.selection)
</code></pre>

<p>This means that for projects with a <code>build.ninja</code> file, we can press <abbr title="Command-B">⌘B</abbr> to build except when in a text file <strong>and</strong> we have a selection, in that case, <abbr title="Command-B">⌘B</abbr> means Bold.</p>

<p>TextMate knows about a handful of build systems and SCM systems, if yours is missing from <a href="https://github.com/textmate/textmate/blob/master/Frameworks/file/src/path_info.cc#L40">the list</a>, please send us a note (or pull request) and we’ll add it.</p>

<p>There are times when TextMate can’t provide the desired attribute scopes. For example I use <a href="https://github.com/CxxTest">CxxTest</a> and created a bundle with snippets that only make sense in test files. If these can be scoped specifically to my tests, I can use simpler tab triggers, for example I can override <code>main<abbr title="Tab">⇥</abbr></code> or <code>cl<abbr title="Tab">⇥</abbr></code> for something which is more appropriate for test files, but test files are just regular C++ files, so what to do?</p>

<p>If you look in the <a href="https://github.com/textmate/textmate/blob/master/.tm_properties">.tm_properties</a> of the TextMate source you will see we have these lines:</p>

<pre><code>[ tests/*.{cc,mm} ]
scopeAttributes = 'attr.test.cxxtest'
TM_NINJA_TARGET = '${TM_FILEPATH/^.*?([^\/]*)\/tests\/.*$/$1\/test/}'
</code></pre>

<p>The key here is <code>scopeAttributes</code>. We use that to add our own scope attributes to test files, which by convention are always placed in a <code>tests</code> directory.</p>

<p>This way the <a href="https://github.com/textmate/cxxtest.tmbundle">CxxTest bundle</a> can scope all its items to <code>attr.test.cxxtest</code> and not worry about (globally) eclipsing “standard” keys and tab triggers, when specializing them for test files.</p>

<p>You’ll also notice I set the <code>TM_NINJA_TARGET</code> environment variable for test files. The regular expression might look scary, but basically with a path like:</p>

<pre><code>/Users/duff/Projects/TextMate/Frameworks/scm/tests/t_git.cc
</code></pre>

<p>It will set <code>TM_NINJA_TARGET</code> to <code>scm/test</code>. This means pressing <abbr title="Command-B">⌘B</abbr> in a test file will build the framework’s test target (i.e. run the tests).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/beyond-document-scopes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Injection Grammars &amp; Project Variables</title>
		<link>http://blog.macromates.com/2012/injection-grammars-project-variables/</link>
		<comments>http://blog.macromates.com/2012/injection-grammars-project-variables/#comments</comments>
		<pubDate>Thu, 16 Aug 2012 09:21:11 +0000</pubDate>
		<dc:creator>Allan Odgaard</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=329</guid>
		<description><![CDATA[I was recently dealing with issue #157 and wanted to store a reference in the source. Of course this reference should be an underlined link and allow us to easily go to the online issue, yet I don’t want a 50 character long URL in the source, so how do we go about this? Highlight [...]]]></description>
				<content:encoded><![CDATA[<p>I was recently dealing with <a href="https://github.com/textmate/textmate/issues/157">issue #157</a> and wanted to store a reference in the source.</p>

<p>Of course this reference should be an underlined link and allow us to easily go to the online issue, yet I don’t want a 50 character long URL in the source, so how do we go about this?</p>

<p><span id="more-329"></span></p>

<h2>Highlight</h2>

<p>The first key to the solution is “injection grammars”. A new feature in 2.0 allows you to create a new grammar, and rather than apply it to the whole file, you tell TextMate which scope it should be applied to using a <a href="http://manual.macromates.com/en/scope_selectors">scope selector</a>.</p>

<p>This means we can add small grammars for strings, comments, and similar, and we already have a few of these. Looking in the <a href="https://github.com/textmate/hyperlink-helper.tmbundle">Hyperlink Helper bundle</a> we see this grammar injected into <code>text, string, comment</code> (this is the version prior to my changes):</p>

<pre><code>{   patterns = (
        {   match = '(?x)
                ( (https?|s?ftp|ftps|file|smb|afp|nfs|(x-)?man(-page)?|gopher|txmt)://|mailto:)
                [-:@a-zA-Z0-9_.,~%+/?=&amp;#]+(?&lt;![.,?:])
            ';
            name = 'markup.underline.link.hyperlink';
        },
    );
}
</code></pre>

<p>This means we get URLs highlighted inside strings, comments, and in text files (e.g. <code>text.plain</code>).</p>

<p>I decided on a reference syntax like <code>&lt;issue://157&gt;</code> so adding <code>issue</code> to the URL schemes in the above match pattern gives me highlight of these references in all comments, strings, and text files. That was easy!</p>

<h2>Action</h2>

<p>Next problem to solve is how to actually open them. We already have an <em>“Open Current URL”</em> command in the <a href="https://github.com/textmate/text.tmbundle">Text bundle</a> bound to enter (<abbr title="Enter">⌅</abbr>) and scoped to <code>markup.underline.link</code> so by default, pressing enter (fn return) on an issue will open it as a URL. Let’s inspect this command, you can find it by following these steps:</p>

<ol>
<li>Place caret on an underlined URL</li>
<li>Choose <em>Bundles → Select Bundle Item…</em> (<abbr title="Control-Command-T">⌃⌘T</abbr>)</li>
<li>Switch to key equivalent search (<abbr title="Command-4">⌘4</abbr>)</li>
<li>Press enter (<abbr title="Enter">⌅</abbr>) to see what is bound to that key</li>
<li>Press option return (<abbr title="Option-Return">⌥↩</abbr>) or the arrow button to edit that item</li>
</ol>

<p>This reveals that the command (written as a shell script) is doing:</p>

<pre><code>open "$(cat)"
</code></pre>

<p>The command has its input set to “selection or current scope” (presently the fallback is not visible in 2.0’s preliminary bundle editor). This means that <code>stdin</code> for this command will be the entire link (the “or scope” part).</p>

<p>We could modify this command to support the special <code>issue</code> scheme, but that is not elegant. Instead we make a minor but important change to the injection grammar from above. We change the <code>name</code> key to <code>markup.underline.link.$2.hyperlink</code>. What we did was add <code>$2</code> which is the second capture from the regular expression, namely the URL scheme (more about <a href="http://blog.macromates.com/2011/format-strings/">syntax allowed in format strings</a>).</p>

<p>This means that when we are on a URL we’ll get the URL’s scheme in the scope. So placing caret on <code>&lt;issue://157&gt;</code> (placed in a comment) and pressing <abbr title="Control-Shift-P">⌃⇧P</abbr> (to see current scope) shows us we now have:</p>

<pre><code>markup.underline.link.issue.hyperlink
</code></pre>

<p>What’s great about this is that we can now create a new command, still using enter as key equivalent, but using a more specific <a href="http://manual.macromates.com/en/scope_selectors">scope selector</a> so that it only targets <code>issue</code> links.</p>

<p>This command could simply be:</p>

<pre><code>open "https://github.com/textmate/textmate/issues/$(cat)"
</code></pre>

<p>But we can do better!</p>

<h2>Generalization</h2>

<p>TextMate 2 makes it easy to deal with project specific variables, I won’t repeat all of it here but instead recommend you read about <a href="http://blog.macromates.com/2011/git-style-configuration/">folder and file type specific settings</a>.</p>

<p>The gist of it is that you <a href="https://github.com/textmate/textmate/issues/89#issuecomment-7674796">should</a> place a <code>.tm_properties</code> file in the root of your project and in this, you can specify, amongst others, (environment) variables for the project. So for <a href="https://github.com/textmate/textmate/blob/master/.tm_properties">TextMate’s .tm_properties</a> I added:</p>

<pre><code>TM_ISSUE_URL = 'https://github.com/textmate/textmate/issues/%s'
</code></pre>

<p>Our <em>“Open Issue Link”</em> command can read this variable and use it to construct the final URL. Since I figured this would be useful for others than me, I <a href="https://github.com/textmate/hyperlink-helper.tmbundle/commit/570d25795d4c68d0ac809073a238c40dabe26ccc">added the command</a> to the hyperlink helper bundle and its source looks like this:</p>

<pre><code>#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -wKU
require "#{ENV['TM_SUPPORT_PATH']}/lib/escape"

abort "TM_ISSUE_URL is unset for this project." unless ENV.has_key? 'TM_ISSUE_URL'

link = STDIN.read
if link =~ %r{issue://(.+)}
  url = ENV['TM_ISSUE_URL'] % $1
  %x{ /usr/bin/open #{e_sh url} }
else
  abort "Not an issue link: ‘#{link}’"
end
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/injection-grammars-project-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ars Technica Interview</title>
		<link>http://blog.macromates.com/2012/ars-technica-interview/</link>
		<comments>http://blog.macromates.com/2012/ars-technica-interview/#comments</comments>
		<pubDate>Fri, 10 Aug 2012 19:56:15 +0000</pubDate>
		<dc:creator>Allan Odgaard</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=326</guid>
		<description><![CDATA[Chris Foresman did this nice interview with me. I hope it clears up some of the confusion that yesterday’s announcement may have left you with.]]></description>
				<content:encoded><![CDATA[<p><a href="http://arstechnica.com/author/chris-foresman/">Chris Foresman</a> did <a href="http://arstechnica.com/apple/2012/08/odgaard-i-will-continue-working-on-textmate-as-long-as-i-am-a-mac-user/">this nice interview with me</a>.</p>

<p>I hope it clears up some of the confusion that yesterday’s announcement may have left you with.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/ars-technica-interview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TextMate 2 at GitHub</title>
		<link>http://blog.macromates.com/2012/textmate-2-at-github/</link>
		<comments>http://blog.macromates.com/2012/textmate-2-at-github/#comments</comments>
		<pubDate>Thu, 09 Aug 2012 15:06:14 +0000</pubDate>
		<dc:creator>Allan Odgaard</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=322</guid>
		<description><![CDATA[Today I am happy to announce that you can find the source for TextMate 2 on GitHub. I’ve always wanted to allow end-users to tinker with their environment, my ability to do this is what got me excited about programming in the first place, and it is why I created the bundles concept, but there [...]]]></description>
				<content:encoded><![CDATA[<p>Today I am happy to announce that you can find the <a href="https://github.com/textmate/textmate">source for TextMate 2 on GitHub</a>.</p>

<p>I’ve always wanted to allow end-users to tinker with their environment, my ability to do this is what got me excited about programming in the first place, and it is why I created the bundles concept, but there are limits to how much a bundle can do, and with the still growing user base, I think the best move forward is to open source the program.</p>

<p>The choice of license is <a href="http://www.gnu.org/copyleft/gpl.html">GPL 3</a>. This is partly to avoid a closed source fork and partly because the hacker in me wants all software to be free (<a href="http://www.gnu.org/philosophy/free-sw.html">as in speech</a>), so in a time where our platform vendor is taking steps to limit our freedom, this is my small attempt of countering such trend.</p>

<p>I am also a pragmatist and realize that parts of the TextMate code base is useful for other (non-free) applications, so I may later move to a less restrictive license, as is currently the case with the bundles. For now, please get in touch with us if there are subsets of the code base you wish to use for non-free software, and we might be able to work something out.</p>

<p>Anything related to the code base, including contributions, can be discussed at the <a href="http://lists.macromates.com/listinfo/textmate-dev">textmate-dev</a> list or <a href="irc://irc.freenode.net/#textmate">#textmate</a> on <a href="http://freenode.net/">freenode.net</a>. Pull requests can be sent via GitHub but if you plan to make larger changes, it might be good to discuss them first if you want to ensure that we are interested in accepting a pull request for such change or simply want advice on how to go about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/textmate-2-at-github/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mountain Lions</title>
		<link>http://blog.macromates.com/2012/mountain-lions/</link>
		<comments>http://blog.macromates.com/2012/mountain-lions/#comments</comments>
		<pubDate>Wed, 25 Jul 2012 12:40:08 +0000</pubDate>
		<dc:creator>Michael Sheets</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=320</guid>
		<description><![CDATA[As you start to upgrade your system to the latest cat from Cupertino we have created a page on the wiki as a place to keep track of any issues and notes about Mountain Lion and TextMate. We will be keeping this updated if any new issues are found. You can bring up any issues [...]]]></description>
				<content:encoded><![CDATA[<p>As you start to upgrade your system to the latest cat from Cupertino we have created a <a href="http://wiki.macromates.com/Troubleshooting/MountainLion">page on the wiki</a> as a place to keep track of any issues and notes about Mountain Lion and TextMate.  We will be keeping this updated if any new issues are found.</p>

<p>You can bring up any issues or questions on the <a href="http://macromates.com/community">mailing list</a> or you can contact us directly <a href="http://macromates.com/contact">by email</a> or on <a href="http://twitter.com/macromates">Twitter</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/mountain-lions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Layout Engine</title>
		<link>http://blog.macromates.com/2012/the-layout-engine/</link>
		<comments>http://blog.macromates.com/2012/the-layout-engine/#comments</comments>
		<pubDate>Tue, 24 Jul 2012 10:51:10 +0000</pubDate>
		<dc:creator>James Gray</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=318</guid>
		<description><![CDATA[As in many other areas, TextMate 2&#039;s layout engine has received a bunch of improvements under the hood. It&#039;s sometimes hard to show these changes, at least until new features taking advantage of the changes begin to bubble up to the surface. Let&#039;s take a tour of some of those new features now, so I [...]]]></description>
				<content:encoded><![CDATA[<p>As in many other areas, TextMate 2&#039;s layout engine has received a bunch of improvements under the hood.  It&#039;s sometimes hard to show these changes, at least until new features taking advantage of the changes begin to bubble up to the surface.  Let&#039;s take a tour of some of those new features now, so I can show you just how dynamic what renders has become.</p>

<p>In this article will discuss:</p>

<ul>
<li>The replacement of invisible characters</li>
<li>Per-line soft wrap and indented soft wrap</li>
<li>Dynamic font sizing</li>
<li>Folding pattern upgrades</li>
</ul>

<p><span id="more-318"></span></p>

<h2>Not So Invisible</h2>

<p>When TextMate 2 renders content, certain invisible characters are now shown in a meaningful representation, to you as the user.  By way of example, if I type the following line into a shell script file and run it (with <abbr title="Control-R">⌃R</abbr>):</p>

<pre><code>printf "foo\rbar"
</code></pre>

<p>TextMate 2 shows me this output:</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/07/invisibles.png" alt="invisibles" /></p>

<p>This can help you recognize as hard to detect content is making it&#039;s way into your files.</p>

<h2>That&#039;s a Wrap</h2>

<p>Soft wrap has multiple enhancements in TextMate 2.  First, it can now be turned on and off by line.  Also, you format the wrapped string, which allows for some custom indentation.</p>

<p>A great example of both of these are the new style settings for comments in the Source bundle.  Here&#039;s a setting bound to the <code>comment.line.number-sign</code> scope (among others):</p>

<pre><code>{   indentedSoftWrap = {
        format = '${0/\S/ /g}';
        match = '.*(##?)\s+';
    };
    softWrap = :true;
}
</code></pre>

<p>The <code>softWrap = :true;</code> kicks in soft wrapping for lines ending in this scope.  That might be needed because a lot of users prefer not to wrap actual code content.  Comments are prose though, so it is probably desirable to treat them differently.</p>

<p>The <code>indentedSoftWrap</code> details give a regular expression to <code>match</code> the line where indenting started, and a <a href="http://blog.macromates.com/2011/format-strings/">Format Strings</a> that will be expanded in terms of that match and prepended to each line.</p>

<p>The effect of these settings is that a trailing comment can now be rendered as such:</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/07/soft_wrapped_comment.png" alt="Soft Wrapped Comment" /></p>

<p>It’s worth mentioning that, for the purposes of matching, a line now has a left and a right scope that we can explicitly match against via the new scope selector syntax for selecting on either side.  The left scope is the line’s starting scope and the right scope (which is what’s used by default if the selector doesn’t explicitly select side) is the line’s ending scope.  We will talk more about the new scope selector syntax in a future article.</p>

<h2>Sensible Font Sizing</h2>

<p>The first thing I absolutely have to say about font sizing is that proportional width fonts are now supported.  You asked for it and Allan added it.  Enough said about that.</p>

<p>Another nice new feature is that fonts and their sizing can be altered by scope.  For example, Markdown heading now adjust their size depending on the level of the heading.  This helps them standout.  Here are the settings from the Themes bundle tied to the <code>markup.heading.1</code> scope:</p>

<pre><code>{   fontName = 'Baskerville';
    fontSize = '2.25em';
}
</code></pre>

<p>Now the rule bound to <code>markup.heading.2</code> uses the same font at a smaller size:</p>

<pre><code>{   fontName = 'Baskerville';
    fontSize = '2.1em';
}
</code></pre>

<p>There are rules set for the other headings as well, on down to level six.</p>

<p>Notice that these sizes are being set in <code>em</code> so they will be relative to the rest of the document content.  You can also use <code>pt</code> (absolute) or <code>%</code> (relative).</p>

<h2>Fold on the Dotted Line</h2>

<p>The folding system has been extended with two new patterns to allow indent-based foldings.  Let&#039;s look at some examples of how this works.</p>

<p>For example, we might want to install these folding pattern settings for C++ (scoped to <code>source.c++</code>):</p>

<pre><code>{ foldingIndentedBlockStart  = '^\s*(public|protected|private):\s*(//.*)?$|^\s*/[*](?!.*[*]/)';
  foldingIndentedBlockIgnore = '^\s*#';
}
</code></pre>

<p>The first pattern (<code>foldingIndentedBlockStart</code>) decides what starts a foldable block. In this case it is either a visibility keyword (<code>public</code>/<code>private</code>) or <code>/*</code>.</p>

<p>The latter is to make a comment block like the following foldable:</p>

<pre><code>/*
 *  t_foldings.cc
 *  TextMate 2
 *  
 *  Created by Allan Odgaard on 2011-09-30.
 *  Copyright 2011 MacroMates. All rights reserved.
 */
</code></pre>

<p>The second pattern (<code>foldingIndentedBlockIgnore</code>) represents lines to ignore. For C++ this would be preprocessor directives:</p>

<pre><code>   class foldings_t
   {
   public:
      foldings_t (arguments);
#if 0
      virtual ~foldings_t ();
#endif

   private:
      /* data */
   };
</code></pre>

<p>This allows us to still fold from <code>public</code> and down to <code>private</code> despite the non-indented preprocessor directives.</p>

<p>For Markdown&#039;s folding settings (scoped to <code>text.html.markdown</code>), let&#039;s look at some more sneaky patterns:</p>

<pre><code>{  foldingIndentedBlockStart  = '^#+\s+';
   foldingIndentedBlockIgnore = '^(?!#+\s+)';
}
</code></pre>

<p>We let a heading be a start marker and then we effectively ignore everything which is not a heading, causing those lines to be included in the foldable block despite not being indented.  This allows you to collapse entire sections of a Markdown document down to just the headings.</p>

<p>These are just some of the ways TextMate 2 can now dynamically modify content as it is displayed for you.  Expect to see more developments in this area in the future, as the new layout engine gives plenty of room for growth.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/the-layout-engine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Find and Replace</title>
		<link>http://blog.macromates.com/2012/using-find-and-replace/</link>
		<comments>http://blog.macromates.com/2012/using-find-and-replace/#comments</comments>
		<pubDate>Fri, 06 Jul 2012 10:16:27 +0000</pubDate>
		<dc:creator>James Gray</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://blog.macromates.com/?p=313</guid>
		<description><![CDATA[Since the earliest word processors Find and Replace has been a standard feature expected by users editing almost any content. You can score extra points with the programming crowd if you support Regular Expressions, the swiss army knife mini-language of Find and Replace operations. Of course, TextMate 1 had both. TextMate 2 adds some subtle [...]]]></description>
				<content:encoded><![CDATA[<p>Since the earliest word processors Find and Replace has been a standard feature expected by users editing almost any content.  You can score extra points with the programming crowd if you support Regular Expressions, the swiss army knife mini-language of Find and Replace operations.  Of course, TextMate 1 had both.</p>

<p>TextMate 2 adds some subtle refinements to this already strong collection of features.</p>

<p>In this article will discuss:</p>

<ul>
<li>Keyboard usage of Find operations</li>
<li>New visual feedback provided for these operations</li>
<li>How to speed up your searches</li>
<li>Enhancements to the Find dialogs</li>
</ul>

<p><span id="more-313"></span></p>

<h2>The Three Shortcuts You Should Already Know</h2>

<p>Before we get into the Find enhancements, I need to make sure you&#039;ve taken the time to learn three very important Find shortcuts.</p>

<p>Personally, I&#039;m pretty lax on keyboard shortcuts.  I don&#039;t claim you need to know them all.  Sometimes a trip into the menus is totally acceptable.  In fact, there are shortcuts I recommend people don&#039;t learn for various reasons.  However, there are exceptions.  Some keyboard shortcuts are more important than others.  Some are almost required knowledge for efficient editing.  Three of those relate to Find operations:</p>

<ul>
<li><abbr title="Command-E">⌘E</abbr> (Use Selection for Find)</li>
<li><abbr title="Command-G">⌘G</abbr> (Find Next)</li>
<li><abbr title="Shift-Command-G">⇧⌘G</abbr> (Find Previous)</li>
</ul>

<p>Together, these three key combos form a super fast means to navigate Find operations without even needing to stop off at a dialog first.  Just select something, throw it on the Find clipboard with <abbr title="Command-E">⌘E</abbr>, and start jumping to matches with <abbr title="Command-G">⌘G</abbr> and/or <abbr title="Shift-Command-G">⇧⌘G</abbr>.</p>

<p>The real reason to learn these keys though is that they are Mac OS X standards.  This isn&#039;t just about TextMate.  Any well behaved Mac program with Find should honor these same keys.  Learn them once.  Use them everywhere.  I literally mean everywhere too, because the Find clipboard is shared between all applications.</p>

<h2>It&#039;s <abbr title="Command-G">⌘G</abbr> Everywhere</h2>

<p>That brings us to the first couple of TextMate 2 tweaks.</p>

<p>TextMate has always had a slightly hidden feature on <abbr title="Control-S">⌃S</abbr>.  It&#039;s called Incremental Search, which is just a fancy way of saying that it starts matching as you type.  The problem with the TextMate 1 version of this feature is that it used its own shortcuts for moving to the next or previous match.</p>

<p>TextMate 2 brings this feature inline with the rest of the OS by switching to <abbr title="Command-G">⌘G</abbr> and <abbr title="Shift-Command-G">⇧⌘G</abbr> for moving to the next and previous matches respectively.</p>

<p>Along the same lines, you can now walk through Find in Project (<abbr title="Shift-Command-F">⇧⌘F</abbr>) matches using <abbr title="Command-G">⌘G</abbr>.  Even if the next match is another file, TextMate 2 will take you there.</p>

<p>Now you can just remember that <abbr title="Command-G">⌘G</abbr> means Find Next everywhere.</p>

<h2>The Good and Bad of the Other Keyboard Shortcuts</h2>

<p>Now that we&#039;ve talked about the holy trinity of keyboard shortcuts, it&#039;s worth noting that TextMate adds one very handy Find shortcut of its own.  You might want to consider devoting brain power to learning this as well:</p>

<ul>
<li><abbr title="Shift-Command-E">⇧⌘E</abbr> (Use Selection for Replace)</li>
</ul>

<p>That pairs beautifully with <abbr title="Command-E">⌘E</abbr> and can save you a dialog visit for operations that need a Replace as well Find.</p>

<p>Of course, TextMate adds a ton of other shortcuts for Find operations.  One I find myself letting go of in TextMate 2 is Replace All (<abbr title="Control-Command-F">⌃⌘F</abbr>).  I used it quite a bit with TextMate 1 where I would often grab a search, press <abbr title="Command-E">⌘E</abbr>, grab the desired replacement, use <abbr title="Shift-Command-E">⇧⌘E</abbr> to set that, and finally Replace All (<abbr title="Control-Command-F">⌃⌘F</abbr>).  With TextMate 2&#039;s Find All (<abbr title="Option-Command-F">⌥⌘F</abbr>) I prefer to shorten that to select, <abbr title="Command-E">⌘E</abbr>, <abbr title="Option-Command-F">⌥⌘F</abbr>, and edit.  See <a href="http://blog.macromates.com/2011/multiple-carets/">the article on Multiple Carets</a> for a more thorough discussion of just how great Find All can be.</p>

<h2>Earning Tips</h2>

<p>Another tweak keyboard Find users are likely to enjoy is the addition of tooltip feedback for a few operations.  If you <abbr title="Command-G">⌘G</abbr>/<abbr title="Shift-Command-G">⇧⌘G</abbr> past the last match, a tooltip tells you that.</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/07/todo.png" alt="A Find tooltip" /></p>

<p>Also, you get a tooltip with match counts during Find All or Replace All operations.  That&#039;s handy since they can involve more matches than you can see on the screen.</p>

<p>Finally, you will see little stars marking matches in the gutter as you are working through a Find in Project searches.  This can help you see where your caret will go next and/or how many matches remain.</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/07/star.png" alt="A match star" /></p>

<p>These are simple but appreciated enhancements.</p>

<h2>The Need for Speed</h2>

<p>TextMate has always had a Find in Project (<abbr title="Shift-Command-F">⇧⌘F</abbr>) feature and it&#039;s terrific to be able to scan a huge set of files or use a Regular Expression to do some clever mass editing.  I&#039;ll be honest though and say that this feature took some heat during the TextMate 1 era for being on the slow side.  A lot of users resorted to using tools like grep or ack to achieve similar results faster.</p>

<p>It you have turned your back on the feature in the past, give it another shot after upgrading to TextMate 2.</p>

<p>First, it&#039;s just plain faster now.  That&#039;s a great start all by itself.  If you really need faster searching though, it&#039;s often attainable using Find in Project&#039;s new <em>In</em> and <em>matching</em> fields to restrict a Find to certain folders and/or to a &#034;glob&#034; of matching files respectively.  For example, <code>*.{html,css}</code> is a great glob for renaming a CSS class inside of your HTML and CSS files.</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/07/restricted.png" alt="A restricted Find in Project" /></p>

<h2>Remember Your History</h2>

<p>Ever been in that situation where you thought, &#034;I had that regex just a moment ago!&#034;.  You&#039;ve always been able to get those old searches back in TextMate by opening the Find dialog and using the history pop-up there.</p>

<p>Keeping with our skip-the-dialog theme though, TextMate 2 now allows you to use old searches straight from the keyboard.  Just invoke Find History (<abbr title="Control-Option-Command-F">⌃⌥⌘F</abbr>), arrow down to the desired search string, and press <abbr title="Return">↩</abbr> to restart that search.</p>

<p>This can be pretty handy if you are alternating between a small number of Find operations.</p>

<h2>Better Dialogs</h2>

<p>While I&#039;ve been pretty hard on the Find dialogs in this article, there are good reasons to access them at times.  When you do, you&#039;ll be treated to some new features there as well.</p>

<p>First, the unification of the Find and Find in Project dialogs means that you can get all of the matches from a single document presented in a list (as Find in Project has always done).  To see this list, use the Find All button (note that this is different from the Find All menu command).</p>

<p>There are also the new Full Words and Ignore Whitespace checkboxes.  Full Words hasn&#039;t been implemented yet, but Ignore Whitespace allows the amount of whitespace used to separate content to differ between the search string and matched content.  A typical use case for this would be if you have multiple lines of code that you want to find.  For example, say that I have five lines of code that I am almost certain is copied from elsewhere and I want to refactor it into a shared function.  A problem with finding the other use of that code is that it might be indented differently.  Use Ignoring Whitespace though and TextMate 2 will still find it.</p>

<p><img src="http://blog.macromates.com/wp-content/uploads/2012/07/find_options.png" alt="New Find options" /></p>

<p>In the enhanced Find in Project dialog of TextMate 2, you may also enjoy knowing that <abbr title="Command-1">⌘1</abbr>, <abbr title="Command-2">⌘2</abbr>, … <abbr title="Command-N">⌘N</abbr> will open that number of file with matches in it.  You can see which number is attached to which file by clicking of the result list header, for a pop-up.  You can also use the collapse all arrow to the left of this header to make it easy to count the files, as well as see the number of matches each contains.  This can save you a trip to the mouse when you know just what you are hunting for.</p>

<p>It&#039;s probably obvious that the result list also allows you to control what does and doesn&#039;t get updated, via the checkbox next to each match.  There are some hidden features here worth noting.  First, <abbr title="Option">⌥</abbr>-clicking a checkbox will toggle all of the checks for that file.  You can also copy content from the result list, complete with a file and line reference.  Just click on the desired entry and trigger Edit → Copy (<abbr title="Command-C">⌘C</abbr>).</p>

<p>Replacements are also smarter in TextMate 2.  Remember that they are <a href="http://blog.macromates.com/2011/format-strings/">Format Strings</a>, with all of the new abilities that entails.  The match list will also reflect changes as you are editing a replacement string in TextMate 2.  It&#039;s nice to be able to preview the changes you are about to make, before actually making them.  This is especially helpful when you are using clever Format String replacements.</p>

<p>None of these changes are major new features, but together they really round out and add to the robustness of TextMate 2&#039;s Find and Replace operations.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.macromates.com/2012/using-find-and-replace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
