gnu: glade: Use 'glib-or-gtk-build-system'.
[jackhill/guix/guix.git] / emacs / guix-command.el
index ea29461..7069c51 100644 (file)
@@ -1,6 +1,6 @@
 ;;; guix-command.el --- Popup interface for guix commands  -*- lexical-binding: t -*-
 
-;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;; Copyright © 2015, 2016 Alex Kost <alezost@gmail.com>
 
 ;; This file is part of GNU Guix.
 
@@ -65,6 +65,7 @@
 (require 'guix-help-vars)
 (require 'guix-read)
 (require 'guix-base)
+(require 'guix-build-log)
 (require 'guix-guile)
 (require 'guix-external)
 
@@ -131,7 +132,8 @@ to be modified."
 
 (guix-command-define-argument-improver
     guix-command-improve-action-argument
-  '(("graph"       :char ?G)
+  '(("container"   :char ?C)
+    ("graph"       :char ?G)
     ("environment" :char ?E)
     ("publish"     :char ?u)
     ("pull"        :char ?P)
@@ -173,7 +175,9 @@ to be modified."
 (defvar guix-command-improve-common-build-argument
   '(("--no-substitutes"  :char ?s)
     ("--no-build-hook"   :char ?h)
-    ("--max-silent-time" :char ?x)))
+    ("--max-silent-time" :char ?x)
+    ("--rounds"          :char ?R :fun read-number)
+    ("--with-input"      :char ?W)))
 
 (defun guix-command-improve-common-build-argument (argument)
   (guix-command-modify-argument-from-alist
@@ -189,13 +193,18 @@ to be modified."
 (guix-command-define-argument-improver
     guix-command-improve-build-argument
   '(("--no-grafts"   :char ?g)
+    ("--file"        :fun guix-read-file-name)
     ("--root"        :fun guix-read-file-name)
     ("--sources"     :char ?S :fun guix-read-source-type :switch? nil)
     ("--with-source" :fun guix-read-file-name)))
 
 (guix-command-define-argument-improver
     guix-command-improve-environment-argument
-  '(("--exec" :fun read-shell-command)
+  '(("--ad-hoc"
+     :name "--ad-hoc " :fun guix-read-package-names-string
+     :switch? nil :option? t)
+    ("--expose" :char ?E)
+    ("--share" :char ?S)
     ("--load" :fun guix-read-file-name)))
 
 (guix-command-define-argument-improver
@@ -234,6 +243,7 @@ to be modified."
      :switch? nil :option? t)
     ("--install-from-file" :fun guix-read-file-name)
     ("--manifest"       :fun guix-read-file-name)
+    ("--profile"        :fun guix-read-file-name)
     ("--do-not-upgrade" :char ?U)
     ("--roll-back"      :char ?R)
     ("--show"           :char ?w :fun guix-read-package-name)))
@@ -366,11 +376,15 @@ to be modified."
     (let ((command (car commands)))
       (cond
        ((member command
-                '("archive" "build" "challenge" "edit" "environment"
+                '("archive" "build" "challenge" "edit"
                   "graph" "lint" "refresh"))
         (argument :doc "Packages" :fun 'guix-read-package-names-string))
+       ((equal commands '("container" "exec"))
+        (argument :doc "PID Command [Args...]"))
        ((string= command "download")
         (argument :doc "URL"))
+       ((string= command "environment")
+        (argument :doc "Command [Args...]" :fun 'read-shell-command))
        ((string= command "gc")
         (argument :doc "Paths" :fun 'guix-read-file-name))
        ((member command '("hash" "system"))
@@ -384,10 +398,22 @@ to be modified."
              (string= command "import"))
         (argument :doc "Package name"))))))
 
+(defvar guix-command-additional-arguments
+  `((("environment")
+     ,(guix-command-make-argument
+       :name "++packages " :char ?p :option? t
+       :doc "build inputs of the specified packages"
+       :fun 'guix-read-package-names-string)))
+  "Alist of guix commands and additional arguments for them.
+These are 'fake' arguments that are not presented in 'guix' shell
+commands.")
+
 (defun guix-command-additional-arguments (&optional commands)
   "Return additional arguments for COMMANDS."
   (let ((rest-arg (guix-command-rest-argument commands)))
-    (and rest-arg (list rest-arg))))
+    (append (guix-assoc-value guix-command-additional-arguments
+                              commands)
+            (and rest-arg (list rest-arg)))))
 
 ;; Ideally only `guix-command-arguments' function should exist with the
 ;; contents of `guix-command-all-arguments', but we need to make a
@@ -469,7 +495,11 @@ to be modified."
 ;;; Post processing popup arguments
 
 (defvar guix-command-post-processors
-  '(("hash"
+  '(("environment"
+     guix-command-post-process-environment-packages
+     guix-command-post-process-environment-ad-hoc
+     guix-command-post-process-rest-multiple-leave)
+    ("hash"
      guix-command-post-process-rest-single)
     ("package"
      guix-command-post-process-package-args)
@@ -543,6 +573,21 @@ Leave '--' string as a separate argument."
    args (rx string-start (or "--install " "--remove ") (+ any))
    :split? t))
 
+(defun guix-command-post-process-environment-packages (args)
+  "Adjust popup ARGS for specified packages of 'guix environment'
+command."
+  (guix-command-post-process-matching-args
+   args (rx string-start "++packages " (group (+ any)))
+   :group 1
+   :split? t))
+
+(defun guix-command-post-process-environment-ad-hoc (args)
+  "Adjust popup ARGS for '--ad-hoc' argument of 'guix environment'
+command."
+  (guix-command-post-process-matching-args
+   args (rx string-start "--ad-hoc " (+ any))
+   :split? t))
+
 (defun guix-command-post-process-args (commands args)
   "Adjust popup ARGS for guix COMMANDS."
   (let* ((command (car commands))
@@ -576,7 +621,7 @@ Leave '--' string as a separate argument."
       (("size")
        ,(guix-command-make-argument
          :name "view" :char ?v :doc "View map"))
-      (("system" "dmd-graph") ,graph-arg)
+      (("system" "shepherd-graph") ,graph-arg)
       (("system" "extension-graph") ,graph-arg)))
   "Alist of guix commands and additional 'execute' action arguments.")
 
@@ -602,7 +647,7 @@ Leave '--' string as a separate argument."
      ("view" . guix-run-view-graph))
     (("size")
      ("view" . guix-run-view-size-map))
-    (("system" "dmd-graph")
+    (("system" "shepherd-graph")
      ("view" . guix-run-view-graph))
     (("system" "extension-graph")
      ("view" . guix-run-view-graph)))
@@ -647,12 +692,11 @@ Perform pull-specific actions after operation, see
 open the log file(s)."
   (let* ((args (if (member "--log-file" args)
                    args
-                 (apply #'list (car args) "--log-file" (cdr args))))
+                 (cl-list* (car args) "--log-file" (cdr args))))
          (output (guix-command-output args))
          (files  (split-string output "\n" t)))
     (dolist (file files)
-      (guix-find-file-or-url file)
-      (guix-build-log-mode))))
+      (guix-build-log-find-file file))))
 
 (defun guix-run-view-graph (args)
   "Run 'guix ARGS ...' graph command, make the image and open it."
@@ -673,10 +717,9 @@ open the log file(s)."
          (map-file (or wished-map-file (guix-png-file-name)))
          (args (if wished-map-file
                    args
-                 (apply #'list
-                        (car args)
-                        (concat "--map-file=" map-file)
-                        (cdr args)))))
+                 (cl-list* (car args)
+                           (concat "--map-file=" map-file)
+                           (cdr args)))))
     (guix-command-output args)
     (guix-find-file map-file)))