Search code examples
emacsmodeline

setting inline-open in modeline in emacs


I have this in my .emacs:

(c-set-offset 'inline-open 0)

Is there a way to "unset" inline-open in a modeline so that for some files inline-open does cause an indentation?

Thanks.


Solution

  • You can accomplish this with file variables like you suspect. Either at the top, or at the bottom.

    To do this at the top, add:

    // -*- eval: (setq c-offsets-alist (assq-delete-all 'inline-open c-offsets-alist)) -*-
    

    at the top of your file.

    Alternatively, you can add it at the end of your file in a slightly different format.

    // Local Variables:
    // eval: (setq c-offsets-alist (assq-delete-all 'inline-open c-offsets-alist))
    // End:
    

    Note: Emacs will ask you the first time you open a file with this kind of trickery, and if you answer !, Emacs will automatically add this code to the list of things that are considered "safe" in file local variables. It will set safe-local-variable-values in your .emacs.customization.el file.

    Note 2: The snippets of code are using C++ style comments, adjust appropriately if you need C comments, or some other comment scheme.