4 gnome-c-style is an Emacs minor mode for editing C source code in [GNOME C coding style](https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en).
5 In particular, it is useful to properly line-up [function arguments](https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#functions) and
6 [function declarations in header files](https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#header-files).
8 It also provides commands to insert basic snippets.
13 * M-x package-install gnome-c-style
14 * Add the following lines to ~/.emacs/init.el:
17 (add-hook 'c-mode-hook 'gnome-c-style-mode)
24 --------------|-----------------------------------------------------------|
25 | C-c C-g a | Align argument list at the current point |
26 | C-c C-g r | Align function declarations in the current region |
27 | C-c C-g C-g | Compute optimal alignment columns from the current region |
28 | C-c C-g g | Guess alignment columns from the current region |
29 | C-c C-g f | Set alignment column to the current point |
30 | C-c C-g c | Insert ```module_object``` |
31 | C-c C-g C | Insert ```MODULE_OBJECT``` |
32 | C-c C-g C-c | Insert ```ModuleObject``` |
33 | C-c C-g s | Insert custom snippet |
38 If you have the following code in a header file:
40 GGpgCtx *g_gpg_ctx_new (GError **error);
42 typedef void (*GGpgProgressCallback) (gpointer user_data,
48 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
49 GGpgProgressCallback callback,
51 GDestroyNotify destroy_data);
52 void g_gpg_ctx_add_signer (GGpgCtx *ctx, GGpgKey *key);
53 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
54 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx, guint index);
55 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
58 Mark the region, type ```C-c C-g C-g```, and you will see the optimum
62 identifier-start: 9, arglist-start: 41, arglist-identifier-start: 64
65 Then, mark the region again, type ```C-c C-g r```, and you will get
69 GGpgCtx *g_gpg_ctx_new (GError **error);
71 typedef void (*GGpgProgressCallback) (gpointer user_data,
77 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
78 GGpgProgressCallback callback,
80 GDestroyNotify destroy_data);
81 void g_gpg_ctx_add_signer (GGpgCtx *ctx,
83 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
84 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
86 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
89 Note that ```typedef``` is skipped as it is not a function declaration.