Let ensure-package-installation return nil on failure
This commit is contained in:
parent
4cec3cf570
commit
d02c59fe1e
143
README.org
143
README.org
@ -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))
|
||||
(when (bound-and-true-p package-selected-packages)
|
||||
(cl-pushnew package package-selected-packages)))))
|
||||
(if (package-installed-p package)
|
||||
(when (bound-and-true-p package-selected-packages)
|
||||
(cl-pushnew package package-selected-packages))
|
||||
(setq ok nil)))
|
||||
ok))
|
||||
#+end_src
|
||||
|
||||
* [[info:emacs#Help][Help (info)]]
|
||||
@ -1353,24 +1356,23 @@ 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")))
|
||||
(if command
|
||||
(custom-set-variables
|
||||
`(math-preview-command ,command)
|
||||
'(math-preview-raise 0.5)
|
||||
'(math-preview-scale 1))
|
||||
;; https://stackoverflow.com/a/17509764 answers:
|
||||
;; How to install an npm package from github directly?
|
||||
(cl-destructuring-bind (exit-code output)
|
||||
(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)))))))
|
||||
(with-eval-after-load 'math-preview
|
||||
(let ((command (executable-find "~/node_modules/.bin/math-preview")))
|
||||
(if command
|
||||
(custom-set-variables
|
||||
`(math-preview-command ,command)
|
||||
'(math-preview-raise 0.5)
|
||||
'(math-preview-scale 1))
|
||||
;; https://stackoverflow.com/a/17509764 answers:
|
||||
;; How to install an npm package from github directly?
|
||||
(cl-destructuring-bind (exit-code output)
|
||||
(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))))))))
|
||||
#+end_src
|
||||
|
||||
*** TODO Improve the AUCTeX configuration slowly
|
||||
@ -2943,34 +2945,33 @@ 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
|
||||
'anaconda-mode ; strangles python-mode
|
||||
'company-anaconda ; complete anything in anaconda-mode
|
||||
)
|
||||
(when (ensure-package-installation
|
||||
'anaconda-mode ; strangles python-mode
|
||||
'company-anaconda) ; complete anything in anaconda-mode
|
||||
|
||||
(with-eval-after-load 'python
|
||||
(with-eval-after-load 'company
|
||||
(when (and (fboundp 'anaconda-mode)
|
||||
(fboundp 'company-anaconda))
|
||||
(defun my-disable-anaconda-mode ()
|
||||
(when (derived-mode-p 'python-mode)
|
||||
(anaconda-mode -1)
|
||||
(make-variable-buffer-local 'company-backends)
|
||||
(setq company-backends
|
||||
(delq 'company-anaconda
|
||||
(mapcar #'identity company-backends)))
|
||||
(anaconda-eldoc-mode -1)))
|
||||
(defun my-enable-anaconda-mode ()
|
||||
(when (derived-mode-p 'python-mode)
|
||||
(anaconda-mode +1)
|
||||
(make-variable-buffer-local 'company-backends)
|
||||
(setq company-backends
|
||||
(cons 'company-anaconda
|
||||
(delq 'company-semantic
|
||||
(delq 'company-capf
|
||||
(mapcar #'identity company-backends)))))
|
||||
(anaconda-eldoc-mode
|
||||
(if (file-remote-p default-directory) -1 1)))))))
|
||||
(with-eval-after-load 'python
|
||||
(with-eval-after-load 'company
|
||||
(when (and (fboundp 'anaconda-mode)
|
||||
(fboundp 'company-anaconda))
|
||||
(defun my-disable-anaconda-mode ()
|
||||
(when (derived-mode-p 'python-mode)
|
||||
(anaconda-mode -1)
|
||||
(make-variable-buffer-local 'company-backends)
|
||||
(setq company-backends
|
||||
(delq 'company-anaconda
|
||||
(mapcar #'identity company-backends)))
|
||||
(anaconda-eldoc-mode -1)))
|
||||
(defun my-enable-anaconda-mode ()
|
||||
(when (derived-mode-p 'python-mode)
|
||||
(anaconda-mode +1)
|
||||
(make-variable-buffer-local 'company-backends)
|
||||
(setq company-backends
|
||||
(cons 'company-anaconda
|
||||
(delq 'company-semantic
|
||||
(delq 'company-capf
|
||||
(mapcar #'identity company-backends)))))
|
||||
(anaconda-eldoc-mode
|
||||
(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))
|
||||
(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)))
|
||||
#+end_src
|
||||
|
||||
** [[https://countvajhula.com/2021/09/25/the-animated-guide-to-symex/][Structural editing]]
|
||||
@ -3336,22 +3336,21 @@ 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
|
||||
'(rainbow-x-colors-major-mode-list
|
||||
'(c++-mode
|
||||
c-mode
|
||||
emacs-lisp-mode
|
||||
inferior-emacs-lisp-mode
|
||||
java-mode
|
||||
lisp-interaction-mode
|
||||
org-mode
|
||||
python-mode)))
|
||||
(rainbow-mode +1))
|
||||
(when (fboundp 'rainbow-mode)
|
||||
(custom-set-variables
|
||||
'(rainbow-x-colors-major-mode-list
|
||||
'(c++-mode
|
||||
c-mode
|
||||
emacs-lisp-mode
|
||||
inferior-emacs-lisp-mode
|
||||
java-mode
|
||||
lisp-interaction-mode
|
||||
org-mode
|
||||
python-mode)))
|
||||
(rainbow-mode +1)))
|
||||
#+end_src
|
||||
|
||||
** [[https://karthinks.com/software/batteries-included-with-emacs/][Flash the line around point for visual feedback]]
|
||||
|
Loading…
x
Reference in New Issue
Block a user