0

My dotemacsfile looks like the following.

(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/") t)
(package-initialize) ;load and activate packages, including auto-complete
(ac-config-default)
(global-auto-complete-mode t)

But when I run the above in a scratch buffer using M-x eval buffer, I get symbol's function definition is void : ac-config-default.

(The error is different from the error I get when I do emacs --init-debug test.R where the init file is in my home directory. I won't show that error in order to not confuse things.)

1

1 Answer 1

1

You probably just forgot to install the package that ac-config-default comes from. Run M-x list-packages, find the auto-complete package (use C-s to search), and install it.

From the extended discussion, it turns out that it wasn’t clear what the difference between installing and loading a package was. Installing a package means downloading it from the internet, decompressing it, and putting the files where Emacs can find them. Loading a package means that Emacs actually reads some or all of the files, so that you can use what’s in them.

Installing happens once, and is usually done by running list-packages and choosing which packages to install, while loading happens every time you start Emacs.

The information you added to your init file was setting up your desired package sources, so that you could install packages from the source you prefer, telling the package system to load any installed packages by calling package-initialize, followed by configuring the specific package you are interested in. These were all necessary, but you missed the important step of actually installing that package :).

14
  • Thank you. It says that the archive is melpa so I think that the add-to-list line should do that, right ? Atleast it says that at the link here in the answer by elethan. In fact, this is where I got the code in the first place. Your help is still appreciated. emacs.stackexchange.com/questions/18982/…
    – mark leeds
    Oct 21, 2021 at 6:03
  • What was left out of that answer was that at some point you have to actually install the package. Installing the package downloads it from the internet, unpacks it, and puts it where Emacs can find it. Unless you actually do that, your Emacs will not be able to use the package.
    – db48x
    Oct 21, 2021 at 6:33
  • 1
    Modifying your init file won’t help. You should open emacs, ignore the error you’re currently getting, run the command list-packages interactively (that is, type M-x then type list-packages and hit enter). This will download a list of packages from MEPLA, since that is your package source. Find auto-complete in this list of packages. Move your cursor down to that line and type i to mark it for installation. Feel free to mark any other packages you want as well. Finally, type x to execute these instructions. Emacs will download and install the marked packages.
    – db48x
    Oct 21, 2021 at 7:35
  • 1
    Yea, if @markleeds responds and says that this cleared up the problem, I’ll edit the answer to include it all. I don’t see much to indicate that it wouldn’t, though.
    – db48x
    Oct 21, 2021 at 17:23
  • 2
    This is in regard to db48x's suggestion to take out the two added lines, list the packages and install them using I. IT WORKED LIKE A CHARM !!! No errors when I did emacs --debug-init. So, I'm good now. Thanks to all but particularly db48x and NickD. It's really appreciated. I'm hopefully over the basic-intro hump and can progress in my emacs customization. The positive part of this was that I would have never figured out the whole melpa, list packages and installing thing on my own so asking was definitely necessary. Hopefully I can give this list a break for a good while. Thank you again.
    – mark leeds
    Oct 23, 2021 at 6:17

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.