Questions tagged [c]

is for C source code editing, completions, formatting, compiling, folding, searching, executing, syntax checking, debugging, and other modern IDE features that Emacs supports.

Filter by
Sorted by
Tagged with
4
votes
1answer
1k views

C brace indentation

I am new to Emacs and trying to learn the basics. I am writing a few C programs and I noticed that the default brace indentation is as follows: for(i = 0; i < 10; ++i) { // code }...
0
votes
1answer
2k views

auto-complete-c-headers just works with C. No result with C++

I installed the auto-complete-c-headers package and did the .emacs configs as follows: ; start auto-complete with emacs (require 'auto-complete) ; do default config for auto-complete (require 'auto-...
1
vote
1answer
844 views

Completion for variables in C using company-gtags, or not Semantic

I have a working C IDE without Semantic (too slow for me), from instructions here, with completion provided by company-gtags (I think. Maybe clang does something too?). Completion at point works for ...
1
vote
0answers
387 views

Code completion for C++

I have just started using emacs, after coming from using Xcode. I would like to get code completion for C++, however there are a whole bunch of things that don't really explain what they do (at least ...
2
votes
1answer
7k views

Auto-complete C/C++ functions

I want code completion for C/C++ functions and variables from headers. I tried to install Auto-complete and Company, but C/C ++ functions/variables aren't complemented. Here is the relevant portion ...
3
votes
1answer
2k views

Emacs does not contain package “package”

I want to add C auto-completion at least so that I can use Emacs on a regular basis as my C editor. I am new to Emacs, and I had already it installed in my system, because it came with the OS (I think)...
5
votes
2answers
112 views

Swap two statement on adjacent lines in C when one statement takes multiple lines

Assume that I have the following code: int x; string s = "some very long " " string"; I would like to have one command that swaps the order of these without ending up with something like: ...
7
votes
1answer
182 views

How can I build/package Emacs so that the C source files are installed to a standard find-function-C-source-directory?

I want to be able to view C source code of Emacs functions. For example, I want to be able to do M-: (find-function 'message). Emacs prompts me for directory the C sources, so it can set find-...
1
vote
0answers
25 views

How can I have C functions coloured based on whether they are defined?

Colleague of mine showed me a cool feature of gnome-builder which does colour symbols based on whether they are defined or not and I was wondering whether it is possible in Emacs as well. And by that ...
2
votes
1answer
441 views

How to make an alias in eshell

I want to make an alias in eshell so that when I type gcc it actually does gcc -Wall -pedantic -std=c99 but when I make the alias, it just displays gcc -Wall -pedantic -std=c99 and doesn't actually ...
1
vote
2answers
1k views

How to set up hotkey for compiling c code and run the compiled file?

I used to use tmux with vim to write codes in C/C++. So I split the screen into two in tmux and then press F3 to "make" the file. And then I can press F4 to run the "main" file in the next subscreen. ...
2
votes
2answers
4k views

Better syntax-higlighting for member variables and function calls in cpp-mode

In atom, C++ files are well colored unlike emacs cpp-mode. Emacs does not highlight references to member variables, function calls or member functions. They all are uncolored. The left is from emacs ...
0
votes
0answers
86 views

How to add a key map in Emacs source code?

I found ESC-prefix and Control-X-prefix defined in keymap.c: initial_define_key (global_map, 033, "ESC-prefix"); initial_define_key (global_map, Ctl ('X'), "Control-X-prefix"); But no matter what ...
6
votes
2answers
143 views

How to add a new .c file to Emacs source code

I've added my own .c file to Emacs /src directory as well as the following lines emacs.o: ... file.c file.h file.o: file.c in deps.mk I get file.o generated, but it is not linked when generating ...
11
votes
2answers
4k views

How to get semantic syntax highlighting on emacs for C/C++ code

I'm new to emacs and programming in general so please bear with me. I'm trying to use emacs as my C/C++ IDE, and I noticed that in CC mode the variables/functions seemed to be highlighted only during ...
17
votes
1answer
2k views

How to automatically create neat C comment blocks while typing?

Some code editors such as eclipse automatically form neat blocks when you start typing a multi-line comment: Is there some package or another way to do this in emacs too? Edit: To clarify: I do not ...
0
votes
0answers
85 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 ...
2
votes
2answers
240 views

Does your project use Elisp for build automation?

I'm building a new appliance, linking BusyBox with Tor on top of a minimal GNU/Linux operating system. I'd like to try something different for the automated build infrastructure with this one and ...
0
votes
1answer
772 views

Emacs GDB does not load shared library symbols

I am trying to debug a C/MPI library that I have built. All objects are compiled using GCC and -ggdb, they are also linked using -ggdb. When I try to attach a gdb session to the process with the -p ...
1
vote
1answer
595 views

Emacs (semantic) include not working for relative personal includes

This works: Running semantic-decoration-include-visit (opens the included header): #include <string.h> #include "/usr/include/gtk-3.0/gtk/gtk.h" Works well. This does not: But if I ...
0
votes
0answers
530 views

Wrong indent in c-mode and c++-mode

In my coding style tabs used to indent and spaces for align. I've configure Emacs for this, but some times emacs places 4 spaces instead of tabulation in some blocks of code. If can be fixed by ...
1
vote
1answer
391 views

How to indent C correctly

I've read several answers on here and on Google and have tried several solutions but nothing is fixing this for me. Right now, if I try to write C code Emacs indents it like so: #include <stdio....
3
votes
0answers
148 views

Turn C Electric Indentation off only for specific characters

Extending Customizing c-mode indentation behavior in emacs-24.4 How can electric indentation be disabled for other specific keys without disabling the entire mode? Specifically, how can electric ...
1
vote
2answers
738 views

How to display type of C variable in a curses type menu?

A friend of mine who uses vim had this useful feature enabled, that allowed him to see type/completion information in a dropdown window even in terminal mode. Currently in emacs I have to actually ...
6
votes
2answers
4k views

emacs cscope integration basics

I am a long term eclipse CDT user migrating to emacs (ver. 23.3.1), because I have to work on a large C codebase accessible only through a telnet/ssh shell. After going through several online guides, ...
11
votes
3answers
1k views

How can I automatically insert a prototype in foo.h from foo.c?

Suppose I'm writing a C program in a file foo.c: int add_numbers(int x, int y, int z) { // Very complex implementation here. return x + y + z; } I want a command that will insert a ...
7
votes
2answers
696 views

Hook that indicates when the cursor has been moved by scrolling

Inspired by this question: Let Emacs move the cursor off-screen, I am considering writing a minor mode that will keep the cursor in a fixed position that is not affected by scrolling operations. I ...
1
vote
2answers
1k views

Why does hook to set up C++ mode indentation not work?

This is my code (defun my/set-c-mode () (local-set-key (kbd "C-c C-c") 'compile) (setq compilation-finish-function 'compilation-exit-autoclose-clone) (setq c-default-style "linux") (setq c-indent-...
8
votes
4answers
449 views

How do I disable ffap (find file at point) when the first two non-space characters in a line are '//'?

In Verilog/C/C++, comments can begin with //. Here's an example comment, //This is a comment I like to use the find-file-at-point feature. If my cursor is on the file name in `include "some_file.v"....