使用 MELPA 自动安装 emacs 包 [英] Auto install emacs packages with MELPA

查看:29
本文介绍了使用 MELPA 自动安装 emacs 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 init.el 文件中声明我想在 emacs 中使用的所有包.我想知道是否可以加载丢失的包,例如启动 emacs 时 MELPA 没有通过列表和标记我要安装的?

I want to declare all packages that I want to use in emacs in a init.el file. I wonder if its possible to load the missing packages with e.g. MELPA when I startup emacs without going through the list and mark the ones I want to install?

推荐答案

新答案:

虽然我的原始答案仍然有效,但我现在使用Jordon 建议的方法.use-package 是用于整理 Emacs 配置的绝佳工具.事实上,当我写我的原始答案时,我已经在使用它来进行干净的包加载.

New answer:

While my original answer is still valid, I now use the method suggested by Jordon. use-package is a fantastic tool for tidy Emacs configurations. In fact, I was already using it for clean package loading when I wrote my original answer.

当时忽略了一路看其底部README,因此没有意识到它也可以处理包安装:

At that time, I neglected to read all the way to the bottom of its README, and therefore didn't realize that it could handle package installation as well:

您可以使用 use-package 从 ELPA 中通过 package.el 加载包.如果您在多台机器之间共享您的 .emacs,这将特别有用;相关的软件包将在放入您的 .emacs 后自动下载.如果包不存在,:ensure 键将自动安装包:

For package.el users

You can use use-package to load packages from ELPA with package.el. This is particularly useful if you share your .emacs between several machines; the relevant packages will download automatically once placed in your .emacs. The :ensure key will install the package automatically if it is not already present:

(use-package tex-site
  :ensure auctex)

加载 package.el 并初始化我的包存储库后,我的配置包含

After loading package.el and initializing my package repositories, my configuration contains

(if (not (package-installed-p 'use-package))
    (progn
      (package-refresh-contents)
      (package-install 'use-package)))

(require 'use-package)

以及随后的许多像这样的片段:

and subsequently many snippets like this:

;;; Expand-region
(use-package expand-region
  :ensure expand-region
  :bind ("C-=" . er/expand-region))

如果您觉得这些信息有用,请给 Jordon 点赞.

If you find this information useful, please give Jordon an upvote.

看看 CaskPallet,共同解决这个问题.

Have a look at Cask and Pallet, which work together to solve this problem.

来自木桶网站:

Cask for Emacs 就像 Bundler 之于 Ruby.它旨在使 Emacs 中的 ELPA 依赖管理无痛(尽可能无痛).这包括您本地的 Emacs 安装和 Emacs 包开发.

Cask for Emacs is what Bundler is to Ruby. It aims to make ELPA dependency management in Emacs painless (as painless as it can be). This includes both your local Emacs installation and Emacs package development.

安装 Cask 之后,您需要在 Emacs 配置中添加如下内容:

After installing Cask, you'll need to add something like this to your Emacs configuration:

(require 'cask)
(cask-initialize)

Cask 为 elisp 依赖项定义了特定于域的语言.要安装软件包,您需要如此处概述的内容:

Cask defines a doman-specific language for elisp dependencies. For installing packages, you'll need something like what is outlined here:

(source melpa)

(depends-on "auto-complete")
(depends-on "dash")
(depends-on "f")
(depends-on "flycheck")
(depends-on "helm")
(depends-on "magit")
(depends-on "popup")
(depends-on "projectile")
(depends-on "s")
(depends-on "smartparens")
(depends-on "yasnippet")

请注意,这不会进入您的 Emacs 配置文件,而是进入 ~/.emacs.d/Cask.

Note that this does not go into your Emacs config file, but rather into ~/.emacs.d/Cask.

Pallet 使用交互安装的软件包更新 Cask 文件,例如通过M-x package-list-packages,这样你就不用手动维护上面的文件了.

Pallet updates the Cask file with packages installed interactively, e.g. via M-x package-list-packages, so you don't have to manually maintain the above file.

这篇关于使用 MELPA 自动安装 emacs 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