<p>Currently my workflow with Emacs when I am coding in C or C++ involves three windows.  The largest on the right contains the file I am working with.  The left is split into two, the bottom being a shell which I use to type in compile or make commands, and the top is often some sort of documentation or README file that I want to consult while I am working.  Now I know there are some pretty expert Emacs users out there, and I am curious what other Emacs functionally is useful if the intention is to use it as a complete IDE.  Specifically, most IDEs usually fulfill these functions is some form or another:</p>

<ul>
<li>Source code editor</li>
<li>Compiler</li>
<li>Debugging</li>
<li>Documentation Lookup</li>
<li>Version Control</li>
<li>OO features like class lookup and object inspector </li>
</ul>

<p>For a few of these, it's pretty obvious how Emacs can fit these functions, but what about the rest?  Also, if a specific language must be focused on, I'd say it should be C++. </p>

<p><strong>Edit:</strong> One user pointed out that I should have been more specific when I said 'what about the rest'.  Mostly I was curious about efficient version control, as well as documentation lookup.  For example, in SLIME it is fairly easy to do a quick hyperspec lookup on a Lisp function.  Is there a quick way to look up something in C++ STL documentation (if I forgot the exact syntax of <a href="http://www.sgi.com/tech/stl/hash_map.html" rel="noreferrer">hash_map</a>, for example)?</p>

