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 gnome-c-style 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 'gnome-c-style-mode "gnome-c-style" "GNOME-style C minor mode" t)
22 (add-hook 'c-mode-hook 'gnome-c-style-mode)
29 --------------|-----------------------------------------------------------|
30 | C-c C-g a | Align argument list at the current point |
31 | C-c C-g r | Align function declarations in the current region |
32 | C-c C-g C-g | Compute optimal alignment columns from the current region |
33 | C-c C-g g | Guess alignment columns from the current region |
34 | C-c C-g s | Set alignment column to the current point |
35 | C-c C-g c | Insert ```module_object``` |
36 | C-c C-g C | Insert ```MODULE_OBJECT``` |
37 | C-c C-g C-c | Insert ```ModuleObject``` |
38 | C-c C-g s | Insert custom snippet |
43 If you have the following code in a header file:
45 GGpgCtx *g_gpg_ctx_new (GError **error);
47 typedef void (*GGpgProgressCallback) (gpointer user_data,
53 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
54 GGpgProgressCallback callback,
56 GDestroyNotify destroy_data);
57 void g_gpg_ctx_add_signer (GGpgCtx *ctx, GGpgKey *key);
58 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
59 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx, guint index);
60 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
63 Mark the region, type ```C-c C-g C-g```, and you will see the optimum
67 identifier-start: 9, arglist-start: 41, arglist-identifier-start: 63
70 Then, mark the region again, type ```C-c C-g r```, and you will get
74 GGpgCtx *g_gpg_ctx_new (GError **error);
76 typedef void (*GGpgProgressCallback) (gpointer user_data,
82 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
83 GGpgProgressCallback callback,
85 GDestroyNotify destroy_data);
86 void g_gpg_ctx_add_signer (GGpgCtx *ctx,
88 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
89 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
91 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
94 Note that ```typedef``` is skipped as it is not a function declaration.