Commit ef1c3bd1 authored by Ludovic Courtès's avatar Ludovic Courtès
Browse files

kernel: Handle ";;guix describe" magic.

* guix-jupyter-kernel.scm (channels->shtml): Move heading to...
(reply-for-channels): ... here.
(reply-channel-description): New procedure.
(reply-execute-request): Handle ";;guix describe".
(%magic-commands): Add "describe".
parent b1f7b125
......@@ -162,16 +162,14 @@ NAME with MANIFEST."
(define (channels->shtml channels)
"Return SHTML representing CHANNELS."
`(div
(bold "Switched to these Guix channels:")
(p (table
,@(map (lambda (channel)
`(tr (tc (a (@ (href ,(channel-url channel)))
(code ,(channel-name channel))))
(tc (code ,(if (channel-commit channel)
(channel-commit-hyperlink channel)
(channel-branch channel))))))
channels)))))
`(p (table
,@(map (lambda (channel)
`(tr (tc (a (@ (href ,(channel-url channel)))
(code ,(channel-name channel))))
(tc (code ,(if (channel-commit channel)
(channel-commit-hyperlink channel)
(channel-branch channel))))))
channels))))
(define* (reply-for-channels kernel message channels
#:key profile (count 0))
......@@ -183,7 +181,26 @@ to CHANNELS in PROFILE."
(lst lst))
channels)))
(reply-html kernel message
(sxml->html-string (channels->shtml instances))
(sxml->html-string
`(div
(bold "Switched to these Guix channels:")
,(channels->shtml instances)))
count)))
(define* (reply-channel-description kernel message inferior
#:key (count 0))
"Reply to MESSAGE, which comes from KERNEL, with a description of the
channels currently used by INFERIOR."
(let* ((profile (inferior-eval '(begin
(use-modules (guix describe))
(current-profile))
inferior))
(channels (profile-channels profile)))
(reply-html kernel message
(sxml->html-string
`(div
(bold "Using these Guix channels:")
,(channels->shtml channels)))
count)))
(define* (reply-for-channel-failure kernel message channels error
......@@ -402,6 +419,13 @@ stripped."
(send-message proxy (execute-request-sans-magic message))
(let ((state (increment-execution-count state)))
(set-proxy-state-default-environment state name)))))
((";;guix" "describe")
(let* ((state (ensure-proxy-state-inferior state))
(inferior (proxy-state-inferior state)))
(reply-channel-description kernel message
(proxy-state-inferior state)
#:count count)
(increment-execution-count state)))
((";;guix" "pin" commit)
(let ((count (proxy-state-execution-count state))
(channels (map (lambda (ch)
......@@ -471,7 +495,7 @@ python-ipykernel"))
(define %magic-commands
;; The ";;guix" magic commands.
'("download" "environment" "pin"))
'("describe" "download" "environment" "pin"))
(define (reply-complete-request kernel kind message state)
"Reply to a \"complete_request\" message--i.e., a completion request.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment