Faruk Akgul

The Sleeping Beauty: Emacs

October 11, 2010 | View Comments

I think everyone would agree on that there are only two text editors in the history of mankind: emacs and vim. I'm not going to say which one is better than the other.

I'm a programmer and I work with files everyday so just like every other developer I care about the editor I use and how it looks to increase my efficiency.

Configuring Emacs - Fullscreen Mode

I use emacs in fullscreen mode but unfortunately Cocoa Emacs 23 doesn't support fullscreen mode. However, I found out a Japanese guy (Daisuke Murase) has patched it and put it on github (ありがとう、 ダイスケ!)

Here are the instructions to build it;

git clone git://github.com/typester/emacs.git
cd emacs
./configure --with-ns
make bootstrap
make install
mv nextstep/Emacs.app /Applications

The next you should do is to bind a key for fullscreen mode in your .emacs file.

(global-set-key (kbd "BIND_A_KEY") 'ns-toggle-fullscreen)

Customizing The Emacs

If you don't want to see the welcome message every time you open emacs;

(setq inhibit-startup-message t)

To highlight the line which contain the cursor in every buffer;

(global-hl-line-mode 1)

I use indent space as 2 rather than 4;

(setq standard-indent 2)

Emacs uses both spaces and tabs to indent lines but I prefer only spaces.

(setq-default indent-tabs-mode nil)

To show line number and column number;

(line-number-mode 1)
(column-number-mode 1)

I don't want Emacs to backup the files.

(setq make-backup-files nil)

To swap the windows;

(defun swap-windows ()
  (cond ((/= (count-windows ) 2)
         (message "you need 2 windows"))
         (let* ((w1 (first (window-list)))
                (w2 (second (window-list)))
                (b1 (window-buffer w1))
                (b2 (window-buffer w2))
                (s1 (window-start w1))
                (s2 (window-start w2)))
           (set-window-buffer w1 b2)
           (set-window-buffer w2 b1)
           (set-window-start w1 s2)
           (set-window-start w2 s1))))
  (other-window 1))

(global-set-key (kbd "C-c s") 'swap-windows)

I look at Emacs window every single day for long hours so it must look pretty to my eyes. For that, I use molokai theme for emacs.

(load "~/.emacs.d/plugins/color-theme-molokai.el")

And you need to choose a decent monospaced font. Inconsolata, Consolas, Monaco, Menlo are good choices whereas Courier, Courier New are not. Menlo has become Mac OS X's default monospace font since Snow Leopard.

(set-default-font "Menlo-12")

I always prefer some transparency in my editor and console. Like, when I type pseudocode, say in Java, it's good to have transparency. 85% transparency level is enough for me.

(eval-when-compile (require 'cl))
 (defun toggle-transparency ()
   (if (/=
        (cadr (find 'alpha (frame-parameters nil) :key #'car))
       (set-frame-parameter nil 'alpha '(100 100))
     (set-frame-parameter nil 'alpha '(85 60))))
 (global-set-key (kbd "C-c t") 'toggle-transparency)

That's pretty much covers my .emacs file. I use YASnippet, SLIME, Org-Mode and some other plugins which I didn't cover in this post.


blog comments powered by Disqus