我想使用脚本在移动到新计算机时自动安装所有软件包。
我写了这个脚本,emacs给了我Package ‘highlight-symbol-’ is unavailable
#! emacs -q --script
;;; load package module
(require 'package)
(dolist (url '(("melpa" . "https://melpa.org/packages/")
("melpa-stable" . "http://stable.melpa.org/packages/")
))
(add-to-list 'package-archives url t))
(package-initialize)
;;; read package list from `packages` file
(defvar *packages-list '("highlight-symbol" "monokai-theme"))
(unless package-archive-contents
(package-refresh-contents))
;;; install packages
(dolist (package *packages-list)
(if (package-installed-p (intern package))
(princ (format "%s already installed \n" package))
(progn
(princ (format "%s is installing \n" package))
(package-install package)
(princ (format "%s installed \n\n")))))
我尝试了什么:
emacs -q
并尝试进入 scratch 。 (package-install package)
仍有问题。DONT-SELECT
含义,所以我尝试了(package-install package nil)
和(package-install package "")
,但仍有问题。我该如何解决?我在这个剧本中犯了什么误解。 谢谢!
答案 0 :(得分:0)
对不起,伙计们,这是一个愚蠢的问题。
答案是package-install
接受符号,但字符串。
我将代码更改为(package-install (intern package)
,然后就可以了。