5
votes

I am running the most recent version of auto-complete in elpa with the new stable release of Emacs (24.3) in Linux. I have the following setup on my Emacs init file.

(add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
(require 'auto-complete-config)
(setq-default ac-sources
          '(
        ac-source-filename
        ac-source-abbrev 
        ac-source-dictionary
        ac-source-words-in-same-mode-buffers))
(ac-config-default)

If I start typing: /home/james/.em in a buffer (e.g. a Python buffer) I would expect auto-complete to suggest:

.emacs
.emacs.d

but it does not show anything. The same thing happens with other files.

Sometimes I do see suggestions and/or the pop-up menu shows up, but other times it doesn't.

Any thoughts why?

1
Where are you typing /home/james/.em? I don't think autocomplete works in the minibuffer. Maybe you are looking for M-x ido-mode?Ista
Thanks @Ista. It's on a python buffer (although I tried other buffers, such as a buffer with .emacs). I updated the OPAmelio Vazquez-Reina
did you looked for ido-mode?Arpit Rawat
@ArpitRawat I use helm (formerly known as anything) instead. But why does that matter?Amelio Vazquez-Reina

1 Answers

4
votes

ac-config-default sets a list of sources that does not include ac-source-filename. By calling this function after setq-default ac-sources you are resetting them back to the defaults. The auto-complete manual suggests setting mode-hooks to set up the desired sources for specific modes. The example from the manual is

(defun my-ac-emacs-lisp-mode ()
  (setq ac-sources '(ac-source-symbols ac-source-words-in-same-mode-buffers)))

(add-hook 'emacs-lisp-mode-hook 'my-ac-emacs-lisp-mode)

Adapting this to python-mode should be easy enough. Alternatively you can globally override the settings set by ac-config-default by calling it first, i.e.

(require 'auto-complete-config)
(ac-config-default)
(setq-default ac-sources
          '(
        ac-source-filename
        ac-source-abbrev 
        ac-source-dictionary
        ac-source-words-in-same-mode-buffers))

That way setq-default ac-sources will override the sources set by ac-config-default rather than the other way around.