Based on this reply, my code has the following function that installs its dependencies:
(defun literef-install-packages()
"Install any missing packages. The code is taken from
`https://stackoverflow.com/a/10093312/2725810'."
(setq package-list '(org org-ref pdf-tools smooth-scrolling company))
; list the repositories containing them
(setq package-archives '(("elpa" . "http://tromey.com/elpa/")
("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(dolist (package package-list)
(unless (package-installed-p package)
(when
(yes-or-no-p (concat
"The package " (symbol-name package)
" is not installed. Install it? "))
(package-install package)
(when (eq package 'pdf-tools) (pdf-tools-install))))))
The problems is that Emacs comes with built-in org
, which makes it impossible to install the version from MELPA by using (package-install 'org)
, since the package is "already installed". How do I fix my code to work for org
as well as it works for the other packages?
I looked through package.el
to find a way to get to the list of available packages. The closest I found was the variable package-alist
. However, it only contains 20 entries, so it is not what I am looking for.
In addition, I do not know how to technically install a package with a specified version. Namely (package-install 'org)
says that the package is already installed, but (package-install 'org-9.1.14)
says that such a package is not available, although I do see org
version 9.1.14
in the package manager and am able to install it from there.
The other idea is to uninstall the built-in org
first so as to be able to use (package-install 'org)
to install the latest version. However, I do not know what to supply as an argument to (package-delete)
.
UPDATE: I have posted my solution here.