diff options
author | Alex Kost <alezost@gmail.com> | 2015-09-13 21:34:23 +0300 |
---|---|---|
committer | Alex Kost <alezost@gmail.com> | 2015-09-15 15:19:31 +0300 |
commit | ea369ee1b0c1e70e70998c0318972a4823aba3b9 (patch) | |
tree | 23ebe8e5b1d690293683677e91137bb5118d0dcf /emacs/guix-main.scm | |
parent | 46e17df661fa6c92d0863827f3affb9385b95395 (diff) | |
download | patches-ea369ee1b0c1e70e70998c0318972a4823aba3b9.tar patches-ea369ee1b0c1e70e70998c0318972a4823aba3b9.tar.gz |
emacs: Display guix command errors in the minibuffer.
* emacs/guix-main.scm (output+error): New procedure.
(guix-command-output): Use it.
* emacs/guix-base.el (guix-command-output): Display error output in the
minibuffer.
Diffstat (limited to 'emacs/guix-main.scm')
-rw-r--r-- | emacs/guix-main.scm | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm index c9b84d36d9..e29a0a0acc 100644 --- a/emacs/guix-main.scm +++ b/emacs/guix-main.scm @@ -71,6 +71,18 @@ (define (list-maybe obj) (if (list? obj) obj (list obj))) +(define (output+error thunk) + "Call THUNK and return 2 values: output and error output as strings." + (let ((output-port (open-output-string)) + (error-port (open-output-string))) + (with-output-to-port output-port + (lambda () (with-error-to-port error-port thunk))) + (let ((strings (list (get-output-string output-port) + (get-output-string error-port)))) + (close-output-port output-port) + (close-output-port error-port) + (apply values strings)))) + (define (full-name->name+version spec) "Given package specification SPEC with or without output, return two values: name and version. For example, for SPEC @@ -953,9 +965,11 @@ GENERATIONS is a list of generation numbers." (const #t))) (define (guix-command-output . args) - "Return string with 'guix ARGS ...' output." - (with-output-to-string - (lambda () (apply guix-command args)))) + "Return 2 strings with 'guix ARGS ...' output and error output." + (output+error + (lambda () + (parameterize ((guix-warning-port (current-error-port))) + (apply guix-command args))))) (define (help-string . commands) "Return string with 'guix COMMANDS ... --help' output." |