2

I am a new to Emacs , i downloaded auto-complete , moved it to ~/.emacs.d/plugins/ then modified the .emacs file to look like :

(add-to-list 'load-path (file-name-as-directory
                     (expand-file-name "~/.emacs.d/plugins/auto-complete"))\
)

(require 'auto-complete)
(global-auto-complete-mode t)

(ac-config-default)
(custom-set-variables
;; 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.                           
'(menu-bar-mode nil)
'(package-archives (quote (("melpa" . "http://stable.melpa.org/packages/") ("g\
nu" . "http://elpa.gnu.org/packages/")))))
(custom-set-faces
;; 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.                           
)

when i restart emacs , it displays the following error :

Warning (initialization): An error occurred while loading `/Users/zeaksilva/.emacs':

File error: Cannot open load file, auto-complete

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.
Malabarba
  • 22,878
  • 6
  • 78
  • 163
Eddy
  • 21
  • 1
  • 1
    It is sufficient to do this `(add-to-list 'load-path "~/.emacs.d/plugins/")` instead of the first three lines. What's up with this trailing `\\` on line two? –  Nov 08 '14 at 21:37
  • 2
    @Eddy is there a reason you're installing manually, and not with Emacs's package manager? It's an easier way to manage it, especially with later updates. – zck Nov 08 '14 at 21:47
  • @zck ok . i`ve installed it via Emacs's package manager , but how do i activate it , when i try to type something no magic happens ? – Eddy Nov 08 '14 at 21:57
  • You have to actually call the function. If you want it to happen automatically, I recommend `company-mode`. – Sean Allred Nov 08 '14 at 22:06
  • FWIW - the question is duplicated at [S.O.](http://stackoverflow.com/q/26821686/729907). – Drew Nov 08 '14 at 22:31
  • How you use a library is a different question from how you load it. If you have a question about how to use `autocomplete` then please post a separate question for that. – Drew Nov 08 '14 at 22:50

2 Answers2

2

Repeating my response at S.O. -

Put (setq debug-on-error t) at the beginning of your init file. Or better yet, append --debug-init to the command line you use to invoke Emacs. That will open the debugger when the error occurs. But it seems that the file that has (provide 'autocomplete) in it, or that file's directory, is not in your load-path. When the debugger opens, use C-h v load-path, and see whether it is correct. If not, correct it.

In sum, to be loaded by require, the library needs to be provided, and its location needs to be in your load-path. That's all.

Drew
  • 75,699
  • 9
  • 109
  • 225
1

Try this:

(defconst additional-lisp-dir (expand-file-name "plugins" user-emacs-directory))
(add-to-list 'load-path additional-lisp-dir)
;; Add subdirs to load-path
(let ((default-directory additional-lisp-dir))
  (normal-top-level-add-subdirs-to-load-path))

This way you'll add only the top level directory and subdirs will be added automatically

Moreover, why do you install packages manually and not via package-list-packages?

igorepst
  • 141
  • 1
  • 7
  • FWIW - "Installing" a package by putting it in your `load-path` and using `require` is no more "manual" than is invoking `package-list-packages` and "installing" it using that UI. It's just a different manual method of loading. One can even argue that it is a simpler and more direct way to load (you tell Emacs to load it, and from where). `package.el` could be considered simpler, perhaps, if you are *not* going to load it but just rely on autoloads. But if you load it, you load it - nothing magical, and nothing non-manual, about either approach. – Drew Nov 08 '14 at 22:46
  • Obviously, your comment is right, Drew. For that I've included the code in my answer. I'm actually use both things: packages installed in 'elpa' dir. + my config in 'lisp' dir (split from init.el) – igorepst Nov 09 '14 at 07:27
  • Ah, now I see, that the title of this question was changed significantly by Drew, so his answer suits now better – igorepst Nov 09 '14 at 12:27