I've worked at two places where code is supposed to be indented/formatted according to gnu indent (ie there's a prescribed set of options to gnu indent that's to be used). Is there an easy way to set up emacs to do indentation the same way given the options?

For example, currently I work at a place that uses gst-indent, that is running indent -br -cbi0 -cli2 -bls -l80 -nut -ce -nlp -ci4 -hnl -ts8 -i2 -lps on the file gives the desired indentation style.

Of course the options aren't all about indentation, ideally I would like emacs to honor other aspects of the parameters as for example limiting line length etc.

  • One of the pre-fab c-default-style styles is "gnu". Is that what you're referring to? You can see help by doing C-h v c-default-style <ret>... – cyberbisson Jun 4 '19 at 19:47
  • @cyberbisson No, gnu indent is a program that reformats source code. I want emacs to do the same job given the arguments to gnu indent. – skyking Jun 10 '19 at 4:20
  • Oh I get it now, so you want to do like gst-indent-region with your settings, if such a beast exists... This is something clang-format does, so it certainly seems possible. – cyberbisson Jun 10 '19 at 13:05

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.