Compact my usage of ensure-package-installation

This commit is contained in:
Gerard Vermeulen 2022-04-30 11:19:32 +02:00
parent e78aa66830
commit 66d19b7e71

View File

@ -785,8 +785,7 @@ may hang or die.
#+caption: Ensure =applescript-mode= installation.
#+name: lst:ensure-applescript-mode-installation
#+begin_src emacs-lisp
(when (ensure-package-installation
'applescript-mode)) ; mode to edit AppleScript code
(when (ensure-package-installation 'applescript-mode))
#+end_src
* Completion
@ -1356,9 +1355,7 @@ LaTeX =BiBTeX= dialect for backwards compatibility. Listing
#+caption: Configure =math-preview=.
#+name: lst:configure-math-preview
#+begin_src emacs-lisp
(when (ensure-package-installation
'math-preview) ; display LaTeX math with MathJax
(when (ensure-package-installation 'math-preview)
(with-eval-after-load 'math-preview
(let ((command (executable-find "~/node_modules/.bin/math-preview")))
(if command
@ -2433,8 +2430,7 @@ the [[https://github.com/gromnitsky/wordnut#readme][wordnut]] prerequisites.
#+caption: System check for =wordnut=.
#+name: lst:check-wordnut
#+begin_src emacs-lisp
(when (ensure-package-installation
'wordnut) ; WordNet lexical database interface
(when (ensure-package-installation 'wordnut)
(unless (executable-find "wn")
(message "`wordnut' fails to find the `wn' executable")))
#+end_src
@ -2452,8 +2448,7 @@ Listing [[lst:configure-writegood-mode]] configures [[https://github.com/bnbeckw
#+caption: Configure =writegood-mode=.
#+name: lst:configure-writegood-mode
#+begin_src emacs-lisp
(when (ensure-package-installation
'writegood-mode) ; bullshit and weasel-word detector
(when (ensure-package-installation 'writegood-mode)
(global-set-key (kbd "C-c g") #'writegood-mode))
#+end_src
@ -2477,9 +2472,7 @@ languages.
#+begin_src emacs-lisp
;; https://ianyepan.github.io/posts/format-all/
;; https://github.com/lassik/emacs-format-all-the-code#readme
(when (ensure-package-installation
'format-all) ; universal code formatters interface
(when (ensure-package-installation 'format-all)
(when (fboundp 'format-all-ensure-formatter)
(add-hook 'prog-mode-hook #'format-all-ensure-formatter)))
#+end_src
@ -2968,9 +2961,7 @@ Listing [[lst:configure-blacken]] configures [[https://github.com/pythonic-emacs
#+caption: Configure =blacken=.
#+name: lst:configure-blacken
#+begin_src emacs-lisp
(when (ensure-package-installation
'blacken) ; Black Python code formatter client
(when (ensure-package-installation 'blacken)
(when (fboundp 'blacken-buffer)
(defun advice-derived-python-mode-p (fn &rest args)
(if (derived-mode-p 'python-mode)
@ -3018,10 +3009,7 @@ 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
(when (ensure-package-installation
'anaconda-mode ; strangles python-mode
'company-anaconda) ; complete anything in anaconda-mode
(when (ensure-package-installation 'anaconda-mode 'company-anaconda)
(with-eval-after-load 'python
(with-eval-after-load 'company
(when (and (fboundp 'anaconda-mode)
@ -3092,9 +3080,7 @@ configures =code-cells=.
#+caption: Configure =code-cells=.
#+name: lst:configure-code-cells
#+begin_src emacs-lisp
(when (ensure-package-installation
'code-cells) ; lightweight notebooks in Emacs
(when (ensure-package-installation 'code-cells)
(with-eval-after-load 'code-cells
(let ((map code-cells-mode-map))
(define-key map (kbd "M-p") #'code-cells-backward-cell)
@ -3174,9 +3160,7 @@ 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
(when (ensure-package-installation
'ws-butler) ; remove trailing whitespace
(when (ensure-package-installation 'ws-butler)
(when (require 'ws-butler nil 'noerror)
(custom-set-variables
'(ws-butler-keep-whitespace-before-point nil))
@ -3424,9 +3408,7 @@ and names in buffers for debugging.
#+caption: Enable =rainbow-mode=.
#+name: lst:enable-rainbow-mode
#+begin_src emacs-lisp
(when (ensure-package-installation
'rainbow-mode) ; set background color to color string
(when (ensure-package-installation 'rainbow-mode)
(when (fboundp 'rainbow-mode)
(custom-set-variables
'(rainbow-x-colors-major-mode-list
@ -3642,7 +3624,7 @@ enable =emms=.
#+caption: Configure =elfeed=.
#+name: lst:configure-elfeed
#+begin_src emacs-lisp
(when (ensure-package-installation 'elfeed) ; web feed reader
(when (ensure-package-installation 'elfeed)
(when (fboundp 'elfeed)
(global-set-key (kbd "C-x w") #'elfeed))
@ -3684,7 +3666,7 @@ using =emms= with =elfeed=. Listing [[lst:configure-emms]] configures =emms=.
#+caption: Configure =emms=.
#+name: lst:configure-emms
#+begin_src emacs-lisp
(when (ensure-package-installation 'emms) ; Emacs Multi-Media System
(when (ensure-package-installation 'emms)
(with-eval-after-load 'emms
(custom-set-variables
'(emms-player-list '(emms-player-mpd emms-player-mpv))))