Time is scarce these days - and with no prospect of any extraordinary reduction in the number of tasks I need to work on my level of productivity. Here are some thoughts on getting more out of Emacs.
Productivity is many things, starting with the way we think, through the habits we end up adapting, to the tools we use. Many years of software development has made clear to me the effect of having a good IDE and I have thus defined 3 factors which greatly improve productivity and 3 factors which inhibit it.
The three factors which make you more productive:
Emacs Emacs Emacs
The three factors which slow you down:
Vim Vim Vim
A question which came up recently in #clojure was exactly that of editors, is Emacs the only way to go ? Answer: I'm not sure. Vim-Clojure is pretty powerful, but oddly enough it only works with Vim. For NetBeans we have Enclojure, which broke during installation of the latest version from Github, but I have previously had luck installing earlier versions. And finally there's talk of an IntelliJ plugin called LaClojure which looks very promising as well - If you're not approaching Clojure from an Emacs background, try out those 2 if Emacs is too big a mouthful.
Emacs has a great pull on developers using all languages and it's no different for the Clojurian. Emacs has editing capabilities which aid producitivty quite a bit, but its primary pull comes from its vast integration capabilities with other systems. Here are a few key components of my setup:
Normally there's not a lot to say about this - You have a number of themes to pick from, select one you like and thats it. Except for me its not. I use htmlize whenever I post code on this blog, meaning I mark a region in my blog, hit M-x blog and the code is converted to colored HTML which is then sent to my clipboard. That means when I change color-themes, the blog changes looks. Earlier today etate pasted a home-grown theme on #clojure which I immediately adopted:
(defun color-theme-dark-bliss () "" (interactive) (color-theme-install '(color-theme-dark-bliss ((foreground-color . "#eeeeee") (background-color . "#001122") (background-mode . dark) (cursor-color . "#ccffcc")) (bold ((t (:bold t)))) (bold-italic ((t (:italic t :bold t)))) (default ((t (nil)))) (font-lock-builtin-face ((t (:foreground "#f0f0aa")))) (font-lock-comment-face ((t (:italic t :foreground "#aaccaa")))) (font-lock-delimiter-face ((t (:foreground "#aaccaa")))) (font-lock-constant-face ((t (:bold t :foreground "#ffaa88")))) (font-lock-doc-string-face ((t (:foreground "#eeccaa")))) (font-lock-doc-face ((t (:foreground "#eeccaa")))) (font-lock-reference-face ((t (:foreground "#aa99cc")))) (font-lock-function-name-face ((t (:foreground "#ffbb66")))) (font-lock-keyword-face ((t (:foreground "#ccffaa")))) (font-lock-preprocessor-face ((t (:foreground "#aaffee")))) (font-lock-string-face ((t (:foreground "#bbbbff")))))))
Call that function from anywhere in your .emacs and you're set.
I've gone back and forth on this a lot, but today I've decided that having your IRC contacts directly in your buffers make sense, so I thought I'd share. To get started, grap ERC and add this to your .emacs:
(add-to-list 'load-path "~/.emacs.d/erc") (require 'erc)
That will load the basic functionality. Then to set up ERC to track your nickname(s) do something like this:
;; Only track my nick(s) (defadvice erc-track-find-face (around erc-track-find-face-promote-query activate) (if (erc-query-buffer-p) (setq ad-return-value (intern "erc-current-nick-face")) ad-do-it)) (setq erc-keywords '("Lau" "lau" "ljensen")) (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE" "324" "329" "332" "333" "353" "477"))
That will also keep ERC from annoying you with JOINS/PARTS. Then as a little something extra, I added OSD notifications for all you Ubuntu users:
;; Use libnotify (defun clean-message (s) (setq s (replace-regexp-in-string "'" "'" (replace-regexp-in-string "\"" """ (replace-regexp-in-string "&" "&" (replace-regexp-in-string "<" "<" (replace-regexp-in-string ">" ">" s))))))) (defun call-libnotify (matched-type nick msg) (let* ((cmsg (split-string (clean-message msg))) (nick (first (split-string nick "!"))) (msg (mapconcat 'identity (rest cmsg) " "))) (shell-command-to-string (format "notify-send -u critical '%s says:' '%s'" nick msg)))) (add-hook 'erc-text-matched-hook 'call-libnotify)
So now when somebody highlights you, you'll get something like this:

While chatting, people throw many links which don't exactly follow the http://www.dom.com syntax, so to agressively identify those links and make them clickable, add:
;; Be overly eager to identify URLs (setq erc-button-url-regexp "\\([-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]+\\.\\)+[-a-zA-Z0-9_=!?#$@~`%&*+\\/:;,]*[-a-zA-Z0-9\\/]")
I looted that from EmacsWiki and it seems to work, although I'd hate to debug it.
;; Enable logging (setq erc-log-channels-directory "~/.erc/logs/") (setq erc-save-buffer-on-part t) (defadvice save-buffers-kill-emacs (before save-logs (arg) activate) (save-some-buffers t (lambda () (when (eq major-mode 'erc-mode) t))))
That'll make sure you get everything logged correctly, so all we need to do now, is launch ship:
;; Launch (setq erc-autojoin-channels-alist '(("freenode.net" "#clojure"))) (erc-select :server "irc.freenode.net" :port 6667 :nick "yournick")
There we go! Now you have Rich Hickey and the gang right in your favorite IDE and you can copy/paste snippets directly from #clojure to your REPL - Hows that for productive? If you really want to get going with ERC, make sure you stop by the EmacsWiki entry, especially the logging can be improved I think.
If I had more time to blog about Emacs extensions, Org-Mode would be at the top of my list. Its a very powerful mode which lets to integrate task planning seamlessly with the rest of your business in Emacs, I recommend you check it out.
Regarding Raynes' quote, we were discussing meta-programming, namely macros in Ruby and seemed to be the case that Ruby macros are so far from Lisp macros, that claiming a connection is a stretch - any Rubyists who can elaborate on why Ruby is called a "Lisp chainsaw" ?