Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Major mode for C, C++, Objective-C, Java, CORBA IDL, Pike, AWK. Included in GNU Emacs and XEmacs.

0
votes
1answer
24 views

Customizing indentation style for continuation lines?

I would like to customize the "k&r" indentation style, so that continuation lines are indented 8 spaces, like this: if (first && second) { // <- 8 spaces. third(); } -- ...
0
votes
0answers
15 views

How to preserve correct indentation with a macro in a C++ class declaration in cc-mode

The code base I work with uses macros in class declarations e.g. class DLLMACRO SomeClass { SomeClass(); // ... }; (These are for enabling/disabling Windows dll export macros.) This throws off ...
1
vote
0answers
19 views

Enable `cc-mode` documentation highlightning per minor mode

I am writing a minor mode for enabling support for JML within Java files. I realized the syntax highlighting with cc-mode's support for documentation comments. It works if I set c-doc-comment-style ...
3
votes
1answer
29 views

How to re-enable syntax highlighting of code that have been disabled by #if preprocessor statements

Code between #if SYMBOL and #endif is greyed out in cc-mode if the SYMBOL has not been defined within the current file. The project that I´m currently working on has a common code base for Mac and ...
0
votes
0answers
14 views

How to make brackets be indented on the same line as declatadin

//i want autoindentation be like this int main(void) { //main body if(true) { //if body } return(0); } how can I achive this in cc-mode? I found that there is something like hanging-braces, ...
0
votes
1answer
38 views

enlarge font of functions only in C code

I am trying to do exactly this for my C code, but once I edit latex, the setting is still active in uncomfortable places. I need to preserve the setting once I exit emacs and in all the buffers with C ...
2
votes
1answer
53 views

Indentation of multi-line arrays within braces?

Currently in C mode, contents of a muli-line arrays are aligned with the brace. eg: const unsigned int array[4] = { A, B, ...
1
vote
0answers
95 views

Is this a c-default-style? If not, how can i configure it?

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: ...
0
votes
1answer
62 views

Customized c-offsets-alist override c-file-style in dir-locals

Assuming I customized my default C indentation settings through M-x customize-variable c-offsets-alist: (custom-set-variables '(c-offsets-alist (quote ((statement-case-open . 0) (...
0
votes
2answers
202 views

prevent auto indent temporarily for multi line conditional, loops, etc

When I am writing in c-mode, I prefer to write multi-line control statements in the following way. if( cond1 && cond2 || cond3 ) { /* stuff */ } for( i = 0; i < N; ++i ) { ...
0
votes
1answer
26 views

Which value for topmost-intro-cont, to align variable names in c-mode?

In c-mode, how to align following code so, that the second variable name's starting character (A) is aligned below the first variable name's starting character (V)? static unsigned int V_name_1, ...
0
votes
0answers
34 views

How to indent c++ “special” source lines that don't end with semicolons

I'm working with a system that uses special macros a lot. For instance: class UDSSLib : public UFunctionLibrary { GENERATED_BODY() void foo(); int i; } The problem is the GENERATED_BODY() line....
0
votes
0answers
41 views

C++ incorrect template-args-cont detection

So I have been using emacs for a few weeks with cc-mode 5.33 now, and I ran into this annoying issue where I get incorrect indentation as a result of a presumably incorrect syntactic analysis. ...
0
votes
0answers
38 views

Indentation of ternary expressions in C/C++ mode

Currently, I'm using a slight modified version of google-c-style package to deal with the format of my C++ code. Everything just fine except the indentation of the ternary expressions. What I want is ...
0
votes
0answers
117 views

emacs hangs on c++-mode when writting the character '<'

I'm very surprised with this. I was just programming, and suddendly, I opened a file that was almost empty, to add a new definition: template and emacs freeze when trying to write <. I shutted ...
1
vote
0answers
15 views

Personalize indentation for new C++ language features [duplicate]

I'm starting to use C++-17, and one of the new features is if constexpr, which breaks completely the usual if identation: int main() { if constexpr(true) { return 1; } else { ...
1
vote
1answer
199 views

Indenting within block comments in C-mode Emacs

After writing functions in C/C++, I like to format my block comments that explain a function's purpose, parameters, use, and so on. (See example below) However, to indent my comments in emacs, I ...
8
votes
1answer
254 views

formatting constexpr if in c++-mode

I recently started using C++17, which brings constexpr if. This however screws up c++-modes default indentation. // emacs 25.3.2 with --no-init if constexpr (n == 1) { // Why? } else if ...
0
votes
1answer
46 views

objc-mode: Comment-end face is not same face as comment-start

How can I configure/modify objc-mode so that the face of comment-end is the same face as comment-start? [The goal is to have commend-end always use font-lock-comment-delimiter-face, instead of font-...
5
votes
2answers
440 views

How to use C++ comments “//” in c-mode?

In c-mode comment-region is adding /* */ style comments. Is there a way to default to using C++ style // prefix in C source files instead?
1
vote
1answer
68 views

Make wide string literal for C/C++

Is there function/package that allows to make "wide string literals" as defined by C/C++ standards. That is, where one has to replace all non-ascii characters with escaped "\x.." sequences.
1
vote
0answers
77 views

Structures are defined using a macro, flycheck gives errors

In our source code we surround structures with a macro (MKDIFF) that serves as a flag for the Makefile system. It does not expand into anything, just a flag. Flycheck (understandably) flags these ...
2
votes
0answers
135 views

How to set indentation style substatement-open offset parameter from .dir-locals.el?

Within CC mode, for C and C++ files inside a directory, I'd like to have the open braces following a case/do/for/if/while not indented, whatever the style is and without having to change anything in ....
1
vote
2answers
81 views

Stop reindenting `if` after `else`

Given the file test.c: int main() { if (a) foo(); else if (b) // line 6 bar(); else baz(); } Whenever a comma or paren is typed while point is on line 6 (...
1
vote
0answers
306 views

Emacs as environment for iOS development

Is there any modes which may improve development experience for nowadays ObjC (syntax highlight for method calls, properties, blocks, literals, lightweight generics, modern keywords)? Ideally with ...
3
votes
1answer
63 views

Update cc-style to use a mix of tabs and spaces, depending on context?

I'm looking for a way to mix tabs and spaces in my cc-styles. Whilst I question the sanity of this coding style, and wouldn't ever choose to use it had I the choice (seems other people share my view),...
2
votes
2answers
722 views

cc-styles c-offsets-alist setting for C++11 lambda brace indentation

I am trying to configure my cc-styles to use a single basic offset for the braces of an inline defined lambda. I have a function template which takes a functor as an argument template<typename ...
0
votes
1answer
105 views

emacs cc-mode installation issue

I am relatively new to emacs. I'm wanting to set up cc-mode. I'm having trouble with the process. When I initially viewed list-packages, a search brought up cc-mode, but something I've done means it ...
2
votes
1answer
571 views

Override c++-mode font lock

I am improving the C++ highlighting in Emacs with the minor mode: modern-cpp-font-lock. Consider this following C++14 code: int main() { int i = 1'2'3l; } From cppreference.com Optional single ...
0
votes
0answers
470 views

How do I prevent indentation of braces in function arguments with csharp-mode

I'm new to customizing Emacs, and I'm struggling to get csharp-mode's indentation to match Visual Studio's defaults (which my coworkers use). I'm starting from the defaults of the Spacemacs csharp ...
4
votes
4answers
80 views

How do I find the variable or lisp code controlling a face at a particular column?

For the longest time I have been ignoring a face change at column 80 in my Java code. The text switches to a pinkish color as shown below. Now it is sufficiently bothersome that I would like to ...
0
votes
1answer
172 views

Setup c-mode indentation, braces and tabs

I've been trying to setup cc-mode based files to behave in the way I want, but with so many varying opinions and suggested ways of doing things, I've not been able to get things just right. All I ...
4
votes
2answers
152 views

Minor modes not working with derived mode from c++-mode

I created a derived mode (using define-derived-mode) based on c++-mode to include new keywords, etc. The mode is working great, but I'm having problems with other minor modes that stop working with ...
1
vote
2answers
62 views

CC-Mode doesn't indent arguments to templated functions starting with a curly bracket

[Reposted here after a comment from wilx on stackoverflow.com] Consider the following snippet of C++ code, indented using cc-mode: auto good1 = f(a, {1, 2}); // ((arglist-cont-...
8
votes
0answers
126 views

Custom indentation for specific lines?

I currently try to figure out, how I can handle some lines specifically without messing up the indentation of the rest of the buffer. Consider the following function MyFunc as an example: void MyFunc(...
1
vote
2answers
86 views

delete-c-electric-paren deletes active region in CC mode with delete-selection-mode enabled

I've the delete-selection-mode enabled. In programming modes like Python and Lua, or in general modes like Fundamental or Text, when there's an active region, pressing ( rightly wraps the region with ...
3
votes
1answer
368 views

rgrep default files pattern

How can I modify the default FILES pattern in rgrep for C++ mode? For C mode the default is *.[ch]. For C++, it is *.cc *.cxx *.cpp *.C *.CC *.c++. I would like to change it to *.cc *.[ch]xx *.[ch]...
2
votes
2answers
185 views

Added spaces between function arguments

I'd like to transform: function arg(a,b,c){} to function arg( a, b, c ){} Is there a way to do this or set it as part of c style auto indentation? So it will happen when editing JavaScript, C++, ...
2
votes
2answers
232 views

Create new major mode from cc-mode that allows comments with two dashes

It is possible and relatively easy to create a new major mode, deriving from c-mode, and just add two dashes '--' to work as comments too? I have checked many resources, but couldn't find anything ...
0
votes
0answers
79 views

Make Helm Projectile to show external sources

I'm pretty new to emacs (was using Vim), primarily using it for Ruby on Rails projects. At my free time, I like to write some C code for STM32 micro-controllers. Unlike RoR project, C project for ...
4
votes
0answers
2k views

Support C++11 syntax in c++-mode

I want correct indentation with my C++ code. The following piece of code indents properly. It nicely indents the access label and the member declaration independently. class Test : public Base { ...
2
votes
0answers
50 views

Is it possible to detect C/C++/Java variable declarations.?

I'm writing a minor mode to handle automatic spacing of operator characters, but I'm having some trouble with C/C++. The problem is that I can't figure out how to tell in general whether a * is a ...
1
vote
0answers
415 views

c-indent-line-or-region: Variable binding depth exceeds max-specpdl-size

I'm trying to define a new major mode using define-generic-mode and want to try reusing c-indent-line-or-region for my indent-line-function. I've inserted (set (make-local-variable 'indent-line-...
3
votes
1answer
104 views

Rainbow-Delimiters and CC-Mode Conflics

I just recently found the "rainbow-delimiters-mode" package and found it quite useful, however I seem to have run into a snag with it when using it in C-like languages: Naturally, I'd prefer to ...
2
votes
3answers
440 views

Changing or adding compiling options in cc-mode

In cc-mode, when we go to compile, M-x followed by compile, the default option is make -k. If I hit the down arrow, I am told no defaults available. Is it possible to add the option g++ -Wall ...
0
votes
2answers
227 views

GNU Emacs - Space in compile command

I have written code to customize the compile-command to use MSBuild.exe if a .vcxproj file is found in the current directory for c-mode files via a c-mode-common-hook. Since MSBuild is not in the path ...
1
vote
2answers
4k views

How to configure linum-mode in spacemacs?

How can I configure spacemacs to always have linum-mode active in C/C++ buffers (cc-mode)?
4
votes
1answer
488 views

How to highlight “constexpr” in cc-mode?

Question Pretty straightforward: How to highlight constexpr in cc-mode (editing C++ code)? Example If I use const as in the following example const double = 3.14 const gets highlighted as a ...
2
votes
2answers
980 views

C++ Incorrect Enum Indentation

It seems like cc-mode indentation is working rather well, however I seem to have run into a minor issue when creating a few enums in C++. Emacs seems to handle almost all kinds of enums rather well ...
1
vote
0answers
83 views

How does forward-list work for “<>” in c++-mode?

I am trying to understand how forward-list matches template delimiters <> in c++-mode. forward-list in lisp.el calls scan-lists with the appropriate arguments. The documentation for scan-lists ...