[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/09: ui: Factorize 'print-diagnostic-prefix'.
From: |
guix-commits |
Subject: |
07/09: ui: Factorize 'print-diagnostic-prefix'. |
Date: |
Wed, 10 Apr 2019 06:41:10 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit cc3697d5438a861f78a1e5ed57f592ea9ee327be
Author: Ludovic Courtès <address@hidden>
Date: Wed Apr 10 10:26:39 2019 +0200
ui: Factorize 'print-diagnostic-prefix'.
* guix/ui.scm (define-diagnostic): Emit call to 'print-diagnostic-prefix'.
(print-diagnostic-prefix): New procedure.
---
guix/ui.scm | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/guix/ui.scm b/guix/ui.scm
index 953cf9e..8893cc8 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -136,9 +136,7 @@ messages."
(and (string? (syntax->datum #'fmt))
(free-identifier=? #'underscore #'G_))
#'(begin
- (format (guix-warning-port) "~:[~*~;guix ~a: ~]~a"
- (program-name) (program-name)
- (gettext prefix %gettext-domain))
+ (print-diagnostic-prefix prefix)
(format (guix-warning-port) (gettext fmt %gettext-domain)
args (... ...))))
((name (N-underscore singular plural n) args (... ...))
@@ -146,9 +144,7 @@ messages."
(string? (syntax->datum #'plural))
(free-identifier=? #'N-underscore #'N_))
#'(begin
- (format (guix-warning-port) "~:[~*~;guix ~a: ~]~a"
- (program-name) (program-name)
- (gettext prefix %gettext-domain))
+ (print-diagnostic-prefix prefix)
(format (guix-warning-port)
(ngettext singular plural n %gettext-domain)
args (... ...))))))))))
@@ -166,6 +162,14 @@ messages."
(report-error args ...)
(exit 1)))
+(define (print-diagnostic-prefix prefix)
+ "Print PREFIX as a diagnostic line prefix."
+ (format (guix-warning-port) "~:[~*~;guix ~a: ~]~a"
+ (program-name) (program-name)
+ (if (string-null? prefix)
+ prefix
+ (gettext prefix %gettext-domain))))
+
(define (print-unbound-variable-error port key args default-printer)
;; Print unbound variable errors more nicely, and in the right language.
(match args
- branch master updated (6b11da7 -> 9e1e046), guix-commits, 2019/04/10
- 01/09: guix package: Use absolute file names in search path recommendations., guix-commits, 2019/04/10
- 02/09: doc: Adjust desktop instructions for GDM., guix-commits, 2019/04/10
- 05/09: ui: Fix i18n for diagnostic messages., guix-commits, 2019/04/10
- 09/09: ui: Colorize diagnostics., guix-commits, 2019/04/10
- 08/09: ui: Diagnostic procedures can display error location., guix-commits, 2019/04/10
- 04/09: Add (guix colors)., guix-commits, 2019/04/10
- 06/09: ui: Make diagnostic message prefix translatable., guix-commits, 2019/04/10
- 03/09: store: 'with-store' expands to a single procedure call., guix-commits, 2019/04/10
- 07/09: ui: Factorize 'print-diagnostic-prefix'.,
guix-commits <=