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.
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.
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.
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.
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")
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.