summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--emacs/guix-base.el21
-rw-r--r--emacs/guix-main.scm18
2 files changed, 39 insertions, 0 deletions
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index 4c7782dd53..d1593e285d 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -1085,6 +1085,27 @@ FILE.  With a prefix argument, also prompt for PROFILE."
      operation-buffer)))
 
 
+;;; Executing guix commands
+
+(defun guix-run-command-in-repl (args)
+  "Execute 'guix ARGS ...' command in Guix REPL."
+  (guix-eval-in-repl
+   (apply #'guix-make-guile-expression
+          'guix-command args)))
+
+(defun guix-command-output (args)
+  "Return string with 'guix ARGS ...' output."
+  (guix-eval-read
+   (apply #'guix-make-guile-expression
+          'guix-command-output args)))
+
+(defun guix-help-string (&optional commands)
+  "Return string with 'guix COMMANDS ... --help' output."
+  (guix-eval-read
+   (apply #'guix-make-guile-expression
+          'help-string commands)))
+
+
 ;;; Pull
 
 (defcustom guix-update-after-pull t
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 341657d931..bd42f8fc21 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -931,6 +931,24 @@ GENERATIONS is a list of generation numbers."
                 (package-source-derivation->store-path derivation))))))
 
 
+;;; Executing guix commands
+
+(define (guix-command . args)
+  "Run 'guix ARGS ...' command."
+  (catch 'quit
+    (lambda () (apply run-guix args))
+    (const #t)))
+
+(define (guix-command-output . args)
+  "Return string with 'guix ARGS ...' output."
+  (with-output-to-string
+    (lambda () (apply guix-command args))))
+
+(define (help-string . commands)
+  "Return string with 'guix COMMANDS ... --help' output."
+  (apply guix-command-output `(,@commands "--help")))
+
+
 ;;; Lists of packages, lint checkers, etc.
 
 (define (graph-type-names)