[{'answer_id': 63501, 'author': 'Bryan Oakley', 'author_id': 7432, 'author_profile': 'https://Stackoverflow.com/users/7432', 'pm_score': 4, 'selected': False, 'text': "<p>Instead of running a make command in the shell window, have you tried M-x compile? It will run your make command, display errors, and in many cases make it very easy to jump to the line of code that caused the error if the output includes filenames and line numbers.</p>\n\n<p>If you're a fan of IDEs, you might also want to look at emacs' speedbar package (M-x speedbar). And, if you haven't already,  learn about how to use tags tables to navigate your code.</p>\n"}, {'answer_id': 63511, 'author': 'Ben Collins', 'author_id': 3279, 'author_profile': 'https://Stackoverflow.com/users/3279', 'pm_score': 7, 'selected': True, 'text': '<p>You\'ll have to be specific as to what you mean by "the rest".  Except for the object inspector (that I"m aware of), emacs does all the above quite easily:</p>\n\n<ul>\n<li>editor (obvious)</li>\n<li>compiler - just run <code>M-x compile</code> and enter your compile command.  From there on, you can just <code>M-x compile</code> and use the default.  Emacs will capture C/C++ compiler errors (works best with GCC) and help you navigate to lines with warnings or errors.</li>\n<li>Debugging - similarly, when you want to debug, type <code>M-x gdb</code> and it will create a gdb buffer with special bindings</li>\n<li>Documentation Lookup - emacs has excellent CScope bindings for code navigation.  For other documentation: Emacs also has a manpage reader, and for everything else, there\'s the web and books.</li>\n<li>version control - there are lots of Emacs bindings for various VCS backends (CVS, SCCS, RCS, SVN, GIT all come to mind)</li>\n</ul>\n\n<p>Edit: I realize my answer about documentation lookup really pertained to code navigation.  Here\'s some more to-the-point info:  </p>\n\n<ul>\n<li><a href="http://www.delorie.com/gnu/docs/emacs/emacs_289.html" rel="noreferrer">Looking up manpages, info manuals, and Elisp documentation from within emacs</a></li>\n<li><a href="https://bitbucket.org/jonwaltman/pydoc-info" rel="noreferrer">Looking up Python documentation from within Emacs</a>.  </li>\n</ul>\n\n<p>Google searching will no doubt reveal further examples.</p>\n\n<p>As the second link shows, looking up functions (and whatever) in other documentation can be done, even if not supported out of the box.</p>\n'}, {'answer_id': 63624, 'author': 'HD.', 'author_id': 6525, 'author_profile': 'https://Stackoverflow.com/users/6525', 'pm_score': 3, 'selected': False, 'text': '<p>I agree that you should learn about M-x compile (bind that and M-x next-error to a short key sequence).</p>\n\n<p>Learn about the bindings for version control (e.g. vc-diff, vc-next-action, etc.)</p>\n\n<p>Look into registers.  You not only can remember locations in buffers but whole window configurations (C-x r w -- window-configuration-to-register).</p>\n'}, {'answer_id': 68846, 'author': 'baudtack', 'author_id': 10738, 'author_profile': 'https://Stackoverflow.com/users/10738', 'pm_score': 5, 'selected': False, 'text': '<p>I have to recommend <a href="http://ecb.sourceforge.net/" rel="noreferrer" title="Emacs Code Browser Homepage">Emacs Code Browser</a> as a more "traditional" IDE style environment for emacs.</p>\n\n<p><strong>EDIT</strong>: I also now recommend <a href="http://www.emacswiki.org/emacs/Magit" rel="noreferrer">Magit</a> highly over the standard VCS interface in emacs.</p>\n'}, {'answer_id': 69690, 'author': 'jfm3', 'author_id': 11138, 'author_profile': 'https://Stackoverflow.com/users/11138', 'pm_score': 2, 'selected': False, 'text': "<p>compile, next-error, and previous-error are all pretty important commands for C++ development in Emacs (works great on grep output too).  Etags, visit-tags-table, and find-tag are important as well.  completion.el is one of the great unsung hacks of the 20th century, and can speed up your C++ hacking by an order of magnitude.  Oh and let's not forget ediff.</p>\n\n<p>I've yet to learn how to use version control without visiting a shell, but now that I'm running commits so much more frequently (with git) I will probably have to.</p>\n"}, {'answer_id': 81868, 'author': 'Chopmo', 'author_id': 13747, 'author_profile': 'https://Stackoverflow.com/users/13747', 'pm_score': 3, 'selected': False, 'text': '<p>A starting point (which may be non-obvious) for exploring the VC features of Emacs is <strong>M-x vc-next-action</strong>. </p>\n\n<p>It does the "next logical version control operation" on the current file, depending on the state of the file and the VC backend. So if the file is not under version control, it registers it, if the file has been changed, the changes are submitted etc. </p>\n\n<p>It takes a little getting used to, but I find it very useful. </p>\n\n<p>Default keybinding is <strong>C-x v v</strong></p>\n'}, {'answer_id': 161770, 'author': 'dkagedal', 'author_id': 24458, 'author_profile': 'https://Stackoverflow.com/users/24458', 'pm_score': 3, 'selected': False, 'text': '<p>For version control, there are several things that you can use, depending on what version control system you use. But some of the functionality is common to all of them.</p>\n\n<p><b>vc.el</b> is the built-in way to handle version control at a file level. It has backends for most version control systems. For instance, the Subversion backend comes with Emacs, and there are git backends and others available from other sources.</p>\n\n<p>The most useful command is <b>C-x v v</b> (vc-next-action) that does the appropriate next action for the file you are visiting. This might mean updating from the repository or commiting your changes, vc.el also rebinds <b>C-x C-q</b> to check in and out files if you are using a system that needs it (like RCS).</p>\n\n<p>Other very useful commands are <b>C-x v l</b> and <b>C-x v =</b> that show you the log and current diff for the file you are using.</p>\n\n<p>But for real productivity, you should avoid using the single-file vc.el commands other than for simple things. There are several packages that can give you an overview of the status of your whole tree, and give you more power, and not to mention the ability to create coherent commits spanning several files.</p>\n\n<p>Most of these are heavily influenced or based on the original <b>pcl-cvs</b>/<b>pcvs</b> for CVS. There are even two of them that comes with subversion, <b>psvn.el</b> and <b>dsvn.el</b>. There are packages for git etc.</p>\n'}, {'answer_id': 261280, 'author': 'Alex Ott', 'author_id': 18627, 'author_profile': 'https://Stackoverflow.com/users/18627', 'pm_score': 3, 'selected': False, 'text': '<p>You can find detailed description of emacs &amp; version control integration on <a href="http://xtalk.msk.su/~ott/en/writings/emacs-vcs/index.html" rel="noreferrer">my site</a>.  I\'m also working on article about using Emacs as Development Environment for many languages - C/C++, Java, Perl, Lisp/Scheme, Erlang, etc...</p>\n'}, {'answer_id': 501706, 'author': 'justinhj', 'author_id': 53120, 'author_profile': 'https://Stackoverflow.com/users/53120', 'pm_score': 4, 'selected': False, 'text': '<p>There are corners of emacs that once discovered make you more productive in ways you never thought of. As others have mentioned, using tags is a fantastic and fast way to zoom around your source code and using M-/ (dabbrev-expand) often does exactly what you expect when completing a variable name. </p>\n\n<p>Using occur is useful to get a buffer with all occurences of a regular expression in a buffer. That\'s really handy when refactoring code and looking for fragments of code or uses of variables, or if you use TODO markers in your source files and you want to visit them all.</p>\n\n<p>flush-lines, sort-numeric-fields, replace-regexp and rectangle functions can be really useful for taking a dump from some tool and converting it to useful data such as an elisp program or a comma delimited spreadsheet. </p>\n\n<p>I wrote a page about IDE like things you can do with emacs </p>\n\n<p><a href="http://justinsboringpage.blogspot.com/2007/09/11-visual-studio-tricks-in-emacs.html" rel="noreferrer">http://justinsboringpage.blogspot.com/2007/09/11-visual-studio-tricks-in-emacs.html</a></p>\n\n<p>Learning elisp is a another great way to answer for yourself what else emacs can do beyond what a typical IDE can do. </p>\n\n<p>For example I\'ve blogged about writing Perforce helper functions like blame (writing your own means you can make it behave exactly as you want)...</p>\n\n<p><a href="http://justinsboringpage.blogspot.com/2009/01/who-changed-line-your-working-on-last.html" rel="noreferrer">http://justinsboringpage.blogspot.com/2009/01/who-changed-line-your-working-on-last.html</a></p>\n\n<p>I\'ve also written code that dynamically creates comments for a function at point, that matches the coding standards I\'m working with. </p>\n\n<p>None of my elisp code is particularly great, and most of it exists already in libraries, but it\'s really useful to be able to make emacs do custom stuff that just comes up during a working day. </p>\n'}, {'answer_id': 594533, 'author': 'Jonas Kölker', 'author_id': 58668, 'author_profile': 'https://Stackoverflow.com/users/58668', 'pm_score': 2, 'selected': False, 'text': '<p>On documentation lookup: that depends on your programming language(s).</p>\n\n<p>C libraries and system calls are typically documented in man pages.  For that you can use <code>M-x man</code>.  Some things may be documented better in info pages; use <code>M-x info</code>.</p>\n\n<p>For elisp itself, use <code>C-h f</code>.  For python, use <code>&gt;&gt;&gt; help(&lt;function, class, module&gt;)</code> in the interpreter.</p>\n\n<p>I find that most other languages offer documentation in html form.  For that, try an embedded browser (I use w3m).  Set your <code>BROWSER</code> environment variable to a wrapper script around <code>emacsclient  -e "(w3m-goto-url-new-session \\"$@\\")"</code> (on *nix), in case something might open a browser and you want it opened inside emacs.</p>\n'}, {'answer_id': 845544, 'author': 'wr.', 'author_id': 101430, 'author_profile': 'https://Stackoverflow.com/users/101430', 'pm_score': 2, 'selected': False, 'text': '<p>You might also find <a href="http://www.emacswiki.org/emacs/TabBarMode" rel="nofollow noreferrer">tabbar</a> useful. It emulates the only behavior I missed when moving from Eclipse to Emacs. Bound to "," and "." for moving to the previous and next tab bar, it relives you from switching the buffer by Ctrl-x b all the time.</p>\n\n<p>Unfortunately, the mentioned web page does not provide the correct version to download. Most Ubuntu versions, however, deliver it in their emacs-goodies packages.</p>\n'}, {'answer_id': 1616958, 'author': 'Cheeso', 'author_id': 48082, 'author_profile': 'https://Stackoverflow.com/users/48082', 'pm_score': 2, 'selected': False, 'text': '<p>There\'s a <a href="http://www.emacswiki.org/emacs/MSTFS" rel="nofollow noreferrer">TFS.el for emacs integration into Microsoft TFS</a>. It works with any TFS, including the TFS that runs Codeplex.com.  </p>\n\n<p>Basic steps to setup:</p>\n\n<ol>\n<li><p>Place tfs.el in your load-path.</p></li>\n<li><p>In your .emacs file:  </p>\n\n<pre><code>(require \'tfs)\n(setq tfs/tf-exe  "c:\\\\vs2008\\\\common7\\\\ide\\\\tf.exe")\n(setq tfs/login "/login:domain\\\\userid,password")\n      -or-\n(setq tfs/login (getenv "TFSLOGIN"))  ;; if you have this set\n</code></pre></li>\n<li><p>also in your .emacs file, set local or global key bindings for tfs commands.  like so:</p>\n\n<pre><code>(global-set-key  "\\C-xvo" \'tfs/checkout)\n(global-set-key  "\\C-xvi" \'tfs/checkin)\n(global-set-key  "\\C-xvp" \'tfs/properties)\n(global-set-key  "\\C-xvr" \'tfs/rename)\n(global-set-key  "\\C-xvg" \'tfs/get)\n(global-set-key  "\\C-xvh" \'tfs/history)\n(global-set-key  "\\C-xvu" \'tfs/undo)\n(global-set-key  "\\C-xvd" \'tfs/diff)\n(global-set-key  "\\C-xv-" \'tfs/delete)\n(global-set-key  "\\C-xv+" \'tfs/add)\n(global-set-key  "\\C-xvs" \'tfs/status)\n(global-set-key  "\\C-xva" \'tfs/annotate)\n(global-set-key  "\\C-xvw" \'tfs/workitem)\n</code></pre></li>\n</ol>\n'}, {'answer_id': 4621015, 'author': 'Cheeso', 'author_id': 48082, 'author_profile': 'https://Stackoverflow.com/users/48082', 'pm_score': 2, 'selected': False, 'text': '<p>I use emacs on Windows.  the compile module is nice, but I wanted compile to be smarter about the compile command line it suggests.  <a href="http://www.gnu.org/software/emacs/manual/html_node/emacs/Specifying-File-Variables.html#Specifying-File-Variables" rel="nofollow">It\'s possible to use "File Variables" to specify <code>compile-command</code></a>, but I wanted something a little smarter than that. So I wrote a little function to help out. It guesses the compile command to use, to prompt the user with, when running <code>compile</code>. </p>\n\n<p>The guess function looks for a vbproj or csproj or sln file, and if found, it suggests msbuild.  Then it looks at the buffer file name, and depending on that, suggests different things.  A .wxs file means it\'s a WIX project, and you likely want to build an MSI, so the guess logic suggests an nmake command for the MSI.  If it\'s a Javascript module, then the suggestion is to run jslint-for-wsh.js to lint the .js file.  As a fallback, it suggests nmake. </p>\n\n<p>The code I use looks like this:</p>\n\n<pre><code>(defun cheeso-guess-compile-command ()\n  "set `compile-command\' intelligently depending on the\ncurrent buffer, or the contents of the current directory."\n  (interactive)\n  (set (make-local-variable \'compile-command)\n       (cond\n        ((or (file-expand-wildcards "*.csproj" t)\n             (file-expand-wildcards "*.vcproj" t)\n             (file-expand-wildcards "*.vbproj" t)\n             (file-expand-wildcards "*.shfbproj" t)\n             (file-expand-wildcards "*.sln" t))\n         "msbuild ")\n\n        ;; sometimes, not sure why, the buffer-file-name is\n        ;; not set.  Can use it only if set.\n        (buffer-file-name\n         (let ((filename (file-name-nondirectory buffer-file-name)))\n           (cond\n\n            ;; editing a .wxs (WIX Soluition) file\n            ((string-equal (substring buffer-file-name -4) ".wxs")\n             (concat "nmake "\n                     ;; (substring buffer-file-name 0 -4) ;; includes full path\n                     (file-name-sans-extension filename)\n                     ".msi" ))\n\n            ;; a javascript file - run jslint\n            ((string-equal (substring buffer-file-name -3) ".js")\n             (concat (getenv "windir")\n                     "\\\\system32\\\\cscript.exe c:\\\\users\\\\cheeso\\\\bin\\\\jslint-for-wsh.js "\n                     filename))\n\n            ;; something else - do a typical .exe build\n            (t\n             (concat "nmake "\n                     (file-name-sans-extension filename)\n                     ".exe")))))\n        (t\n         "nmake "))))\n\n\n(defun cheeso-invoke-compile-interactively ()\n  "fn to wrap the `compile\' function.  This simply\nchecks to see if `compile-command\' has been previously set, and\nif not, invokes `cheeso-guess-compile-command\' to set the value.\nThen it invokes the `compile\' function, interactively."\n  (interactive)\n  (cond\n   ((not (boundp \'cheeso-local-compile-command-has-been-set))\n    (cheeso-guess-compile-command)\n    (set (make-local-variable \'cheeso-local-compile-command-has-been-set) t)))\n  ;; local compile command has now been set\n  (call-interactively \'compile))\n\n;; in lieu of binding to `compile\', bind to my monkeypatched function\n(global-set-key "\\C-x\\C-e"  \'cheeso-invoke-compile-interactively)\n</code></pre>\n\n<p>I tried doing this as "before advice" for the compile function but couldn\'t get it to work satisfactorily. So I defined a new function and bound it to the same keystroke combination I have been using for <code>compile</code>. </p>\n\n<hr>\n\n<blockquote>\n  <p><strong>EDIT</strong> there is now "<a href="http://marmalade-repo.org/packages/smarter-compile" rel="nofollow">smarter-compile.el</a>" which takes this idea one step further.</p>\n</blockquote>\n'}, {'answer_id': 14636137, 'author': 'Muhammet Can', 'author_id': 460281, 'author_profile': 'https://Stackoverflow.com/users/460281', 'pm_score': 3, 'selected': False, 'text': '<p>Okay, everyone here is giving perfect hints to make emacs a great IDE. </p>\n\n<p>But anyone should keep in mind that, when you customize your emacs with a lot of extension (especially with the ones for type-checking on the fly, function definition lookups etc) your emacs will load very, very slow for an editor. </p>\n\n<p>To workaround this, I would highly recommend to use emacs in <code>server mode</code>. </p>\n\n<p>It is pretty simple to use, no need to customize your init file.\nYou just need to start emacs in daemon mode;</p>\n\n<pre><code>emacs --daemon\n</code></pre>\n\n<p>This will create an emacs server, then you can connect it either from terminal, or from gui. I\'d also recommend to create some aliases to make it easy to call. </p>\n\n<pre><code>alias ec="emacsclient -t"\nalias ecc="emacsclient -c &amp;"\n# some people also prefer this but no need to fight here;\nalias vi="emacsclient -t"\n</code></pre>\n\n<p>This way, emacs will fire up even faster than gedit, promise.</p>\n\n<p>The one possible problem here, if you are running emacs daemon from your casual user, you probably can\'t connect emacs server as <code>root</code>.  </p>\n\n<p>So, if you need to open a file that has root access; use <code>tramp</code> instead. Just run your emacs client with your normal user and open files like this;</p>\n\n<pre><code>C-x C-f\n/sudo:root@localhost/some/file/that/has/root/access/permissions\n# on some linux distro it might be `/su:root@...` \n</code></pre>\n\n<p>This made my life easier, I can open my heavy customized python IDE in miliseconds this way. You may also want to add emacs --daemon to your system startup, or create a desktop file for emacsclient. Thats up to you. </p>\n\n<p>More on emacs daemon and emacs client can be found at wiki;</p>\n\n<p><a href="http://www.emacswiki.org/emacs/EmacsAsDaemon" rel="noreferrer">http://www.emacswiki.org/emacs/EmacsAsDaemon</a></p>\n\n<p><a href="http://www.emacswiki.org/emacs/EmacsClient" rel="noreferrer">http://www.emacswiki.org/emacs/EmacsClient</a>  </p>\n'}, {'answer_id': 33721012, 'author': 'Philipp Claßen', 'author_id': 783510, 'author_profile': 'https://Stackoverflow.com/users/783510', 'pm_score': 2, 'selected': False, 'text': '<p>In the recent years, Clang became an important part of the Emacs C++ support. Atila Neves had a talk on CppCon 2015:\n<a href="https://youtu.be/5FQwQ0QWBTU" rel="nofollow">"Emacs as a C++ IDE"</a></p>\n\n<p>It is a 16 minute talk, where he shows solutions for the following topics:</p>\n\n<ul>\n<li>Jump to definition</li>\n<li>Auto-completion</li>\n<li>On-the-fly syntax highlighting</li>\n<li>Find file in project</li>\n</ul>\n\n<p>Slides can be found <a href="https://github.com/CppCon/CppCon2015/raw/master/Lightning%20Talks%20and%20Lunch%20Sessions/Emacs%20as%20a%20C%2B%2B%20IDE/Emacs%20as%20a%20C%2B%2B%20IDE%20-%20Atila%20Neves%20-%20CppCon%202015.pdf" rel="nofollow">here</a>.</p>\n'}, {'answer_id': 47161628, 'author': 'rocky', 'author_id': 546218, 'author_profile': 'https://Stackoverflow.com/users/546218', 'pm_score': 1, 'selected': False, 'text': '<p>In the Unix or X windows style, I don\'t know that there is an integrated IDE that works for everything. </p>\n\n<p>For interacting with debuggers, just one component of an IDE, consider <a href="https://github.com/realgud" rel="nofollow noreferrer">realgud</a>. The other thing it has that I find useful are parsers for location messages, so that if you have a call stack trace and want to edit at a particular place in the callstack, this front-end interface will can do that. </p>\n\n<p>By far this program could use improvement. But then it could also use people working on it to improve it. </p>\n\n<p>Disclaimer: I work on realgud</p>\n'}, {'answer_id': 53142784, 'author': 'sidharth arya', 'author_id': 9204788, 'author_profile': 'https://Stackoverflow.com/users/9204788', 'pm_score': 3, 'selected': False, 'text': '<p>I know this is a very old post. But this question is valid for emacs beginners.</p>\n\n<p>IMO the best way to use emacs as an ide is to use a <a href="https://langserver.org/" rel="noreferrer">language server protocol</a> with emacs. You can find all the information about language servers in the linked website. </p>\n\n<p>For a quick setup, i would urge you to go to this page <a href="https://github.com/joaotavora/eglot" rel="noreferrer">eglot</a> . IMO eglot does it\'s job pretty well. It integrates well with auto completions packages like company. Provides find reference, and more. </p>\n\n<p>Also for a debugger, you may need specific debuggers for specific languages. You can use gdb from within emacs. Just type <code>M-x gdb</code> . </p>\n\n<p>For compiling your code, it\'s best to use shell-commands. I am working on this project <a href="https://github.com/sidhartharya10/eproj" rel="noreferrer">eproj</a>. It\'s gonna take a while to complete it. But all it does is maps shell command to project type. And builds you project via shell. It does the same to execute command. I may need help completing this project. It\'s not ready for use, but if you know a bit of elisp you can go through the code. </p>\n\n<p>That aside, it\'s always best to use the emacs compile command.</p>\n\n<p>For version control, I haven\'t yet seen any other package which can match the power of <a href="https://github.com/magit/magit" rel="noreferrer">magit</a>. It\'s specific to git. Also for git there is another package git-timemachine, which i find very useful.</p>\n\n<p>Object lookup and class lookup is provided by language server protocol. </p>\n\n<p>A project tree can be used for ide like interface with <a href="https://github.com/magit/magit" rel="noreferrer">treemacs</a>.</p>\n\n<p>There is also a project Interaction Library called <a href="https://github.com/bbatsov/projectile" rel="noreferrer">projectile</a>.</p>\n\n<p>For auto completion, I find <a href="https://github.com/company-mode/company-mode" rel="noreferrer">company-mode</a> very useful. </p>\n\n<p>Truly emacs can be made to do anything.</p>\n'}, {'answer_id': 60396460, 'author': 'acakojic', 'author_id': 9497126, 'author_profile': 'https://Stackoverflow.com/users/9497126', 'pm_score': 2, 'selected': False, 'text': '<p>Try lsp-mode. Now you can use other IDE functionality inside emacs connecting to server. Look for more info: <a href="https://github.com/emacs-lsp/lsp-mode" rel="nofollow noreferrer">lsp-mode</a></p>\n'}]
['https://Stackoverflow.com/questions/63421', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7545/']