Tuesday, May 15, 2007

...more tools...

Tools, tools and more tools...I've been hacking around Finch code all morning trying to understand key bindings. It's slow going, but I'm getting there. Though I haven't learned much to talk about in regards to Finch and its library libgnt, I have learned a lot of useful things that I will continue to use and encourage others to use.

GLib is a powerful library that I wish I had learned a long time ago. For documentation on the functions it has available check this site out. For years I've been writing code and using functions like the ones available here, but I always wrote my own. What a relief to find a library that has all this in it.

My favorite so far is the logging features it has. By calling g_log(), g_print(), or a few others that have different logging levels, it can log all sorts of stuff for you. The cool part is that you can define a method to handle the printing. If you call g_log with different logging levels it will alter where it prints, either to stdout or stderr.

It has many string utility functions. Many are in string.h, but a bunch aren't and I've had to write a few of them in the past. It's nice to have them all here.

It's very easy to use. All you have to do is include glib.h and when you compile you pass it pkg-config. So, "gcc `pkg-config --cflags --libs glib2.0` test.c test" and it works.

So this has been very useful, for future use and because Pidgin is filled with glib use.

Another useful thing I've learned is the use of ctags. Now I've used ctags a few times before. But with the help of my mentor and a few docs I stepped it up a bit. For those of who aren't too familiar with ctags here's a short run through getting things setup.

  1. Run "ctags -R" at the top of your source tree
  2. Open my favorite text editor, Vim, at the root of your source

That's it for getting setup. Now you have the capability to bounce from function call to function with a simple keystroke. Put your cursor over a function call and type CTRL-]. It will take you to the definition of the function. You can do this with variable and custom data types also. Vim stores the jumps you've made in a stack. To pop the last jump off the stack and return to where you were looking type CTRL-t. And voila, you've come back. This has made browsing code , and following it more importantly, a breeze.

The last thing I'd like to mention today is syntax highlighting. I've heard some complain about editors that apply syntax highlighting and say that it makes it more confusing for them to read and understand the code. Well, more power to them for not using this feature. I like it, I find it useful for reading code and I shall continue to love using it. But what I found today was a site that has a list of custom color schemes for a few languages. I'll focus on the link to the C schemes. I looked at a bunch of them, I found that I like the asmanian2 theme. Though, I don't like how it bolds a lot of things. So I'm still working on getting the bold out. :help colorscheme and :help hightlight-args has been a good help in modifying the theme.


Unknown said...

I'm out to see if I can use ctags with python. That would be just wonderful!!! Try traversing code that you don't with only grep and lots of "screens"...

Anonymous said...

as i try to disable the buddy info if you select a contact in finch i naturally have to build finch from src. but when i do a configure and then make && make install it builds only pidgin but not finch. am i blind or do i have to enable finch in some way?

hope you can give me a hint, thanks