Archived
1
0
Fork 0

ui: Move 'location->hyperlink' to (guix diagnostics).

* guix/ui.scm (location->hyperlink): Move to...
* guix/diagnostics.scm: ... here.
* guix/scripts/system/search.scm: Adjust imports accordingly.
This commit is contained in:
Ludovic Courtès 2022-04-01 15:41:00 +02:00
parent d4e858763c
commit 3da62bf5aa
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
3 changed files with 12 additions and 12 deletions

View file

@ -39,6 +39,7 @@
source-properties->location source-properties->location
location->source-properties location->source-properties
location->string location->string
location->hyperlink
&error-location &error-location
error-location? error-location?
@ -259,6 +260,16 @@ a location object."
(($ <location> file line column) (($ <location> file line column)
(format #f "~a:~a:~a" 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 (define-condition-type &error-location &error
error-location? error-location?
(location error-location)) ;<location> (location error-location)) ;<location>

View file

@ -21,6 +21,7 @@
#:use-module (guix ui) #:use-module (guix ui)
#:use-module (guix utils) #:use-module (guix utils)
#:autoload (guix colors) (supports-hyperlinks?) #:autoload (guix colors) (supports-hyperlinks?)
#:autoload (guix diagnostics) (location->hyperlink)
#:use-module (gnu services) #:use-module (gnu services)
#:use-module (gnu services shepherd) #:use-module (gnu services shepherd)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)

View file

@ -118,8 +118,6 @@
package->recutils package->recutils
package-specification->name+version+output package-specification->name+version+output
location->hyperlink
pager-wrapped-port pager-wrapped-port
with-paginated-output-port with-paginated-output-port
relevance relevance
@ -1484,16 +1482,6 @@ followed by \"+ \", which makes for a valid multi-line field value in the
'() '()
str))) str)))
(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* (package->recutils p port #:optional (width (%text-width)) (define* (package->recutils p port #:optional (width (%text-width))
#:key #:key
(hyperlinks? (supports-hyperlinks? port)) (hyperlinks? (supports-hyperlinks? port))