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
1
vote
0answers
629 views

Why do “gnu” and “linux” `c-default-style` treat `c-basic-offset` differently?

These lines in my .emacs (setq-default indent-tabs-mode nil) (setq-default c-default-style "linux") (setq-default c-basic-offset 4) result in the following formatting of my c code (the c-basic-...
1
vote
0answers
123 views

Smarter compile in emacs

I often got to work with projects organized as follows: src/ include/ ... Makefile Is there a way to teach emacs' "compile" function to always use that top-level Makefile regardless which file I'...
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. ...
3
votes
0answers
62 views

Working around preprocessor blocks

I am trying to navigate a C project that has lots of preprocessor directives like this: #ifdef SOME_COMPILE_TIME_VARIABLE for ( idx=0; idx<FOO; idx++ ) { #else for ( idx=0; idx<BAR; idx+...
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
1k 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
0answers
370 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 ...
2
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
111 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: ...
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 ...
1
vote
0answers
24 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
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 ...
2
votes
1answer
372 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 ...
0
votes
0answers
82 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
137 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 ...
16
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 ...
0
votes
1answer
734 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 ...
2
votes
2answers
232 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 ...
1
vote
1answer
547 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
504 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 ...
3
votes
0answers
143 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
1answer
366 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....
1
vote
2answers
718 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 ...
7
votes
2answers
646 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
914 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-...