<?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"
	>

<channel>
	<title>EnigmaCurry &#187; Emacs</title>
	<atom:link href="http://www.enigmacurry.com/category/emacs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.enigmacurry.com</link>
	<description>The Curry Enigma</description>
	<pubDate>Sun, 16 Nov 2008 16:15:27 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Wrangling my finances</title>
		<link>http://www.enigmacurry.com/2008/10/21/wrangling-my-finances/</link>
		<comments>http://www.enigmacurry.com/2008/10/21/wrangling-my-finances/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 19:42:55 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<category><![CDATA[Cool Stuff]]></category>

		<category><![CDATA[Economics]]></category>

		<category><![CDATA[Emacs]]></category>

		<category><![CDATA[finances ledger selenium]]></category>

		<guid isPermaLink="false">http://www.enigmacurry.com/?p=177</guid>
		<description><![CDATA[I&#039;ve gotten better at thinking about my finances over the years but I&#039;ve never had anything better than a mental budget. I&#039;ve never actually written anything down on paper. I&#039;ve got a brand new job so I figure I&#039;ve got a clean slate. Starting right now, I pledge to myself to keep a balanced checkbook [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;ve gotten better at thinking about my finances over the years but I&#039;ve never had anything better than a mental budget. I&#039;ve never actually written anything down on paper. I&#039;ve got a brand new job so I figure I&#039;ve got a clean slate. Starting right now, I pledge to myself to keep a balanced checkbook at all times and to do monthly reviews of my finances looking for things to cut out of my budget.</p>
<p>Fiscal Conscience: Ha! How many times have you said that?<br />
Me: Dozens of times!<br />
Fiscal Conscience: And did you ever actually do it?<br />
Me: No, but this time it will be different!<br />
Fiscal Conscience: You&#039;re going to have do to better than that!<br />
Me: Fine, I&#039;ll show you.</p>
<p>GnuCash is a wonderful piece of open-source accounting software. I have used it myself, dozens of times. But as it happens I inevitably stop using it. Not because the software is flawed per se, it does everything a good accounting application should do:</p>
<ul>
<li>Use Double-Entry accounting</li>
<li>Support multiple currencies</li>
<li>OFX import from online banking sites</li>
<li>etc</li>
</ul>
<p>The only thing they get wrong is the fundamental design choice they made when developing the application: they made it a GUI. Sure, GUIs are great, but in my opinion GUIs should be interfaces to a service oriented application rather than the application itself. Unless I&#039;m sitting at my desk at home I can&#039;t use my application. I don&#039;t consider remote desktops a reasonable response to this problem due to the huge network latency issues as well as firewall problems.</p>
<p>I want to be able to record my transactions from anywhere. At home at my desk, at work at my desk, on my N800 when traveling, or on my phone when running around. With an application fundamentally written as a GUI this is essentially an insurmountable problem. An application written as a service can do all of these things quite easily with minimal amounts of programming.</p>
<p>Enter <a href="http://www.newartisans.com/software/ledger.html">Ledger</a>.</p>
<p>Ledger does not keep track of your accounts. <strong>You</strong> keep track of your accounts in a plain text file and Ledger helps you understand them better. I can update my checkbook register from any text editor, anywhere I am. Most often this is Emacs through SSH on my home computer. Because of the triviality of the file format (being plain text) I can write a simple application that takes text messages from my phone and adds them to the register automatically.</p>
<p><img src="http://www.enigmacurry.com/wp-content/uploads/2008/10/ledgerscreenshot.png" alt="" title="ledgerscreenshot" align="center" /></p>
<p>But what about all my automatic payments?</p>
<p>I have most of my monthly payments automatically debited from my account. This is nice since I don&#039;t have to spend the time submitting payments to X number of companies each month, but is a nightmare when it comes time to balancing my checkbook. What I have done in the past is to just import an OFX file from my bank directly into GnuCash. This works great until you realize that something is wrong with the import and your checkbook is no longer balancing correctly. For this reason alone I prefer to record each transaction I make by hand. My money is my responsibility after all.</p>
<p>So, I wanted to be instantly notified of any debit on my checking account as soon as it happens. This gives me the following:
<ul>
<li>A text message to my phone describing the time, place and amount of the transaction</li>
<li>The total balance of my account</li>
<li>A way to constantly keep an eye on how I&#039;m spending my money without the hassle of (remembering to) signing into my bank account</li>
<li>A reminder to balance my checkbook. (tells me when my actual checking balance has been out of sync with ledger for over 48 hours.)</li>
</ul>
<p>The central peice to this process is getting the transaction data from my bank account. My bank offers online banking but it does not offer an easy way to download my transactions. Sure it supports Quicken and MS Money exports, but its all protected behind a password protected javascript-enabled website. I wanted to use the wonderful <a href="http://wwwsearch.sourceforge.net/mechanize/">mechanize</a> library for python. However, it doesn&#039;t support javascript.</p>
<p>Enter <a href="http://selenium-rc.openqa.org/">Selenium RC</a>.</p>
<p>Selenium RC is an application that can remote control a real web browser and submit and receive data. I run selenium which launches Firefox in a headless X-server (Xvfb) and continuously refreshes my online banking site and parses out my account activity. This is probably a bit memory intensive to always keep a browser open for this specific purpose. I may want to experiment with python-spidermonkey in the future and go back to using mechanize, but I think there&#039;s a lot of glue missing in that solution whereas Selenium RC works perfectly right now!</p>
<p>No code to share at the moment, it&#039;s all a giant hack. If a similar setup appeals to someone out there, let me know and I&#039;ll think about releasing something.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.enigmacurry.com/2008/10/21/wrangling-my-finances/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Shortened URLs in Emacs using is.gd (like tinyurl)</title>
		<link>http://www.enigmacurry.com/2008/09/15/shortened-urls-in-emacs-using-isgd-like-tinyurl/</link>
		<comments>http://www.enigmacurry.com/2008/09/15/shortened-urls-in-emacs-using-isgd-like-tinyurl/#comments</comments>
		<pubDate>Mon, 15 Sep 2008 18:11:20 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<category><![CDATA[Emacs]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.enigmacurry.com/?p=156</guid>
		<description><![CDATA[I&#039;ve casually been teaching myself emacs lisp lately. Today I wrote a utility that shortens long urls within regions using the http://is.gd URL shortening service. There&#039;s plenty of existing code out there that is more lisp like, but this is supposed to be a learning experience for me so I did it myself. I like [...]]]></description>
			<content:encoded><![CDATA[<p>I&#039;ve casually been teaching myself emacs lisp lately. Today I wrote a utility that shortens long urls within regions using the <a href="http://is.gd">http://is.gd</a> URL shortening service. There&#039;s plenty of <a href="http://www.emacswiki.org/cgi-bin/wiki/tinyurl.el">existing code</a> out there that is more lisp like, but this is supposed to be a learning experience for me so I did it myself. I like python and so I used python for most of the heavy lifting.</p>
<p>I created a directory to hold all of my emacs specific python functions: ~/.emacs.d/ryan-pymacs-extensions</p>
<p>I wrote the following python function, shorten_url.py in that directory:</p>
<pre lang="python">
!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = "Ryan McGuire (ryan@enigmacurry.com)"
__date__   = "Mon Sep 15 12:27:14 2008"

import doctest
import urllib2
import re

def shorten_with_is_gd(url):
    """Shorten a URL with is.gd

    >>> shorten_with_is_gd('http://www.enigmacurry.com')
    'http://is.gd/FFP'

    """
    u = urllib2.urlopen("http://is.gd/api.php?longurl="+url)
    return u.read()

def shorten_in_text(text):
    """Shorten all the urls found inside some text

    >>> shorten_in_text('Hi from http://www.enigmacurry.com')
    'Hi from http://is.gd/FFP'

    """
    replacements = {} #URL -> is.gd URL
    #Only check for urls that start with "http://" for now
    for m in re.finditer("http://[^ \n\r]*", text):
        try:
            replacements[m.group()] = shorten_with_is_gd(m.group())
        except:
            replacements[m.group()] = m.group()
    for url,replacement in replacements.items():
        text = text.replace(url, replacement)
    return text

if __name__ == '__main__':
    doctest.testmod(verbose=True)
</pre>
<p>and the following lisp makes &#034;M-x shorten-url&#034; do the rest of the replacement work:</p>
<pre lang="lisp">
;add ~/.emacs.d/ryan-python-extensions to python path
(pymacs-exec "import sys, os")
(pymacs-exec "sys.path.append(os.path.join(os.path.expanduser('~'),'.emacs.d','ryan-pymacs-extensions'))")

;;Shorten URLs with is.gd
(pymacs-exec "import shorten_url")
(defun shorten-url (start end)
  (interactive "r")
  (let ((region (buffer-substring start end)))
    (let ((rt (pymacs-eval (format "shorten_url.shorten_in_text('''%s''')" region))))
      (kill-region start end)
      (insert rt)
      )
  ))
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.enigmacurry.com/2008/09/15/shortened-urls-in-emacs-using-isgd-like-tinyurl/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs IRC (ERC) with Noticeable Notifications</title>
		<link>http://www.enigmacurry.com/2008/08/07/emacs-irc-erc-with-noticeable-notifications/</link>
		<comments>http://www.enigmacurry.com/2008/08/07/emacs-irc-erc-with-noticeable-notifications/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 07:35:50 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<category><![CDATA[Emacs]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Lisp]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.enigmacurry.com/?p=151</guid>
		<description><![CDATA[I use ERC  for all my IRC chatting. I finally got fed up with not noticing someones message because I didn&#039;t have emacs focused. So I spent my evening concocting a more noticeable messaging system through Pymacs and libnotify.
Half way though implementing this, wouldn&#039;t you know it, I found ErcPageMe which does exactly what [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://www.emacswiki.org/cgi-bin/wiki?action=browse;oldid=EmacsIRCClient;id=ERC">ERC </a> for all my IRC chatting. I finally got fed up with not noticing someones message because I didn&#039;t have emacs focused. So I spent my evening concocting a more noticeable messaging system through Pymacs and libnotify.</p>
<p>Half way though implementing this, wouldn&#039;t you know it, I found <a href="http://www.emacswiki.org/cgi-bin/wiki/ErcPageMe">ErcPageMe</a> which does exactly what I wanted. I figured I was learning quite a bit and I continued writing my own version. I expanded on their code and (at least for me) made some improvements. So kudos go to whoever wrote ErcPageMe <img src='http://www.enigmacurry.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The following code will pop up a message on your gnome desktop alerting you whenever you receive a personal message or when someone mentions your nickname in a channel. It also avoids notification for the same user in the same channel if they triggered a message within the last 30 seconds.</p>
<p><center> <img src="/blog-post-images/Emacs-ERC-Notification.png" alt="Emacs ERC Notification through libnotify" /></center></p>
<p>Here is my lisp and embedded python/pymacs code:</p>
<pre lang="lisp">

(defun notify-desktop (title message &#038;optional duration &#038;optional icon)
  "Pop up a message on the desktop with an optional duration (forever otherwise)"
  (pymacs-exec "import pynotify")
  (pymacs-exec "pynotify.init('Emacs')")
  (if icon
      (pymacs-exec (format "msg = pynotify.Notification('%s','%s','%s')"
                           title message icon))
    (pymacs-exec (format "msg = pynotify.Notification('%s','%s')" title message))
    )
  (if duration
      (pymacs-exec (format "msg.set_timeout(%s)" duration))
    )
  (pymacs-exec "msg.show()")
  )

;; Notify me when someone wants to talk to me.
;; Heavily based off of ErcPageMe on emacswiki.org, with some improvements.
;; I wanted to learn and I used my own notification system with pymacs
;; Delay is on a per user, per channel basis now.
(defvar erc-page-nick-alist nil
  "Alist of 'nickname|target' and last time they triggered a notification"
  )
(defun erc-notify-allowed (nick target &#038;optional delay)
  "Return true if a certain nick has waited long enough to notify"
  (unless delay (setq delay 30))
  (let ((cur-time (time-to-seconds (current-time)))
        (cur-assoc (assoc (format "%s|%s" nick target) erc-page-nick-alist))
        (last-time))
    (if cur-assoc
        (progn
          (setq last-time (cdr cur-assoc))
          (setcdr cur-assoc cur-time)
          (> (abs (- cur-time last-time)) delay))
      (push (cons (format "%s|%s" nick target) cur-time) erc-page-nick-alist)
      t)
    )
  )
(defun erc-notify-PRIVMSG (proc parsed)
  (let ((nick (car (erc-parse-user (erc-response.sender parsed))))
	(target (car (erc-response.command-args parsed)))
	(msg (erc-response.contents parsed)))
    ;;Handle true private/direct messages (non channel)
    (when (and (not (erc-is-message-ctcp-and-not-action-p msg))
               (erc-current-nick-p target)
	       (erc-notify-allowed nick target)
	       )
      ;Do actual notification
      (ding)
      (notify-desktop (format "%s - %s" nick
                              (format-time-string "%b %d %I:%M %p"))
                      msg 0 "gnome-emacs")
      )
    ;;Handle channel messages when my nick is mentioned
    (when (and (not (erc-is-message-ctcp-and-not-action-p msg))
               (string-match (erc-current-nick) msg)
               (erc-notify-allowed nick target)
	       )
      ;Do actual notification
      (ding)
      (notify-desktop (format "%s - %s" target
                              (format-time-string "%b %d %I:%M %p"))
                      (format "%s: %s" nick msg) 0 "gnome-emacs")
      )
    )

  )

(add-hook 'erc-server-PRIVMSG-functions 'erc-notify-PRIVMSG)
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.enigmacurry.com/2008/08/07/emacs-irc-erc-with-noticeable-notifications/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs as a powerful Python IDE</title>
		<link>http://www.enigmacurry.com/2008/05/09/emacs-as-a-powerful-python-ide/</link>
		<comments>http://www.enigmacurry.com/2008/05/09/emacs-as-a-powerful-python-ide/#comments</comments>
		<pubDate>Fri, 09 May 2008 22:27:37 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<category><![CDATA[Emacs]]></category>

		<category><![CDATA[Enigma Curry]]></category>

		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.enigmacurry.com/?p=146</guid>
		<description><![CDATA[Last night at the Python user group I gave a short demo on using Emacs as a Python editor/IDE. My macbook pro refused to display on the projector so I thought my demo was going to be a &#039;no go&#039;. Thankfully, sontek allowed me to use his Linux laptop. I hurriedly copied over my emacs [...]]]></description>
			<content:encoded><![CDATA[<p>Last night at the <a href="http://www.utahpython.org">Python user group</a> I gave a short demo on using Emacs as a Python editor/IDE. My macbook pro refused to display on the projector so I thought my demo was going to be a &#039;no go&#039;. Thankfully, <a href="http://blog.sontek.net/">sontek</a> allowed me to use his Linux laptop. I hurriedly copied over my emacs environment, installed a few packages and was able to present after all. I think the demo went fairly well even though I think it was a bit hurried and I forgot to cover a few things, I think I was pretty nervous at the same time because of the fact that the mac didn&#039;t work and got me flustered. Oh well, I think people enjoyed it.</p>
<h3 class="intrablog">My Emacs Environment</h3>
<p>Below are the Emacs features most applicable to Python development:</p>
<ul>
<li><a href="http://rope.sourceforge.net/ropemacs.html">Rope and Ropemacs</a><br />
    Rope is a general (non-emacs specific) Python IDE library. It has awesome support for multiple refactoring methods and code introspection. Inside Emacs, this gives us:</p>
<ul>
<li>Full (working!!) code-completion support of modules, classes, methods etc. (M-/ and M-?)</li>
<li>Instant documentation for element under the cursor (C-c d)</li>
<li>Jump to module/class/method definition of element under the cursor (C-c g). This works for any Python code it finds in your PYTHONPATH, including things from the stdlib.</li>
<li>Refactoring of code (like rename &#8212; C-c r r)</li>
<li>List all occurences of of a name in your entire project</li>
<li> <a href="http://rope.sourceforge.net/ropemacs.html">and More.</a></li>
</ul>
</li>
<li><a href="http://code.google.com/p/yasnippet/">YASnippet</a><br />
    YASnippet is a snippet tool like TextMate. You can expand user defined keywords into whole blocks of predefined code. This is especially useful for the usual boilerplate that would go into a python file like </p>
<p><code>#!/usr/bin/env python</code><br />
and<br />
<code>if __name__ == '__main__':</code></p>
<p> Granted, Python doesn&#039;t require much boilerplate, and therefore this package is much more suited to languages like Java, but I bring it up because I think its cool and if you get into the habit of using it, then a few keystrokes saved here and there will add up over time.
  </li>
<li>Subversion support with <a href="http://www.xsteve.at/prg/emacs/psvn.el">psvn.el</a><br />
    Psvn is a comprehensive subversion client for Emacs. It integrates well with ediff mode so you can use it to check changes between versions. It does all of the other boring subversion stuff well too.
  </li>
<li><a href="http://www.cua.dk/ido.html">Ido-mode</a> for buffer switching and file opening.<br />
    Emacs, to the uninitiated, can be confusing because by default there is only one view into a single file at a time. How does one get to another file? Instead of cluttering the interface with GUIness and making the user click somewhere (and thereby forcing the user to waste their time by moving their hand off of the keyboard), Emacs gives powerful ways to switch between files. Ido-mode is one of these useful ways &#8212; it makes a list of open files starting with the most frequently visted files and widdles this list down as you type part of the filename. You can have dozens of files open and only be a few keystrokes away from any one of them.
</ul>
<p>A lot of people, for whatever reason, don&#039;t feel that Emacs is an IDE at all. I don&#039;t personally care what you define it as &#8212; the fact remains &#8212; Emacs is a powerful Python environment and despite being over 32 years old has proven to be just as modern as any IDE today, and remains THE most configurable editor (operating system?) ever.</p>
<p>I&#039;ve <a href="/blog-post-files/Ryan-McGuire-Emacs-Environment-05-09-2008.tar.gz">tarred up my Emacs environment for general consumption</a>. Instructions:</p>
<ul>
<li>Install <a href="http://pymacs.progiciels-bpi.ca/">Pymacs</a></li>
<li>Install <a href="http://rope.sourceforge.net/">Rope</a> and <a href="http://rope.sourceforge.net/ropemacs.html">Ropemacs</a></li>
<li>BTW, those three packages should be the only packages other than Emacs you&#039;ll need. Everything else is self contained.
<li>Extract the tarball to your home directory. This creates a directory called ryan-emacs-env.</li>
<li>Rename &#034;ryan-emacs-env&#034; to &#034;.emacs.d&#034;</li>
<li>Symlink my dot-emacs file to your .emacs. Run &#034;ln -s .emacs.d/dot-emacs .emacs&#034;. </li>
<li>If you also want to do Java development run &#034;tar xfvz jde-2.3.5.1.tar.gz&#034;. I leave it tarred because you don&#039;t need to pollute your environment if you&#039;re not going to use Java. (Also for whatever reason, jde doesn&#039;t like to be stuck in my subversion repository so I just leave it tarred up and untar on every machine I check it out on.)</li>
</ul>
<p>Extra tips:</p>
<ul>
<li>Put your .emacs.d directory under version control. Never rely on your distros emacs packages, install all future elisp files yourself in your .emacs.d file and commit to your repository often. This way you&#039;ve got an environment that is easily transportable and synchronizable across multiple machines. This is the major reason why my emacs environment was so fast to trasnfer from my macbook pro to sontek&#039;s laptop during the demo.</li>
<li>Speaking of sontek, he brought up an excellent point in #utahpython the other day, he&#039;s not going to be using my emacs environment except for reference, instead he&#039;s starting with a clean slate. This is by far the best and most prudent thing to do. My emacs environment is a culmination of several years of plugging in and deleting various packages and writing various snippets of elisp. Your needs are always going to be different than mine and you are also going to be better off by educating yourself along the way by creating your own.</li>
</ul>
<p>Some more fun Emacs evangelism:</p>
<ul>
<li>a <a href="http://platypope.org/yada/emacs-demo/">fascinating screencast of Emacs</a> in the role of Ruby editor (many tips here apply to Python too)</li>
<li>Emacs blogs I read:
<ul>
<li><a href="http://emacslife.blogspot.com/">Emacs life</a></li>
<li><a href="http://trey-jackson.blogspot.com/">Life is too short for bad code</a></li>
<li><a href="http://emacs.wordpress.com/">Minor Emacs Wizardry</a></li>
<li><a href="http://www.emacsblog.org/">M-x all-things-emacs</a></li>
<li><a href="http://platypope.org/blog/">Platypope.org</a></li>
<li>Know of any other good ones? Let me know.</li>
</ul>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.enigmacurry.com/2008/05/09/emacs-as-a-powerful-python-ide/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Building Multi-TTY Emacs from CVS on Ubuntu Gutsy Gibbon</title>
		<link>http://www.enigmacurry.com/2007/10/21/building-multi-tty-emacs-from-cvs-on-ubuntu-gusty-gibbon/</link>
		<comments>http://www.enigmacurry.com/2007/10/21/building-multi-tty-emacs-from-cvs-on-ubuntu-gusty-gibbon/#comments</comments>
		<pubDate>Mon, 22 Oct 2007 01:25:26 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<category><![CDATA[Emacs]]></category>

		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.enigmacurry.com/2007/10/21/building-multi-tty-emacs-from-cvs-on-ubuntu-gusty-gibbon/</guid>
		<description><![CDATA[(Historical note May 2008: The build instructions below, while they should still work, are unnecessary as Multi-TTY has been merged into the main Emacs 23 branch and is available in ubuntu repositories: apt-get install emacs-snapshot) 
Last spring I wrote an article about Multi-TTY Emacs. I had promised that I would update instructions for building it [...]]]></description>
			<content:encoded><![CDATA[<p><em>(Historical note May 2008: The build instructions below, while they should still work, are unnecessary as Multi-TTY has been merged into the main Emacs 23 branch and is available in ubuntu repositories: apt-get install emacs-snapshot) </em></p>
<p>Last spring I wrote an article about <a href="http://www.enigmacurry.com/2007/05/24/multi-tty-emacs-on-gentoo-and-ubuntu/">Multi-TTY Emacs</a>. I had promised that I would update instructions for building it on Ubuntu, but since then I have been mainly using Gentoo on my laptop and never got around to updating it. Sorry <img src='http://www.enigmacurry.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I switched to Ubuntu Gutsy Gibbon yesterday. I also got Multi-TTY Emacs running, and here&#039;s the video to prove it (If this is too small to see, <a href="/blog-post-files/Showing off Multi-TTY Emacs on Ubuntu Gutsy Gibbon.ogm">download the original ogg theora version</a>) :</p>
<p><a href="http://www.enigmacurry.com/2007/10/21/building-multi-tty-emacs-from-cvs-on-ubuntu-gusty-gibbon/" title="Watch Flash video!"><img src="http://www.enigmacurry.comhttp://www.enigmacurry.com/blog-post-files/Showing%20off%20Multi-TTY%20Emacs%20on%20Ubuntu%20Gutsy%20Gibbon.jpg" alt="preview image"/></a></p>
<h3>Building CVS Emacs the old fashioned way</h3>
<p>For those of you that want the easy way out, I&#039;ve <a href="/blog-post-files/emacs-cvs-multitty-102107.deb">prebuilt an emacs CVS package that includes the Multi-TTY patch</a>. I&#039;ve tested that the package works on both Gutsy as well as Feisty.</p>
<p>For those of you that would like to learn how this is done, here&#039;s my recipe:</p>
<p>Install all the dependencies<br />
<code lang="bash"><br />
sudo apt-get install build-essential cvs texinfo libx11-dev libxpm-dev libjpeg-dev libpng-dev libgif-dev libtiff-dev libgtk2.0-dev checkinstall<br />
</code><br />
Check out the Emacs code from CVS<br />
<code lang="bash"><br />
cvs -z3 -d:pserver:anonymous@cvs.savannah.gnu.org:/cvsroot/emacs co emacs<br />
</code><br />
Compile the source<br />
<code lang="bash"><br />
cd emacs<br />
./configure --with-gtk --prefix=/usr/local<br />
make bootstrap<br />
make<br />
</code><br />
Checkinstall will build a basic emacs package for us with a minimum of fuss. We don&#039;t want to automatically install this package though for reasons we&#039;ll see below<br />
<code lang="bash"><br />
sudo checkinstall -D --install=no<br />
</code><br />
Checkinstall will ask you to change some values. I changed the maintainer email and the version number.</p>
<p>Checkinstall is great, and works for 99% percent of the packages that I&#039;ve tried it with. Emacs is a bit different though &#8212; the package that checkinstall creates doesn&#039;t include everything that emacs requires, like all the .el files in the lisp folder among other things. So we have to edit the package a bit. For the following code, we&#039;ll assume the .deb file that checkinstall creates is just called &#034;emacs_cvs-10202007-1_i386.deb&#034;, so adjust for whatever checkinstall called your .deb file:</p>
<p>Extract the data from the .deb<br />
<code lang="bash"><br />
dpkg-deb -x emacs_cvs-10202007-1_i386.deb emacs_cvs-10202007-1_i386                #Or whatever your .deb is called<br />
</code><br />
Extract the control information from the .deb<br />
<code lang="bash"><br />
dpkg-deb -e emacs_cvs-10202007-1_i386.deb emacs_cvs-10202007-1_i386/DEBIAN<br />
</code><br />
Now we need to add some of the files that checkinstall left out of the package<br />
<code lang="bash"><br />
cp -a lisp/* emacs_cvs-10202007-1_i386/usr/local/share/emacs/23.0.50/site-lisp/<br />
mkdir emacs_cvs-10202007-1_i386/usr/local/share/emacs/23.0.50/lisp<br />
mkdir -p emacs_cvs-10202007-1_i386/usr/local/libexec/emacs/23.0.50/i686-pc-linux-gnu<br />
cp -a etc emacs_cvs-10202007-1_i386/usr/local/share/emacs/23.0.50/<br />
mkdir emacs_cvs-10202007-1_i386/etc<br />
ln -s ../usr/local/share/emacs/23.0.50/etc/termcap.src emacs_cvs-10202007-1_i386/etc/termcap<br />
</code><br />
Rebuild the modified package<br />
<code lang="bash"><br />
dpkg-deb -b emacs_cvs-10202007-1_i386 emacs_modified.deb<br />
</code></p>
<p>To totally revolutionize the way you use Emacs, remember to check out <a href="http://www.enigmacurry.com/2007/05/24/multi-tty-emacs-on-gentoo-and-ubuntu/">my earlier post on Multi-TTY Emacs</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.enigmacurry.com/2007/10/21/building-multi-tty-emacs-from-cvs-on-ubuntu-gusty-gibbon/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Multi-TTY Emacs on Gentoo and Ubuntu</title>
		<link>http://www.enigmacurry.com/2007/05/24/multi-tty-emacs-on-gentoo-and-ubuntu/</link>
		<comments>http://www.enigmacurry.com/2007/05/24/multi-tty-emacs-on-gentoo-and-ubuntu/#comments</comments>
		<pubDate>Thu, 24 May 2007 20:59:36 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<category><![CDATA[Emacs]]></category>

		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.enigmacurry.com/2007/05/24/multi-tty-emacs-on-gentoo-and-ubuntu/</guid>
		<description><![CDATA[(Historical note Sep 2008: The &#039;ec&#039; script below is no longer (or shortly will not be) required, as there is now a patch that enables emacs as a frameless daemon)
(Historical note May 2008: This post is now over a year old. Multi-TTY Emacs is now part of the main Emacs CVS tree. Most of this [...]]]></description>
			<content:encoded><![CDATA[<p><em>(Historical note Sep 2008: The &#039;ec&#039; script below is no longer (or shortly will not be) required, as there is now a patch that enables emacs as a <a href="http://permalink.gmane.org/gmane.emacs.devel/103368">frameless daemon</a>)</em></p>
<p><em>(Historical note May 2008: This post is now over a year old. Multi-TTY Emacs is now part of the main Emacs CVS tree. Most of this post is still applicable, but the build instructions are very much out of date and for the most part are unnecessary as the multi-tty patch has now made it into most distros. It should just be an &#039;apt-get install emacs-snapshot&#039; away)</em></p>
<p><a href="http://lorentey.hu/project/emacs.html">Multi-TTY</a> Emacs is one of the most useful peices of software I&#039;ve seen in a long time. Emacsclient, the underlying interface for multi-tty, has been around for a while. It allows someone to connect to a long running Emacs session and it avoids the long startup time Emacs usually has. However, it only works in a graphical environment. Multi-TTY Emacs allows us to do the same from either a graphical environment or from a simple terminal (tty).</p>
<p>Here&#039;s a typical use case: I&#039;m at home and I&#039;m using Emacs from within X-windows. I&#039;m using the wonderful IRC client, <a href="http://savannah.gnu.org/projects/erc/">ERC</a>, and asking a question in #python, #emacs, #gentoo etc. but no one seems to be paying any attention and no one is answering my question right away. Oh well, it&#039;s time for me to head off to class or work. I leave Emacs running at home but since I forgot to enable chat logs, it&#039;s rather difficult for me to connect remotely and find out if anyone has responded to my question. With Multi-TTY, I can ssh into my home computer and bring up Emacs in a text console and check my ERC buffer even though I originally started Emacs graphically from X-Windows. Neat.</p>
<p><center><img id="image99" src="http://www.enigmacurry.com/wp-content/uploads/2007/05/emacs-multi-tty.png" alt="Emacs Multi-TTY" /><br/>You can also see <a href="http://www.enigmacurry.com/2007/10/21/building-multi-tty-emacs-from-cvs-on-ubuntu-gusty-gibbon/">a video of it in action</a></center></p>
<p>Multi-TTY is contained in the CVS version (23) of Emacs. Version 23 is still a (tiny) bit rough around the edges, so don&#039;t blame me if while using it it deletes all your files and destroys your life in general. It won&#039;t, but caveat emptor. I am now running multi-tty on Gentoo and Ubuntu Feisty Fawn. Here&#039;s how:</p>
<h3>Gentoo</h3>
<p>On my laptop I run Gentoo Linux. Getting the latest version of Emacs on Gentoo was a breeze! :</p>
<ul>
<li>Setup <a href="http://gentoo-wiki.com/TIP_Overlays#Layman">Layman</a></li>
<li>Add the emacs overlay: <strong><tt>sudo layman -a emacs</tt></strong></li>
<li>Add the following USE flags for app-editors/emacs-cvs:<br />
<tt>sudo flagedit app-editors/emacs-cvs X Xaw3d alsa gif gzip-el jpeg lesstif png sound spell tiff toolkit-scroll-bars xpm -gtk -hesiod -motif -source</tt>.</p>
<li>GTK support is explicitly turned off as it causes problems with multi-TTY. This is no biggie for me as I always have <strong><tt>(menu-bar-mode -1)</tt></strong> and <strong><tt>(tool-bar-mode -1)</tt></strong> set.</li>
</li>
<li>Emerge: <strong><tt>sudo emerge emacs-cvs -va</tt></strong></li>
<li>Tell the system to use the new emacs: <strong><tt>sudo eselect emacs set emacs-23-multi-tty</tt></strong></li>
</ul>
<h3>Ubuntu</h3>
<p>Ubuntu was <em>much</em> more difficult to setup correctly because the repositories don&#039;t have the CVS version yet (emacs-snapshot is 22). So, I&#039;ve compiled it from source myself and once I clean up my instructions I will publish a HOWTO as well as my .deb package.</p>
<p><b>Update: See my new <a href="http://www.enigmacurry.com/2007/10/21/building-multi-tty-emacs-from-cvs-on-ubuntu-gusty-gibbon/">Ubuntu specific post</a> for build instructions</b></p>
<h3>Usage</h3>
<p>Connecting to an already running emacs session is quite easy:</p>
<ul>
<li>In the main emacs session run <strong><tt>M-x server-start</strong></tt></li>
<li>Now just run <strong><tt>emacsclient -c</tt></strong> and you should see a new window pop up that has all the exact same buffers. If you are on a non-graphical terminal you&#039;ll likewise get the same emacs session albeit in text mode.</li>
</ul>
<p>I found some <a href="http://emacslife.blogspot.com/2007/05/multi-tty-emacs.html">excellent tips from sness.net</a> for making this even easier. Here are my variations on his methods:</p>
<p>Make a new file somewhere in your path called <strong><tt>preload_emacs</tt></strong>:<br />
<code lang="bash">#!/bin/bash<br />
# Usage: preload-emacs <name> [<waitp>]<br />
#<br />
# Preloads the Emacs instance called NAME in a detached screen<br />
# session.  Does nothing if the instance is already running.  If WAITP<br />
# is non-empty, the function waits until the server starts up and<br />
# creates its socket; otherwise it returns immediately.<br />
# Visit http://www.enigmacurry.com<br />
# based on http://emacslife.blogspot.com/2007/05/multi-tty-emacs.html</p>
<p>name=&#034;$1&#034;<br />
waitp=&#034;$2&#034;<br />
screendir=&#034;/var/run/screen/S-$USER&#034;<br />
serverdir=&#034;/tmp/emacs$UID&#034;<br />
emacs=/usr/bin/emacs</p>
<p>if [ -z "$name" ]; then<br />
    echo &#034;Usage: preload_emacs <name> [<waitp>]&#034;<br />
    exit 1<br />
fi</p>
<p>if [ ! -e "$screendir"/*."$name" ]; then<br />
    if [ -e "$serverdir/$name" ]; then<br />
    # Delete leftover socket (for the wait option)<br />
    rm &#034;$serverdir/$name&#034;<br />
    fi<br />
    screen -dmS &#034;emacs-$name&#034; &#034;$emacs&#034; -nw &#8211;eval &#034;(setq server-name \&#034;$name\&#034;)&#034; -f server-start<br />
fi<br />
if [ ! -z "$waitp" ]; then<br />
    while [ ! -e "$serverdir/$name" ]; do sleep 0.1; done<br />
fi<br />
</code></p>
<p>Running <strong><tt>preload_emacs -s ryan</tt></strong> will now create an emacs server named &#039;ryan&#039;. It loaded emacs in a screen session so that it will be able to be a long running process (Emacs apparently cannot run without an interface, hence we run it in a screen session to hide it away out of sight.)</p>
<p>To connect, we run <strong><tt>emacsclient -c -s ryan</strong></tt>. Typing plain old <strong><tt>emacs </strong></tt>here will load an entirely new Emacs session, which isn&#039;t really what we want. To make it a bit easier I created a shell script called &#034;ec&#034; that will load an emacsclient with these settings automatically:</p>
<p><code lang="bash"><br />
#!/bin/bash -l<br />
SERVERNAME=ryan<br />
#Attempt to connect to an existing server<br />
emacsclient -c -s $SERVERNAME $*<br />
if [ $? -ne 0 ]<br />
 then<br />
 #Start a new emacs server and connect<br />
 preload_emacs $SERVERNAME 0<br />
 emacsclient -c -s $SERVERNAME $*<br />
fi<br />
</code><br />
Now when I type <strong><tt>ec</strong></tt> it will automatically attempt to connect to an already running emacs server named ryan. If it is not running, it will transparently create the server and then connect to it. </p>
<p>If you make &#034;ec&#034; your system&#039;s default editor, you&#039;ll now be able to use a lightning quick version of emacs for all your editing needs!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.enigmacurry.com/2007/05/24/multi-tty-emacs-on-gentoo-and-ubuntu/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs movement keys</title>
		<link>http://www.enigmacurry.com/2005/05/13/emacs-movement-keys/</link>
		<comments>http://www.enigmacurry.com/2005/05/13/emacs-movement-keys/#comments</comments>
		<pubDate>Fri, 13 May 2005 07:45:17 +0000</pubDate>
		<dc:creator>ryan</dc:creator>
		
		<category><![CDATA[Emacs]]></category>

		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.enigmacurry.com/?p=5</guid>
		<description><![CDATA[
whoa. I just realized something cool in Emacs&#8230; hold down control and use the arrow keys and you can move around by words and paragraphs.
&#8230; I guess I should have RTFM years ago huh? &#8230; I&#039;m such a dolt.

Ryan

]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.enigmacurry.com/blog-post-images/emacs_movement_keys.png" alt="Emacs" align=right width=150 /><br />
<br />whoa. I just realized something cool in Emacs&#8230; hold down control and use the arrow keys and you can move around by words and paragraphs.</p>
<p>&#8230; I guess I should have RTFM years ago huh? &#8230; I&#039;m such a dolt.</p>
<ul>
<li>Ryan</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.enigmacurry.com/2005/05/13/emacs-movement-keys/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
