After some research, I came across the company mode git hub ticket,
which says that company mode uses dabbrev for plain text as backend.
dabbrev has an option to downcase things, it is turned on by default but can be turned off:
(setq company-dabbrev-downcase nil)
Now all is well.
They're pretty much equivalent, but company-mode has a better thought-out API for plugin developers. It's also much more actively maintained. But there are two key differences which may or may not matter to you:
Firstly, company-mode now targets Emacs 24, so if you're stuck with Emacs 23 then you're out of luck. auto-complete still works with Emacs 23.
I've used autocomplete-mode for a good a few years and switched to company-mode a couple of months ago.
In basic usage there's not much of a difference. Like someone else posted this link has a good summary of the differences.
I found company-mode to be easier to configure and to let it do what I want it to. With autocomplete-mode I ran into issues now and ...
I have the following snippet in my configuration and it seems like it's exactly what you want:
;; Add yasnippet support for all company backends
(defvar company-mode/enable-yas t
"Enable yasnippet for all backends.")
(defun company-mode/backend-with-yas (backend)
(if (or (not company-mode/enable-yas) (...
Here is how completion in company works (I am simplifying a bit a more detailed description can be found in documentation of company-backends C-hvcompany-backendsRET.
You have a list of backends (completion engines) company should try to provide completion at point. Company tries each of this backend one after the another and the first one that returns any ...
This is what I created for myself, facing the same issue. It is from company-mode's Emacs Wiki page, but heavily extended:
(defun check-expansion ()
(if (looking-at "\\_>") t
(if (looking-at "\\.") t
(if (looking-at "->") t nil)))))
(defun do-yas-expand ()
Emacs's builtin completion functionality offers similar fuzzy matching (tho by default it's used for "do-so-am" rather than for "DoSoAm") and IIUC recent versions of company-mode do use this at least in some cases.
E.g. if you open an Elisp buffer using Emacs-24.4 and the latest company-mode, if you type (wi-sy company will pop up a completion menu showing ...
FYI, some modes open only one inferior processs. For example, run-python will open an inferior process only if there isn't already an inferior process running. What you suggested with run-python actually does what you want.
For other modes (Matlab?), you could use a function that unhooks itself, like so:
(defun run-python-once ()
You can set a default company-backends, then use hook to append different backends to different mode.
Here is a way I config in my emacs.
;; set default `company-backends'
'((company-files ; files & directory
company-keywords ; keywords
As @Jesse already pointed out, what you want here is the company-files backend. There are several different ways to use it:
Bind a key to call company-files directly.
Use command company-begin-backend. This prompts you for the backend to use, then offers completion candidates.
Use company-other-backend to rotate through the list of backends (see next item)...
You can set company-minimum-prefix-length to a desire value of your choice:
(setq company-minimum-prefix-length 2)
You can use the customize interface M-x customize and search for company in there using the search box. It will list relevant options related to the package. You can also search for a variable with C-h v or search for a command with C-h a, ...
You've configured company-mode to load after your init file is evaluated using the after-init-hook, but are then trying to modify company-backends right away.
That variable isn't defined until company-mode is loaded. You either need to just require company, or defer setting that variable using eval-after-load:
I had also a bad experience with company at the beginning, but in my setup I just put these lines.
(setq company-dabbrev-downcase 0)
(setq company-idle-delay 0)
The first variable is used to skip the downcase that company does to the variables I autocomplete, the second one I think you already have.
(defun tab-indent-or-complete ()
Here's the code that I'm using:
(global-set-key "\C-o" 'aya-open-line)
(defun aya-open-line ()
"Call `open-line', unless there are abbrevs or snippets at point.
In that case expand them. If there's a snippet expansion in progress,
move to the next field. Call `open-line' if nothing else applies."
With company-mode, you can use C-s to search from available candidates that it display. The search query is displayed in the modeline (not really easy to spot, I know. I filed an issue here).
If you want to use Helm for completion, consider using helm-company or ac-helm. Haven't tried with ac-helm, but with helm-company, you can directly bind it to a key to ...
I don't see a way built in to company-mode to do this, but you can add your own key binding to company-active-map.
As a quick experiment I took the company-show-doc-buffer implementation and simply removed the company--electric-do wrapper:
(defun my/company-show-doc-buffer ()
"Temporarily show the documentation buffer for the selection."
You have to run company-files for file completion. You can bind a different map for the files completion completion with
(define-key global-map (kbd "C-.") 'company-files)
Also make sure you have the company-files in company-backends (M-x > customize-group > company > company backends)
This issue is the result of a faulty interaction between overlays with before-string/after-string properties whose contents have a display property attached. It was been reported to Emacs as bug #19201, and since been fixed in Emacs. The fix will make it into the next release.
Meanwhile, you can work around this issue by disabling Flycheck's fringe ...
This can be solved by modifying company-transformers with the following code:
(push (apply-partially #'cl-remove-if
(or (string-match-p "[^\x00-\x7F]+" c)
(string-match-p "[0-9]+" c)
(if (equal major-mode "org")
company-mode has company-capf. So the easiest way is adding pcomplete-completions-at-point to completion-at-point-functions:
(defun my-org-mode-hook ()
(add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
(add-hook 'org-mode-hook #'my-org-mode-hook)
Make sure company-capf is in the list of company-backends.
Unless you invoke one of the completion commands directly (such as M-x company-complete-common), the completion maybe-happens and the popup is rendered in company-post-command.
It looks at the current command, sees if it satisfies the value of company-begin-commands, and calls company--perform.
The latter looks at the buffer contents, and checks whether ...
My complete setup for fixing this annoying default behavior is:
;;; Prevent suggestions from being triggered automatically. In particular,
;;; this makes it so that:
;;; - TAB will always complete the current selection.
;;; - RET will only complete the current selection if the user has explicitly
;;; interacted with Company.
;;; - SPC will ...
company-mode does not rebind C-n or C-p probably to minimize interference with normal editing commands. To cycle through options, Company uses up, down, M-n, and M-p by default.
Use C-h f company-mode to peruse the mode specific documentation for Company. It will show the available bindings for the company popup when it is active.
However if you do want C-...
irony-mode's author here.
So, For tiny projects that I might be working on, which are compiled
with a simple g++ foo.c -o foo, how should I put the compile files to
make irony-mode work?
If you don't have any flags you don't have to do anything. You give irony-mode some flags only so that it can parse your file. In your case, no flags are needed to ...
This is defined in company-active-map. You can unbind the return key in that map:
(define-key company-active-map (kbd "<return>") nil)
Note however that return and tab do different things when there are multiple candidates. Tab is bound to company-complete-common, while return is bound to company-complete-selection. If you unbind the return key then ...