From: Alex Kost <alezost@gmail.com>
To: guix-devel@gnu.org
Subject: [PATCH 1/3] emacs: Display guix command errors in the minibuffer.
Date: Sun, 13 Sep 2015 22:39:19 +0300 [thread overview]
Message-ID: <1442173161-527-2-git-send-email-alezost@gmail.com> (raw)
In-Reply-To: <1442173161-527-1-git-send-email-alezost@gmail.com>
* 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.
---
emacs/guix-base.el | 9 ++++++---
emacs/guix-main.scm | 20 +++++++++++++++++---
2 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 3bee910..8d14095 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -1129,9 +1129,12 @@ The function is called with a single argument - a command line string."
(defun guix-command-output (args)
"Return string with 'guix ARGS ...' output."
- (guix-eval-read
- (apply #'guix-make-guile-expression
- 'guix-command-output args)))
+ (cl-multiple-value-bind (output error)
+ (guix-eval (apply #'guix-make-guile-expression
+ 'guix-command-output args))
+ ;; Remove trailing new space from the error string.
+ (message (replace-regexp-in-string "\n\\'" "" (read error)))
+ (read output)))
(defun guix-help-string (&optional commands)
"Return string with 'guix COMMANDS ... --help' output."
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index c9b84d3..10165c1 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 ()
+ (guix-warning-port (current-error-port))
+ (apply guix-command args))))
(define (help-string . commands)
"Return string with 'guix COMMANDS ... --help' output."
--
2.5.1
next prev parent reply other threads:[~2015-09-13 19:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-13 19:39 [PATCH 0/3] emacs: Add 'guix-build-log-mode' and friends Alex Kost
2015-09-13 19:39 ` Alex Kost [this message]
2015-09-14 7:22 ` [PATCH 1/3] emacs: Display guix command errors in the minibuffer Alex Kost
2015-09-14 11:55 ` Ludovic Courtès
2015-09-14 11:54 ` Ludovic Courtès
2015-09-13 19:39 ` [PATCH 2/3] emacs: Add modes for viewing build logs Alex Kost
2015-09-14 12:01 ` Ludovic Courtès
2015-09-14 12:02 ` Ludovic Courtès
2015-09-15 12:21 ` Alex Kost
2015-09-15 18:56 ` [PATCH] emacs: Add commands to show/hide build log phases Alex Kost
2015-09-18 9:42 ` Ludovic Courtès
2015-09-13 19:39 ` [PATCH 3/3] emacs: Add "View build log" action to build popup Alex Kost
2015-09-14 12:03 ` Ludovic Courtès
2015-09-14 11:54 ` [PATCH 0/3] emacs: Add 'guix-build-log-mode' and friends Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442173161-527-2-git-send-email-alezost@gmail.com \
--to=alezost@gmail.com \
--cc=guix-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).