<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>What keramida said... &#187; Emacs</title>
	<atom:link href="http://keramida.wordpress.com/category/emacs/feed/" rel="self" type="application/rss+xml" />
	<link>http://keramida.wordpress.com</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 11:58:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='keramida.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>What keramida said... &#187; Emacs</title>
		<link>http://keramida.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://keramida.wordpress.com/osd.xml" title="What keramida said..." />
	<atom:link rel='hub' href='http://keramida.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Powerful Regular Expressions Combined with Lisp in Emacs</title>
		<link>http://keramida.wordpress.com/2013/05/16/powerful-regular-expressions-combined-with-lisp-in-emacs/</link>
		<comments>http://keramida.wordpress.com/2013/05/16/powerful-regular-expressions-combined-with-lisp-in-emacs/#comments</comments>
		<pubDate>Thu, 16 May 2013 16:04:58 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=2244</guid>
		<description><![CDATA[Regular expressions are a powerful text transformation tool. Any UNIX geek will tell you that. It&#8217;s so deeply ingrained into our culture, that we even make jokes about it. Another thing that we also love is having a powerful extension &#8230; <a href="http://keramida.wordpress.com/2013/05/16/powerful-regular-expressions-combined-with-lisp-in-emacs/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2244&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Regular expressions are a powerful text transformation tool. Any UNIX geek will tell you that. It&#8217;s so deeply ingrained into our culture, that <a href="http://xkcd.com/208/" title="XKCD: Everybody stand back! I know regular expressions.">we even make jokes about it</a>. Another thing that we also love is having a powerful extension language at hand, and Lisp is one of the most powerful extension languages around (and of course, <a href="http://xkcd.com/224/" title="XKCD: The Language of the Universe">we make jokes about that too</a>).</p>
<p>Emacs, one of the most famous Lisp applications today, has for a while now the ability to combine both of these, to reach entirely new levels of usefulness.  Combining regular expressions and Lisp can do really magical things.</p>
<p>An example that I recently used a few times is parsing &amp; de-humanizing numbers in <a href="https://github.com/dagwieers/dstat" title="dstat project on Github">dstat</a> output.  The output of dstat includes numbers that are printed with a suffix, like &#8216;B&#8217; for bytes, &#8216;k&#8217; for kilobytes and &#8216;M&#8217; for megabytes, e.g.:</p>
<pre>----system---- ----total-cpu-usage---- --net/eth0- -dsk/total- sda-
     time     |usr sys idl wai hiq siq| recv  send| read  writ|util
16-05 08:36:15|  2   3  96   0   0   0|  66B  178B|   0     0 |   0
16-05 08:36:16| 42  14  37   0   0   7|  92M 1268k|   0     0 |   0
16-05 08:36:17| 45  11  36   0   0   7|  76M 1135k|   0     0 |   0
16-05 08:36:18| 27  55   8   0   0  11|  67M  754k|   0    99M|79.6
16-05 08:36:19| 29  41  16   5   0  10| 113M 2079k|4096B   63M|59.6
16-05 08:36:20| 28  48  12   4   0   8|  58M  397k|   0    95M|76.0
16-05 08:36:21| 38  37  14   1   0  10| 114M 2620k|4096B   52M|23.2
16-05 08:36:22| 37  54   0   1   0   8|  76M 1506k|8192B   76M|33.6</pre>
<p>So if you want to graph one of the columns, it&#8217;s useful to convert all the numbers in the same unit. Bytes would be nice in this case.</p>
<p>Separating all columns with &#8216;|&#8217; characters is a good start, so you can use e.g. a CSV-capable graphing tool, or even simple awk scripts to extract a specific column. &#8216;C-x r t&#8217; can do that in Emacs, and you end up with something like this:</p>
<pre>|     time     |cpu|cpu|cpu|cpu|cpu|cpu|eth0 |eth0 | disk| disk|sda-|
|     time     |usr|sys|idl|wai|hiq|siq| recv| send| read| writ|util|
|16-05 08:36:15|  2|  3| 96|  0|  0|  0|  66B| 178B|   0 |   0 |   0|
|16-05 08:36:16| 42| 14| 37|  0|  0|  7|  92M|1268k|   0 |   0 |   0|
|16-05 08:36:17| 45| 11| 36|  0|  0|  7|  76M|1135k|   0 |   0 |   0|
|16-05 08:36:18| 27| 55|  8|  0|  0| 11|  67M| 754k|   0 |  99M|79.6|
|16-05 08:36:19| 29| 41| 16|  5|  0| 10| 113M|2079k|4096B|  63M|59.6|
|16-05 08:36:20| 28| 48| 12|  4|  0|  8|  58M| 397k|   0 |  95M|76.0|
|16-05 08:36:21| 38| 37| 14|  1|  0| 10| 114M|2620k|4096B|  52M|23.2|
|16-05 08:36:22| 37| 54|  0|  1|  0|  8|  76M|1506k|8192B|  76M|33.6|</pre>
<p>The leading and trailing &#8216;|&#8217; characters are there so we can later use orgtbl-mode, an awesome table editing and realignment tool of Emacs.  Now to the really magical step: regular expressions and lisp working together.</p>
<p>What we would like to do is convert text like &#8220;408B&#8221; to just &#8220;408&#8243;, text like &#8220;1268k&#8221; to the value of (1268 * 1024), and finally text like &#8220;67M&#8221; to the value of (67 * 1024 * 1024).  The first part is easy:</p>
<pre>M-x replace-regexp RET \([0-9]+\)B RET \1 RET</pre>
<p>This should just strip the &#8220;B&#8221; suffix from byte values.</p>
<p>For the kilobyte and megabyte values what we would like is to be able to evaluate an arithmetic expression that involves <code>\1</code>.  Something like &#8220;replace <code>\1</code> with the value of <code>(expression \1)</code>&#8220;.  This is possible in Emacs by prefixing the substitution pattern with <code>\,</code>. This instructs Emacs to evaluate the rest of the substitution pattern as a Lisp expression, and use its string representation as the &#8220;real&#8221; substitution text.</p>
<p>So if we match all numeric values that are suffixed by &#8216;k&#8217;, we can use <code>(string-to-number \1)</code> to convert the matching digits to an integer, multiply by 1024 and insert the resulting value by using the following substitution pattern:</p>
<pre>\,(* 1024 (string-to-number \1))</pre>
<p>The full Emacs command would then become:</p>
<pre>M-x replace-regexp RET \([0-9]+\)k RET \,(* 1024 (string-to-number \1)) RET</pre>
<p>This, and the byte suffix removal, yield now the following text in our Emacs buffer:</p>
<pre>|     time     |cpu|cpu|cpu|cpu|cpu|cpu|eth0 |eth0 | disk| disk|sda-|
|     time     |usr|sys|idl|wai|hiq|siq| recv| send| read| writ|util|
|16-05 08:36:15|  2|  3| 96|  0|  0|  0|  66| 178|   0 |   0 |   0|
|16-05 08:36:16| 42| 14| 37|  0|  0|  7|  92M|1298432|   0 |   0 |   0|
|16-05 08:36:17| 45| 11| 36|  0|  0|  7|  76M|1162240|   0 |   0 |   0|
|16-05 08:36:18| 27| 55|  8|  0|  0| 11|  67M| 772096|   0 |  99M|79.6|
|16-05 08:36:19| 29| 41| 16|  5|  0| 10| 113M|2128896|4096|  63M|59.6|
|16-05 08:36:20| 28| 48| 12|  4|  0|  8|  58M| 406528|   0 |  95M|76.0|
|16-05 08:36:21| 38| 37| 14|  1|  0| 10| 114M|2682880|4096|  52M|23.2|
|16-05 08:36:22| 37| 54|  0|  1|  0|  8|  76M|1542144|8192|  76M|33.6|</pre>
<p>Note: Some of the columns are indeed not aligned very well. We&#8217;ll fix that later.  On to the megabyte conversion:</p>
<pre>M-x replace-regexp RET \([0-9]+\)M RET \,(* 1024 1024 (string-to-number \1)) RET</pre>
<p>Which produces a version that has no suffixes at all:</p>
<pre>|     time     |cpu|cpu|cpu|cpu|cpu|cpu|eth0 |eth0 | disk| disk|sda-|
|     time     |usr|sys|idl|wai|hiq|siq| recv| send| read| writ|util|
|16-05 08:36:15|  2|  3| 96|  0|  0|  0|  66| 178|   0 |   0 |   0|
|16-05 08:36:16| 42| 14| 37|  0|  0|  7|  96468992|1298432|   0 |   0 |   0|
|16-05 08:36:17| 45| 11| 36|  0|  0|  7|  79691776|1162240|   0 |   0 |   0|
|16-05 08:36:18| 27| 55|  8|  0|  0| 11|  70254592| 772096|   0 |  103809024|79.6|
|16-05 08:36:19| 29| 41| 16|  5|  0| 10| 118489088|2128896|4096|  66060288|59.6|
|16-05 08:36:20| 28| 48| 12|  4|  0|  8|  60817408| 406528|   0 |  99614720|76.0|
|16-05 08:36:21| 38| 37| 14|  1|  0| 10| 119537664|2682880|4096|  54525952|23.2|
|16-05 08:36:22| 37| 54|  0|  1|  0|  8|  79691776|1542144|8192|  79691776|33.6|</pre>
<p>Finally, to align everything in neat, pipe-separated columns, we enable <code>M-x orgtbl-mode</code>, and type &#8220;C-c C-c&#8221; with the pointer somewhere inside the transformed dstat output.  The buffer now becomes something usable for pretty-much any graphing tool out there:</p>
<pre>| time           | cpu | cpu | cpu | cpu | cpu | cpu |      eth0 |    eth0 |  disk |      disk | sda- |
| time           | usr | sys | idl | wai | hiq | siq |      recv |    send |  read |      writ | util |
| 16-05 08:36:15 |   2 |   3 |  96 |   0 |   0 |   0 |        66 |     178 |     0 |         0 |    0 |
| 16-05 08:36:16 |  42 |  14 |  37 |   0 |   0 |   7 |  96468992 | 1298432 |     0 |         0 |    0 |
| 16-05 08:36:17 |  45 |  11 |  36 |   0 |   0 |   7 |  79691776 | 1162240 |     0 |         0 |    0 |
| 16-05 08:36:18 |  27 |  55 |   8 |   0 |   0 |  11 |  70254592 |  772096 |     0 | 103809024 | 79.6 |
| 16-05 08:36:19 |  29 |  41 |  16 |   5 |   0 |  10 | 118489088 | 2128896 |  4096 |  66060288 | 59.6 |
| 16-05 08:36:20 |  28 |  48 |  12 |   4 |   0 |   8 |  60817408 |  406528 |     0 |  99614720 | 76.0 |
| 16-05 08:36:21 |  38 |  37 |  14 |   1 |   0 |  10 | 119537664 | 2682880 |  4096 |  54525952 | 23.2 |
| 16-05 08:36:22 |  37 |  54 |   0 |   1 |   0 |   8 |  79691776 | 1542144 |  8192 |  79691776 | 33.6 |</pre>
<p>The trick of combining arbitrary Lisp expressions with regexp substitution patterns like <code>\1</code>, <code>\2</code> &#8230; <code>\9</code> is something I have found immensely useful in Emacs. Now that you know how it works, I hope you can find even more amusing use-cases for it.</p>
<p><strong>Update:</strong> The Emacs manual has <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Replace.html" title="Emacs Manual: Regexp Replace">a few more useful examples of <code>\,</code> in action</a>, as pointed out by <a href="https://twitter.com/tunixman" title="Twitter: tunixman">tunixman</a> on Twitter.</p>
<br />Filed under: <a href='http://keramida.wordpress.com/category/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/category/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/category/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/category/freebsd/'>FreeBSD</a>, <a href='http://keramida.wordpress.com/category/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/category/lisp/'>Lisp</a>, <a href='http://keramida.wordpress.com/category/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/category/programming/'>Programming</a>, <a href='http://keramida.wordpress.com/category/software/'>Software</a> Tagged: <a href='http://keramida.wordpress.com/tag/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/tag/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/tag/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/tag/freebsd/'>FreeBSD</a>, <a href='http://keramida.wordpress.com/tag/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/tag/lisp/'>Lisp</a>, <a href='http://keramida.wordpress.com/tag/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/tag/programming/'>Programming</a>, <a href='http://keramida.wordpress.com/tag/software/'>Software</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/2244/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/2244/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2244&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2013/05/16/powerful-regular-expressions-combined-with-lisp-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>Speeding Up Emacs and Parsing Emacs Lisp from Emacs Lisp</title>
		<link>http://keramida.wordpress.com/2013/04/13/speeding-up-emacs-and-parsing-emacs-lisp-from-emacs-lisp/</link>
		<comments>http://keramida.wordpress.com/2013/04/13/speeding-up-emacs-and-parsing-emacs-lisp-from-emacs-lisp/#comments</comments>
		<pubDate>Sat, 13 Apr 2013 08:43:20 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Lisp]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=2231</guid>
		<description><![CDATA[I recently spent a bit of time to clean up all the cruft that my ~/.emacs file and my ~/elisp directory had accumulated. I have been using a multi-file setup to configure my Emacs sessions, since at least 2008. This &#8230; <a href="http://keramida.wordpress.com/2013/04/13/speeding-up-emacs-and-parsing-emacs-lisp-from-emacs-lisp/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2231&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>I recently spent a bit of time to clean up all the cruft that my <code>~/.emacs</code> file and my <code>~/elisp</code> directory had accumulated.  I have been using a multi-file setup to configure my Emacs sessions, since at least 2008. This turned out to be a royal mess after 5+ years of patching stuff without a very clear plan or structure.  The total line-count of both my <code>~/.emacs</code> and all the <code>*.el</code> files I had imported into my <code>~/elisp</code> directory was almost 20,000 lines of code:</p>
<pre class="brush: plain; gutter: false; title: ; toolbar: false; notranslate">
$ wc -l BACKUP/.emacs $( find BACKUP/elisp -name '*.el')
   119 BACKUP/.emacs
    84 BACKUP/elisp/keramida-w3m.el
    90 BACKUP/elisp/keramida-keys.el
   156 BACKUP/elisp/keramida-irc.el
  5449 BACKUP/elisp/erlang.el
   892 BACKUP/elisp/fill-column-indicator.el
   344 BACKUP/elisp/keramida-erc.el
    87 BACKUP/elisp/keramida-chrome.el
    89 BACKUP/elisp/keramida-autoload.el
   141 BACKUP/elisp/keramida-ui.el
    42 BACKUP/elisp/keramida-slime.el
  1082 BACKUP/elisp/ace-jump-mode.el
     2 BACKUP/elisp/scala-mode2/scala-mode2-pkg.el
   907 BACKUP/elisp/scala-mode2/scala-mode2-indent.el
    26 BACKUP/elisp/scala-mode2/scala-mode2-lib.el
   502 BACKUP/elisp/scala-mode2/scala-mode2-fontlock.el
    37 BACKUP/elisp/scala-mode2/scala-mode2-map.el
   808 BACKUP/elisp/scala-mode2/scala-mode2-syntax.el
   111 BACKUP/elisp/scala-mode2/scala-mode2.el
   121 BACKUP/elisp/scala-mode2/scala-mode2-paragraph.el
  1103 BACKUP/elisp/php-mode.el
   142 BACKUP/elisp/themes/cobalt-theme.el
   665 BACKUP/elisp/themes/zenburn-theme.el
   142 BACKUP/elisp/themes/sublime-themes/cobalt-theme.el
    80 BACKUP/elisp/themes/tomorrow-night-blue-theme.el
    80 BACKUP/elisp/themes/tomorrow-night-eighties-theme.el
   115 BACKUP/elisp/themes/tomorrow-theme.el
    80 BACKUP/elisp/themes/tomorrow-night-bright-theme.el
   339 BACKUP/elisp/cmake-mode.el
    95 BACKUP/elisp/keramida-cc-extra.el
  1341 BACKUP/elisp/lua-mode.el
  2324 BACKUP/elisp/markdown-mode.el
   184 BACKUP/elisp/rcirc-notify.el
   167 BACKUP/elisp/keramida-defaults.el
   203 BACKUP/elisp/keramida-hooks.el
    43 BACKUP/elisp/keramida-lang.el
   435 BACKUP/elisp/edit-server.el
   709 BACKUP/elisp/slang-mode.el
    66 BACKUP/elisp/keramida-eshell.el
 19402 total
</pre>
<p>20,000 lines of code is far too much bloat.  It&#8217;s obvious that this was getting out of hand, especially if you consider that I had full configuration files for at least two different IRC clients (rcirc and erc) in this ever growing blob of complexity.</p>
<p>What I did was make a backup copy of everything in <code>~/BACKUP</code> and start over. This time I decided to go a different route from 2008 though.  All my configuration lives in a single file, in <code>~/.emacs</code>, and  I threw away any library from my old <code>~/elisp</code> tree which I haven&#8217;t actively used in the past few weeks. I imported the rest of them into the standard <code>user-emacs-directory</code> of modern Emacsen: at <code>~/.emacs.d/</code>.  I also started using <code>eval-after-load</code> pretty extensively, to speed up the startup of Emacs, and only configure extras <em>after</em> the related packages are loaded.  This means I could trim down the list of preloaded packages even more.</p>
<p>The result, <a href="https://twitter.com/keramida/status/322684039683260416" title="Speeding Up Emacs!">as I tweeted yesterday</a> was an impressive speedup of the entire startup process of Emacs.  Now it can start, load everything and print a message in approximately 0.028 seconds, which is <em>more than 53 times faster</em> than the ~1.5 seconds it required before the cleanup!</p>
<p>I suspected that the main contributor to this speedup was the increased use of <code>eval-after-load</code> forms, but what percentage of the entire file used them?</p>
<p>So I wrote a tiny bit of Emacs Lisp to <em>count</em> how many times each top-level forms appears in my new <code>~/.emacs</code> file:</p>
<pre class="brush: plain; gutter: true; title: ; toolbar: false; notranslate">
(defun file-forms-list (file-name)
  (let ((file-forms nil))
    ;; Keep reading Lisp expressions, until we hit EOF,
    ;; and just add one entry for each toplevel form
    ;; to `file-forms'.
    (condition-case err
        (with-temp-buffer
          (insert-file file-name)
          (goto-char (point-min))
          (while (&lt; (point) (point-max))
            (let* ((expr (read (current-buffer)))
                   (form (first expr)))
              (setq file-forms (cons form file-forms)))))
      (end-of-file nil))
    (reverse file-forms)))

(defun file-forms-alist (file-name)
  (let ((forms-table (make-hash-table :test #'equal)))
    ;; Build a hash that maps form-name =&gt; count for all the
    ;; top-level forms of the `file-name' file.
    (dolist (form (file-forms-list file-name))
      (let ((form-name (format &quot;%s&quot; form)))
        (puthash form-name (1+ (gethash form-name forms-table 0))
                 forms-table)))
    ;; Convert the hash table to an alist of the form:
    ;;    ((form-name . count) (form-name-2 . count-2) ...)
    (let ((forms-alist nil))
      (maphash (lambda (form-name form-count)
                 (setq forms-alist (cons (cons form-name form-count)
                                         forms-alist)))
               forms-table)
      forms-alist)))

(progn
  (insert &quot;\n&quot;)
  (insert (format &quot;%7s %s\n&quot; &quot;COUNT&quot; &quot;FORM-NAME&quot;))
  (let ((total-forms 0))
    (dolist (fc (sort (file-forms-alist &quot;~/.emacs&quot;)
                      (lambda (left right)
                        (&gt; (cdr left) (cdr right)))))
      (insert (format &quot;%7d %s\n&quot; (cdr fc) (car fc)))
      (setq total-forms (+ total-forms (cdr fc))))
    (insert (format &quot;%7d %s\n&quot; total-forms &quot;TOTAL&quot;))))
</pre>
<p>Evaluating this in a scratch buffer shows output like this:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
COUNT FORM-NAME
   32 setq-default
   24 eval-after-load
   14 set-face-attribute
   14 global-set-key
    5 autoload
    4 require
    4 setq
    4 put
    3 defun
    2 when
    1 add-hook
    1 let
    1 set-display-table-slot
    1 fset
    1 tool-bar-mode
    1 scroll-bar-mode
    1 menu-bar-mode
    1 ido-mode
    1 global-hl-line-mode
    1 show-paren-mode
    1 iswitchb-mode
    1 global-font-lock-mode
    1 cua-mode
    1 column-number-mode
    1 add-to-list
    1 prefer-coding-system
  122 TOTAL
</pre>
<p>This showed that I&#8217;m still using a lot of <code>setq-default</code> forms: 26.23% of the top-level forms are of this type. Some of these may still be candidates for lazy initialization, since I can see that many of them are indeed mode-specific, like these two:</p>
<pre class="brush: plain; gutter: true; title: ; toolbar: false; notranslate">
(setq-default diff-switches &quot;-u&quot;)
(setq-default ps-font-size '(8 . 10))
</pre>
<p>But <code>eval-after-load</code> is a close second, with 19.67% of all the top-level forms.  That seems to agree with the original idea of speeding up the startup of everything by delaying package-loading and configuration until it&#8217;s actually needed.</p>
<p>10 of the remaining forms are one-off mode setting calls, like <code>(tool-bar-mode -1)</code>, so 8.2% of the total calls is probably going to stay this way for a long time. That&#8217;s probably ok though, since the list includes several features I find really useful, very very often.</p>
<br />Filed under: <a href='http://keramida.wordpress.com/category/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/category/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/category/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/category/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/category/linux/'>Linux</a>, <a href='http://keramida.wordpress.com/category/lisp/'>Lisp</a>, <a href='http://keramida.wordpress.com/category/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/category/programming/'>Programming</a>, <a href='http://keramida.wordpress.com/category/software/'>Software</a> Tagged: <a href='http://keramida.wordpress.com/tag/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/tag/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/tag/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/tag/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/tag/linux/'>Linux</a>, <a href='http://keramida.wordpress.com/tag/lisp/'>Lisp</a>, <a href='http://keramida.wordpress.com/tag/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/tag/programming/'>Programming</a>, <a href='http://keramida.wordpress.com/tag/software/'>Software</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/2231/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/2231/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2231&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2013/04/13/speeding-up-emacs-and-parsing-emacs-lisp-from-emacs-lisp/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>Fixing Shifted-Arrow Keys in 256-Color Terminals on Linux</title>
		<link>http://keramida.wordpress.com/2013/03/22/linux-xterm-256color-terminfo/</link>
		<comments>http://keramida.wordpress.com/2013/03/22/linux-xterm-256color-terminfo/#comments</comments>
		<pubDate>Fri, 22 Mar 2013 17:26:25 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Open source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=2177</guid>
		<description><![CDATA[The terminfo entry for &#8220;xterm-256color&#8221; that ships by default as part of ncurses-base on Debian Linux and its derivatives is a bit annoying. In particular, shifted up-arrow key presses work fine in some programs, but fail in others. It&#8217;s a &#8230; <a href="http://keramida.wordpress.com/2013/03/22/linux-xterm-256color-terminfo/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2177&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The terminfo entry for &#8220;<code>xterm-256color</code>&#8221; that ships by default as part of <em>ncurses-base</em> on Debian Linux and its derivatives is a bit annoying. In particular, shifted up-arrow key presses work fine in some programs, but fail in others. It&#8217;s a bit of a gamble if <code>Shift-Up</code> works in joe, pico, vim, emacs, mutt, slrn, or what have you.</p>
<p>THis afternoon I got bored enough of losing my selected region in Emacs, because I forgot that I was typing in a terminal launched by a Linux desktop.  SO I thought &#8220;what the heck&#8230; let&#8217;s give the FreeBSD termcap entry for xterm-256color a try&#8221;:</p>
<pre>keramida&gt; <strong>scp bsd:/etc/termcap /tmp/termcap-bsd</strong>
keramida&gt; <strong>captoinfo -e $(                                  \
  echo $( grep '^xterm' termcap | sed -e 's/[:|].*//' ) |  \
  sed -e 's/ /,/g'                                         \
  ) /tmp/termcap  &gt; /tmp/terminfo.src</strong>
keramida&gt; <strong>tic /tmp/terminfo.src</strong></pre>
<p>Restarted my terminal, and quite unsurprisingly, the problem of <code>Shift-Up</code> keys was gone.</p>
<p>The broken <code>xterm-256color</code> terminfo entry from <code>/lib/terminfo/x/xterm-256color</code> is now shadowed by <code>~/.terminfo/x/xterm-256color</code>, and I can happily keep typing without having to worry about losing mental state because of this annoying little misfeature of Linux terminfo entries.</p>
<p>The official terminfo database sources[1], also work fine.  So now I think some extra digging is required to see what <em>ncurses-base</em> ships with.  There&#8217;s definitely something broken in the terminfo entry of <em>ncurses-base</em>, but it will be nice to know which terminal capabilities the Linux package botched.</p>
<p><strong>Notes:</strong><br />
[1] <a href="http://invisible-island.net/ncurses/ncurses.faq.html#which_terminfo" title="Official terminfo database sources">http://invisible-island.net/ncurses/ncurses.faq.html#which_terminfo</a></p>
<br />Filed under: <a href='http://keramida.wordpress.com/category/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/category/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/category/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/category/freebsd/'>FreeBSD</a>, <a href='http://keramida.wordpress.com/category/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/category/linux/'>Linux</a>, <a href='http://keramida.wordpress.com/category/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/category/software/'>Software</a> Tagged: <a href='http://keramida.wordpress.com/tag/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/tag/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/tag/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/tag/freebsd/'>FreeBSD</a>, <a href='http://keramida.wordpress.com/tag/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/tag/linux/'>Linux</a>, <a href='http://keramida.wordpress.com/tag/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/tag/software/'>Software</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/2177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/2177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2177&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2013/03/22/linux-xterm-256color-terminfo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>Automatically Joining Password-Enabled Channels in ERC</title>
		<link>http://keramida.wordpress.com/2013/03/14/automatically-joining-password-enabled-channels-in-erc/</link>
		<comments>http://keramida.wordpress.com/2013/03/14/automatically-joining-password-enabled-channels-in-erc/#comments</comments>
		<pubDate>Thu, 14 Mar 2013 11:56:56 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=2121</guid>
		<description><![CDATA[If, like me, you are using ERC to chat with your IRC friends all over the world, then the next few paragraphs describe how you can set up automatically joining channels in a secure manner, even if the channels require &#8230; <a href="http://keramida.wordpress.com/2013/03/14/automatically-joining-password-enabled-channels-in-erc/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2121&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>If, like me, you are using <a href="http://www.emacswiki.org/ERC" title="Emacswiki: ERC">ERC</a> to chat with your <a href="http://en.wikipedia.org/wiki/Internet_Relay_Chat" title="Internet Relay Chat">IRC</a> friends all over the world, then the next few paragraphs describe how you can set up automatically joining channels in a secure manner, even if the channels require a key.</p>
<p>Being able to auto-join channels after connecting to an IRC server is a <em>must have</em> for any serious IRC client.  This way the user doesn&#8217;t have to laboriously type <code>/join</code> commands again and again, every time the IRC client start, or when there&#8217;s a network problem and the IRC server temporarily disconnects. Typing long lists of channel names gets old really fast if one has to type stuff like this for example:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
/join #public
/join #secret somekeyword
/join #interest
/join #hobby hobbykey
</pre>
<p>Most serious IRC clients have some form of &#8216;autojoin&#8217; feature, that lets you configure the channels they should join when connected to a specific IRC network or to a specific IRC server.  ERC supports auto-joining with a loadable module called <em>erc-join</em>.  You can load this module in your ERC startup code, and then use <em>erc-autojoin-channels-alist</em> to specify which channels to join on a per-server basis.</p>
<p>Loading the <em>erc-join</em> module and enabling auto-join support is the easy bit:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
(require 'erc-join)             ; autojoin support is implemented by erc-join.el
(erc-autojoin-enable)           ; enable channel autojoin support, by default
</pre>
<p>Setting up the list of channels in <em>erc-autojoin-channel-alist</em> is also easy, but it does lend itself to a bit of upfront explanation.  When auto-join code looks at <em>erc-autojoin-channel-alist</em> it expects to find there a list of &#8216;server patterns&#8217; and their associated channels.  So its value should look like this:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
((SERVER-PATTERN-1 . CHANNEL-1 CHANNEL-2 ...)
 (SERVER-PATTERN-2 . CHANNEL-3 CHANNEL-4 CHANNEL-5 ...))
</pre>
<p>When a connection to a new IRC server is established, <em>erc-join</em> has set things up so that <em>erc-autojoin-channels</em> is called.  The <em>erc-autojoin-channels</em> function iterates through <em>erc-autojoin-channels-alist</em> and checks if the server pattern matches the current server-name. If it does, it calls <em>erc-server-join-channel</em> for each of the channels attached to this server pattern.</p>
<p>The server pattern can be a regular expression and pattern matching for the &#8216;server&#8217; part of each <em>erc-autojoin-channels-alist</em> item <em>does not stop when it finds a match</em>.  This means that you can mix and match server patterns in all sorts of amusing ways, e.g. to set up a channel that is automatically joined for all IRC networks, by having an <em>erc-autojoin-channels-alist</em> entry whose server pattern is <code>".*"</code>:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
(setq erc-autojoin-channels-alist
      '((&quot;.*&quot; . &quot;#everywhere&quot;)))
</pre>
<p>Now, for the interesting part. What happens when you want to automatically join channels that require a key. That&#8217;s where the real magic behind <em>erc-server-join-channel</em> kicks in, and lets you store your passwords in a secure place, like e.g. a PGP-encrypted <em>~/.authinfo</em> file in your home directory!</p>
<p>Every time <em>erc-server-join-channel</em> is called it tries to look up a matching entry for the current IRC server and channel names in what Emacs calls &#8220;authentication sources&#8221;.  These are, basically, files in &#8216;netrc&#8217; file format (traditionally used by FTP clients).  If a matching entry is found for the current combination of server and channel in one of the configured netrc files, the <em>password</em> key of this netrc file entry is used as the key for joining the IRC channel. The service name used for netrc entry lookup is also conveniently set to &#8220;irc&#8221;, so that ERC will not pick up unrelated passwords from your netrc files.</p>
<p>A valid netrc file entry, one which ERC can use to locate the key for an IRC channel, looks like this:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
machine irc.freenode.net login &quot;#mychannel&quot; password &quot;supersecret&quot; port irc
</pre>
<p>If this line is present in your <em>~/.authinfo</em> or <em>~/.netrc</em> file, and one of the <em>erc-autojoin-channels-alist</em> entries specifies that &#8220;#mychannel&#8221; should be automatically joined when connected to the IRC server &#8220;irc.freenode.net&#8221;, then ERC will use &#8220;supersecret&#8221; as the key for joining the channel.  This is a much safer alternative than typing the channel passwords yourself at an ERC prompt (because the channel passwords may then be logged on disk, if you have enabled server-buffer logging), and it&#8217;s definitely safer than listing the password in your <em>~/.emacs</em> startup code or other place that can be world-readable.</p>
<p><strong>Putting it All Together</strong></p>
<p>To summarize, configuring ERC to automatically join channels &#8220;#public&#8221; and &#8220;#secret&#8221; when connecting to IRC server &#8220;irc.example.net&#8221;, and to use the secret key &#8220;supersecret&#8221; for the &#8220;#secret&#8221; channel, you can put the following in your ERC startup code:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
(require 'erc-join)
(erc-autojoin-enable)

(setq erc-autojoin-channels-alist
      '((&quot;irc.example.net&quot; . &quot;#public&quot; &quot;#secret&quot;))))
</pre>
<p>and the following in your <em>~/.authinfo</em> or <em>~/.netrc</em> file:</p>
<pre class="brush: plain; light: true; title: ; notranslate">
machine irc.example.net login &quot;#secret&quot; password &quot;supersecret&quot; port irc
</pre>
<br />Filed under: <a href='http://keramida.wordpress.com/category/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/category/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/category/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/category/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/category/software/'>Software</a> Tagged: <a href='http://keramida.wordpress.com/tag/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/tag/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/tag/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/tag/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/tag/software/'>Software</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/2121/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/2121/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2121&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2013/03/14/automatically-joining-password-enabled-channels-in-erc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>Mutt-like Scrolling for Gnus</title>
		<link>http://keramida.wordpress.com/2013/03/11/mutt-like-scrolling-for-gnus/</link>
		<comments>http://keramida.wordpress.com/2013/03/11/mutt-like-scrolling-for-gnus/#comments</comments>
		<pubDate>Mon, 11 Mar 2013 02:56:18 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Open source]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Gnus]]></category>
		<category><![CDATA[Email]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=2109</guid>
		<description><![CDATA[Mutt scrolls the index of email folders up or down, one line at a time, with the press of a single key: &#8216;&#60;&#8217; or &#8216;&#62;&#8217;. This is a very convenient way to skim through email folder listings, so I wrote &#8230; <a href="http://keramida.wordpress.com/2013/03/11/mutt-like-scrolling-for-gnus/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2109&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Mutt scrolls the index of email folders up or down, one line at a time, with the press of a single key: &#8216;&lt;&#8217; or &#8216;&gt;&#8217;.  This is a very convenient way to skim through email folder listings, so I wrote a small bit of Emacs Lisp to do the same in Gnus tonight.</p>
<pre class="brush: plain; title: ; toolbar: false; notranslate">
;;;
;; Scrolling like mutt for group, summary, and article buffers.
;;
;; Being able to scroll the current buffer view by one line with a
;; single key, rather than having to guess a random number and recenter
;; with `C-u NUM C-l' is _very_ convenient.  Mutt binds scrolling by one
;; line to '&lt;' and '&gt;', and it's something I often miss when working
;; with Gnus buffers.  Thanks to the practically infinite customizability
;; of Gnus, this doesn't have to be an annoyance anymore.

(defun keramida-mutt-like-scrolling ()
  &quot;Set up '&lt;' and '&gt;' keys to scroll down/up one line, like mutt.&quot;
  ;; mutt-like scrolling of summary buffers with '&lt;' and '&gt;' keys.
  (local-set-key (kbd &quot;&gt;&quot;) 'scroll-up-line)
  (local-set-key (kbd &quot;&lt;&quot;) 'scroll-down-line))

(add-hook 'gnus-group-mode-hook 'keramida-mutt-like-scrolling)
(add-hook 'gnus-summary-mode-hook 'keramida-mutt-like-scrolling)
(add-hook 'gnus-article-prepare-hook 'keramida-mutt-like-scrolling)
</pre>
<p>This is now the latest addition to my <code>~/.gnus</code> startup code, and we&#8217;re one step closer to making Gnus behave like my favorite old-time mailer.</p>
<br />Filed under: <a href='http://keramida.wordpress.com/category/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/category/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/category/email/'>Email</a>, <a href='http://keramida.wordpress.com/category/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/category/freebsd/'>FreeBSD</a>, <a href='http://keramida.wordpress.com/category/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/category/gnus/'>Gnus</a>, <a href='http://keramida.wordpress.com/category/linux/'>Linux</a>, <a href='http://keramida.wordpress.com/category/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/category/programming/'>Programming</a>, <a href='http://keramida.wordpress.com/category/software/'>Software</a> Tagged: <a href='http://keramida.wordpress.com/tag/computers/'>Computers</a>, <a href='http://keramida.wordpress.com/tag/emacs/'>Emacs</a>, <a href='http://keramida.wordpress.com/tag/email/'>Email</a>, <a href='http://keramida.wordpress.com/tag/free-software/'>Free software</a>, <a href='http://keramida.wordpress.com/tag/freebsd/'>FreeBSD</a>, <a href='http://keramida.wordpress.com/tag/gnulinux/'>GNU/Linux</a>, <a href='http://keramida.wordpress.com/tag/gnus/'>Gnus</a>, <a href='http://keramida.wordpress.com/tag/linux/'>Linux</a>, <a href='http://keramida.wordpress.com/tag/open-source/'>Open source</a>, <a href='http://keramida.wordpress.com/tag/programming/'>Programming</a>, <a href='http://keramida.wordpress.com/tag/software/'>Software</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/2109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/2109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=2109&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2013/03/11/mutt-like-scrolling-for-gnus/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>My Favorite Firefox Extensions</title>
		<link>http://keramida.wordpress.com/2009/12/09/my-favorite-firefox-extensions/</link>
		<comments>http://keramida.wordpress.com/2009/12/09/my-favorite-firefox-extensions/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 06:28:06 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[hellug]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=750</guid>
		<description><![CDATA[The Firefox web browser supports hundreds of extensions in its latest version. There are extensions that tweak its behavior in small but useful ways, addons that add completely new and very innovative features, even entire applications like FTP clients and &#8230; <a href="http://keramida.wordpress.com/2009/12/09/my-favorite-firefox-extensions/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=750&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>The <strong><a href="http://www.mozilla.org/firefox/">Firefox</a></strong> <a href="http://en.wikipedia.org/wiki/Web_Browser">web browser</a> supports hundreds of <a href="http://en.wikipedia.org/wiki/Plug-in_%28computing%29">extensions</a> in its latest version.  There are extensions that tweak its behavior in small but useful ways, addons that add completely new and very innovative features, even entire applications like <a href="http://en.wikipedia.org/wiki/FTP">FTP</a> clients and <a href="http://en.wikipedia.org/wiki/E-mail">e-mail</a> posting programs that run inside the browser.</p>
<p>It would be silly to list <em>all</em> the extensions supported by Firefox here.  There are <em>some</em> extensions, however, which I consider vastly more useful than all the others. These are usually the first things I add to every new Firefox installation before using it for browsing web pages.<span id="more-750"></span> This is a list of these extensions:</p>
<p><strong>It&#8217;s All Text!</strong> &mdash; <a href="https://addons.mozilla.org/en-US/firefox/addon/4125">https://addons.mozilla.org/en-US/firefox/addon/4125</a></p>
<blockquote><p>An extension that permits editing the text of web forms in an external editor.  Many web pages have obnoxious bits of <a href="http://en.wikipedia.org/wiki/JavaScript">JavaScript</a> code that grabs keyboard shortcuts and make editing a pain. Other web pages have too small areas for textual input.  This extension solves both of these problems, by allowing you to edit web form text in a full-screen window of a <em>real</em> editor, like <a href="http://www.gnu.org/software/emacs/">Emacs</a>, <a href="http://www.vim.org/">VIM</a>, <a href="http://kate-editor.org/">Kate</a>, or <a href="http://projects.gnome.org/gedit/">GEdit</a>.</p></blockquote>
<p><strong>NoScript</strong> &mdash; <a href="https://addons.mozilla.org/en-US/firefox/addon/722">https://addons.mozilla.org/en-US/firefox/addon/722</a></p>
<blockquote><p>An extension that can be used to disable JavaScript code by default and then selectively enable the use of JavaScript for only a select subset of the web. JavaScript can often bloat and slow-down the browser, especially if used haphazardly and without proper care by the authors of a web site. Sometimes it even poses a security risk. NoScript can help a lot with these two problems that plague many of the &#8220;<em>modern</em>&#8221; web sites.</p></blockquote>
<p><strong>Open in Browser</strong> &mdash; <a href="https://addons.mozilla.org/en-US/firefox/addon/8207">https://addons.mozilla.org/en-US/firefox/addon/8207</a></p>
<blockquote><p>A &#8220;convenience extension&#8221;, the Open in Browser addon adds an extra option to the open dialog that Firefox pops up when it cannot render a web object inside the browser window. Some web sites report a rather conservative <a href="http://en.wikipedia.org/wiki/MIME_type">MIME type</a> for the objects they serve, commonly reporting that an object is a raw <em><a href="http://en.wikipedia.org/wiki/Byte_stream">byte stream</a></em>, even if the object itself is the source code of a <a href="http://en.wikipedia.org/wiki/Scripting">script</a>. In these cases, the Open in Browser extension enables Firefox to temporarily ignore the MIME type reported by the web server, and display the web object directly inside the browser window; saving you from the trouble of storing a local disk copy and manually launching an external viewer.</p></blockquote>
<p><strong>Video Download Helper</strong> &mdash; <a href="https://addons.mozilla.org/en-US/firefox/addon/3006">https://addons.mozilla.org/en-US/firefox/addon/3006</a></p>
<blockquote><p>A handy extension that lets you download video clips from <a href="http://www.youtube.com/">YouTube</a> and other web sites that require a <a href="http://en.wikipedia.org/wiki/Adobe_Flash">Flash</a> plugin. This Firefox extension makes it possible to locally store the video files, so that they can be played later with <a href="http://en.wikipedia.org/wiki/MPlayer">MPlayer</a>, <a href="http://en.wikipedia.org/wiki/Totem_%28media_player%29">Totem</a>, <a href="http://en.wikipedia.org/wiki/VLC_media_player">VLC</a>, or other media players.  Having the entire media files locally often results in improved playback, as the media player does not have to block video output, waiting for input from a slow network connection.
</p></blockquote>
<p>These are the four Firefox extensions that I install to <em>all</em> my Firefox profiles.  I can probably browse most web sites without them, with a few annoying parts here and a few missing conveniences there, but whenever I have the option these addons are <em>definitely</em> part of my browsing tools.</p>
<p>Which extensions do you like using?  Which ones are those Firefox addons that you &#8220;cannot live without&#8221;?</p>
<br />Posted in Computers, Emacs, Firefox, Free software, Open source, Software Tagged: Computers, Emacs, Firefox, Free software, hellug, Open source, Software <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/750/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/750/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=750&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2009/12/09/my-favorite-firefox-extensions/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>query-replace-regexp or &#8220;making movies enjoyable&#8221;</title>
		<link>http://keramida.wordpress.com/2009/06/05/query-replace-regexp-or-making-movies-enjoyable/</link>
		<comments>http://keramida.wordpress.com/2009/06/05/query-replace-regexp-or-making-movies-enjoyable/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 05:19:04 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[hellug]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=547</guid>
		<description><![CDATA[One of the movies I recently watched came with subtitles in a separate *.srt file. The subtitles had 99% correct timing information, a pretty amazing feat. They had a minor glitch though. Many instances of lowercase &#8216;el&#8217; had been replaced &#8230; <a href="http://keramida.wordpress.com/2009/06/05/query-replace-regexp-or-making-movies-enjoyable/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=547&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>One of the movies I recently watched came with subtitles in a separate <em>*.srt</em> file.  The subtitles had 99% correct timing information, a pretty amazing feat.  They had a minor glitch though.  Many instances of lowercase &#8216;el&#8217; had been replaced with uppercase &#8216;i&#8217;.</p>
<p>I noticed this tiny glitch in the first few lines of text, and then discovered that it was a buglet that occured far too often.  My <a href="http://en.wikipedia.org/wiki/Obsessive-compulsive_disorder">OCD</a> side started feeling bad about the movie, because all the bogus capital &#8216;i&#8217; letters were distracting me from the &#8220;real&#8221; fun of watching the actual movie.</p>
<p>So I stopped watching, and I fired up GNU Emacs on the srt file.<span id="more-547"></span></p>
<p>After 1-2 minutes of work, and a lot of fun with <code>query-replace-regexp</code> I found a nice replacement pattern to interactively fix all the broken &#8216;i&#8217; instances:</p>
<blockquote><pre>M-x <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Query-Replace.html">query-replace-regexp</a> RET
    \([^I ]*\)\(I+\)\([^I ]*\) RET
    \1\,(replace-regexp-in-string "i" "l" (downcase \2))\3 RET</pre>
</blockquote>
<p>This had quite a few false positives, but it did 95% of the work, so I manually fixed the 5-10 instances it didn&#8217;t catch, and I was finally able to enjoy the movie.</p>
<blockquote><p><strong>Note:</strong> The perceptive reader who is also a fan of <a href="http://en.wikipedia.org/wiki/Regular_expression">regular expressions</a> will probably notice very quickly that part of the third line is Lisp code.  This is an amazing feature of regexp replacement in Emacs.  When the special pattern <code>\,</code> appears in the replacement text it evaluates the following expression as Emacs Lisp.  An arbitrarily complex Lisp expression can be used after <code>\,</code> and its return value is used as the replacement text.</p></blockquote>
<p>I&#8217;m positively thrilled that Emacs saved the day&#8230; again :-)</p>
<br />Posted in Computers, Emacs, Free software, Fun, Open source, Software Tagged: Computers, Emacs, Free software, Fun, hellug, Open source, Software <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/547/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/547/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=547&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2009/06/05/query-replace-regexp-or-making-movies-enjoyable/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>Stalking Keramida</title>
		<link>http://keramida.wordpress.com/2009/02/11/stalking-keramida/</link>
		<comments>http://keramida.wordpress.com/2009/02/11/stalking-keramida/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 22:25:03 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[hellug]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=409</guid>
		<description><![CDATA[Quick tip for finding if keramida&#8217;s been active in a machine the last few days. Run the command: % ps xau &#124; sed -n -e 1p -e /sed/d -e '/keramida.*emacs.*daemon/p' Watch for activity in the Emacs daemon, and if you &#8230; <a href="http://keramida.wordpress.com/2009/02/11/stalking-keramida/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=409&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Quick tip for finding if keramida&#8217;s been active in a machine the last few days.</p>
<p>Run the command:</p>
<blockquote><pre>% ps xau | sed -n -e 1p -e /sed/d -e '/keramida.*emacs.*daemon/p'</pre>
</blockquote>
<p>Watch for activity in the Emacs daemon, and if you see any, well&#8230; you know that keramida is active :-)</p>
<br />Posted in Computers, Emacs, Free software, FreeBSD, GNU/Linux, Linux, Open source, Software Tagged: Computers, Emacs, Free software, FreeBSD, GNU/Linux, hellug, Linux, Open source, Software <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/409/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/409/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=409&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2009/02/11/stalking-keramida/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>Emacs 23.0.90 pretest in FreeBSD Ports</title>
		<link>http://keramida.wordpress.com/2009/02/02/emacs-23090-pretest-in-freebsd-ports/</link>
		<comments>http://keramida.wordpress.com/2009/02/02/emacs-23090-pretest-in-freebsd-ports/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 22:31:20 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[hellug]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=395</guid>
		<description><![CDATA[Chong Yidong announced the first pretest of Emacs 23.X last night. http://lists.gnu.org/archive/html/emacs-devel/2009-02/msg00051.html This is the first pretest release of Emacs 23.X and it includes many improvements over Emacs 22.X. Emacs now can link with libotf to handle complex OpenType font &#8230; <a href="http://keramida.wordpress.com/2009/02/02/emacs-23090-pretest-in-freebsd-ports/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=395&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>Chong Yidong announced the first pretest of Emacs 23.X last night.<span id="more-395"></span></p>
<p><a href="http://lists.gnu.org/archive/html/emacs-devel/2009-02/msg00051.html">http://lists.gnu.org/archive/html/emacs-devel/2009-02/msg00051.html</a></p>
<p>This is the first pretest release of Emacs 23.X and it includes many improvements over Emacs 22.X.</p>
<ul>
<li>Emacs now can link with <em>libotf</em> to handle complex OpenType font layouts.</li>
<li>A new set of default icons is used by Emacs 23.</li>
<li>Emacs now supports using both X displays and ttys in one session.</li>
<li>Emacs can now start in the background, as a daemon, using the <em>&#8211;daemon</em> command line option.  In this mode Emacs disconnects from the controlling terminal and starts a background server process.  The <em>emacsclient(1)</em> utility can be used to create new tty windows or X frames attached to this background daemon.</li>
<li>Transient mark mode is now on by default.</li>
<li>&#8220;<code>C-l</code>&#8221; is now bound to the new command <code>recenter-top-bottom</code>, rather than <code>recenter</code>.</li>
<li>&#8220;<code>M-x butterfly</code>&#8221; flips the desired bit on the disk platter.  See <a href="http://xkcd.com/378/">http://xkcd.com/378/</a></li>
<li>&#8220;<code>linum</code>&#8221; is a special mode for displaying line numbers in a buffer, similar to the &#8220;<em>set number</em>&#8221; command of VI.</li>
<li>Many more updates and bug fixes.</li>
</ul>
<p>The full list of changes that Emacs 23.0.90 includes are described in the file &#8220;<code>etc/NEWS</code>&#8221; in the source distribution of the pretest release.</p>
<p>This morning I updated the <em>editors/emacs-devel</em> of FreeBSD to install the 23.0.90 pretest version of Emacs.  Boris Samorodov picked the update out of the list of submitted patches and committed it to the CVS tree of the FreeBSD Ports collection.</p>
<p>Users who are using <em>emacs-devel</em> on FreeBSD, can now update their port to grab this release of Emacs 23.X.</p>
<p>As the new <code>pkg-message</code> of the port describes, this is an experimental release of Emacs 23.X.  The list of new features and bug fixes is impressive, but there may still be problems lurking in the code or even regressions from stable releases.</p>
<p>If you notice anything that is odd, or find something that seems to be a bug, please report it to:</p>
<ul>
<li>My own email address, as listed in the <em>MAINTAINER</em> field of the port makefile.  It should be possible to see my email address by running <em>more(1)</em> on the <em>Makefile</em>, or by using the <em>make(1)</em> utility:<br />
<blockquote><pre>% <strong>cd /usr/ports/editors/emacs-devel</strong>
% <strong>make -V MAINTAINER</strong></pre>
</blockquote>
</li>
<li>Even if the port builds successfully on your system, and it passes all your tests, please feel free to email me and the pretesters mailing list at <a href="mailto:emacs-pretest-bug@gnu.org">emacs-pretest-bug@gnu.org</a>.</li>
</ul>
<p>One of the most important changes in this pretest; one that you should be careful about, and watch out for possible bugs, is the change of the <em>RMAIL</em> mail package from the old <em>Babyl</em> format to UNIX <em>mbox</em> format.  This part of Emacs may be less stable than others; for safety, please back up your mail files before trying the new Rmail.</p>
<br />Posted in Computers, Emacs, Free software, GNU/Linux, Linux, Open source, Software Tagged: Computers, Emacs, Free software, GNU/Linux, hellug, Linux, Open source, Software <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/keramida.wordpress.com/395/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/keramida.wordpress.com/395/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=395&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2009/02/02/emacs-23090-pretest-in-freebsd-ports/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
		<item>
		<title>Gnus message scoring actually works</title>
		<link>http://keramida.wordpress.com/2008/11/15/gnus-message-scoring-actually-works/</link>
		<comments>http://keramida.wordpress.com/2008/11/15/gnus-message-scoring-actually-works/#comments</comments>
		<pubDate>Sat, 15 Nov 2008 08:26:39 +0000</pubDate>
		<dc:creator>keramida</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Emacs]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Gnus]]></category>
		<category><![CDATA[Mercurial]]></category>
		<category><![CDATA[Open source]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[hellug]]></category>

		<guid isPermaLink="false">http://keramida.wordpress.com/?p=330</guid>
		<description><![CDATA[From the let-the-flames-roll-baby department:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=keramida.wordpress.com&#038;blog=118304&#038;post=330&#038;subd=keramida&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>From the <em>let-the-flames-roll-baby</em> department:</p>
<blockquote>]]></content:encoded>
			<wfw:commentRss>http://keramida.wordpress.com/2008/11/15/gnus-message-scoring-actually-works/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/a04f844616a09c24d054c71d44b2e78e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">keramida</media:title>
		</media:content>
	</item>
	</channel>
</rss>
