summaryrefslogtreecommitdiff
path: root/guix/deprecation.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-06-03 23:00:42 +0200
committerLudovic Courtès <ludo@gnu.org>2019-06-03 23:18:47 +0200
commit69962ab7a8e07af77a2eb466be39615d139d5cf0 (patch)
tree0170970c0fd544268dada62649ea770a4408e393 /guix/deprecation.scm
parent1b5ee3bdaacf665ad1e7c6142122389fd7033ea2 (diff)
downloadpatches-69962ab7a8e07af77a2eb466be39615d139d5cf0.tar
patches-69962ab7a8e07af77a2eb466be39615d139d5cf0.tar.gz
deprecation: Use the 'warning' procedure for diagnostics.
Until now, (guix deprecation) had its own warning mechanism, which was inconsistent (it did not use colors, etc.) * guix/deprecation.scm (deprecation-warning-port): Remove (source-properties->location-string): Remove. (warn-about-deprecation): Use 'warning' instead of 'format'. (define-deprecated, define-deprecated/alias): Adjust docstring. * guix/channels.scm (build-from-source): Refer to 'guix-warning-port' instead of 'deprecation-warning-port'.
Diffstat (limited to 'guix/deprecation.scm')
-rw-r--r--guix/deprecation.scm36
1 files changed, 11 insertions, 25 deletions
diff --git a/guix/deprecation.scm b/guix/deprecation.scm
index d704e7ec61..468b2e9b7b 100644
--- a/guix/deprecation.scm
+++ b/guix/deprecation.scm
@@ -18,40 +18,26 @@
(define-module (guix deprecation)
#:use-module (guix i18n)
- #:use-module (ice-9 format)
+ #:use-module (guix diagnostics)
+ #:autoload (guix utils) (source-properties->location)
#:export (define-deprecated
define-deprecated/alias
- warn-about-deprecation
- deprecation-warning-port))
+ warn-about-deprecation))
;;; Commentary:
;;;
;;; Provide a mechanism to mark bindings as deprecated.
;;;
-;;; We don't reuse (guix ui) mostly to avoid pulling in too many things.
-;;;
;;; Code:
-(define deprecation-warning-port
- ;; Port where deprecation warnings go.
- (make-parameter (current-error-port)))
-
-(define (source-properties->location-string properties)
- "Return a human-friendly, GNU-standard representation of PROPERTIES, a
-source property alist."
- (let ((file (assq-ref properties 'filename))
- (line (assq-ref properties 'line))
- (column (assq-ref properties 'column)))
- (if (and file line column)
- (format #f "~a:~a:~a" file (+ 1 line) column)
- (G_ "<unknown location>"))))
-
(define* (warn-about-deprecation variable properties
#:key replacement)
- (format (deprecation-warning-port)
- (G_ "~a: warning: '~a' is deprecated~@[, use '~a' instead~]~%")
- (source-properties->location-string properties)
- variable replacement))
+ (let ((location (and properties (source-properties->location properties))))
+ (if replacement
+ (warning location (G_ "'~a' is deprecated, use '~a' instead~%")
+ variable replacement)
+ (warning location (G_ "'~a' is deprecated~%")
+ variable))))
(define-syntax define-deprecated
(lambda (s)
@@ -60,7 +46,7 @@ source property alist."
(define-deprecated foo bar 42)
(define-deprecated (baz x y) qux (qux y x))
-This will write a deprecation warning to DEPRECATION-WARNING-PORT."
+This will write a deprecation warning to GUIX-WARNING-PORT."
(syntax-case s ()
((_ (proc formals ...) replacement body ...)
#'(define-deprecated proc replacement
@@ -97,7 +83,7 @@ these lines:
where 'nix-server?' is the deprecated name for 'store-connection?'.
-This will write a deprecation warning to DEPRECATION-WARNING-PORT."
+This will write a deprecation warning to GUIX-WARNING-PORT."
(define-syntax deprecated
(lambda (s)
(warn-about-deprecation 'deprecated (syntax-source s)