<?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>The Cliffs of Inanity &#187; Emacs</title>
	<atom:link href="http://tromey.com/blog/?cat=11&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://tromey.com/blog</link>
	<description></description>
	<lastBuildDate>Fri, 17 Feb 2012 15:12:23 +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>Difficulties of elisp</title>
		<link>http://tromey.com/blog/?p=778&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=difficulties-of-elisp</link>
		<comments>http://tromey.com/blog/?p=778#comments</comments>
		<pubDate>Sat, 28 Jan 2012 03:36:02 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=778</guid>
		<description><![CDATA[The thesis that underlies my project to translate the Emacs C code to Common Lisp is that Emacs Lisp is close enough to Common Lisp that the parts of the Emacs C code that implement Lisp can be dropped in favor of the generally superior CL implementation.  This is generally true, but there are a [...]]]></description>
				<content:encoded><![CDATA[<p>The thesis that underlies my <a title="Emacs and Common Lisp, Part 2" href="http://tromey.com/blog/?p=751">project to translate the Emacs C code to Common Lisp</a> is that Emacs Lisp is close enough to Common Lisp that the parts of the Emacs C code that implement Lisp can be dropped in favor of the generally superior CL implementation.  This is generally true, but there are a few difficult bits.</p>
<h1>Symbols</h1>
<p>The primary problem is the translation of symbols when used as variable references.  Consider this code:</p>
<pre>(defvar global 73)
(defun function (argument)
  (let ((local (something-else))
    (+ local argument global)))</pre>
<p>More is going on here than meets the eye.</p>
<p>First, Emacs Lisp uses dynamic binding by default (optional lexical binding is a new feature in Emacs 24).  This applies to function arguments as well as other bindings.  So, you might think you could translate this straightforwardly to:</p>
<pre>(defvar global 73)
(declare (special global))
(defun function (argument)
  (declare (special argument))
  (let ((local (something-else))
    (declare (special local))
    (+ local argument global)))</pre>
<p>This was the approach taken by <a href="http://clocc.cvs.sourceforge.net/clocc/clocc/src/cllib/elisp.lisp?view=markup">elisp.lisp</a>; it defined macros for <code>let</code> and <code>let*</code> (but forgot <code>defun</code>) to do the dirty work:</p>
<pre>(defmacro el::let* ((&amp;rest vars) &amp;rest forms)
  "Emacs-Lisp version of `let*' (everything special)."
  `(let* ,vars (declare (special ,@(mapcar #'from-list vars))) ,@forms))</pre>
<p>But not so fast!  Emacs also has buffer-local variables.  These are variables where the value is associated with the current buffer; switching buffers makes a different binding visible to Lisp.  These require no special syntax, and a variable can be made buffer-local at any time.  So, we can break the above translation simply by evaluating:</p>
<pre>(make-local-variable 'global)
(setq global 0)</pre>
<p>Whoops!  Now the function will return the wrong result &#8212; the translation will have no way to know that is should refer to the buffer-local value.  (Well, ok, pretend that the <code>setq</code> magically worked somehow&#8230;)</p>
<p>My idea for implementing this is pretty convoluted.  Actually I have two ideas, one &#8220;user&#8221; and one &#8220;kernel&#8221;:</p>
<h2>User</h2>
<p>I think it is possible to use <code>define-symbol-macro</code> on all symbols that come from Elisp, so that we can tell the CL compiler about the real implementation.  However, a symbol can either be treated as a variable, or it can be treated as a symbol-macro &#8212; not both at the same time.  So, we will need a second location of some kind to store the real value.  Right now I&#8217;m thinking a symbol in another package, but maybe a cons or some other object would work better. In either case, we&#8217;d need a macro, a <code>setf</code> method for its expansion, and some extra-tricky redefinitions of <code>let</code> and <code>defun</code> to account for this change.</p>
<p>This would look something like:</p>
<pre>(define-symbol-macro global (elisp:get-elisp-value 'global))
(defsetf elisp:get-elisp-value elisp:set-elisp-value))
;; Details left as an exercise for the reader.</pre>
<p>This solution then has to be applied to buffer-, keyboard-, and frame-local variables.</p>
<h2>Kernel</h2>
<p>The kernel method is a lot simpler to explain: hack a Common Lisp implementation to directly know about buffer-locals.  SMOP!  But on the whole I think this approach is to be less preferred.</p>
<h1>Other Problems</h1>
<p>Emacs Lisp also freely extends other typical data types with custom attributes.  I consider this part of the genius of Emacs; a more ordinary program would work within the strictures of some defined, external language, but Emacs is not so cautious or constrained.  (Emacs is sort of a case study in breaking generally accepted rules of programming; which makes one wonder whether those rules are any good at all.)</p>
<p>So, for example, strings in Emacs have properties as a built-in component.  The solution here is simple &#8212; we will just translate the Emacs string data type as a whole, something we probably have to do anyway, because Emacs also has its own idiosyncratic approach to different encodings.</p>
<p>In elisp, <code>aref</code> can be used to access elements of other vector-like objects, not just arrays; there are some other odd little cases like this.  This is also easily handled; but it left me wondering why things like <code>aref</code> aren&#8217;t generic methods in CL. It often seems to me that a simpler, more orthogonal language lies inside of CL, struggling to get free. I try not to think these thoughts, though, as that way lies Scheme and the ridiculous fragmentation that has left Lisp unpopular.</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=778</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Emacs and Common Lisp, Part 2</title>
		<link>http://tromey.com/blog/?p=751&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=emacs-and-common-lisp-part-2</link>
		<comments>http://tromey.com/blog/?p=751#comments</comments>
		<pubDate>Wed, 25 Jan 2012 15:01:21 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=751</guid>
		<description><![CDATA[This is a followup to my earlier post on converting the Emacs C code into Common Lisp.  This one is a bit more technical, diving into some specifics of the conversion process. Basics One important fact is that we do not need to convert an arbitrary C program to Common Lisp.  This might or might [...]]]></description>
				<content:encoded><![CDATA[<p>This is a followup to my <a href="http://tromey.com/blog/?p=709">earlier post</a> on converting the Emacs C code into Common Lisp.  This one is a bit more technical, diving into some specifics of the conversion process.</p>
<h1>Basics</h1>
<p>One important fact is that we do not need to convert an arbitrary C program to Common Lisp.  This might or might not be efficiently possible &#8212; but we do not care.  We only need to convert Emacs.  This is simpler for two reasons.  First, we can just ignore any C construct that Emacs does not use.  If the translator barfs after some new update, we can fix it then.  Second, Emacs itself is already written in a relatively Lispy style, being a Lisp implementation itself.  We further exploit this by allowing the translator to know some details about Emacs.  As a trivial example, all the <code>Smumble</code> globals created by the <code>DEFUN</code> marco need not be translated into Common Lisp as structure constants &#8212; they are an artifact of the implementation, and will show up directly in the generated <code>defuns</code> instead.</p>
<h1>What to ignore</h1>
<p>A good portion of Emacs is simply redundant in the CL world.  There are a few types (cons, vector, integers, functions) that are shareable &#8212; in fact, sharing these is part of the goal of this effort.  There are also a number of functions which are effectively identical.  There are also entire redundant modules, like the garbage collector, or the bytecode interpreter.</p>
<p>The question is how to have the translator differentiate between what is useful and what is not, without breaking builds of future versions of Emacs.</p>
<p>I don&#8217;t currently think there is a high road to solving this problem.  For modules like the GC, I plan to have ad hoc translator rules for the particular source files.  For functions and data types, I&#8217;m adding new GCC attributes that I can use to mark the ignorable definitions.</p>
<h1>Types</h1>
<p>There are two type-related issues that arise when translating the source.</p>
<p>First, how should Emacs-specific types be represented?  Primarily these types are structures, like <code>struct buffer</code> or <code>struct string</code> (we cannot use the CL string type, because Emacs adds properties directly to the string, and Emacs has its own idiosyncratic character handling).  My answer here is to just straightforwardly translate them to <code>defstruct</code>.</p>
<p>The other question is when translating a C function, what do we do with the types of local variables?  For the most part I am pretending that they don&#8217;t exist.  This works fine except for local arrays and structures, but these are easily handled by initializing variables properly. My rationale is that while this is slower, it lets me get something working more quickly, and we can always update the translator to emit CL type declarations later on.</p>
<p>This simple approach doesn&#8217;t actually cover all the needed cases.  For example, there is code in Emacs that takes the address of a local variable and passes it somewhere.  This is easy to deal with; much of the remaining work is just digging through the code looking for special cases to clean up.</p>
<p>I&#8217;m similarly omitting type declarations from the generated structures.  One possible nice side effect of this approach is that it will make it easier to lift Emacs&#8217; file-size restrictions, because there will no longer be any code assuming that the size is a <code>fixnum</code>.</p>
<h1>Macros</h1>
<p>Many low-level details of the Emacs implementation are hidden in macros.  For example, Emacs stuffs some type information into the low-order bits of pointers.  It uses macros to add or remove this information.  For this build, I redefine these macros to do nothing.  This makes the GCC Gimple representation much closer to the abstract meaning of the program, and thus simpler to translate.</p>
<p>There are also some macros that are useful to redefine so that we can more easily hook into them from the translator.  For example, Emacs has a C macro <code>INTEGERP</code> that is used to check whether its argument is an integer.  Normally this macro uses bit twiddling to get its answer, but I redefine it like so:</p>
<pre>#undef INTEGERP
extern Lisp_Object *INTEGERP (Lisp_Object)
    __attribute__((lisp_form("integerp")));</pre>
<h1>Example</h1>
<p>The translator is not nearly complete, but it can already do a fair job at translating simple functions.  For example, here is &#8220;<code>forward-point</code>&#8221; from the Emacs C code:</p>
<pre>DEFUN ("forward-point", Fforward_point, Sforward_point, 1, 1, 0,
       doc: /* Return buffer position N characters after (before if N negative) point.  */)
  (Lisp_Object n)
{
  CHECK_NUMBER (n);

  return make_number (PT + XINT (n));
}</pre>
<p>Here is what the translator comes up with:</p>
<pre>(defun Fforward_point (n)
  (let (
    temp-var-0
    Qintegerp.316
    temp-var-1
    current_buffer.317
    temp-var-2
    )
    (block nil (tagbody
      bb-0
        ; no gimple here
      bb-1
        ; no gimple here
      bb-2
        (setf temp-var-0 (integerp n))
        (if (== temp-var-0 nil)
          (go bb-3)
          (go bb-4))
      bb-3
        (setf Qintegerp.316 Qintegerp)
        (wrong_type_argument Qintegerp.316 n)
      bb-4
        (setf current_buffer.317 current_buffer)
        (setf temp-var-2 (buffer-pt current_buffer.317))
        (setf temp-var-1 (+ temp-var-2 n))
        (return temp-var-1)
  ))))

(defun elisp:forward-point (arg0)
  (Fforward_point arg0))</pre>
<p>The output looks pretty weird, because the translator works after GCC&#8217;s CFG is built, and so the most straightforward translation is to use this mess with <code>tagbody</code>.  I doubt this matters much, but in any case the translator is readily hackable &#8212; it is still less than 400 lines of Python, including comments.</p>
<p>One thing to note is the translation of &#8220;<code>PT</code>&#8220;.  This is actually a macro that refers to the current buffer:</p>
<pre>#define PT (current_buffer-&gt;pt + 0)</pre>
<p>The translator properly turns this into a reference to &#8220;<code>buffer-pt</code>&#8220;.</p>
<p>Another detail is the handling of packages.  My plan is to put the Emacs implementation into one package, and then any elisp into a second package called &#8220;<code>elisp</code>&#8220;.  A <code>DEFUN</code> in the C code will actually generate two functions: the internal one, and the elisp-visible one; hence the &#8220;<code>elisp:</code>&#8221; in the translation.</p>
<h1>Next Steps</h1>
<p>There&#8217;s still a good amount of work to be done.  The converter punts on various constructs; type translation is implemented but not actually wired up to anything; the translator should emit definitions for alien functions; and plenty more.</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=751</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Emacs and Common Lisp</title>
		<link>http://tromey.com/blog/?p=709&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=emacs-and-common-lisp</link>
		<comments>http://tromey.com/blog/?p=709#comments</comments>
		<pubDate>Thu, 05 Jan 2012 17:40:14 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=709</guid>
		<description><![CDATA[Recently I&#8217;ve been thinking about how to rebase Emacs on Common Lisp. First, why rebase?  Performance is the biggest reason.  Emacs Lisp is a very basic lisp implementation.  It has a primitive garbage collector and basic execution model, and due to how it is written, it is quite hard to improve this in place. Seccond, [...]]]></description>
				<content:encoded><![CDATA[<p>Recently I&#8217;ve been thinking about how to rebase Emacs on Common Lisp.</p>
<p>First, why rebase?  Performance is the biggest reason.  Emacs Lisp is a very basic lisp implementation.  It has a primitive garbage collector and basic execution model, and due to how it is written, it is quite hard to improve this in place.</p>
<p>Seccond, why Common Lisp?  Two reasons: first, Emacs Lisp resembles Common Lisp in many ways; elisp is like CL&#8217;s baby brother.  Second, all of the hard problems in Lisp execution have already been solved excellently by existing, free-software CL implementations.  In particular, the good CL implementations have much better garbage collectors, native compilation, threads, and FFI; we could expose the latter two to elisp in a straightforward way.</p>
<p>By &#8220;rebase&#8221; I mean something quite ambitious &#8212; rewrite the C source of Emacs into Common Lisp.  I think this can largely be automated via a GCC plugin (e.g., written using <a href="https://fedorahosted.org/gcc-python-plugin/">David Malcolm&#8217;s Python plugin</a>).  Full automation would let the CL port be just another way to build Emacs, following the upstream development directly until all the Emacs maintainers can be convinced to drop C entirely (cough, cough).</p>
<p>Part of the rewrite would be dropping code that can be shared with CL.  For example, we don&#8217;t need to translate the Emacs implementation of &#8220;<code>cons</code>&#8220;, we can just use the CL one.</p>
<p>Some CL glue would be needed to make this all work properly.  These days it can&#8217;t be quite as small as <a href="http://clocc.cvs.sourceforge.net/clocc/clocc/src/cllib/elisp.lisp?view=markup">elisp.lisp</a>, but it still would not need to be very big.  The trickiest problem is dealing with buffer-local variables; but I think that can be done by judicious use of <code>define-symbol-macro</code> in the elisp reader.</p>
<p>Emacs might be the only program in the world that would see a performance improvement from rewriting in CL <img src='http://tromey.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .  The reason for this is simple: Emacs&#8217; performance is largely related to how well it executes lisp code, and how well the GC works.</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=709</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Semantic</title>
		<link>http://tromey.com/blog/?p=701&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=semantic</link>
		<comments>http://tromey.com/blog/?p=701#comments</comments>
		<pubDate>Wed, 21 Dec 2011 19:11:03 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=701</guid>
		<description><![CDATA[I&#8217;ve been running an Emacs built from bzr for a while now.  I did this so I could try a newer version of Semantic; the one in Emacs 23 is just too broken to use. Semantic, in case you haven&#8217;t heard of it, is an ambitious project to turn Emacs into an IDE.  Really it [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been running an Emacs built from bzr for a while now.  I did this so I could try a newer version of Semantic; the one in Emacs 23 is just too broken to use.</p>
<p>Semantic, in case you haven&#8217;t heard of it, is an ambitious project to turn Emacs into an IDE.  Really it is quite a crazy project in some ways &#8212; it includes its own implementation of CLOS (which opens a strange Emacs maintenance debate: how can CLOS be ok but the CL package not be?) and a port of Bison to elisp (but again, strange: the port is really a pure port, it does not use sexps as the input &#8212; bizarre).</p>
<p>Semantic is now usable in Emacs &#8212; I&#8217;ve found a few buglets, but nothing serious.  In fact, now I find it indispensible.</p>
<p>I have it configured in the most Emacsy way of all: I didn&#8217;t make any changes, I just enabled it with <code>M-x semantic-mode</code>.  Then I visited a bunch of gdb source files.  Semantic started indexing them in the background.</p>
<p>Now when I want to jump to a declaration or definition of a function, I use <code>C-c , J</code>.  The key binding is nuts, of course, but I&#8217;ve been too lazy to rebind it yet.  Anyway, this acts basically like <code>M-.</code>, except you don&#8217;t have to ever run etags.  Wonderful.</p>
<p>Semantic has some other nice features, too, but I haven&#8217;t really used them yet.  If you&#8217;re using it I&#8217;d love to hear what you do with it.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=701</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Blog Reading Solved</title>
		<link>http://tromey.com/blog/?p=683&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=blog-reading-solved</link>
		<comments>http://tromey.com/blog/?p=683#comments</comments>
		<pubDate>Sat, 14 Aug 2010 19:13:50 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=683</guid>
		<description><![CDATA[I wrote a while ago about my blog-reading woes.  Those woes are now over! Lars Magne Ingebrigtsen, of Gnus and gmane fame, has now brought us gwene &#8212; an RSS to NNTP gateway.  You enter the feeds you want to read, and soon they show up as newsgroups in gmane.  Thanks also should go to [...]]]></description>
				<content:encoded><![CDATA[<p>I <a href="http://tromey.com/blog/?p=602">wrote</a> a while ago about my blog-reading woes.  Those woes are now over!</p>
<p>Lars Magne Ingebrigtsen, of Gnus and <a href="http://www.gmane.org/">gmane </a>fame, has now brought us <a href="http://www.gwene.org/">gwene</a> &#8212; an RSS to NNTP gateway.  You enter the feeds you want to read, and soon they show up as newsgroups in gmane.  Thanks also should go to Ted Zlanatov, for bringing this up on the gmane discussion list, and thus getting it all rolling.</p>
<p>I haven&#8217;t quite retired my rss2email cron job, but that is mostly out of laziness.  Any day now.</p>
<p>Normally I am unhappy about the whole SaaS trend, but gmane gets a pass.  I am not sure if it is because Lars seems trustworthy, or because NNTP is so obviously a fringe interest, or because gmane is at least theoretically replaceable in the event of the worst.</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=683</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Fun with rewriting</title>
		<link>http://tromey.com/blog/?p=665&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=fun-with-rewriting</link>
		<comments>http://tromey.com/blog/?p=665#comments</comments>
		<pubDate>Sat, 10 Oct 2009 04:33:15 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=665</guid>
		<description><![CDATA[There&#8217;s a fun source rewriting trick that I&#8217;ve wanted to try out for a long time &#8212; and I finally got a chance to do it while working on the multi-threading patch for Emacs. The Problem In the multi-threaded Emacs, a let binding must be thread-local, because this is really the only way to manage [...]]]></description>
				<content:encoded><![CDATA[<p>There&#8217;s a fun source rewriting trick that I&#8217;ve wanted to try out for a long time &#8212; and I finally got a chance to do it while working on the multi-threading patch for Emacs.</p>
<h3>The Problem</h3>
<p>In the multi-threaded Emacs, a let binding must be thread-local, because this is really the only way to manage dynamic binding in the presence of threads.  Emacs also has a notion of a buffer-local variable, and furthermore some buffer-local variables are stored directly in the internal struct buffer &#8212; that is, assignments to the variable in lisp are transformed by the lisp implementation into a field assignment in C.  These fields are freely used elsewhere in the C code.</p>
<p>Our implementation of thread-locals, though, is an alist mapping a thread object to the variable&#8217;s value.  So, to keep the C code working properly, we need to rewrite every field access to use a function that finds the proper per-thread value.</p>
<h3>The Idea</h3>
<p>The idea, of course, is automated rewriting.  However, like many other GNU programs, Emacs is heavily macroized, and furthermore may be the last program in the whole distro that uses K&amp;R-style function definitions.  For these reasons I assumed that existing refactoring tools would not work well.</p>
<p>Luckily, though, this problem doesn&#8217;t require a very sophisticated refactoring tool.  Really all we need to do is find the location of each field reference, and then find the start of the left-hand-side, and then rewrite that into the new form.</p>
<h3>The Hack</h3>
<p>All we really need is to find a series of locations &#8212; the rest we can handle with some straightforward elisp scripting.  And what simpler way is there to get locations than to get the compiler to give them to us?</p>
<p>I wrote a batch script in elisp to automate the whole procedure.  Why elisp?  Not only is it a natural, perhaps even required, fit when hacking on Emacs, it also has some nice &#8220;sexp&#8221; functions which allow skipping over properly-parenthesized expressions.  This means I could do without a whole parser.  And why automate the whole process?  I expected it wouldn&#8217;t work properly the first time; having a single script let me git reset after each test run and simply re-run from scratch.</p>
<p>This elisp script first edits struct buffer to rename each field.  Then it runs make to rebuild Emacs.  This causes the compiler to emit an error message for each bad field access.</p>
<p>A critical point here is that I used GCC svn trunk.  Only recent versions of GCC emit correct column numbers in error messages .  GCC 4.4 might have worked, I am not sure &#8212; and in the end I needed a small libcpp patch to deal with a certain macro case.</p>
<p>The elisp script reads the output of make and pulls out the error messages.  For each error on a given line, it works in reverse order (so that multiple fixes on one line will work properly without the bother of inserting markers), rewriting the field accesses.  I wrote a bit of ad hoc code to back up to the start of the left-hand-side of the field access; doing this well is a bit funny, like writing a parser that works backwards, but in my case I knew I could get away with something relatively simple (I think this little sub-hack caused the script to miss less than 10 rewrites, i.e., tolerable).</p>
<p>I would guess that this script got 90% of the field accesses.  I had to fix up a few by hand, mostly in macro definitions in header files.  And, I had to revert a few changes as well, mostly in the garbage collector (which wants to see the real underlying alist, not the per-thread value).  Still, diffstat says: 49 files changed, 1305 insertions(+), 1021 deletions(-) &#8212; in other words, not something you&#8217;d want to do by hand.</p>
<p>So, ok, this is horrible.  But fun!  I think I will end up doing it again, for frame- and keyboard-local variables.  Maybe someday I&#8217;ll finish my patch to make libcpp properly track locations through macros, and then the script can even fix up macro definitions for me.</p>
<p>I&#8217;m not extremely interested in Eclipse-style refactoring &#8212; where the tool provides a couple dozen refactorings for you.  Instead, I think I want my refactoring tool to answer queries for me, so I can feed that information to a customized rewriting script.</p>
<p>Another way I could have done this was writing a GCC plugin with treehydra or MELT, but unfortunately my free time is so limited that I haven&#8217;t managed to even build either one yet.  Once plugins are in the Fedora GCC, I think it would be very worthwhile to package up treehydra&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=665</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>package.el and Emacs</title>
		<link>http://tromey.com/blog/?p=661&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=package-el-and-emacs</link>
		<comments>http://tromey.com/blog/?p=661#comments</comments>
		<pubDate>Thu, 01 Oct 2009 03:12:58 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=661</guid>
		<description><![CDATA[It looks like package.el is going to go into Emacs after all.  I&#8217;m psyched! I made a git branch (still local) to hack on this. Of course, now I realize that there are bugs to fix and features to add and cleanups to make before this is really feasible&#8230;]]></description>
				<content:encoded><![CDATA[<p>It looks like package.el is going to go into Emacs after all.  I&#8217;m psyched!</p>
<p>I made a git branch (still local) to hack on this.</p>
<p>Of course, now I realize that there are bugs to fix and features to add and cleanups to make before this is really feasible&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=661</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Emacs and Threading, Take 2</title>
		<link>http://tromey.com/blog/?p=654&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=emacs-and-threading-take-2</link>
		<comments>http://tromey.com/blog/?p=654#comments</comments>
		<pubDate>Thu, 24 Sep 2009 22:36:59 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=654</guid>
		<description><![CDATA[I&#8217;ve recanted. Contrary to my earlier post on this topic, I now think implementing threading in Emacs is possible. A patch from Giuseppe Scrivano inspired me, and I started my own patch to do it. This was sort of fun. I wrote a batch script in elisp to rewrite some of the Emacs sources &#8212; [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve recanted.  Contrary to my <a href="http://tromey.com/blog/?p=305">earlier post on this topic</a>, I now think implementing threading in Emacs is possible.  A patch from <a href="http://it.gnu.org/~gscrivano/">Giuseppe Scrivano</a> inspired me, and I started my own patch to do it.</p>
<p>This was sort of fun.  I wrote a batch script in elisp to rewrite some of the Emacs sources &#8212; yay semantic patching!</p>
<p>Thanks to Giuseppe, this is now <a href="http://gitorious.org/emacs-mt">hosted on Gitorious</a>.  We&#8217;re both working there, on different branches, merging code back and forth.  I&#8217;ve mostly been working on variable bindings, and he&#8217;s very active, both with low-level changes and cool things getting Gnus to work in a separate thread.</p>
<p>If you&#8217;re interested in helping out, we discuss it on emacs-devel, but really we&#8217;d welcome any sort of contact.</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=654</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Emacs 23</title>
		<link>http://tromey.com/blog/?p=643&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=emacs-23</link>
		<comments>http://tromey.com/blog/?p=643#comments</comments>
		<pubDate>Tue, 15 Sep 2009 00:42:14 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=643</guid>
		<description><![CDATA[Much to my surprise, the Fedora Emacs maintainers pushed Emacs 23 into the (ostensibly stable) Fedora 11 repository.  I was a bit afraid to upgrade, since Emacs really is the cornerstone of my entire workflow.  My desire for new features quickly overcame my fear, though. The first thing you will notice is that Emacs is [...]]]></description>
				<content:encoded><![CDATA[<p>Much to my surprise, the Fedora Emacs maintainers pushed Emacs 23 into the (ostensibly stable) Fedora 11 repository.  I was a bit afraid to upgrade, since Emacs really is the cornerstone of my entire workflow.  My desire for new features quickly overcame my fear, though.</p>
<p>The first thing you will notice is that Emacs is much prettier.  It now uses XFT to render, so you get antialiasing.  For normal work, I don&#8217;t really care much, but this is why I used CVS Emacs last year for presentations: it makes a huge difference in situations where prettiness matters.  Unfortunately this seems to have negatively affected redisplay performance.</p>
<p>Another major feature I have been loving is support for multiple terminals.  I use this in two ways.</p>
<p>I run my Emacs on my main machine, of course.  This is the centerpiece of my desktop: I use it for hacking, for mail and news, and for irc.  Previously, if I used my laptop, I couldn&#8217;t easily access all this state; but now I can <code>ssh</code> to my main machine, run <code>emacsclient -t</code>, and have access to everything.</p>
<p>I&#8217;ve also set <code>EDITOR</code> to <code>emacsclient -t</code>.  This means that when I run git commit in a shell, the commit message shows up in a new emacs frame on that terminal.  This is very convenient for &#8220;quickie&#8221; edits, because it means not having to switch my focus.  (If I had to pick a single reason that Emacs improves my productivity, this would be it: it makes it very easy to keep one&#8217;s focus.)</p>
<p>Funnily, though, I don&#8217;t actually run <code>git commit</code> in a shell very often any more, because the new <code>vc-dir</code> mode is good enough that I can do some common git operations without leaving Emacs.  If you tried VC in earlier versions of Emacs, then you probably remember it as a horrible joke &#8212; it worked fine for RCS, but was miserable at anything else.  <code>vc-dir</code> is something like a generalized <code>pcl-cvs</code>, so you can work on a whole directory tree at once (and do so efficiently, unlike the old <code>vc-dired</code>).  <code>vc-dir</code> is still pretty new, and there are some necessary operations that aren&#8217;t exposed (<code>git push</code>), but it is still a very nice step forward.</p>
<p>This release is definitely worth upgrading to.</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=643</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Wish List Item</title>
		<link>http://tromey.com/blog/?p=602&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wish-list-item</link>
		<comments>http://tromey.com/blog/?p=602#comments</comments>
		<pubDate>Thu, 10 Sep 2009 03:06:43 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Emacs]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://tromey.com/blog/?p=602</guid>
		<description><![CDATA[I&#8217;ve been trying for a while to figure out how best to read blogs. Right now I use three different methods &#8212; I use iGoogle for some things, plain old web browsing for some, and then gnus for one feed.  What a pain!  I&#8217;ve also tried other readers in the past &#8212; a couple web-based [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been trying for a while to figure out how best to read blogs.</p>
<p>Right now I use three different methods &#8212; I use iGoogle for some things, plain old web browsing for some, and then gnus for one feed.  What a pain!  I&#8217;ve also tried other readers in the past &#8212; a couple web-based one, Azureus, maybe something else.</p>
<p>None of these are ideal for me.  I think what I would really like is to use Gnus for everything, except Gnus blocks annoyingly while fetching the feeds.  So, I could use nntp//rss.  But then I am setting up and configuring yet another program, setting it up to run when I log in, forgetting to copy its configuration to my laptop, etc.</p>
<p>I wish there were &#8220;gmane for rss&#8221; &#8212; a site that ran nttp//rss for me and let me subscribe to any old feed using my news reader.  Anybody know of one?</p>
<p>Wait!  I have other complaints too!  I&#8217;ll save those for later&#8230; I&#8217;m turning into the sort of person who wishes RSS were NNTP and that Common Lisp were popular again.  What is happening to me?!?</p>
]]></content:encoded>
			<wfw:commentRss>http://tromey.com/blog/?feed=rss2&#038;p=602</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>
