简体   繁体   English

有没有办法从命令行安装ELPA包?

[英]Is there a way to install ELPA packages from command line?

I'm interested in standardizing the emacs configurations that a few of us use (~5 people). 我有兴趣标准化我们几个人使用的emacs配置(~5个人)。

Is there a way to install ELPA packages from lisp functions that can be included in a script if we know the set of packages we want? 有没有办法从lisp函数安装ELPA包,如果我们知道我们想要的包集合,可以包含在脚本中? All I can find is how to call up list-packages and install individual packages graphically. 我能找到的就是如何调用list-packages并以图形方式安装各个包。

What you need is to use package-install function, like: 你需要的是使用package-install功能,如:

(mapc 'package-install install-list)

the install-list variable should contain a list of names of packages that you want to install. install-list变量应包含要安装的软件包的名称列表。

Another thing you can do it make your own package that depends on the other packages that you want installed. 您可以做的另一件事是创建自己的包,这取决于您要安装的其他包。 Then install that package. 然后安装该包。

Packages can be installed from file with: 可以从文件安装包:

Mx package-install-from-file

or you can make your own package archive with the package in, you can use elpakit to do that. 或者您可以使用包制作自己的包存档,您可以使用elpakit来执行此操作。

You can also do this from the command line: 您也可以从命令行执行此操作:

emacs -e "(progn (package-initialize)(package-install 'packagename))"

to install from the operating system command line if you wish. 如果您愿意,可以从操作系统命令行安装。

You may also want to take a look at cask . 您可能还想看看木桶 It allows you to declare the packages you want to install in file named Cask using a DSL described here . 它允许您使用此处描述的DSL声明要在名为Cask文件中安装的软件包。 Then from the command line go to the directory and run cask . 然后从命令行转到目录并运行cask It will install all the packages declared in the Cask file. 它将安装Cask文件中声明的所有包。

In you init file you will need to add the following lines to use the packages installed by cask. 在init文件中,您需要添加以下行以使用cask安装的软件包。

(require 'cask "~/.cask/cask.el")
(cask-initialize)

In addition you can get the list of already installed ELPA packages by 此外,您还可以获取已安装的ELPA包的列表

(defun eab/print-0 (body)
  "Insert value of body in current-buffer."
  (let ((print-length nil)
        (eval-expression-print-length nil))
    (prin1 `,body (current-buffer))))

(defun eab/package-installed ()
  "Get the list of ELPA installed packages."
  (mapcar (lambda (x) (car x)) package-alist))

(eab/print-0 (eab/package-installed))

and the same for el-get packages 和el-get包一样

(defun eab/el-get-installed ()
  "Get the list of el-get installed packages."
  (mapcar 'intern
      (el-get-list-package-names-with-status "installed")))

(eab/print-0 (eab/el-get-installed))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM