<?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>Dysfunctional Programming &#187; code</title>
	<atom:link href="http://www.joshmatthews.net/blog/category/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joshmatthews.net/blog</link>
	<description>/* You are not expected to understand this */</description>
	<lastBuildDate>Tue, 24 Jan 2012 20:50:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Fast and the Furious: bzexport</title>
		<link>http://www.joshmatthews.net/blog/2011/07/the-fast-and-the-furious-bzexport/</link>
		<comments>http://www.joshmatthews.net/blog/2011/07/the-fast-and-the-furious-bzexport/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 23:18:03 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=126</guid>
		<description><![CDATA[If you&#8217;re a bzexport user, you&#8217;ll want to pull the latest revision. It&#8217;s recently been getting slower due to the number of http requests that need to be made (the tradeoff here is that it&#8217;s also been getting more correct), but I&#8217;ve pushed three patches that have reversed that downward slide into the molasses. By [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a <a href="http://hg.mozilla.org/users/tmielczarek_mozilla.com/bzexport/">bzexport</a> user, you&#8217;ll want to pull the latest revision. It&#8217;s recently been getting slower due to the number of http requests that need to be made (the tradeoff here is that it&#8217;s also been getting more correct), but I&#8217;ve pushed three patches that have reversed that downward slide into the molasses. By sending more data than is strictly necessary, caching information such as user name to email translations, and avoiding fetching data that rarely changes, I&#8217;ve noticeably improved the running time of bzexport on my machine. Give it a shot!</p>
<p>If you&#8217;re not a bzexport user, and you write patches that are submitted to bugzilla, you&#8217;re missing out. Bzexport simplifies that process of getting a patch out of your local machine and into the hands of your reviewer, making you a happier and more productive person.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2011/07/the-fast-and-the-furious-bzexport/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nsCOMPtr has never been so pretty</title>
		<link>http://www.joshmatthews.net/blog/2011/06/nscomptr-has-never-been-so-pretty/</link>
		<comments>http://www.joshmatthews.net/blog/2011/06/nscomptr-has-never-been-so-pretty/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 20:39:52 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=117</guid>
		<description><![CDATA[Jim Blandy announced his archer-mozilla pretty-printers for Spidermonkey late last year. I&#8217;ve used them a few times while working on some JS proxy bugs, and I&#8217;ve found them to be invaluable. So invaluable, in fact, that I&#8217;ve written a bunch of pretty-printers for some pain points outside of js/. If this prospect excites you so [...]]]></description>
			<content:encoded><![CDATA[<p>Jim Blandy announced his <a href="http://itcouldbesomuchbetter.wordpress.com/2010/12/20/debugging-spidermonkey-with-archer-2/">archer-mozilla</a> pretty-printers for Spidermonkey late last year. I&#8217;ve used them a few times while working on some JS proxy bugs, and I&#8217;ve found them to be invaluable. So invaluable, in fact, that I&#8217;ve written a bunch of pretty-printers for some pain points outside of js/.  If this prospect excites you so much that you can&#8217;t be bothered to read the remaining examples, you can acquire the code from <a href="http://hg.mozilla.org/users/josh_joshmatthews.net/archer-mozilla/">its hg repo</a>. Please note, you&#8217;ll need to be using gdb >7.2 (meaning probably <a href="http://www.gnu.org/software/gdb/current/">trunk</a> at the time of writing) due to dependencies on the dynamic_type feature which was recently added.</p>
<h2>What&#8217;s supported right now:</h2>
<h3>nsCOMPtr&lt;nsIFoo&gt;</h3>
<p>If you print an nsCOMPtr, you&#8217;ll see one of two things:<br />
<code>[(nsIFoo*) 0x0]</code><br />
or<br />
<code>[(nsConcreteFoo*) 0x12345678]</code></p>
<p>In addition, pretty-printers chain, so if there&#8217;s a pretty printer for nsConcreteFoo*, you&#8217;ll see that printed instead of just the pointer value.  Furthermore, nsRefPtr and nsAutoPtr are also supported, and maybe nsWeakPtr (untested).</p>
<h3>nsCString/nsString</h3>
<p>It prints the string inline, up to the limit specified by gdb. This probably only works for ascii strings at the moment; the code is a bit of a mess.</p>
<h3>nsTArray/InfallibleTArray</h3>
<p>You&#8217;ll get output along the lines of <code>[0x12345678, 0x12345678]</code> at the moment. Like the smart pointers, each printed element will be pretty-printed if possible.</p>
<h3>nsStandardURL*</h3>
<p>You&#8217;ll see the spec printed. This works wonderfully when you&#8217;re looking at an object with nsCOMPtr&lt;nsIURI&gt; foo, where foo is actually pointing to an nsStandardURL object.</p>
<h3>Tagged reference counts</h3>
<p>You know in cycle-collected objects when the refcount shows you <code>mTagged = 0x8</code>? Yeah, not any more.</p>
<h3>PRPackedBool</h3>
<p>I found the existing display of <code>mBoolVal = 1 '\001'</code> to be silly.</p>
<h2>What&#8217;s coming up?</h2>
<p>I&#8217;ve got a list of things that still need fixing/improving, and I&#8217;m open to suggestions/patches.</p>
<ul>
<li>Auto arrays &#8211; the kinda-sorta work right now, but it looks gross.</li>
<li>COM/void/observer arrays &#8211; don&#8217;t work at all</li>
<li>Hashtables &#8211; don&#8217;t work at all right now</li>
<li>Stricter regexes for matching types &#8211; things like pointers to arrays are matched by the nsTArray printer right now</li>
<li>Auto strings &#8211; I don&#8217;t remember if they don&#8217;t work at all or semi-work</li>
<li>PRUnichar* &#8211; doesn&#8217;t work.</li>
</ul>
<p>and so on and so forth. It&#8217;s really not difficult to write more printers, and it improves the output of gdb immensely in my opinion. Give it a shot! The instructions for how to set this up can be found in the README file. You&#8217;ll need a version of gdb > 7.2 (probably trunk, at the time of writing), since my printers rely on gdb.Type.dynamic_type.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2011/06/nscomptr-has-never-been-so-pretty/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Self-serve tools: now more likely to work</title>
		<link>http://www.joshmatthews.net/blog/2011/06/self-serve-tools-now-more-likely-to-work/</link>
		<comments>http://www.joshmatthews.net/blog/2011/06/self-serve-tools-now-more-likely-to-work/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 17:11:46 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=114</guid>
		<description><![CDATA[If you&#8217;ve given my self-serve tools a try (in particular, cancel.py) and had it claim that it couldn&#8217;t authorize you, it&#8217;s time to give it another shot. Steven Fink, being the wonderful person he is, dove in and found some weirdness going on with my usage of urllib and the self-serve API performing redirections. The [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve given my <a href="http://hg.mozilla.org/users/josh_joshmatthews.net/self-serve-tools">self-serve tools</a> a try (in particular, cancel.py) and had it claim that it couldn&#8217;t authorize you, it&#8217;s time to give it another shot. <a href="http://blog.mozilla.com/sfink/">Steven Fink</a>, being the wonderful person he is, dove in and found some weirdness going on with my usage of urllib and the self-serve API performing redirections. The end result is that the tool is significantly more likely to work for you, and if it doesn&#8217;t, I am really interested in seeing the output of <code>python cancel.py -d</code>, which makes urllib be significantly more verbose about what it&#8217;s sending and receiving.  Good hunting!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2011/06/self-serve-tools-now-more-likely-to-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build smarter, not harder</title>
		<link>http://www.joshmatthews.net/blog/2011/05/build-smarter-not-harder/</link>
		<comments>http://www.joshmatthews.net/blog/2011/05/build-smarter-not-harder/#comments</comments>
		<pubDate>Mon, 30 May 2011 15:54:38 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=107</guid>
		<description><![CDATA[I spent the past six weeks roaming around Europe with a netbook, and used that time productively to get some work done on Firefox. Part of that involved building on Windows for the first time, and experiencing the joy of pymake. However, I found the extra characters required to fire off incremental builds with pymake [...]]]></description>
			<content:encoded><![CDATA[<p>I spent the past six weeks roaming around Europe with a netbook, and used that time productively to get some work done on Firefox. Part of that involved building on Windows for the first time, and experiencing the joy of pymake. However, I found the extra characters required to fire off incremental builds with pymake pushed me just past the pain point required to get me to write some sort of automation. With that in mind, I introduce <a href="http://hg.mozilla.org/users/josh_joshmatthews.net/smartmake">smartmake</a>, a tool to allow you to specify as little information as possible to build incrementally while still ending up with a working finished build.</p>
<p>Here&#8217;s how it works: I&#8217;ve encoded some basic dependencies into a python file (any changes to layout/build, netwerk/build, js/src, etc. require a rebuild of toolkit/library, any changes to layout/ or dom/ require rebuilding layout/build, etc). You pass a list of srcdir directories that have been changed to the script, and it prints out a list of of build commands joined by &#038;&#038;, ie:</p>
<p><code>$ smartmake ipc/ipdl dom/src/geolocation<br />
make -C objdir/ipc/ipdl &#038;&#038; make -C objdir/dom/src/geolocation &#038;&#038; make -C objdir/layout/build &#038;&#038; make -C objdir/toolkit/library</code></p>
<p>It&#8217;s a pretty dumb tool at the moment, and there are certainly lots of edge cases that don&#8217;t actually work correctly. However, I found it useful enough in Europe that when I returned home to a different machine, I missed it. It&#8217;s hardcoded for my own setup right now, but I&#8217;ll try to make it more general if people are interested (ie. the objdir and cmd variables could be read from a config file). Hit me up with any requests or if you have wonderful ideas for how to improve it.</p>
<p><strong>Update:</strong> I&#8217;ve genericized it a small amount. Now, you&#8217;ll need to create .hg/.smartmake like so:<br />
<code>[smartmake]<br />
objdir: objdir/<br />
cmd: make -C</code><br />
before the updated smartmake will allow you to continue. Notice that this is per tree, not global. Furthermore, smartmake.py is designed to be used as a tool that outputs a command line &#8211; I have a shell alias that pipes its output to sh.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2011/05/build-smarter-not-harder/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Cancelling builds from the console, now easier than ever!</title>
		<link>http://www.joshmatthews.net/blog/2011/04/build-cancellation-from-the-console-gets-some-loving/</link>
		<comments>http://www.joshmatthews.net/blog/2011/04/build-cancellation-from-the-console-gets-some-loving/#comments</comments>
		<pubDate>Sat, 16 Apr 2011 18:19:29 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=103</guid>
		<description><![CDATA[The self-serve tools, specifically cancel.py has received some important usability upgrades at the urging of jst and ehsan. Now, simply running python cancel.py will be enough to get you going &#8211; you&#8217;ll be prompted for your username, password, branch and hg revision. The builds displayed also show their state (running, pending or complete) as well, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://hg.mozilla.org/users/josh_joshmatthews.net/self-serve-tools/">The self-serve tools</a>, specifically cancel.py has received some important usability upgrades at the urging of jst and ehsan.  Now, simply running
<pre>python cancel.py</pre>
<p> will be enough to get you going &#8211; you&#8217;ll be prompted for your username, password, branch and hg revision.  The builds displayed also show their state (running, pending or complete) as well, so it&#8217;s easier to find what you&#8217;re looking for.  Let me know if there are more changes you&#8217;d like made!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2011/04/build-cancellation-from-the-console-gets-some-loving/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Self-serve, now in bulk</title>
		<link>http://www.joshmatthews.net/blog/2011/03/self-serve-now-in-bulk/</link>
		<comments>http://www.joshmatthews.net/blog/2011/03/self-serve-now-in-bulk/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 03:38:06 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=92</guid>
		<description><![CDATA[Update: the tool is now easier to use and doesn&#8217;t require adding your password as an argument. See this post for more details. I&#8217;m a big fan of the self-serve tool that RelEng provided for people with LDAP access. When I can see a try build going bad, I can cancel all the remaining builds [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> the tool is now easier to use and doesn&#8217;t require adding your password as an argument. See <a href="http://www.joshmatthews.net/blog/2011/04/build-cancellation-from-the-console-gets-some-loving/">this post</a> for more details.</p>
<p>I&#8217;m a big fan of the <a href="https://build.mozilla.org/buildapi/self-serve/">self-serve tool</a> that RelEng provided for people with LDAP access.  When I can see a try build going bad, I can cancel all the remaining builds and free up resources, or retrigger completed builds if I want to get extra results.  Unfortunately, the server is fairly slow to respond and the UI to perform these actions is clumsy.  Luckily, there&#8217;s a really simple API available to allow anyone with access to make use of these tools in more traditional (read: non-graphical) means.  Allow me to introduce you to a new repo I set up today to make working with the self-serve API easier &#8211; <a href="http://hg.mozilla.org/users/josh_joshmatthews.net/self-serve-tools/">self-serve tools</a>.  <code>selfserve.py</code> contains simple wrappers for every API point exposed, and some basic documentation of the values returned by most of the calls.  <code>cancel.py</code> is an example of a really simple tool that can be built on top of the wrappers to allow for bulk cancellation.  Here&#8217;s what a session looks like:</p>
<pre>[jdm@Phaethon self-serve-tools]$ python cancel.py -u "jmatthews@mozilla.com" -p my5ecureP4ssword123 -r 306838f27b33 -b try
1: Linux x86-64 tryserver leak test build
2: Linux tryserver build
3: OS X 10.6.2 tryserver build
4: WINNT 5.2 tryserver build
5: Maemo 5 QT tryserver build
6: OS X 10.6.2 tryserver leak test build
7: Maemo 5 GTK tryserver build
8: Android R7 tryserver build
9: Linux tryserver leak test build
10: WINNT 5.2 tryserver leak test build
11: OS X 10.5.2 tryserver leak test build
12: Linux QT tryserver build
13: Linux x86-64 tryserver build
14: all
Builds to cancel: 1 3 5
Cancelling Linux x86-64 tryserver leak test build
Cancelling OS X 10.6.2 tryserver build
Cancelling Maemo 5 QT tryserver build
</pre>
<p>This is just the first cut, but I&#8217;m excited not to have to use the web interface any more.  Please feel free to add further documentation, or even new tools!  I&#8217;m excited to see what other people can build with this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2011/03/self-serve-now-in-bulk/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>nsITimer anti-pattern</title>
		<link>http://www.joshmatthews.net/blog/2011/03/nsitimer-anti-pattern/</link>
		<comments>http://www.joshmatthews.net/blog/2011/03/nsitimer-anti-pattern/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 16:40:56 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=85</guid>
		<description><![CDATA[I&#8217;ve filed bug 640629 to address an intermittent source of orange: incorrect nsITimer creation. I first ran across it while working on making httpd.js collect garbage more frequently, a task which quickly turned into orange whack-a-mole as more and more problematic test constructs popped out of the nether. Mounir Lamouri (volkmar) recently fixed another instance [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve filed <a href="http://bugzil.la/640629">bug 640629</a> to address an intermittent source of orange: incorrect nsITimer creation.  I first ran across it while working on <a href="http://bugzil.la/508128">making httpd.js collect garbage more frequently</a>, a task which quickly turned into orange whack-a-mole as more and more problematic test constructs popped out of the nether.  Mounir Lamouri (volkmar) recently fixed another instance of the nsITimer problem, so I thought I&#8217;d address it in public and do some education.</p>
<p>When you see a construct like this, you should be wary:</p>
<div class="dean_ch" style="white-space: nowrap;"><span class="kw2">function</span> doSomething<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw2">var</span> timer = Cc<span class="br0">&#91;</span><span class="st0">&quot;@mozilla.org/timer;1&quot;</span><span class="br0">&#93;</span>.<span class="me1">createInstance</span><span class="br0">&#40;</span>Ci.<span class="me1">nsITimer</span><span class="br0">&#41;</span>;<br />
&nbsp; timer.<span class="me1">initWithCallback</span><span class="br0">&#40;</span>callback, delay, timer.<span class="me1">TYPE_ONE_SHOT</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>There&#8217;s a common misconception that timers retain an extra reference that is released after they fire.  This is false.  If a timer is created and stored in a locally-scoped variable and the scope is exited, the timer is at risk of being garbage-collected before the timer fires.  To combat this, store a reference to the timer elsewhere &#8211; a member of an object that outlives the current scope, a global variable, it doesn&#8217;t matter.  Do your part &#8211; save a timer&#8217;s life today.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2011/03/nsitimer-anti-pattern/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Knowledge++</title>
		<link>http://www.joshmatthews.net/blog/2010/04/knowledge/</link>
		<comments>http://www.joshmatthews.net/blog/2010/04/knowledge/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 04:39:46 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[mozilla]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=79</guid>
		<description><![CDATA[Nine days ago, I made an off-hand remark in #content that I might be able to get the geolocation service working in Fennectrolysis by the end of the day if my plans worked out. I also remember referring to the process as &#8220;not a big deal.&#8221; Since that moment, I have put in a significant [...]]]></description>
			<content:encoded><![CDATA[<p>Nine days ago, I made an off-hand remark in #content that I might be able to get the <a href="http://bugzil.la/552822">geolocation service</a> working in <a href="http://wiki.mozilla.org/Mobile/e10s">Fennectrolysis</a> by the end of the day if my plans worked out.  I also remember referring to the process as &#8220;not a big deal.&#8221;  Since that moment, I have put in a significant amount of work (at least several hours every day), and learned:</p>
<ul>
<li>My estimating skills are severely underdeveloped</li>
<li>How to make use of the cycle collector</li>
<li>How weak references work</li>
<li>Best practices for XPCOM reference counting</li>
<li>There&#8217;s a confusing thing called nsIClassInfo which I should learn more about, but I know enough to force it to do my bidding for now</li>
<li>How non-modal prompts work</li>
<li>The meaning of obscure GCC linker errors like &#8220;undefined reference to vtable&#8221;</li>
<li>How to implement an XPCOM object in Javascript</li>
<li>Implementing XPCOM objects in Javascript frequently results in much more pleasant code than C++</li>
</ul>
<p>Having said all that, yesterday I got the Fennec geolocation permission prompt to appear when triggered by a content page, and the proper callback was called when I allowed or canceled the request, so I&#8217;m confident that I can have a patch up for review by the end of the holiday weekend.  Of course, given my track record, that means it might be up by the end of the week.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2010/04/knowledge/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Faster mercurial patch queue merging with emacs</title>
		<link>http://www.joshmatthews.net/blog/2010/03/faster-mercurial-patch-queue-merging-with-emacs/</link>
		<comments>http://www.joshmatthews.net/blog/2010/03/faster-mercurial-patch-queue-merging-with-emacs/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 01:41:03 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[mozilla]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=52</guid>
		<description><![CDATA[As a follow-up to my previous post about merging mq reject in emacs, I thought I&#8217;d share some improvements to the process that I&#8217;ve made since then. &#40;defun switch-hg-reject &#40;&#41; &#160; &#40;interactive&#41; &#160; &#40;let &#40;&#40;other-file &#160; &#160; &#160;&#40;if &#40;string= &#40;substring &#40;buffer-file-name&#41; -4 nil&#41; &#34;.rej&#34;&#41; &#160; &#160; &#160; &#160; &#160;&#40;substring &#40;buffer-file-name&#41; 0 -4&#41; &#160; &#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow-up to <a href="http://www.joshmatthews.net/blog/2010/01/dealing-with-mercurial-patch-queue-rejects-in-emacs/">my previous post</a> about merging mq reject in emacs, I thought I&#8217;d share some improvements to the process that I&#8217;ve made since then.</p>
<div class="dean_ch" style="white-space: nowrap;"><span class="br0">&#40;</span><span class="kw1">defun</span> switch-hg-reject <span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#40;</span>interactive<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#40;</span><span class="kw1">let</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>other-file<br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#40;</span><span class="kw1">if</span> <span class="br0">&#40;</span>string= <span class="br0">&#40;</span>substring <span class="br0">&#40;</span>buffer-file-<span class="kw1">name</span><span class="br0">&#41;</span> <span class="nu0">-4</span> <span class="kw1">nil</span><span class="br0">&#41;</span> <span class="st0">&quot;.rej&quot;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#40;</span>substring <span class="br0">&#40;</span>buffer-file-<span class="kw1">name</span><span class="br0">&#41;</span> <span class="nu0">0</span> <span class="nu0">-4</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#40;</span>concat <span class="br0">&#40;</span>buffer-file-<span class="kw1">name</span><span class="br0">&#41;</span> <span class="st0">&quot;.rej&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#40;</span><span class="kw1">if</span> <span class="br0">&#40;</span>file-exists-p other-file<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#40;</span>save-selected-window<br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span>switch-to-buffer-other-window <span class="br0">&#40;</span>find-file-noselect other-file<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#40;</span>message <span class="st0">&quot;No alternate reject file found&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></p>
<p><span class="br0">&#40;</span><span class="kw1">defun</span> kill-hg-reject <span class="br0">&#40;</span><span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#40;</span>interactive<span class="br0">&#41;</span><br />
&nbsp; <span class="br0">&#40;</span><span class="kw1">let</span> <span class="br0">&#40;</span><span class="br0">&#40;</span>reject-file <span class="br0">&#40;</span>concat <span class="br0">&#40;</span>buffer-file-<span class="kw1">name</span><span class="br0">&#41;</span> <span class="st0">&quot;.rej&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="br0">&#40;</span>kill-buffer<br />
&nbsp; &nbsp; &nbsp;<span class="br0">&#40;</span>find-buffer-visiting reject-file<span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></p>
<p><span class="br0">&#40;</span>global-set-key <span class="br0">&#40;</span>kbd <span class="st0">&quot;C-c r&quot;</span><span class="br0">&#41;</span> &#8216;switch-hg-reject<span class="br0">&#41;</span><br />
<span class="br0">&#40;</span>global-set-key <span class="br0">&#40;</span>kbd <span class="st0">&quot;C-x r&quot;</span><span class="br0">&#41;</span> &#8216;kill-hg-reject<span class="br0">&#41;</span></div>
<p>It turns out that swapping back and forth between the reject and the original in a single window felt was quite inefficient.  With these changes, the reject opens up in another window (think emacs terminology here) on <code>C-c r</code>, and I can kill it later with <code>C-x r</code>.  This also works better with other modules like uniquify &#8211; the code from the previous post would fail when trying to access rejects associated with buffers name &#8220;Makefile.in|ipc&#8221;.  No longer must you suffer the indignity of process!  Merging can, and should, be fun!  BEHOLD MY WORKS AND DESPAIR.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2010/03/faster-mercurial-patch-queue-merging-with-emacs/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cross-compiling with MinGW on Fedora</title>
		<link>http://www.joshmatthews.net/blog/2010/02/cross-compiling-with-mingw-on-fedora/</link>
		<comments>http://www.joshmatthews.net/blog/2010/02/cross-compiling-with-mingw-on-fedora/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 13:22:29 +0000</pubDate>
		<dc:creator>Josh Matthews</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[megazeux]]></category>
		<category><![CDATA[projects]]></category>

		<guid isPermaLink="false">http://www.joshmatthews.net/blog/?p=55</guid>
		<description><![CDATA[My goodness, I&#8217;m impressed. Having released the first iteration of my robotic debugger, I was informed that the fork()/exec() combo isn&#8217;t portable to Windows. Nobody volunteered any patches immediately, so I decided to read up on cross-compiling since I really dislike having to reboot into my other partition. Turns out that the entire MinGW stack [...]]]></description>
			<content:encoded><![CDATA[<p>My goodness, I&#8217;m impressed.  Having <a href="http://www.digitalmzx.net/forums/index.php?showtopic=14776&#038;hl=">released</a> the first iteration of my robotic debugger, I was informed that the fork()/exec() combo isn&#8217;t portable to Windows.  Nobody volunteered any patches immediately, so I decided to read up on cross-compiling since I really dislike having to reboot into my other partition.  Turns out that the entire MinGW stack has been packaged up for Fedora, meaning that all I had to do in the end was:<br />
<code># yum install mingw32-gcc mingw32-gcc-c++ mingw32-libpng mingw32-SDL<br />
$ mingw32-make -j2</code></p>
<p>It wasn&#8217;t quite that easy &#8211; since Megazeux uses a non-standard configure script, I had to correct a few faulty assumptions.  I never figured out the correct way to use
<pre>/usr/i686-pc-mingw32/sys-root/mingw/bin/sdl-config</pre>
<p> instead of the default one, so that got hardcoded somewhere.  Also, Megazeux relies on libogg and libvorbis, which haven&#8217;t been pushed to the fedora repository yet (packaging limbo ahoy!), but I was able to grab some rpms that the mingw32 packager helpfully left lying around.  All in all, a very successful and satisfying experience.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshmatthews.net/blog/2010/02/cross-compiling-with-mingw-on-fedora/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

