I am a saint in the church of emacs!

There’s always a war between the most powerful editors – emacs v/s vi. This rivalry has become a lasting part of hacker culture and the free software community. I was a happy user of vi, until I discovered the power of emacs. And now, trust me, I just love using emacs, its one of my passion. I believe, I can spend entire day with just emacs opened and without switching to any other window. This sweet editor has support for gdb, autocomplete, cscope, compilation, emails and even browser. What more could one wish for? In this post, I will talk about some tips to add wings to emacs and make it fly freely.

When you have a project with thousands of million lines of code, like linux kernel source or webkit source, it necessitates to have some source code navigation tools. Mostly obvious choice is cscope. How about integrating cscope with emacs? Well, you have xcscope!

Installation of xcscope is very simple,
a). Download xcscope. Make sure that, this file is saved in some path searchable by emacs.
b). Make sure cscope-indexer is installed.
c). Edit your emacs and this line
    (require 'xcscope)
d). Optionally, have key bindings for some of the common cscope commands,
    (define-key global-map [(ctrl f3)] 'cscope-set-initial-directory)
    (define-key global-map [(ctrl f4)] 'cscope-unset-initial-directory)
    (define-key global-map [(ctrl f5)] 'cscope-find-this-symbol)
    (define-key global-map [(ctrl f6)] 'cscope-find-global-definition-no-prompting)
    (define-key global-map [(ctrl f7)] 'cscope-find-egrep-pattern)
    (define-key global-map [(ctrl f8)] 'cscope-find-this-file)
    (define-key global-map [(ctrl f9)] 'cscope-next-symbol)
    (define-key global-map [(ctrl f10)] 'cscope-next-file)
    (define-key global-map [(ctrl f11)] 'cscope-prev-symbol)
    (define-key global-map [(ctrl f12)] 'cscope-prev-file)
    (define-key global-map [(meta f9)] 'cscope-display-buffer)
    (define-key global-map [(meta f10)] 'cscope-display-buffer-toggle)

Hmmm. My emacs looked better with cscope, but, we, the engineers are lazy typing lots of code. That when I found Emacs Auto Complete. This pretty lisp package has a very neat way of displaying drop-down with list of possible auto completion. Worth having it in your emacs.

Whats more? Want to integrate Git inside emacs? Check GIT emacs. Though I am not really impressed with the features of this packages, it does serve the purpose.

M-x compile allows you to invoke the compilation from within emacs. One issue which I had with compilation buffer is, some characters from compilation output were not getting displayed, instead their ascii codes used to get displayed. It turns out that, we need to tell emacs that compilation output is in UTF-8, so that it can interpret them correctly. To do so, have this line in you .emacs file.
(prefer-coding-system 'utf-8)

Other annoying part of compilation buffer is, its not used to get scrolled as compilation goes. To automatically scroll the compilation buffer and stop scrolling when an error occurs, add these line in .emacs.
'(compilation-scroll-output first-error))

Cool. My emacs looks a lot prettier now, but, there is something that made it to look sad! Yes, the fonts. I really hated the default font of emacs!. I always wished to have ‘monospace’ font to which vim defaults to. Well, you got to do following steps to have monospace font.

echo "Emacs.font: Monospace-10" >> ~/.Xresources
xrdb -merge ~/.Xresources

Now my emacs is the most sexiest editor and I am one of the happy saints in the church of emacs!

Post a comment or leave a trackback: Trackback URL.


  • vamshi  On June 7, 2010 at 4:07 pm

    Create a new course in Moto…

    We need Video Tutorial….

  • vamshi  On June 8, 2010 at 10:09 am

    write some articles which are user frdly also..

  • Sid  On August 6, 2010 at 12:17 pm

    “I was a happy user of vi, until I discovered the power of emacs. And now, trust me, I just love using emacs” …………….

    I am sorry dude ………… I dint want to comment on such a nice entry …. but that was only until i read the above lines which makes me remember …. How ******* “Pathetic” vi user you are … or you will ever be …. and FYI vi is now vim …. and i leave this note on the last lines … agreeing that emacs is also one of the good editors !

    • nayankk  On August 6, 2010 at 1:12 pm

      Sid, I never said vim is bad, I just said emacs is more powerful than vim. Real programmers use emacs. !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: