我对emacs相对较新,我一直在尝试设置.emacs文件,我可以轻松地从一台机器移植到另一台机器,而无需每次都手动重新安装所有软件包。为了实现这一点,我使用了this post的解决方案,直到现在它已成功运行。这是我的代码:
;; First, install use-package:
(package-initialize)
(require 'package)
(add-to-list 'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(dolist (package '(use-package))
(unless (package-installed-p package)
(package-install package)))
;; Then, install each of the following packages, if necessary:
(use-package paredit :ensure t)
(dolist (package '(auto-complete
auto-complete-c-headers
yasnippet
))
(unless (package-installed-p package)
(package-install package))
(require package))
在上面的代码中,如果删除对auto-complete-c-headers
的引用,一切都会完美无缺。如果我添加它(如上面的代码段),emacs将无法使用我的.emacs
文件。正在运行emacs --debug-init
会给我以下内容:
Debugger entered--Lisp error: (error "Package `auto-complete-c-headers-' is unavailable")
signal(error ("Package `auto-complete-c-headers-' is unavailable"))
error("Package `%s-%s' is unavailable" auto-complete-c-headers "")
package-compute-transaction(nil ((auto-complete-c-headers)))
package-install(auto-complete-c-headers)
(if (package-installed-p package) nil (package-install package))
(while --dolist-tail-- (setq package (car --dolist-tail--)) (if (package-installed-p package) nil (package-install package)) (require package) (setq --dolist-tail-- (cdr --dolist-tail--)))
(let ((--dolist-tail-- (quote (auto-complete auto-complete-c-headers yasnippet))) package) (while --dolist-tail-- (setq package (car --dolist-tail--)) (if (package-installed-p package) nil (package-install package)) (require package) (setq --dolist-tail-- (cdr --dolist-tail--))))
eval-buffer(#<buffer *load*> nil "/home/morane/.emacs" nil t) ; Reading at buffer position 2236
load-with-code-conversion("/home/morane/.emacs" "/home/morane/.emacs" t t)
load("~/.emacs" t t)
#[0 "\205\262
我真的不明白发生了什么。我已经用M-x package-install
检查了回购,它就在那里并且可用。有什么想法吗?为了您的信息,我在Ubuntu 16.04.3上运行emacs 24.5.1。另外,我安装了use-package
。