cammil
cammil

Reputation: 9919

How do I check if emacs has a library installed?

I want to check whether pymacs has been installed.

Upvotes: 0

Views: 2092

Answers (3)

Stuart Hickinbottom
Stuart Hickinbottom

Reputation: 1360

Not sure if you're talking about ELPA packages, but I have the following definitions in my .emacs:

  (defun sh-elpa-ensure-package (name)
      "Make sure that a particular package is installed; if not then
  automatically download, compile and install it.

  This is primarily used by sh-elpa-require to allow deployment of
  the configuration to a new machine - packages will therefore be
  downloaded on that fresh machine (following installation they are
  automatically kept up to date by the package manager).

  Use this as follows:
  (sh-elpa-ensure-package 'org)"
      (if (not (package-installed-p name))
          (package-install name)))

    (defun sh-elpa-require (name)
      "A replacement for the standard Emacs 'require'
  function. This uses sh-elpa-require to download and install a
  package if necessary prior to using the standard 'require'
  function to import it. This is useful to allow the configuration
  to just 'sh-elpa-require' a package and not have to bother
  checking whether it has been installed yet."
      (sh-elpa-ensure-package name)
      (require name))

I can then include code such as the following in my .emacs to activate the package - if it's not already installed then this will download it from ELPA and byte-compile it before it is "required":

(sh-elpa-require 'pymacs)

If you're just talking about checking whether a package is installed from elisp, then you can also pick the bones of that out of the above snippet - see the (if (not (package-installed-p name)) bit.

Upvotes: 2

alinsoar
alinsoar

Reputation: 15793

There are many ways to do it.

  • type apropos, then pymacs. If it finds the symbols, it was loaded.

  • (require 'pymacs) -- if it does not return error, it was loaded

  • if you already loaded it, it called (provide 'pymacs), and the variable load-history keeps the symbols

There are still other ways to ckeck it.

Upvotes: 3

Nicolas Dudebout
Nicolas Dudebout

Reputation: 9262

M-x locate-library will tell you if emacs can find the library in its load-path. If it does not return anything you might need to edit your load-path first.

Upvotes: 6

Related Questions