~:: kalyan ::~

January 23, 2009

emacs tweak

Filed under: emacs, open-source, Script — Tags: — skalyanasundaram @ 5:58 pm

In my old project there used to be many #if 0 .. #endif which does not fall in to the comment-face of the c-mode. This always confuses me. It would be good if that block is colored like a comment. So that i can just ignore that place.

I wrote the following elisp code which adds the #if 0 section to the comment section keywords of the c-mode.
'(("\s-*#\s-*if\s-*0\s-*n\(.*n\)*?\s-*#\s-*endif\s-*" 0 font-lock-comment-face append)))

I have left \s-* in many places as it is because even using back reference does not improve any readability.



  1. or u can use gvim and get all these out of the box 😉

    Comment by Sankar — January 25, 2009 @ 8:52 am

  2. Nice one !

    Comment by Johnny — January 26, 2009 @ 5:26 am

  3. Sankar: Oh really? vim supports this? what happens if the macro has to be processed first.

    For example I have,
    #define FALSE 0
    #if FALSE
    what will happen, would vim interpret all of this?

    And to answer your question, I am not interested to operate my fingers just because my slippers are slightly not fit. 😉
    or even,
    Just to get the cool air to my room, i would fix a AC, i wont remove my ceiling. 😉

    Comment by skalyanasundaram — January 27, 2009 @ 12:37 pm

RSS feed for comments on this post. TrackBack URI

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 )

Google+ photo

You are commenting using your Google+ 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

Create a free website or blog at WordPress.com.

%d bloggers like this: