简体   繁体   中英

Emacs as a C Programming IDE Configuration?

I use emacs as my main IDE for programming in C. I am exploring ways of configuring emacs to function more as an IDE rather than as a simple text editor. Of course I want syntax highlighting and preferably some code completion. I also want separate buffers to allow shell commands and to Mx compile. I want it to open into this multi-buffer form automatically when visiting a C source file, rather than having to launch each buffer separately. I will be using this mainly for Linux/BSD Unix development, though I also code on Mac OS X (again Unix) and Windows (Windows 7 64bit).

I explored the Emacs starter kit posted by Phil Hagelberg (technomancy), but it seems very oriented towards dynamic languages and use of git. I use emacs mainly for developing in C and use mercurial for VC. I am also a relative newbie making configuration of emacs relatively daunting for me.

I am now playing with CEDET and the Emacs Code Browser (ECB) package which is more along the lines of what I want, but is still not perfect.

Any suggestions on customizing emacs as a C programming IDE welcome.

It's been a while since I've done C but here are a few pointers.

  1. Use flymake for on the fly error analysis. I have used it for Python and C and it's really awesome.
  2. Syntax highlighting is there by default in the C mode.
  3. Mx compile is geared towards make so if you have a Makefile in your setup, it should work fine (the defauly flymake rules use this as well). A rule like this

    check-syntax:

     gcc -Wall -o nul -S ${CHK_SOURCES}

    would take care of flymake. This is useful when you edit in subdirectories but want to compile fromt he top.

  4. etags is useful to jump around the code. GnuGlobal also seems to be popular.
  5. Can't comment on ECB since I've never really gotten it to work completely and when I sort of did, I never found it that useful. I use autocomplete.el to do completions but it's not context sensitive.
  6. There is no suggestion 6.
  7. The inbuilt vc integration is not so hot for git and so I use magit instead. There should be similar issues with mercurial.
  8. There are some notes here on setting up your indentation .
  9. You should use which function mode . It's saved me a lot of headache in the past.
  10. The defaults for GUD are pretty decent but you should take a while and familiarise yourself with them to use it's power completely.
  11. I heavily use org-capture to move TBDs into my org mode buffers so that I can track them as TODO items. This is for all languages. I also use org-mode to maintain a development diary for all my projects.

Good luck.

Read this excellent guide on how to configure CEDET. I'd also advise you to use cscope and ECB alongside it. As Noufal already mentioned autocomplete and flymake are very helpful. I'd also recommend you autopair mode .

i didn't try out Emacs-IDE but it seems useful and may help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM