简体   繁体   English

如何更改emacs软件包存储库?

[英]How to change the emacs package repository?

I use Emacs 24.3.1 on a Ubuntu 14.4. 我在Ubuntu 14.4上使用Emacs 24.3.1。 I'd like the list-packages command to list packages from the MELPA depository. 我想用list-packages命令列出MELPA存放处的软件包。 I have followed the instructions here and here , to no avail. 我已按照此处此处的指示进行操作,但无济于事。 Specifically, following the advice given in the first link I added the following lines to my ~./emacs file: 具体来说,按照第一个链接中的建议,我在〜。/ emacs文件中添加了以下几行:

(when (>= emacs-major-version 24)
  (require 'package)
  (package-initialize)
  (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
  )

and restarted my emacs. 然后重启我的emacs。 This didn't have any effect, so I deleted the lines above and, following the advice given in the second link, added the following lines to my ~/.emacs file: 这没有任何效果,因此我删除了上面的行,并按照第二个链接中的建议将以下行添加到了我的〜/ .emacs文件中:

(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "https://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.milkbox.net/packages/")))

I restarted my emacs, but this had no effect either. 我重新启动了emacs,但这也没有任何效果。

The reason I think that these attempts had no effect is that after each attempt I listed the available packages using the list-package command and did not find the package highlight-chars.el which I am interested in and which appears on the list at the MELPA website . 我认为这些尝试没有效果的原因是,每次尝试后,我都使用list-package命令列出了可用的软件包,但没有找到我感兴趣的,并出现在列表中列表中 Highlight-chars.el软件包。 MELPA网站

How can I instruct the list-packages command to search the MELPA depository? 如何指示list-packages命令搜索MELPA存放处?

The first thing you should check after restarting is the value of the variable in question. 重新启动后,您应检查的第一件事是相关变量

Ch v package-archives RET Ch v package-archives RET

Whether or not it has the value you've tried to set is what's of primary interest. 它是否具有您尝试设置的值是首要关注的问题。

If it doesn't, then presumably something else in your config is setting a conflicting value. 如果不是,则可能是您配置中的其他内容正在设置冲突值。

I would hazard a guess that you have the package-archives variable customized , and that the stored custom value is clobbering the value you're setting with setq . 我可能会猜测您已对package-archives变量进行了自定义 ,并且所存储的自定义值正在破坏您使用setq设置的值。

For instance, the following init file would have the effect described: 例如,以下初始化文件将具有描述的效果:

(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
                         ("marmalade" . "https://marmalade-repo.org/packages/")
                         ("melpa" . "http://melpa.milkbox.net/packages/")))

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-archives (quote (("gnu" . "http://elpa.gnu.org/packages/")))))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

Those custom-set-* forms could also be in a separate file, and therefore less obvious. 这些custom-set-*表单也可以放在单独的文件中,因此不太明显。

Try Mx customize-option RET package-archives RET 尝试使用Mx customize-option RET package-archives RET

Select "Revert" and "Erase Customizations" to remove any value saved via this interface. 选择“还原”和“删除自定义”以删除通过此界面保存的所有值。

I'll speculate that the fact that Emacs' default initialisation of the package system happens after evaluating your init file may also be a factor here. 我推测,Emacs对软件包系统的默认初始化是在评估您的初始化文件之后发生的事实,这也可能是一个因素。 People often recommend calling (package-initialize) in your init file but leave out the information that you want to have (setq package-enable-at-startup nil) in tandem with that, to prevent the initialisation happening twice. 人们通常建议在您的init文件中调用(package-initialize) ,但(setq package-enable-at-startup nil)要保留您想要的信息(setq package-enable-at-startup nil) ,以防止两次初始化。 If that second initialisation occurs after the package-archives variable has changed again via customization, it might cause additional impediments to the system working the way you had wanted it to. 如果第二次初始化发生在package-archives变量通过自定义再次更改后,则可能会对系统产生其他阻碍,如您所愿。

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

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