Let ensure-package-installation return nil on failure

This commit is contained in:
Gerard Vermeulen 2022-04-28 06:55:41 +02:00
parent 4cec3cf570
commit d02c59fe1e

View File

@ -546,14 +546,17 @@ the contents of packages and allows to update packages to the latest version.
(unless noninteractive
(package-install-selected-packages))
(defun ensure-packages-installed (&rest packages)
"Install installation of all packages in PACKAGES."
(unless noninteractive
(defun ensure-package-installation (&rest packages)
"Ensure installation of all packages in PACKAGES."
(let ((ok t))
(dolist (package packages)
(unless (package-installed-p package)
(package-install package))
(if (package-installed-p package)
(when (bound-and-true-p package-selected-packages)
(cl-pushnew package package-selected-packages)))))
(cl-pushnew package package-selected-packages))
(setq ok nil)))
ok))
#+end_src
* [[info:emacs#Help][Help (info)]]
@ -1353,9 +1356,8 @@ LaTeX =BiBTeX= dialect for backwards compatibility. Listing
#+caption: Configure =math-preview=.
#+name: lst:configure-math-preview
#+begin_src emacs-lisp
(ensure-packages-installed
'math-preview ; display LaTeX math with MathJax
)
(when (ensure-package-installation
'math-preview) ; display LaTeX math with MathJax
(with-eval-after-load 'math-preview
(let ((command (executable-find "~/node_modules/.bin/math-preview")))
@ -1370,7 +1372,7 @@ LaTeX =BiBTeX= dialect for backwards compatibility. Listing
(shell-command-with-exit-code
"npm" "install" "git+https://gitlab.com/matsievskiysv/math-preview.git")
(if (= 0 exit-code) (message "%s" (string-trim output))
(error "%s" (string-trim output)))))))
(error "%s" (string-trim output))))))))
#+end_src
*** TODO Improve the AUCTeX configuration slowly
@ -2943,10 +2945,9 @@ for how to handle ~company-backends~ as a local variable in listing
#+caption: Configure =anaconda= with =company= for Python.
#+name: lst:configure-anaconda+company-for-python
#+begin_src emacs-lisp
(ensure-packages-installed
(when (ensure-package-installation
'anaconda-mode ; strangles python-mode
'company-anaconda ; complete anything in anaconda-mode
)
'company-anaconda) ; complete anything in anaconda-mode
(with-eval-after-load 'python
(with-eval-after-load 'company
@ -2970,7 +2971,7 @@ for how to handle ~company-backends~ as a local variable in listing
(delq 'company-capf
(mapcar #'identity company-backends)))))
(anaconda-eldoc-mode
(if (file-remote-p default-directory) -1 1)))))))
(if (file-remote-p default-directory) -1 1))))))))
#+end_src
#+caption[Define =my-toggle-anaconda-mode= for Python]:
@ -3085,15 +3086,14 @@ library. It is a requirement of several packages in this Emacs setup ([[https:/
#+caption: Configure =ws-butler=.
#+name: lst:configure-ws-butler
#+begin_src emacs-lisp
(ensure-packages-installed
'ws-butler ; remove trailing whitespace
)
(when (ensure-package-installation
'ws-butler) ; remove trailing whitespace
(when (require 'ws-butler nil 'noerror)
(custom-set-variables
'(ws-butler-keep-whitespace-before-point nil))
(add-hook 'prog-mode-hook #'ws-butler-mode)
(add-hook 'text-mode-hook #'ws-butler-mode))
(add-hook 'text-mode-hook #'ws-butler-mode)))
#+end_src
** [[https://countvajhula.com/2021/09/25/the-animated-guide-to-symex/][Structural editing]]
@ -3336,9 +3336,8 @@ and names in buffers for debugging.
#+caption: Enable =rainbow-mode=.
#+name: lst:enable-rainbow-mode
#+begin_src emacs-lisp
(ensure-packages-installed
'rainbow-mode ; set background color to color string
)
(when (ensure-package-installation
'rainbow-mode) ; set background color to color string
(when (fboundp 'rainbow-mode)
(custom-set-variables
@ -3351,7 +3350,7 @@ and names in buffers for debugging.
lisp-interaction-mode
org-mode
python-mode)))
(rainbow-mode +1))
(rainbow-mode +1)))
#+end_src
** [[https://karthinks.com/software/batteries-included-with-emacs/][Flash the line around point for visual feedback]]