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.
  • 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? – rekado Nov 8 '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 8 '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 8 '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 8 '14 at 22:06
  • FWIW - the question is duplicated at S.O.. – Drew Nov 8 '14 at 22:31
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.

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?

  • 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 8 '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 9 '14 at 7:27
  • Ah, now I see, that the title of this question was changed significantly by Drew, so his answer suits now better – igorepst Nov 9 '14 at 12:27

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.