Emacs package to generate GObject boilerplate

Gergely Polonkai
Sep 28, 2016 :: 17:40

Before I started using Vala (and sometimes even after that) I often needed to generate new classes based on GObject.

If you have ever worked with GObject in C, you know how tedious it can be. You need a pretty long boilerplate just to register your class, and, if you want to be introspectable (and readable, actually), your function names can grow really long.

To overcome this problem back in my ViM days, I used template files, where I could replace class prefixes and names with a few keyboard macros. As I never really dug into ViM scripting other than using some plugins, I never got farther than that. Then came Emacs.

I use Emacs for about two years now very extensively, up to and including GLib-based development. I tried the template approach, but it felt to be a really poor experience, especially given that I made my feet wet with Emacs Lisp. So I dug deeper, and created a package for that.

A screenshot of GobGen in action

GobGen has its own buffer with some widgets, a bit similar to customize. You can enter the name of your new object and its parent, specify some settings. Then you press Generate, and you are presented with two new buffers, one for the .c and another for the .h boilerplate.

There are a lot of things to do, actually. There is already an open issue for creating a major mode for this buffer, and there are some minor switches I’d like to add, but it is already usable. You can grab it from MELPA (my first package there; woo!) or from my GitHub account.

comments powered by Disqus

Gergely Polonkai is a systems engineer of a telco company, and also a freelancer self- and software developer.

He is learning about different IT subjects since the late 1990s. These include web development, application building, systems engineering, IT security and many others. He also dug his nose deeply into free software, dealing with different types of Linux and its applications, while also writing and contributing to some open source projects.

On this site he is writing posts about different stuff he faces during work (oh my, yet another IT solutions blog), hoping they can help others with their job, or just to get along with their brand new netbook that shipped with Linux.

“I believe one can only achieve success if they follow their own instincts and listen to, but not bend under others’ opinions. If you change your course just because someone says so, you are following their instincts, not yours.”