New Phone

I finally got a new phone. My old iphone, with it's terrible speaker, will finally be put to rest. I wanted to try something new so I got an android phone. More specifically I got a motorola atrix.

So far it has been pretty nice. I'm excited to finally join the ranks of other smart phone users that can do things like send photos and use GPS.

My one complaint is that with android being an open platform, the carriers and handset makers have a lot of leeway to require information. For example, I've already had to agree to an insane amount of "terms and conditions." At this point though, it is a small price to pay to have a phone that works.

Sending Email with Wanderlust

At work we have a bunch of email addresses that get sent to a large set of users. Since I started, I've always gotten my mail forwarded to my personal email account, which works really well except for these mailing lists that complain that the mail being sent is not coming from the real email address. Seeing as I use Wanderlust and Emacs for my email, I knew there had to be a way to configure things to use my work smtp server for work emails and gmail for the rest. The key was looking at the the 'wl-draft-config-alist' setting. This is a simple list of key/values that get applied when a header or part of the body get matched. In my case, I wanted to match on the From field and send it via the correct smtp server.

Along side the 'wl-draft-config-alist' is the 'wl-templates-alist', which helps to setup a draft with appropriate headers. I should mention that I tried a ton of different settings to get this to work. I'm sure I could have put all this in my .wl file and that would have been enough, but alas that wasn't the case.

The first step is to go ahead and make a couple templates for writing mail. I created a default and an work template that maily just set the 'From' header to the appropriate value. After that I added some code to my 'wl-draft-config-alist' for each account. The the templates I added via customize in Emacs, while the 'wl-draft-config-alist' I was able to add to my .wl file. The latter seemed to fail when adding variables that needed to be changed. Here is an example of what I added:

 
(setq wl-draft-config-alist 
 '( 
 ("^From: .*eric@work.com" 
 (wl-smtp-authenticate-type . "login") 
 (wl-smtp-posting-user . "eric") 
 (wl-smtp-posting-server . "webmail.work.com") 
 (wl-local-domain . "work.com") 
 (wl-from . "Eric Larson ") 
 (wl-reply-to . "Eric Larson ") 
 ) 
 
 ("^From: .*eric@personal.org" 
 (wl-smtp-authenticate-type . "plain") 
 (wl-smtp-posting-user . "eric@personal.org") 
 (wl-smtp-posting-server . "smtp.gmail.com") 
 (wl-local-domain . "gmail.com") 
 (wl-from . "Eric Larson ") 
 (wl-reply-to . "Eric Larson ") 
 ) 
 )) 

Then, when writing email, I hit C-c C-j and select the work template. When I send the mail it uses the correct server and handles any authentication correctly.

Some Emacs Tips

Recently I've been making an effort to automate mundane tasks within Emacs. It makes it easy to include things in my development environment and generally helps keep more things conveniently accessible. Here are some tips that have helped me get more out of Emacs.

Using the Shell

I'm a big fan of shell-mode because it lets you use a shell within an Emacs buffer. This makes things like copying and pasting much more intuitive. It also makes little things like using less and more pointless because you can use the same keybindings you would in a file. One thing that takes a little getting used to is where bash keybindings collide with Emacs. For example, in bash C-p will get the last command you entered but in shell-mode that will move the cursor up. Generally, in shell-mode you can just use the meta modifier instead and get the bash behavior. I've found this to be very natural and find myself wishing I had the same bindings in real shells.

Shell-mode is also nice for running servers. If you develop Rails or Python web apps you usually have a set of command line script you run for things like tests or web servers. Running these in shell mode makes it nice to have an IDE like experience where you can consistently see the running process within your editor. Likewise, you get to review and move around in the output like you would a normal file. This can be really helpful if you made a change that caused a ton of tests to fail and the output is rather overwhelming.

Command Line Applications

As most Emacs users probably do not program in Lisp professionally it is good to consider ways you can use your programming language of choice within Emacs. The shell-command-on-region function is one such tool that helps to make integrating your scripts simple and easy. The function lets you select a region in a buffer and send that as stdin to some application. Just to give you an idea of what you can do, I wrote a small Python script for accepting stdin and pasting it to a company pastebin. I then wrote a simple wrapper function for automatically calling the shell-command-on-region and immediately found an exceptionally helpful tool. Here is the code:


 
(defun qpaste ( ) 
  "Pastes the selected area to the work pastebin." 
  (interactive) 
  (let (string) 
    (unless (mark) 
      (error "There is nothing selected.")) 
    (shell-command-on-region (point) (mark) "qpaste -u elarson"))) 

I can't even describe how helpful this has been pasting tracebacks and diffs that I've gotten via my shell in shell-mode.

Automating Server Starting

One thing IDEs can do well is create an environment where you can start up a set of services to establish a development environment. There are around 5 or 6 different services I need running for development. This ranges from MongoDB to web servers and supporting applications. For these sorts of things there is comint-mode, which is the mode that shell-mode is based on. Here is an example starting a web sever, mongodb and a supporting search service:


 
(defun foo-mongo ( ) 
   (interactive) 
   (setq cmd "mongod --dbpath=/home/eric/Work/foo/db") 
   (comint-simple-send (make-comint "foo-mongo" "bash") cmd)) 
 
(defun foo-web-server ( ) 
   (interactive) 
   (setq cmd "cd ~/Work/foo/web/ && workon foo && paver run_web") 
   (comint-simple-send (make-comint "foo-web-server" "bash") cmd)) 
 
(defun foo-search-server ( ) 
   (interactive) 
   (setq cmd "cd ~/Work/foo/web/ && workon foo && paver run_search") 
   (comint-simple-send (make-comint "foo-search-server" "bash") cmd)) 
 
