在 Emacs 中更新包 [英] Updating packages in Emacs

查看:42
本文介绍了在 Emacs 中更新包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下软件包设置(不确定是否有更好的推荐):

I have the following setup for packages (not sure if there is a better recommended one):

(require 'package)
(setq package-archives '(("ELPA" . "http://tromey.com/elpa/") 
                          ("gnu" . "http://elpa.gnu.org/packages/")
                          ("marmalade" . "http://marmalade-repo.org/packages/")))

; Apparently needed for the package auto-complete (why?)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.milkbox.net/packages/") t)

(package-initialize)
(setq url-http-attempt-keepalives nil)

我有三个关于软件包安装和更新的问题.

I have three questions related to the installation and updating of packages.

Q1. 有没有办法更新可用包(和最新版本)列表并更新特定包?

Q1. Is there a way to update the list of available packages (and most recent versions) and update a specific package?

问题 2 以下软件包来源有什么区别?:

Q.2 What is the difference between the following package sources?:

  • ELPA,
  • GNU
  • 果酱
  • melpa

问题 3 将它们添加到 package-archives 的顺序是否重要?

Q.3 Does it matter the order in which they are added to package-archives?

推荐答案

  1. 为了自动更新包列表,只有在没有包列表的情况下,使用如下:

(when (not package-archive-contents)
    (package-refresh-contents))

为了更新所有已安装的包,输入 package-list-packages,这将带你到 *Packages* 缓冲区(同时更新包列表),然后键入 U x.

In order to update all installed packages, type package-list-packages, which will take you to the *Packages* buffer (and also update the list of packages), and then type U x.

package-refresh-contents 无条件地尝试从您添加到 package-archives 的所有存储库中下载包列表;如果您已经下载了包列表,package-archive-contents 为非 nil.

package-refresh-contents unconditionally tries to download a package list from all repos you've added to package-archives; package-archive-contents is non nil if you have already downloaded the package list.

ELPA 是原始版本.我不认为它真的得到维护了,但我不确定.我不使用它.

ELPA is the original. I don't think it's really maintained anymore, but I'm not sure. I don't use it.

GNU 是官方的".它与 Emacs 一起维护,这意味着事情应该总是有效,但更新和新包不会经常出现.

GNU is "official". It's maintained along with Emacs, which means things should always work but updates and new packages don't come very often.

Marmalade 基本上是一个可以上传完整包的网站,它会被添加到果酱仓库中.您不只是提交指向包上游的链接,它也不会完全自动化包的创建.我认为这是正确的事情,因为您不一定要跟踪上游.不幸的是,它已经有一段时间没有维护了,但最近有人接管了它,所以它应该会在某个时候恢复并变得更好.

Marmalade is basically a website where you can upload a complete package, and it will be added to the marmalade repo. You don't just submit a link to the package's upstream, and it doesn't quite automate the creation of the package completely. I think this is the Right Thing, because you don't necessarily want to track upstream. Unfortunately, it has been unmaintained for a while, but someone recently took it over so it should be back and better at some point.

Melpa 需要一个 URL,例如EmacsWiki lisp 区域或 github 存储库,并从中自动构建包.因此,它通常最多落后于它所跟踪的一天.虽然它跟踪上游,但我在实践中从未遇到过问题,这就是我的大部分包裹的来源.还有 Melpa Stable,它与 Melpa 类似,但抓取上游 repo 的标记修订版而不是最新修订版.Melpa stable 的包比 Melpa 少.

Melpa takes a URL to e.g. the EmacsWiki lisp area or a github repo, and builds a package automatically from it. Thus it is usually at most a day behind whatever it is tracking. Although it tracks upstream, I've never had a problem in practice, and this is where most of my packages are from. There is also Melpa Stable, which is like Melpa but grabs tagged revisions of the upstream repo instead of the latest revision. Melpa stable has fewer packages than Melpa.

Org mode 有自己的 package.el 存储库(http://orgmode.org/elpa/).

Org mode has its own package.el repo (http://orgmode.org/elpa/).

所有包存储库的工作方式都相同,您只需将它们添加到您的 package-archives 中即可.

All of the package repos work the same, you just add them to your package-archives.

这里有一个更深入的关于这个主题的博文,我基本同意.

Here's a more in-depth blog post about this subject, which I mostly agree with.

我不确定,但我认为如果一个包在不同的存储库中重复,则存储库在 package-archives 中出现的顺序决定了优先级.我不知道更高的优先级是在列表的开头还是结尾.

I'm not sure, but I think if a package is duplicated in different repos, the order the repos appear in in package-archives determines precedence. I don't know if higher precedence is at the beginning or end of the list.

更新:在 Emacs 25 中,有一个变量 package-archive-priorities 可用于确定包存储库的优先级(例如,更喜欢 ELPA 而不是 MELPA).

Update: In Emacs 25, there is a variable package-archive-priorities that you can use to prioritize your package repos (e.g. prefer ELPA over MELPA).

<小时>

这里是我的init.el的相关部分,如果你有兴趣:


Here is the relevant section of my init.el, if you're interested:

(setq jpk-packages
      '(
        ac-dabbrev
        ...
        yasnippet
        ))

(package-initialize)
(add-to-list 'package-archives
             '("melpa" . "http://melpa.org/packages/"))
(add-to-list 'package-archives
             '("org" . "http://orgmode.org/elpa/"))

;; install any packages in jpk-packages, if they are not installed already
(let ((refreshed nil))
  (when (not package-archive-contents)
    (package-refresh-contents)
    (setq refreshed t))
  (dolist (pkg jpk-packages)
    (when (and (not (package-installed-p pkg))
             (assoc pkg package-archive-contents))
      (unless refreshed
        (package-refresh-contents)
        (setq refreshed t))
      (package-install pkg))))

(defun package-list-unaccounted-packages ()
  "Like `package-list-packages', but shows only the packages that
  are installed and are not in `jpk-packages'.  Useful for
  cleaning out unwanted packages."
  (interactive)
  (package-show-package-list
   (remove-if-not (lambda (x) (and (not (memq x jpk-packages))
                            (not (package-built-in-p x))
                            (package-installed-p x)))
                  (mapcar 'car package-archive-contents))))

这篇关于在 Emacs 中更新包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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