1

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 jump to a separate point in code (using M-.) which can be quite distracting, is there a way to enable this ?

I looked at other C IDE related questions but none of them seem to have answer to this question.

  • Is that drop down menu a completion menu? If so, you can install irony-mode and see full information of each completion candidates; it looks like this. Alternatively, you can also use company-clang that comes with company that gives you something like previous screenshot. – Tu Do Feb 26 '15 at 6:32
  • I updated my answer with a demo to show you how it actually looks like. – Tu Do Feb 26 '15 at 17:30
3

You can install irony-mode and see full information of each completion candidates; it looks like this. Alternatively, you can also use company-clang that comes with company that gives you something like previous screenshot. Note that to have something similar to the screenshot and using Irony, you have to install Company to install company-irony. If you want to display function signature information in the minibuffer, use irony-eldoc. In summary, you have to install 4 packages from MELPA: Company + Irony + Company Irony + Irony Eldoc, and Clang by manually building it yourself following the official guide, or simply install it from the package manager of your OS (i.e. apt-get, yum...). All of this procedure is still much easier from setting YCM server and making it work with Vim.

Note that to build Irony, you have to install Cmake and run M-x irony-install-server, press RET and wait it build the server. After the build is finished, you can start using the auto-completion. Clang supports a few compilation systems. If you use Make, simply create an empty .clang_complete, add include paths where Irony should searches for completion symbols in your project using -Ipath/relative/to/.clang_complete. You can read about .clang_complete fully here. You don't need .clang_complete file or any of the build system, Irony will still work. But then it only looks for files in current directory. To look further, you have to tell it as suggested above.

A picture is worth a thousand words. Here is a gif demo:

company-irony

As you see, a completion popup with type information. If you notice, when I move the cursor to each completion candidate, a short message is displayed in the minibuffer briefly describes the candidate. After pressing RET to insert a desired candidate and change the parameters to actual arguments, I moved point to the candidate I inserted and its type information and a short summary message is displayed in the minibuffer.

So, one of those solutions should solve your completion problem. Since you put Helm tag there, I assume you use Helm. If so, you can use helm-gtags and use helm-gtags-dwim at a symbol at point. It will list all function signature in a Helm buffer without jumping to it. You can look at all the function signatures, then press C-g to go back to your current buffer. The advantage compare with the minibuffer approach is that you can look up more than one definition, while minibuffer can only show you one closest match it could find.

EDIT: If you use Emacs 24.4. you may also want to try Semantic Refactor. Here are the demos.

1

Look into semantic modes. In particular, global-semantic-idle-summary-mode, which shows a summary of the symbol under point (including type information) in the echo area.

semantic-idle-summary-mode

Note that semantic is very powerful, but it still has limitations. Complex template code, for example, can confuse it. I don't do too much complex C++, so I've never seen it fail. The LLVM is probably more powerful, but semantic is built into Emacs, which adds a level of convenience.

While you specifically call for a "curses style menu", I personally think the echo area is the better place for such information. It is consistent with the rest of Emacs, and does not obscure the code. Note that character graphics are very tricky in Emacs ATM. If you really want, we can work on displaying this information with popup.el or the like.

  • Oh actually the curses style menu is not a deal breaker, I guess what you are showing could take care of 80% of the requirement – Pushpendre Feb 26 '15 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.