I've just started using spacemacs and the docstrings for cc-styles are a bit daunting. I've also just started working on a new project in c, and would like to keep consistent with existing style:

struct map_s
  uint8_t     (*key_hash   )(const void* key);
  bool        (*key_match  )(const void* a, const void* b);
  const void* (*item_key   )(const void* item);
  void        (*item_delete)(void* item);

  map_node_t* base[256];

My question is, is this a style already implemented as one of the c-default-style options? If not, can anyone give me pointers on specifically how to get the cc-styles package to add the padding in the function pointer names so that the opening and closing brace are aligned for each member line?

  • I don’t believe this behavior is part of cc-mode at all. Automatic formatting usually concerns braces and functions. You will probably have to align these yourself after writing them; after all, how would the mode know how many spaces to add before the next lines existed? See M-x align. – InHarmsWay Apr 30 '18 at 10:42
  • i was wondering if someone had already implemented something along these lines; akin to the way tables work in org-mode. I will look into align as you suggest. – Aidenhjj Apr 30 '18 at 11:15
  • It seems that this feature has been missing for a while: stackoverflow.com/questions/7032982/… – Felipe Lema Apr 30 '18 at 12:45
  • looks like align might do what i want. i will post my solution here if i can get it to work. – Aidenhjj Apr 30 '18 at 12:47
  • maybe something like this stackoverflow.com/a/24472616/3795491 – Aidenhjj Apr 30 '18 at 13:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.