4 In the C coding style commonly used in GNOME, identifiers are written
5 in camel case and function arguments are aligned to the right end.
6 That makes it a bit cumbersome to keep your code consistent with the
7 style, even with align.el or plugins like yasnippet.
9 gobject-minor-mode is an Emacs minor mode intended to help editing C
10 source code in that style. It mainly provides two features: text
11 alignment and snippet insersion.
17 * Copy .elc files somewhere in your load-path
18 * Add the following lines to ~/.emacs/init.el:
21 (autoload 'gobject-minor-mode "gobject-minor-mode" "GObject minor mode" t)
22 (add-hook 'c-mode-hook 'gobject-minor-mode)
29 --------------|---------------------------------------------------|
30 | C-c C-g g | Guess alignment columns from the current region |
31 | C-c C-g s | Set alignment column to point |
32 | C-c C-g a | Align argument list at point |
33 | C-c C-g r | Align function declarations in the current region |
34 | C-c C-g c | Insert ```module_object``` |
35 | C-c C-g C | Insert ```MODULE_OBJECT``` |
36 | C-c C-g C-c | Insert ```ModuleObject``` |
37 | C-c C-g s | Insert custom snippet |
42 If you have the following code in a header file:
44 GGpgCtx *g_gpg_ctx_new (GError **error);
46 typedef void (*GGpgProgressCallback) (gpointer user_data,
52 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
53 GGpgProgressCallback callback,
55 GDestroyNotify destroy_data);
56 void g_gpg_ctx_add_signer (GGpgCtx *ctx, GGpgKey *key);
57 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
58 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx, guint index);
59 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
62 Mark the region, type ```C-c C-g g```, and you will see the optimum
66 identifier-start: 9, arglist-start: 41, arglist-identifier-start: 63
69 Then, mark the region again, type ```C-c C-g r```, and you will get
73 GGpgCtx *g_gpg_ctx_new (GError **error);
75 typedef void (*GGpgProgressCallback) (gpointer user_data,
81 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
82 GGpgProgressCallback callback,
84 GDestroyNotify destroy_data);
85 void g_gpg_ctx_add_signer (GGpgCtx *ctx,
87 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
88 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
90 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
93 Note that ```typedef``` is skipped as it is not a function declaration.