Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [cc-mode]

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

Filter by
Sorted by
Tagged with
1 vote
0 answers
19 views

Add preprocessor like prefix for C/C++ indentation

I want to extend the existing indentation capabilities for macro constructs which behave like preprocessor directives. Consider the following code example: void fkt() { const int a = 0; MY_MACRO(...
theldoria's user avatar
  • 1,845
1 vote
1 answer
24 views

C++, arglist-intro indent based on the indentation of previous line?

Consider the following C/C++ code { auto x = f(g(h( "aaa"))); } The "aaa" is indented this way, because c-offset-alist has (arglist-intro . +) (I think ...
MetroWind's user avatar
  • 187
1 vote
0 answers
42 views

Previewing latex in cc-mode

I'm trying to write c/c++ code with comments in LaTeX. My .emacs file has the single line (require 'org) My source c/c++ file has the single line \[ \int x \] If I'm in python mode, fortran mode, ...
user3856370's user avatar
1 vote
1 answer
58 views

How to edit an awk file in emacs 28.2 without using AWK//l mode defined in cc-mode.el

While trying to edit an awk file with emacs 28.2 its not self-inserting all charcaters, but trying to evaluate certain keystrokes! For example if I press 3 emacs sees C-u 3-! Pressing a causes it to ...
alls0rts's user avatar
  • 366
1 vote
1 answer
120 views

How to set up K&R everywhere (1TBS) brace style in cc-mode?

I'd like Emacs to follow this indentation style: struct Foo { void bar() { for (int i=0; i<10; i++) { if (condition) { // code // code ...
sajmon's user avatar
  • 56
0 votes
1 answer
50 views

Calling c-electric-brace programmatically

I'm currently extending the tempo.el template insertion system to be sensitive to C styles. Specifically, I want to insert braces using c-electric-brace. How programmatically insertion of braces as ...
Nordlöw's user avatar
  • 507
0 votes
0 answers
113 views

format a region of text file with cc mode

I have a textfile.txt with content like the following *decltype with two or more arguments decltype does not take two arguments. Simply it can have an expression as its argument, and the comma ...
emacs-user-2021's user avatar
0 votes
0 answers
45 views

How to show enumerator's integral value?

Is there a way to print out the integral value of enumerator? I tried to search related questions but no good. So I suspect that this isn't a common requirement for most of people. But I do ...
HQW.ang's user avatar
1 vote
0 answers
382 views

Configuring Doom Emacs to autocomplete code within a header file

I am pretty new to Doom emacs and am so far loving it. However, I am having trouble autocompleting code when from an external include file. I have the following code and am having trouble ...
user3166083's user avatar
0 votes
0 answers
64 views

How to change a core emacs file? (specifically cc-mode.el)

I asked a question here which has not been answered yet. I was able to pinpoint where my problem originated from in the core files. If I could just delete those lines, I reckon my problem would be ...
Alan's user avatar
  • 37
1 vote
1 answer
92 views

Turning off indentation for goto labels

I'm using the ellemtel style for my C code. This mode indents goto labels like this: void f(int x) { if (x) { goto LABEL0; } else { goto LABEL1; } LABEL0: printf("x is zero\n&...
tkf's user avatar
  • 113
2 votes
1 answer
258 views

Java 15 Text Blocks in CC Mode?

Java SE 15 adds (finally) support for multiline string literals that start with """\n and end with """. Has anyone updated java-mode (CC Mode) to recognize this construct?...
Colin Fraizer's user avatar
4 votes
1 answer
212 views

How to convert single line comments to multiline comments?

I have a bunch of single line comment blocks in C-code that I want to change to multiline. Example: // foo // bar should become: /* foo * bar */ How can I do this easily in Emacs?
Arne's user avatar
  • 409
0 votes
0 answers
139 views

How can I disable semicolon electric behaviour without impacting the other electric chars in CC-mode?

In CC-mode when the electric behavior of characters is enabled, typing the semicolon character triggers the c-electric-semi&comma command. That inserts the semicolon, terminates the line, moves ...
PRouleau's user avatar
  • 796
2 votes
1 answer
54 views

Altering syntax highlighting for a particular expression

In c-mode, I would like all lines beginning with exec sql to have that expression grey and the rest of the line in the default face. How might I achieve that?
Toothrot's user avatar
  • 3,264
2 votes
1 answer
550 views

converting c-mode hooks to use-package fails in non-obvious ways

Emacs version 26.3 on a mac I have this (simplified) c(c)-mode config: (add-hook 'c-mode-common-hook '(lambda () (c-set-style "bsd"))) which works when I visit a c file. When I ...
Kannan Varadhan's user avatar
2 votes
1 answer
528 views

Workaround for "Invalid search bound (wrong side of point)" in CC Mode

Emacs 24.x and 25.x have a bug in CC Mode which can result in some operations failing with the error Invalid search bound (wrong side of point) For example, I can reproduce it with the following ...
Gilles 'SO- stop being evil''s user avatar
1 vote
0 answers
118 views

How to avoid annoying `auto-fill` behaviour in `c-mode` comment?

Recently I write quite a lot comments for c/c++ files. I use auto-fill-mode for comment auto format. But I found a quite annoying problem: whenever I input SPC at the end of a comment line, the cursor ...
chihyang's user avatar
0 votes
1 answer
88 views

Inline elements of variable list value in rx() macro call [duplicate]

Is there a more compact way to make use of the rx macro in cases where we want to inline a list of strings from a variable? Such as (defconst c++20-new-keywords-list (list "char8_t" "import" ...
Nordlöw's user avatar
  • 507
2 votes
0 answers
100 views

Derived mode from CC Mode: how do I write one?

Where is the definitive, up-to-date guide on how to write a derived mode from CC Mode. I have a mode that's malfunctioning and thought I might just rewrite it, but information I find is spotty and ...
Adrian's user avatar
  • 21
0 votes
0 answers
86 views

`scad-mode` (derived from CC Mode) hangs Emacs. How to debug/fix?

I have found that scad-mode.el, a derived mode from CC Mode, which can be found here: https://github.com/openscad/openscad/blob/master/contrib/scad-mode.el hangs emacs if I type #( into the window,...
Adrian's user avatar
  • 21
1 vote
1 answer
129 views

How do I suppress indentation after labels in Groovy?

I'm writing some Groovy code, and in my unit tests I have something like the following: def testFoo(){ given: //setup statement 1 //setup statement 2 //... when: //Execute ...
quanticle's user avatar
  • 202
0 votes
1 answer
441 views

How to set tabulator size in the awk mode?

After installing a new kubuntu (16.04) and emacs (25.2.2) I have had indentation problems. It seems like indentation default values have changed or maybe I am missing some configuration file? ...
whamalai's user avatar
0 votes
1 answer
534 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(); } -- ...
Eleno's user avatar
  • 1,448
1 vote
0 answers
70 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 ...
wadoon's user avatar
  • 11
3 votes
1 answer
206 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 ...
Mikael Springer's user avatar
0 votes
1 answer
84 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 ...
onlycparra's user avatar
3 votes
1 answer
266 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, ...
ideasman42's user avatar
  • 8,826
1 vote
0 answers
286 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: ...
Aidenhjj's user avatar
  • 111
3 votes
1 answer
793 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) (...
Vladimir Panteleev's user avatar
1 vote
2 answers
704 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 ) { ...
skyfire's user avatar
  • 107
0 votes
1 answer
176 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, ...
jue's user avatar
  • 4,576
1 vote
1 answer
230 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....
GaryO's user avatar
  • 496
1 vote
0 answers
25 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 { ...
ABu's user avatar
  • 280
2 votes
1 answer
791 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 ...
Ricardo Iglesias's user avatar
11 votes
1 answer
929 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 ...
topisani's user avatar
  • 113
0 votes
1 answer
89 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-...
lawlist's user avatar
  • 19.2k
6 votes
2 answers
3k 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?
ideasman42's user avatar
  • 8,826
1 vote
1 answer
136 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.
dilettant's user avatar
  • 135
1 vote
0 answers
159 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 ...
SFbay007's user avatar
  • 584
3 votes
0 answers
451 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 ....
Yann Droneaud's user avatar
1 vote
2 answers
154 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 (...
Vladimir Panteleev's user avatar
2 votes
0 answers
412 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 ...
Netsu's user avatar
  • 555
3 votes
1 answer
173 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),...
Steve Lorimer's user avatar
3 votes
2 answers
2k 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 ...
Steve Lorimer's user avatar
0 votes
1 answer
280 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 ...
Will's user avatar
  • 1
4 votes
1 answer
1k 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 ...
user avatar
3 votes
4 answers
168 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 ...
pajato0's user avatar
  • 399
0 votes
1 answer
745 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 ...
Diego Barros's user avatar
3 votes
2 answers
243 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 ...
Sassa's user avatar
  • 133