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). 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 [function declarations in header files](https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#functions).
9 * M-x package-install gnome-c-style
10 * Add the following lines to ~/.emacs/init.el:
13 (add-hook 'c-mode-hook 'gnome-c-style-mode)
20 --------------|-----------------------------------------------------------|
21 | C-c C-g a | Align argument list at the current point |
22 | C-c C-g r | Align function declarations in the current region |
23 | C-c C-g C-g | Compute optimal alignment columns from the current region |
24 | C-c C-g g | Guess alignment columns from the current region |
25 | C-c C-g s | Set alignment column to the current point |
26 | C-c C-g c | Insert ```module_object``` |
27 | C-c C-g C | Insert ```MODULE_OBJECT``` |
28 | C-c C-g C-c | Insert ```ModuleObject``` |
29 | C-c C-g s | Insert custom snippet |
34 If you have the following code in a header file:
36 GGpgCtx *g_gpg_ctx_new (GError **error);
38 typedef void (*GGpgProgressCallback) (gpointer user_data,
44 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
45 GGpgProgressCallback callback,
47 GDestroyNotify destroy_data);
48 void g_gpg_ctx_add_signer (GGpgCtx *ctx, GGpgKey *key);
49 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
50 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx, guint index);
51 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
54 Mark the region, type ```C-c C-g C-g```, and you will see the optimum
58 identifier-start: 9, arglist-start: 41, arglist-identifier-start: 63
61 Then, mark the region again, type ```C-c C-g r```, and you will get
65 GGpgCtx *g_gpg_ctx_new (GError **error);
67 typedef void (*GGpgProgressCallback) (gpointer user_data,
73 void g_gpg_ctx_set_progress_callback (GGpgCtx *ctx,
74 GGpgProgressCallback callback,
76 GDestroyNotify destroy_data);
77 void g_gpg_ctx_add_signer (GGpgCtx *ctx,
79 guint g_gpg_ctx_get_n_signers (GGpgCtx *ctx);
80 GGpgKey *g_gpg_ctx_get_signer (GGpgCtx *ctx,
82 void g_gpg_ctx_clear_signers (GGpgCtx *ctx);
85 Note that ```typedef``` is skipped as it is not a function declaration.