I'm updating my Ubuntu distro to LTS 16.04 release.

I followed the instructions given at irony mode in github and company irony in github in order to get autocompletion features in Emacs. For both packages, I have put the given configuration into .emacs file located in my home directory.

Now when I open a C++ file, the Emacs status bar indicates C++/l Irony Abbrev message. So, deduce that Emacs has understood something related to ironic mode. However, until now I cannot appreciate some autocompletion behavior.

So, after doing some searches without getting a solution, I would want to ask to this forum for some clue or help. What should I revise? Is there some specific step for Ubuntu 16.04?

EDIT: this is the content of my init.el file in the .emacs.d directory:

(when (>= emacs-major-version 24)
  (require 'package)
   '("melpa" . "http://melpa.org/packages/")

 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(custom-enabled-themes (quote (manoj-dark))))
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.

(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)

;; replace the `completion-at-point' and `complete-symbol' bindings in
;; irony-mode's buffers by irony-mode's function
(defun my-irony-mode-hook ()
  (define-key irony-mode-map [remap completion-at-point]
  (define-key irony-mode-map [remap complete-symbol]
(add-hook 'irony-mode-hook 'my-irony-mode-hook)
(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

The directory .emacs.d contains a subdir called elpa which contains another subdir irony-20160628.1329 where I suppose is installed irony mode.

  • This is almost certainly something in your init file rather than something about Ubuntu.
    – Dan
    Jul 13 '16 at 12:43
  • @Dan I edited my question and put the content of the init file. Thanks for your interest
    – lrleon
    Jul 13 '16 at 13:02

I'm pretty sure you're missing the company-irony mode here. As far as I know, irony is not enough for autocompleting. At least not with your setup.

I'll first explain a kind-of-short answer to it which should be ok if you're familiar with emacs. If you're not, just keep on reading. I'll explain everything after the short answer anyway.

So, install company-irony (look up their website as I cant post more than 2 links) and follow it's instructions. Appending the following to your init.el or .emacs should do the trick after installing company-irony.

(eval-after-load 'company '(add-to-list 'company-backends 'company-irony))

That one is the short answer. If you find that:

  1. It does not work
  2. You do not understand what that is

Read on.

First, irony-mode is some sort of backend made to help you when you code C/C++. By itself if cannot (as far as I understand) help you very much. So what you usually do is install a frontend that actually can get the help irony gives to it and show it to you.

For autocompletion, there are two big candidates: company, and auto-complete (look this one up if you want). These two take options from various backends and help you complete. If you install either you will notice they can help you when coding Emacs-lisp (the init.el file). Anyway, these two support irony backend, and I already explained the company way to do so. That should be enough explanation for what's going on.

If you have trouble with auto completion candidates when using company or auto-complete, you can have a look at this video which explains the whole process (don't follow the Mac-specific instructions though).

The show doesn't end there, though, you can take advantage of irony to tell you errors from your code. There's a package called Flycheck that highlights errors, which of course, has an irony backend, but that's another story.

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.