[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/opam-switch-mode 515d08dfb3 09/31: check and handle opam e
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/opam-switch-mode 515d08dfb3 09/31: check and handle opam errors |
Date: |
Mon, 14 Nov 2022 08:59:59 -0500 (EST) |
branch: elpa/opam-switch-mode
commit 515d08dfb3eadc511cd8fb8706dd3f183ff652a1
Author: Hendrik Tews <Hendrik.Tews@kernkonzept.com>
Commit: Hendrik Tews <Hendrik.Tews@kernkonzept.com>
check and handle opam errors
---
opam-mode.el | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/opam-mode.el b/opam-mode.el
index 72bc71513d..bfcd98b316 100644
--- a/opam-mode.el
+++ b/opam-mode.el
@@ -92,6 +92,8 @@ discarded. If SWITCH is not nil, an option \"--swith=SWITCH\"
is
added. If SEXP is t, option --sexep is added. All remaining
arguments ARGS are added as arguments.
+Return exit status of the opam invocation.
+
Internally this function uses `process-file' internally and will
therfore respect file-name handlers specified via
`default-directory'."
@@ -107,17 +109,22 @@ therfore respect file-name handlers specified via
nil '(t nil) nil sub-cmd options)))
(defun opam-command-as-string (sub-cmd &optional switch sexp &rest args)
- "Return output of opam SUB-CMD as string.
+ "Return output of opam SUB-CMD as string or nil.
Same as `opam-run-command-without-stderr' but return all output
-as string."
+as string. Return nil if opam command fails."
(with-temp-buffer
- (apply 'opam-run-command-without-stderr sub-cmd switch sexp args)
- (buffer-string)))
+ (let ((status
+ (apply 'opam-run-command-without-stderr sub-cmd switch sexp args)))
+ (if (eq status 0)
+ (buffer-string)
+ nil))))
(defun opam-get-root ()
"Get the opam root directory.
This is the opam variable 'root'."
(let ((root (opam-command-as-string "var" nil nil "root")))
+ (unless root
+ (error "opam var root failed"))
(when (eq (aref root (1- (length root))) ?\n)
(setq root (substring root 0 -1)))
root))
@@ -145,7 +152,9 @@ This is the opam variable 'root'."
"Return all opam switches as list of strings."
(let (opam-switches)
(with-temp-buffer
- (opam-run-command-without-stderr "switch")
+ (unless (eq (opam-run-command-without-stderr "switch") 0)
+ ;; opam exit status different from 0 -- some error occured
+ (error "opam switch failed"))
(goto-char (point-min))
(forward-line)
(while (re-search-forward "^.. *\\([^ ]*\\).*$" nil t)
@@ -250,9 +259,13 @@ not any other shells outside emacs."
(error "No saved opam environment, cannot reset."))
(if (equal switch-name "")
(opam-reset-env)
- (let ((opam-env
- (car (read-from-string
- (opam-command-as-string "env" switch-name t)))))
+ (let ((output-string (opam-command-as-string "env" switch-name t))
+ opam-env)
+ (unless output-string
+ (error
+ "opam env %s failed - probably because of invalid opam switch \"%s\""
+ switch-name switch-name))
+ (setq opam-env (car (read-from-string output-string)))
(unless opam-saved-env
(opam-save-current-env opam-env))
(opam-set-env opam-env))))
- [nongnu] branch elpa/opam-switch-mode created (now a306f75d82), ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode dea35145a3 30/31: Merge pull request #7 from ProofGeneral/add-doc, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 515d08dfb3 09/31: check and handle opam errors,
ELPA Syncer <=
- [nongnu] elpa/opam-switch-mode cad8510077 18/31: refactor: Run `M-x package-lint-current-buffer` and address its feedback, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 0db601100c 17/31: docs: Run `M-x checkdoc` and address its feedback, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 3d63566b0d 04/31: provide README, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode dd6a86ddad 23/31: Add LICENSE, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 16b8276f85 13/31: use -- for internal stuff, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 5f3d2102ae 26/31: Add OCaml keyword and https://opam.ocaml.org URL, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 7c648a0719 16/31: docs: details (#3), ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 22fa9efcb6 27/31: docs(README.md): Add install section, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode f62c708225 14/31: typo fix, ELPA Syncer, 2022/11/14
- [nongnu] elpa/opam-switch-mode 95a3b4225a 15/31: fix: (opam-switch-mode) × 3 bug (#4), ELPA Syncer, 2022/11/14