emacs - 错误: package. el尚未初始化

标签 emacs elisp

我正在组织.emacs文件,以更好地跟踪我要添加到它的所有内容。

这样做时,我遇到了标题中描述的错误,但我不确定为什么

这是我的.emacs文件:(注释的负载仅供我引用)

;;;; Emacs config file

;; convenience function for loading multiple libs in a single call
(defun load-libs (&rest libs) 
  (dolist (lib libs) 
    (load-library lib)))

;; path to custom libraries as well as the libraries themselves
(add-to-list 'load-path "~/.emacs.d/lisp/")
(load-libs "convenience" "editor-behaviour")

;; Add support for the package manager
(require 'package)
;; Add various package archives
(add-to-list 'package-archives
         '("marmalade" . "http://marmalade-repo.org/packages/")
         '("melpa" . "http://melpa.milkbox.net/packages/"))

;; Installs packages if they aren't already
(package-refresh-and-install        ; from convenience.el
 'scala-mode2 'sbt-mode 'haskell-mode 'geiser 'auto-complete 'ac-geiser 'cider)

;; Initialise packages
(package-initialize)

;; libs dependent on the packages being initialized go here
(load-library "autocomplete-config")

;; Enable Haskell indentation
(custom-set-variables 
 '(haskell-mode-hook '(turn-on-haskell-indentation)))

运行emacs .emacs --debug-init给我以下输出:
Debugger entered--Lisp error: (error "package.el is not yet initialized!")
  signal(error ("package.el is not yet initialized!"))
  error("package.el is not yet initialized!")
  package-installed-p(scala-mode2)
  (if (package-installed-p pkg) nil (package-refresh-contents) (package-install pkg))
  (while --dolist-tail-- (setq pkg (car --dolist-tail--)) (if (package-installed-p pkg) $
  (let ((--dolist-tail-- pkgs) pkg) (while --dolist-tail-- (setq pkg (car --dolist-tail-$
  package-refresh-and-install(scala-mode2 sbt-mode haskell-mode geiser auto-complete ac-$
  eval-buffer(#<buffer  *load*> nil "/Users/ElectricCoffee/.emacs" nil t)  ; Reading at $
  load-with-code-conversion("/Users/ElectricCoffee/.emacs" "/Users/ElectricCoffee/.emacs$
  load("~/.emacs" t t)
  #[0 "^H\205\262^@     \306=\203^Q^@\307^H\310Q\202;^@ \311=\204^^^@\307^H\312Q\202;^@\$
  command-line()
  normal-top-level()

根据我的理解,这表明它与convenience.el有关,但其中仅此而已:
(defun package-refresh-and-install (&rest pkgs)
  "Utility function to refresh package contents and install several packages at once"
  (dolist (pkg pkgs)
    (unless (package-installed-p pkg)
      (package-refresh-contents)
      (package-install pkg))))

所以我不确定在哪里出错了...有什么帮助吗?

最佳答案

您需要先调用package-initialize,然后再调用package-refresh-and-install

关于emacs - 错误: package. el尚未初始化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26116882/

相关文章:

windows - Linux 和 Windows 下 emacs 中 webdev 的可靠配置?

emacs - 全局覆盖 emacs 键绑定(bind)

emacs - 如何在 emacs 中 grep 光标下的当前单词?

emacs - Elisp 中的高阶函数

macos - -bash : emacs: command not found (after updating mac to CATALINA)

emacs - 使用 let-bound 变量穿透 `set-process-sentinel` 层次结构

emacs - 如何将 org-directory 下的 .org 文件添加到议程

Emacs 的 PHP 语法高亮器

emacs - Emacs Lisp 中的 GNU+Linux 构建框架?

emacs - 从 emacs 回答/询问 SO 问题。?