diff options
Diffstat (limited to 'guix/diagnostics.scm')
| -rw-r--r-- | guix/diagnostics.scm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/guix/diagnostics.scm b/guix/diagnostics.scm index 337a73c1a2..9f0d558f2f 100644 --- a/guix/diagnostics.scm +++ b/guix/diagnostics.scm @@ -39,6 +39,7 @@ source-properties->location location->source-properties location->string + location->hyperlink &error-location error-location? @@ -203,7 +204,10 @@ macro-expansion time." (gettext prefix %gettext-domain)))) (if location (format (guix-warning-port) "~a: ~a" - (location-color (location->string location)) + (location-color + (if (supports-hyperlinks? (guix-warning-port)) + (location->hyperlink location) + (location->string location))) (prefix-color prefix)) (format (guix-warning-port) "~:[~*~;guix ~a: ~]~a" (program-name) (program-name) @@ -228,7 +232,7 @@ macro-expansion time." by Guile's `source-properties', `frame-source', `current-source-location', etc." ;; In accordance with the GCS, start line and column numbers at 1. Note - ;; that unlike LINE and `port-column', COL is actually 1-indexed here... + ;; that unlike LINE and `port-column', COL is actually 0-indexed here... (match loc ((('line . line) ('column . col) ('filename . file)) ;common case (and file line col @@ -259,6 +263,16 @@ a location object." (($ <location> file line column) (format #f "~a:~a:~a" file line column)))) +(define (location->hyperlink location) + "Return a string corresponding to LOCATION, with escapes for a hyperlink." + (let ((str (location->string location)) + (file (if (string-prefix? "/" (location-file location)) + (location-file location) + (search-path %load-path (location-file location))))) + (if file + (file-hyperlink file str) + str))) + (define-condition-type &error-location &error error-location? (location error-location)) ;<location> |
