如何检查emacs是否安装了库?

时间:2012-07-17 14:26:33

标签: emacs

我想检查是否已安装pymacs。

3 个答案:

答案 0 :(得分:5)

M-x locate-library会告诉您emacs是否可以在load-path中找到该库。如果它没有返回任何内容,您可能需要先修改load-path

答案 1 :(得分:2)

有很多方法可以做到。

  • 键入apropos,然后键入pymacs。如果找到符号,则表示已加载。

  • (需要'pymacs) - 如果没有返回错误,则加载

  • 如果您已加载它,则调用(提供'pymacs),变量load-history保留符号

还有其他方法可以解决这个问题。

答案 2 :(得分:1)

不确定您是否在讨论ELPA包,但我的.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))

然后我可以在我的.emacs中包含以下代码来激活软件包 - 如果它尚未安装,那么这将从ELPA下载并在“必需”之前对其进行字节编译:

(sh-elpa-require 'pymacs)

如果您只是在讨论检查是否从elisp安装了一个软件包,那么您也可以从上面的代码段中选择一个软件包 - 请参阅(if (not (package-installed-p name))位。