8

I am using company-mode for completion purposes. But somehow, some package always draws in auto-complete as well, which collides with company-mode, since both offer a popup with completion candidates. I want to blacklist auto-complete, since I do not need it. How can I do that? I know there is a variable package-pinned-package, but I cannot see how to blacklist a package — maybe by using an invalid archive?

  • 1
    Note that there is no collision per se. For autocomplete-mode to be a problem, it must be enabled first, same goes for company-mode. – wasamasa Feb 10 '16 at 9:47
  • For some reason, it gets enabled without me doing any customizations. – Arne Feb 10 '16 at 10:05
  • If it is a requirement of another package then it has to be installed, but it should be possible to not have autocomplete be active in any buffer where company-mode is active. Perhaps you need to manually disable autocomplete in the *mode-hook of any affected major modes? – Mark Aufflick Feb 10 '16 at 11:41
  • 1
    I suggest you to find out what does. Either it's you (and something in your init file, a possibility that has become a lot more probable since the acceptance of starter kits) or another package (which is a bug). Both bisection and searching your ~/.emacs.d for something along the lines of (auto-complete-mode) would work. – wasamasa Feb 10 '16 at 11:47
  • 1
    Packages generally shouldn't enable auto-complete-mode for you (save some very specific circumstances). If you're 100%sure that you're not enabling it yourself, I suggest you file an issue in that package reporting this. – Malabarba Feb 10 '16 at 13:13
7

I don't know how to blacklist the installation of a package. But it's easy to prevent it from loading. If you put (provide 'auto-complete) in your init file, then any package that tries to load auto-complete will be told that it's already loaded.

(More precisely, this takes care of libraries that load auto-complete in the normal way, with require. If there's any code that uses load directly (which would be unusual), you need to put this in a separate file called auto-complete.el.)

Of course, if the package requires auto-complete, it's probably because it'll use it. But maybe a package only declares autocomplete sources and has useful functionality otherwise. So you can make the part that you don't want a no-op. Depending on what the package does, you may need other similar definitions.

(provide 'auto-complete)
(defmacro ac-define-source (&rest ignored)
  "A no-op since I blacklist `auto-complete'.")
7

What @Gilles wrote is the general answer I would have given also.

But note that using provide does not prevent code from loading the package. It prevents code from loading the package only by require. If code uses load, load-library, load-file etc. then this trick has no effect.

If you really need to prevent code from loading a given library, a better approach is to provide a proxy library that gets loaded in its stead. For example, in a directory that comes earlier in your load-path, add a phony auto-complete.el that does nothing except (provide 'auto-complete).

That way, whenever code tries to load the library using load or load-library your proxy library will be loaded instead of the one you are avoiding.

However, if code uses load-file and provides the absolute address of the file of the library you are trying to avoid, then that file will be loaded. I don't see a good solution for that case (except to remove or replace that file).

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.