0

我只是在尝试 emacs(来自 vim)。

$  emacs --version
GNU Emacs 27.2
Copyright (C) 2021 Free Software Foundation, Inc.
GNU Emacs comes with ABSOLUTELY NO WARRANTY.
You may redistribute copies of GNU Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

$ cat ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
;; Comment/uncomment this line to enable MELPA Stable if desired.  See `package-archive-priorities`
;; and `package-pinned-packages`. Most users will not need or want to do this.
;;(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(package-initialize)
(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.
 )

我已经运行M-x package-refresh-contents了多次,但仍然没有列出许多我想安装的软件包。例如,去模式

尝试安装 go-mode

知道我在哪里搞砸了吗?谢谢!

编辑

我刚刚尝试了 spacemacs,我想要的包出现在列表中......

4

2 回答 2

1
于 2021-09-05T18:50:40.100 回答
1

根据您的描述,似乎MELPA根本没有加载软件包。
所以,首先,检查什么C-h v package-archives输出。它是否在返回的列表中输出“melpa”?

您也可以运行并查看列出的结果中M-x package-list-packages是否有任何存档包。melpa

在我的配置中,我以这种方式明确设置包档案:

(require 'package)

(setq package-archives
      '(("gnu" . "https://elpa.gnu.org/packages/")
        ("gnu-devel" . "https://elpa.gnu.org/devel/")
        ("nongnu" . "https://elpa.nongnu.org/nongnu/")
        ("melpa" . "https://melpa.org/packages/")))

此外,由于Emacs 27.1 “不再需要在您的 init 文件中调用'package-initialize' ” 。

因此,您应该能够安全地删除(package-initialize)call 或有条件地使用它,例如:

(when (< emacs-major-version 27)
  (package-initialize))
于 2021-09-05T10:50:31.527 回答