(defun foo-start-all ( ) 
   (interactive) 
   (foo-mongo) 
   (foo-search-server) 
   (foo-web-server)) 

This lets you run M-x foo-start-all and get your entire stack running in a shell-mode like buffer each named according to what is running. You can use this basic pattern to do things like run tests as well and even send the result to your own script using the shell-command-on-region to do things with the output. The possibilities are endless, but more importantly, you can make Emacs more helpful through automating mundane tasks really easily.

Organize Your .emacs

This is a really basic aspect, but being able to load your own functions like the ones mentioned above means you might write a lot of them. You might even have some hooks that create them whenever you start a new project. With that in mind it is helpful then to break up your .emacs file into manageable bits. One thing that makes reading through your .emacs easier is getting rid of the customize settings. This is as easy as:

(setq custom-file "~/.emacs-custom.el")
(load custom-file)

This will save all your customization settings in a .emacs-custom.el file. In my case, I had a pretty extensive color customization for font-faces, so avoiding having to see that every time I visited my .emacs was a big win.

As you start writing your own functionality, you can create your own files for those functions as well. This is also really easy to do. Here is an example:



;; foo-app-functions.el
(defun foo-tests ( )
  (interactive) 
  (setq cmd "cd ~/Work/foo/web/ && workon foo && paver tests") 
  (comint-simple-send (make-comint "foo-tests" "bash") cmd)) 
(provide 'foo-app-functions) 

;; in your .emacs 
(require 'foo-app-functions) 

That is it! It's really simple and lets you easily organize your .emacs. Along the same lines, I have a site-lisp directory that I keep all my extra modes and custom files. Just add it to the load path and require the necessary functionality.

 
(add-to-list 'load-path "~/site-lisp") 

Wrapping Up

That is pretty much it. As you can probably tell, I'm far from a guru. But even with these few small tips, I've found Emacs to be a much nicer place. I've managed to start using it for my email, IRC, shell and I even blog with it thanks to Posterous. Even if you don't use Emacs, I think it is clear that having the ability to use and customize a piece of software like this is critical to becoming a better developer. It helps you to take on the role of a user and acknowledge places where things can improve. It also forces you to consider what is going to be "good enough". Hopefully these tips help to get a little more value from your Emacs experience.

Weighing Decisions

Sometimes it can extremely difficult for me to make decisions. The idea that one choice could have an extremely long lasting consequences can be rather debilitating. Specifically, we've been looking at some recent record offers and it is really tough to make decisions. They all have their pluses and minuses, which makes it extremely difficult to decide the best course of action. I should mention that I'm extremely grateful to even have an option at all. I know we work pretty hard, but the music business is so subjective with talent being one of the major contributors to success, that I can't help but feel extremely lucky to have any options whatsoever.

No matter what stroke of luck we managed to catch, it still remains that if we make the wrong decisions now, it could effectively nullify any gains we have managed to make. This is an excruciating idea. Music is not like programming in that there is no concept of scaling. With music, you can try to become more prolific but very quickly quality suffers. If you create an application, that knowledge is usually directly applicable to some other application almost immediately. Whether that is a new web framework, programming language or library, you have new tools that can be extremely helpful in overcoming fields. If your album doesn't get enough attention, that is it. Those songs have been used and in some cases sold. There is no taking the lyrics and reusing them a few hundred times over or taking a riff and adding it to all the songs in the next record. Failure has a very deep permenance.

This makes decisions regarding your career very serious. If you choose incorrectly, you potentially lose time, creative output, money, control and the opportunity to succeed. At one point this gamble was very much worth it for bands because they could often get a big enough advance that if they were smart would help in setting up things to move on, even though a band might have failed. Now, labels d on't give you anything and yet still want to take everything. In some cases that might be OK. In the end fans drive everything, so if a label has a good route to helping you find fans, then it might be worth it. This might come in the form of paying for publicity (the bare minimum) to paying for things like videos, special projects and events. Having a backer in your corner can sometimes be worth giving up some "intellectual property" in order to get implementation support. Likewise, it can be just as beneficial to keep the ties as small as possible and hope that the label has the secret sauce to make the smaller mentions count enough that they reverberate through the industry and eventually land on the steps of fans. This is appealing because it is cheaper, which means who ever pays for it is not going to expect to gain control over large portions of the artist's career. The downside is you're rolling the dice in terms of the effectiveness of the resources. More money means you can cover all the bases, even if they may not be the most effecti ve. It is a classic breadth vs. depth problem.

The social media guru would most likely point out that you could do it all on your own using the power of the web. I consider it a given that bands try to utilize their abilities to create as large of an online presence as possible. With that in mind, you still can't dispute that with enough money you can do pretty much anything in terms of exposure. It doesn't necessarily always propagate to dedicated fans and it absolutely will require giving most freedoms as an artist, but nonetheless, it is important to realize that while the gatekeepers are changing and expanding, there is still quite a bit of the old system in place.

Getting back to making a decision, I hope it has become somewhat apparent that no matter what you do, you're effectively gambling. If you win and get fans, you might have sacrificed your ownership, in which case you don't get paid. If you win and get ownership, the number of fans might be limited t o the point you still don't paid. There is always the possibility tha t you simply choose incorrectly and you get nothing. The real kicker is that we're talking music. I enjoy hitting a jackpot on some video poker like anyone else, but betting my songs and a potential career as a musician makes it really tough to choose.

When it is all said and done, I do believe there is a right choice to be made. That choice will be the one that no matter the outcome, we'll feel we evaluated the pros and cons and developed our plan assuming the worst and the best. Even though the decision will be really hard, the up side is that it will just be the beginning of many more decisions exciting work.