all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH 0/7] Add "guix-devel-…" commands.
@ 2015-07-25  8:49 Alex Kost
  2015-07-25  8:49 ` [PATCH 1/7] emacs: Move guile related code to "guix-guile.el" Alex Kost
                   ` (7 more replies)
  0 siblings, 8 replies; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel

Rather big patchset but only a couple of additions.

[PATCH 1/7] emacs: Move guile related code to "guix-guile.el".
[PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el".
[PATCH 3/7] emacs: Add code to call guile procedures.
[PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
[PATCH 5/7] ui: Add 'show-derivation-outputs'.
[PATCH 6/7] guix build: Add 'build-package'.
[PATCH 7/7] emacs: Add 'guix-devel-use-current-module'.

Patches 1, 2 and 5 are just for some auxiliary code reorganizing.

Patch 6 adds 'build-package' procedure to (guix scripts build) module,
which is probably not the best place for it, but since it uses (guix ui)
module to show some output, I don't know what module is more suitable.

And finally, I'm afraid building guix package in a Geiser REPL may not
be very useful because of <https://github.com/jaor/geiser/issues/28>
(you have wait for the REPL command to be finished before continuing to
edit .scm-file).

Anyway, Ludovic, is that what you meant?:
<https://gnunet.org/bot/log/guix/2015-07-21#T704966>

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH 1/7] emacs: Move guile related code to "guix-guile.el".
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
@ 2015-07-25  8:49 ` Alex Kost
  2015-08-18 13:50   ` Ludovic Courtès
  2015-08-18 13:51   ` Ludovic Courtès
  2015-07-25  8:49 ` [PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el" Alex Kost
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Kost

* emacs/guix-backend.el (guix-make-guile-expression): Move to...
* emacs/guix-guile.el: ... here.  New file.
* emacs/guix-base.el: Use it.
---
 emacs/guix-backend.el | 18 ------------------
 emacs/guix-base.el    |  1 +
 emacs/guix-guile.el   | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 18 deletions(-)
 create mode 100644 emacs/guix-guile.el

diff --git a/emacs/guix-backend.el b/emacs/guix-backend.el
index 73a429b..7e55bea 100644
--- a/emacs/guix-backend.el
+++ b/emacs/guix-backend.el
@@ -315,24 +315,6 @@ additional internal REPL if it exists."
 (defvar guix-operation-buffer nil
   "Buffer from which the latest Guix operation was performed.")
 
-(defun guix-make-guile-expression (fun &rest args)
-  "Return string containing a guile expression for calling FUN with ARGS."
-  (format "(%S %s)" fun
-          (mapconcat
-           (lambda (arg)
-             (cond
-              ((null arg) "'()")
-              ((or (eq arg t)
-                   ;; An ugly hack to separate 'false' from nil
-                   (equal arg 'f)
-                   (keywordp arg))
-               (concat "#" (prin1-to-string arg t)))
-              ((or (symbolp arg) (listp arg))
-               (concat "'" (prin1-to-string arg)))
-              (t (prin1-to-string arg))))
-           args
-           " ")))
-
 (defun guix-eval (str &optional wrap)
   "Evaluate guile expression STR.
 If WRAP is non-nil, wrap STR into (begin ...) form.
diff --git a/emacs/guix-base.el b/emacs/guix-base.el
index fe89584..8b4ea5c 100644
--- a/emacs/guix-base.el
+++ b/emacs/guix-base.el
@@ -30,6 +30,7 @@
 (require 'cl-lib)
 (require 'guix-profiles)
 (require 'guix-backend)
+(require 'guix-guile)
 (require 'guix-utils)
 (require 'guix-history)
 (require 'guix-messages)
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
new file mode 100644
index 0000000..112262e
--- /dev/null
+++ b/emacs/guix-guile.el
@@ -0,0 +1,47 @@
+;;; guix-guile.el --- Auxiliary tools for working with guile code
+
+;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file provides functions for parsing guile code, making guile
+;; expressions, etc.
+
+;;; Code:
+
+(defun guix-make-guile-expression (fun &rest args)
+  "Return string containing a guile expression for calling FUN with ARGS."
+  (format "(%S %s)" fun
+          (mapconcat
+           (lambda (arg)
+             (cond
+              ((null arg) "'()")
+              ((or (eq arg t)
+                   ;; An ugly hack to separate 'false' from nil.
+                   (equal arg 'f)
+                   (keywordp arg))
+               (concat "#" (prin1-to-string arg t)))
+              ((or (symbolp arg) (listp arg))
+               (concat "'" (prin1-to-string arg)))
+              (t (prin1-to-string arg))))
+           args
+           " ")))
+
+(provide 'guix-guile)
+
+;;; guix-guile.el ends here
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el".
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
  2015-07-25  8:49 ` [PATCH 1/7] emacs: Move guile related code to "guix-guile.el" Alex Kost
@ 2015-07-25  8:49 ` Alex Kost
  2015-08-18 13:52   ` Ludovic Courtès
  2015-07-25  8:49 ` [PATCH 3/7] emacs: Add code to call guile procedures Alex Kost
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Kost

* emacs/guix-backend.el: Adjust commentary. Move "eval" code to ...
  (guix-eval): Remove.
  (guix-eval-read, guix-eval-in-repl): Adjust to use new functions.
* emacs/guix-geiser.el: ...here.  New file.
  (guix-geiser-eval, guix-geiser-eval-read, guix-geiser-eval-in-repl):
  New functions.
---
 emacs/guix-backend.el | 39 ++++++++----------------------
 emacs/guix-geiser.el  | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 29 deletions(-)
 create mode 100644 emacs/guix-geiser.el

diff --git a/emacs/guix-backend.el b/emacs/guix-backend.el
index 7e55bea..8ccfaa6 100644
--- a/emacs/guix-backend.el
+++ b/emacs/guix-backend.el
@@ -1,6 +1,6 @@
-;;; guix-backend.el --- Communication with Geiser
+;;; guix-backend.el --- Making and using Guix REPL
 
-;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
 
 ;; This file is part of GNU Guix.
 
@@ -19,9 +19,10 @@
 
 ;;; Commentary:
 
-;; This file provides the code for interacting with Guile using Geiser.
+;; This file provides the code for interacting with Guile using Guix REPL
+;; (Geiser REPL with some guix-specific additions).
 
-;; By default (if `guix-use-guile-server' is non-nil) 2 Geiser REPLs are
+;; By default (if `guix-use-guile-server' is non-nil) 2 Guix REPLs are
 ;; started.  The main one (with "guile --listen" process) is used for
 ;; "interacting" with a user - for showing a progress of
 ;; installing/deleting Guix packages.  The second (internal) REPL is
@@ -53,6 +54,7 @@
 
 (require 'geiser-mode)
 (require 'guix-emacs)
+(require 'guix-geiser)
 
 (defvar guix-load-path
   (file-name-directory (or load-file-name
@@ -315,28 +317,10 @@ additional internal REPL if it exists."
 (defvar guix-operation-buffer nil
   "Buffer from which the latest Guix operation was performed.")
 
-(defun guix-eval (str &optional wrap)
-  "Evaluate guile expression STR.
-If WRAP is non-nil, wrap STR into (begin ...) form.
-Return a list of strings with result values of evaluation."
-  (with-current-buffer (guix-get-repl-buffer 'internal)
-    (let* ((wrapped (if wrap (geiser-debug--wrap-region str) str))
-           (code `(:eval (:scm ,wrapped)))
-           (ret (geiser-eval--send/wait code)))
-      (if (geiser-eval--retort-error ret)
-          (error "Error in evaluating guile expression: %s"
-                 (geiser-eval--retort-output ret))
-        (cdr (assq 'result ret))))))
-
 (defun guix-eval-read (str &optional wrap)
-  "Evaluate guile expression STR.
-For the meaning of WRAP, see `guix-eval'.
-Return elisp expression of the first result value of evaluation."
-  ;; Parsing scheme code with elisp `read' is probably not the best idea.
-  (read (replace-regexp-in-string
-         "#f\\|#<unspecified>" "nil"
-         (replace-regexp-in-string
-          "#t" "t" (car (guix-eval str wrap))))))
+  "Evaluate STR with guile expression using Guix REPL.
+See `guix-geiser-eval-read' for details."
+  (guix-geiser-eval-read str wrap (guix-get-repl-buffer 'internal)))
 
 (defun guix-eval-in-repl (str &optional operation-buffer operation-type)
   "Switch to Guix REPL and evaluate STR with guile expression there.
@@ -350,10 +334,7 @@ successful executing of the current operation,
   (setq guix-repl-operation-p t
         guix-repl-operation-type operation-type
         guix-operation-buffer operation-buffer)
-  (let ((repl (guix-get-repl-buffer)))
-    (with-current-buffer repl
-      (geiser-repl--send str))
-    (geiser-repl--switch-to-buffer repl)))
+  (guix-geiser-eval-in-repl str (guix-get-repl-buffer)))
 
 (provide 'guix-backend)
 
diff --git a/emacs/guix-geiser.el b/emacs/guix-geiser.el
new file mode 100644
index 0000000..1f0cf72
--- /dev/null
+++ b/emacs/guix-geiser.el
@@ -0,0 +1,67 @@
+;;; guix-geiser.el --- Interacting with Geiser
+
+;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file provides functions to evaluate guile code using Geiser.
+
+;;; Code:
+
+(require 'geiser-mode)
+
+(defun guix-geiser-repl ()
+  "Return the current Geiser REPL."
+  (or geiser-repl--repl
+      (geiser-repl--repl/impl 'guile)
+      (error "Geiser REPL not found")))
+
+(defun guix-geiser-eval (str &optional wrap repl)
+  "Evaluate STR with guile expression using Geiser REPL.
+If REPL is nil, use the current Geiser REPL.
+If WRAP is non-nil, wrap STR into (begin ...) form.
+Return a list of strings with result values of evaluation."
+  (with-current-buffer (or repl (guix-geiser-repl))
+    (let* ((wrapped (if wrap (geiser-debug--wrap-region str) str))
+           (code `(:eval (:scm ,wrapped)))
+           (ret (geiser-eval--send/wait code)))
+      (if (geiser-eval--retort-error ret)
+          (error "Error in evaluating guile expression: %s"
+                 (geiser-eval--retort-output ret))
+        (cdr (assq 'result ret))))))
+
+(defun guix-geiser-eval-read (str &optional wrap repl)
+  "Evaluate STR with guile expression using Geiser REPL.
+For the meaning of WRAP, see `guix-geiser-eval'.
+Return elisp expression of the first result value of evaluation."
+  ;; Parsing scheme code with elisp `read' is probably not the best idea.
+  (read (replace-regexp-in-string
+         "#f\\|#<unspecified>" "nil"
+         (replace-regexp-in-string
+          "#t" "t" (car (guix-geiser-eval str wrap repl))))))
+
+(defun guix-geiser-eval-in-repl (str &optional repl)
+  "Switch to Geiser REPL and evaluate STR with guile expression there."
+  (if repl
+      (geiser-repl--switch-to-buffer repl)
+    (geiser--go-to-repl))
+  (geiser-repl--send str))
+
+(provide 'guix-geiser)
+
+;;; guix-geiser.el ends here
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 3/7] emacs: Add code to call guile procedures.
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
  2015-07-25  8:49 ` [PATCH 1/7] emacs: Move guile related code to "guix-guile.el" Alex Kost
  2015-07-25  8:49 ` [PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el" Alex Kost
@ 2015-07-25  8:49 ` Alex Kost
  2015-08-18 13:52   ` Ludovic Courtès
  2015-07-25  8:49 ` [PATCH 4/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Kost

* emacs/guix-guile.el (guix-guile-make-call-expression): New function.
* emacs/guix-geiser.el (guix-geiser-call, guix-geiser-call-in-repl): New
  functions.
---
 emacs/guix-geiser.el | 13 +++++++++++++
 emacs/guix-guile.el  |  7 +++++++
 2 files changed, 20 insertions(+)

diff --git a/emacs/guix-geiser.el b/emacs/guix-geiser.el
index 1f0cf72..14f48c9 100644
--- a/emacs/guix-geiser.el
+++ b/emacs/guix-geiser.el
@@ -24,6 +24,7 @@
 ;;; Code:
 
 (require 'geiser-mode)
+(require 'guix-guile)
 
 (defun guix-geiser-repl ()
   "Return the current Geiser REPL."
@@ -62,6 +63,18 @@ Return elisp expression of the first result value of evaluation."
     (geiser--go-to-repl))
   (geiser-repl--send str))
 
+(defun guix-geiser-call (proc &rest args)
+  "Call (PROC ARGS ...) synchronously using the current Geiser REPL.
+PROC and ARGS should be strings."
+  (guix-geiser-eval
+   (apply #'guix-guile-make-call-expression proc args)))
+
+(defun guix-geiser-call-in-repl (proc &rest args)
+  "Call (PROC ARGS ...) in the current Geiser REPL.
+PROC and ARGS should be strings."
+  (guix-geiser-eval-in-repl
+   (apply #'guix-guile-make-call-expression proc args)))
+
 (provide 'guix-geiser)
 
 ;;; guix-geiser.el ends here
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
index 112262e..87af192 100644
--- a/emacs/guix-guile.el
+++ b/emacs/guix-guile.el
@@ -24,6 +24,13 @@
 
 ;;; Code:
 
+(defun guix-guile-make-call-expression (proc &rest args)
+  "Return \"(PROC ARGS ...)\" string.
+PROC and ARGS should be strings."
+  (format "(%s %s)"
+          proc
+          (mapconcat #'identity args " ")))
+
 (defun guix-make-guile-expression (fun &rest args)
   "Return string containing a guile expression for calling FUN with ARGS."
   (format "(%S %s)" fun
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
                   ` (2 preceding siblings ...)
  2015-07-25  8:49 ` [PATCH 3/7] emacs: Add code to call guile procedures Alex Kost
@ 2015-07-25  8:49 ` Alex Kost
  2015-07-25 18:51   ` Mathieu Lirzin
  2015-08-18 14:05   ` Ludovic Courtès
  2015-07-25  8:49 ` [PATCH 5/7] ui: Add 'show-derivation-outputs' Alex Kost
                   ` (3 subsequent siblings)
  7 siblings, 2 replies; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Kost

* emacs/guix-guile.el (guix-guile-current-module): New function.
* emacs/guix-devel.el: New file.
  (guix-devel-use-modules, guix-devel-use-current-module): New functions.
* doc/emacs.texi (Emacs Development): New node.  Document
  'guix-devel-use-current-module'.
---
 doc/emacs.texi      | 29 ++++++++++++++++++++++++++++-
 emacs/guix-devel.el | 44 ++++++++++++++++++++++++++++++++++++++++++++
 emacs/guix-guile.el | 13 +++++++++++++
 3 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 emacs/guix-devel.el

diff --git a/doc/emacs.texi b/doc/emacs.texi
index 180037a..6920bef 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -19,7 +19,8 @@ guix package}).  Specifically, ``guix.el'' makes it easy to:
 * Usage: Emacs Usage.			Using the interface.
 * Configuration: Emacs Configuration.	Configuring the interface.
 * Prettify Mode: Emacs Prettify.	Abbreviating @file{/gnu/store/@dots{}} file names.
-* Completions: Emacs Completions.       Completing @command{guix} shell command.
+* Completions: Emacs Completions.	Completing @command{guix} shell command.
+* Development: Emacs Development.	Tools for Guix developers.
 @end menu
 
 @node Emacs Initial Setup
@@ -554,3 +555,29 @@ something:
 @item @code{guix lint --checkers=synopsis,des}@key{TAB}
 
 @end itemize
+
+
+@node Emacs Development
+@subsection Development
+
+This section describes some additional commands for Guix developers who
+use Geiser to work with guile code.
+
+@table @kbd
+
+@item M-x guix-devel-use-current-module
+Use the current guile module.  Often after opening a scheme file, you
+want to use a module it defines, so you switch to the Geiser REPL and
+write @code{,use (some module)} there.  You may just use this command
+instead.
+
+@end table
+
+And as always if you use a command often, it is a good idea to bind a
+key to it, for example like this:
+
+@example
+(with-eval-after-load 'scheme
+  (define-key scheme-mode-map (kbd "C-c u")
+    'guix-devel-use-current-module))
+@end example
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
new file mode 100644
index 0000000..e99b289
--- /dev/null
+++ b/emacs/guix-devel.el
@@ -0,0 +1,44 @@
+;;; guix-devel.el --- Development tools
+
+;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file provides commands useful for developing Guix (or even arbitrary
+;; guile code) with Geiser.
+
+;;; Code:
+
+(require 'guix-guile)
+(require 'guix-geiser)
+
+(defun guix-devel-use-modules (&rest modules)
+  "Use guile MODULES."
+  (apply #'guix-geiser-call "use-modules" modules))
+
+;;;###autoload
+(defun guix-devel-use-current-module ()
+  "Use the current guile module."
+  (interactive)
+  (let ((module (guix-guile-current-module)))
+    (guix-devel-use-modules module)
+    (message "Using %s module." module)))
+
+(provide 'guix-devel)
+
+;;; guix-devel.el ends here
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
index 87af192..ffa8848 100644
--- a/emacs/guix-guile.el
+++ b/emacs/guix-guile.el
@@ -24,6 +24,19 @@
 
 ;;; Code:
 
+(require 'geiser-guile)
+
+(defun guix-guile-current-module ()
+  "Return string with current guile module.
+Return nil, if current buffer does not define a module."
+  ;; Modified version of `geiser-guile--get-module'.
+  (save-excursion
+    (geiser-syntax--pop-to-top)
+    (when (or (re-search-backward geiser-guile--module-re nil t)
+              (looking-at geiser-guile--library-re)
+              (re-search-forward geiser-guile--module-re nil t))
+      (match-string-no-properties 1))))
+
 (defun guix-guile-make-call-expression (proc &rest args)
   "Return \"(PROC ARGS ...)\" string.
 PROC and ARGS should be strings."
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 5/7] ui: Add 'show-derivation-outputs'.
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
                   ` (3 preceding siblings ...)
  2015-07-25  8:49 ` [PATCH 4/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
@ 2015-07-25  8:49 ` Alex Kost
  2015-08-18 14:07   ` Ludovic Courtès
  2015-07-25  8:49 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Kost

* guix/scripts/build.scm (guix-build): Extract code from here and move to...
* guix/ui.scm (show-derivation-outputs): ... here.  New procedure.
---
 guix/scripts/build.scm |  9 +--------
 guix/ui.scm            | 11 ++++++++++-
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index d593b5a..f169853 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -490,14 +490,7 @@ arguments with packages that use the specified source."
                          roots))
               ((not (assoc-ref opts 'dry-run?))
                (and (build-derivations store drv)
-                    (for-each (lambda (d)
-                                (format #t "~{~a~%~}"
-                                        (map (match-lambda
-                                              ((out-name . out)
-                                               (derivation->output-path
-                                                d out-name)))
-                                             (derivation-outputs d))))
-                              drv)
+                    (for-each show-derivation-outputs drv)
                     (for-each (cut register-root store <> <>)
                               (map (lambda (drv)
                                      (map cdr
diff --git a/guix/ui.scm b/guix/ui.scm
index 28d4b97..f17eae9 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2,7 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
-;;; Copyright © 2014 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
@@ -57,6 +57,7 @@
             show-bug-report-information
             string->number*
             size->number
+            show-derivation-outputs
             show-what-to-build
             show-what-to-build*
             show-manifest-transaction
@@ -489,6 +490,14 @@ error."
      (leave (_ "expression ~s does not evaluate to a package~%")
             str))))
 
+(define (show-derivation-outputs derivation)
+  "Show outputs of DERIVATION."
+  (format #t "~{~a~%~}"
+          (map (match-lambda
+                 ((out-name . out)
+                  (derivation->output-path derivation out-name)))
+               (derivation-outputs derivation))))
+
 (define* (show-what-to-build store drv
                              #:key dry-run? (use-substitutes? #t))
   "Show what will or would (depending on DRY-RUN?) be built in realizing the
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 6/7] guix build: Add 'build-package'.
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
                   ` (4 preceding siblings ...)
  2015-07-25  8:49 ` [PATCH 5/7] ui: Add 'show-derivation-outputs' Alex Kost
@ 2015-07-25  8:49 ` Alex Kost
  2015-08-18 14:15   ` Ludovic Courtès
  2015-07-25  8:49 ` [PATCH 7/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
  2015-08-18 13:50 ` [PATCH 0/7] Add "guix-devel-…" commands Ludovic Courtès
  7 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Kost

* guix/scripts/build.scm (build-package): New procedure.
---
 guix/scripts/build.scm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index f169853..b710b59 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -39,9 +40,20 @@
             set-build-options-from-command-line
             set-build-options-from-command-line*
             show-build-options-help
-
+            build-package
             guix-build))
 
+(define (build-package package . build-options)
+  "Build PACKAGE using BUILD-OPTIONS."
+  (with-store store
+    (let* ((drv (run-with-store store
+                  (package->derivation package)))
+           (drvs (list drv)))
+      (apply set-build-options store build-options)
+      (show-what-to-build store drvs)
+      (build-derivations store drvs)
+      (show-derivation-outputs drv))))
+
 (define (register-root store paths root)
   "Register ROOT as an indirect GC root for all of PATHS."
   (let* ((root (string-append (canonicalize-path (dirname root))
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 7/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
                   ` (5 preceding siblings ...)
  2015-07-25  8:49 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
@ 2015-07-25  8:49 ` Alex Kost
  2015-08-18 14:17   ` Ludovic Courtès
  2015-08-18 13:50 ` [PATCH 0/7] Add "guix-devel-…" commands Ludovic Courtès
  7 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-07-25  8:49 UTC (permalink / raw)
  To: guix-devel; +Cc: Alex Kost

Suggested by Ludovic Courtès <ludo@gnu.org>.

* emacs/guix-guile.el (guix-guile-definition-regexp): New variable.
  (guix-guile-current-definition): New function.
* emacs/guix-devel.el (guix-devel-build-current-package-definition): New
  command.
* doc/emacs.texi (Emacs Development): Document it.
---
 doc/emacs.texi      |  6 ++++++
 emacs/guix-devel.el |  9 +++++++++
 emacs/guix-guile.el | 17 +++++++++++++++++
 3 files changed, 32 insertions(+)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index 6920bef..5f1584c 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -571,6 +571,12 @@ want to use a module it defines, so you switch to the Geiser REPL and
 write @code{,use (some module)} there.  You may just use this command
 instead.
 
+@item M-x guix-devel-build-current-package-definition
+Build package defined by the current variable definition.  If you
+modified the current package definition, don't forget to reevaluate it
+before calling this command (for example, with @kbd{C-M-x} (@pxref{To
+eval or not to eval,,, geiser, Geiser User Manual})).
+
 @end table
 
 And as always if you use a command often, it is a good idea to bind a
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
index e99b289..1d3f381 100644
--- a/emacs/guix-devel.el
+++ b/emacs/guix-devel.el
@@ -39,6 +39,15 @@
     (guix-devel-use-modules module)
     (message "Using %s module." module)))
 
+;;;###autoload
+(defun guix-devel-build-current-package-definition ()
+  "Build package defined by the current top-level variable definition."
+  (interactive)
+  (guix-devel-use-modules "(guix scripts build)"
+                          (guix-guile-current-module))
+  (guix-geiser-call-in-repl "build-package"
+                            (guix-guile-current-definition)))
+
 (provide 'guix-devel)
 
 ;;; guix-devel.el ends here
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
index ffa8848..aa5d747 100644
--- a/emacs/guix-guile.el
+++ b/emacs/guix-guile.el
@@ -26,6 +26,23 @@
 
 (require 'geiser-guile)
 
+(defvar guix-guile-definition-regexp
+  (rx bol "(define"
+      (zero-or-one "*")
+      (zero-or-one "-public")
+      (one-or-more space)
+      (zero-or-one "(")
+      (group (one-or-more (or word (syntax symbol)))))
+  "Regexp used to find the guile definition.")
+
+(defun guix-guile-current-definition ()
+  "Return string with name of the current top-level guile definition."
+  (save-excursion
+    (beginning-of-defun)
+    (if (looking-at guix-guile-definition-regexp)
+        (match-string-no-properties 1)
+      (error "Couldn't find the current definition"))))
+
 (defun guix-guile-current-module ()
   "Return string with current guile module.
 Return nil, if current buffer does not define a module."
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-25  8:49 ` [PATCH 4/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
@ 2015-07-25 18:51   ` Mathieu Lirzin
  2015-07-26  8:29     ` Alex Kost
  2015-08-18 14:05   ` Ludovic Courtès
  1 sibling, 1 reply; 49+ messages in thread
From: Mathieu Lirzin @ 2015-07-25 18:51 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> writes:

> * emacs/guix-guile.el (guix-guile-current-module): New function.
> * emacs/guix-devel.el: New file.
>   (guix-devel-use-modules, guix-devel-use-current-module): New functions.
> * doc/emacs.texi (Emacs Development): New node.  Document
>   'guix-devel-use-current-module'.

[...]

> @@ -19,7 +19,8 @@ guix package}).  Specifically, ``guix.el'' makes it easy to:
>  * Usage: Emacs Usage.			Using the interface.
>  * Configuration: Emacs Configuration.	Configuring the interface.
>  * Prettify Mode: Emacs Prettify.	Abbreviating @file{/gnu/store/@dots{}} file names.
> -* Completions: Emacs Completions.       Completing @command{guix} shell command.
> +* Completions: Emacs Completions.	Completing @command{guix} shell command.
> +* Development: Emacs Development.	Tools for Guix developers.
>  @end menu

What do you think about integrating it in section "Contributing" instead?

> +And as always if you use a command often, it is a good idea to bind a
> +key to it, for example like this:
> +
> +@example
> +(with-eval-after-load 'scheme
> +  (define-key scheme-mode-map (kbd "C-c u")
> +    'guix-devel-use-current-module))
> +@end example

I remember reading somewhere in the Emacs manual that "C-c <Letter>" is
meant for user customization in the global key map (can't remember where
;)). So what suggesting "C-c C-u" which is a mode specific key binding?

--
Mathieu Lirzin

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-25 18:51   ` Mathieu Lirzin
@ 2015-07-26  8:29     ` Alex Kost
  2015-07-26 14:00       ` Mathieu Lirzin
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-07-26  8:29 UTC (permalink / raw)
  To: Mathieu Lirzin; +Cc: guix-devel

Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:

> Alex Kost <alezost@gmail.com> writes:
>
>> * emacs/guix-guile.el (guix-guile-current-module): New function.
>> * emacs/guix-devel.el: New file.
>>   (guix-devel-use-modules, guix-devel-use-current-module): New functions.
>> * doc/emacs.texi (Emacs Development): New node.  Document
>>   'guix-devel-use-current-module'.
>
> [...]
>
>> @@ -19,7 +19,8 @@ guix package}).  Specifically, ``guix.el'' makes it easy to:
>>  * Usage: Emacs Usage.			Using the interface.
>>  * Configuration: Emacs Configuration.	Configuring the interface.
>>  * Prettify Mode: Emacs Prettify.	Abbreviating @file{/gnu/store/@dots{}} file names.
>> -* Completions: Emacs Completions.       Completing @command{guix} shell command.
>> +* Completions: Emacs Completions.	Completing @command{guix} shell command.
>> +* Development: Emacs Development.	Tools for Guix developers.
>>  @end menu
>
> What do you think about integrating it in section "Contributing" instead?

Maybe, I don't have a preference here.

>> +And as always if you use a command often, it is a good idea to bind a
>> +key to it, for example like this:
>> +
>> +@example
>> +(with-eval-after-load 'scheme
>> +  (define-key scheme-mode-map (kbd "C-c u")
>> +    'guix-devel-use-current-module))
>> +@end example
>
> I remember reading somewhere in the Emacs manual that "C-c <Letter>" is
> meant for user customization in the global key map (can't remember where
> ;)). So what suggesting "C-c C-u" which is a mode specific key binding?

I don't know whether there is such (or any other) suggestion anywhere.
But since that was just an example, not a recommendation (not even a
suggestion), I think it doesn't matter what key binding to use there.
Do you have any preference?  What about "C-H-M-s-u"? :-)

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-26  8:29     ` Alex Kost
@ 2015-07-26 14:00       ` Mathieu Lirzin
  2015-07-26 18:11         ` Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Mathieu Lirzin @ 2015-07-26 14:00 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> writes:

> Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:
>> What do you think about integrating it in section "Contributing" instead?
>
> Maybe, I don't have a preference here.

Since it's not really related to package management, I think it would be
preferable to move this in the node "The perfect Setup".

>> I remember reading somewhere in the Emacs manual that "C-c <Letter>" is
>> meant for user customization in the global key map (can't remember where
>> ;)). So what suggesting "C-c C-u" which is a mode specific key binding?
>
> I don't know whether there is such (or any other) suggestion anywhere.
> But since that was just an example, not a recommendation (not even a
> suggestion), I think it doesn't matter what key binding to use there.
> Do you have any preference?  What about "C-H-M-s-u"? :-)

I agree it's not really important for advanced Emacs users who will have
no problem choosing something adapted to their setup. Nonetheless IMHO
consistency and simplicity helps newcomers to understand, So I will be
in favour of anything that follows this convention. :)

--8<---------------cut here---------------start------------->8---
(global-set-key (kbd "C-c <letter>") foo-function-callable-anywhere)

(define-key bar-mode-map
            (kbd "C-c C-<letter>")
            'foo-function-for-bar-mode)
--8<---------------cut here---------------end--------------->8---

--
Mathieu Lirzin

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-26 14:00       ` Mathieu Lirzin
@ 2015-07-26 18:11         ` Alex Kost
  2015-07-28  9:19           ` Mathieu Lirzin
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-07-26 18:11 UTC (permalink / raw)
  To: Mathieu Lirzin; +Cc: guix-devel

Mathieu Lirzin (2015-07-26 17:00 +0300) wrote:

> Alex Kost <alezost@gmail.com> writes:
>
>> Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:
>>> What do you think about integrating it in section "Contributing" instead?
>>
>> Maybe, I don't have a preference here.
>
> Since it's not really related to package management, I think it would be
> preferable to move this in the node "The perfect Setup".

OK, you convinced me :-) I'll put the docs there.

>>> I remember reading somewhere in the Emacs manual that "C-c <Letter>" is
>>> meant for user customization in the global key map (can't remember where
>>> ;)). So what suggesting "C-c C-u" which is a mode specific key binding?
>>
>> I don't know whether there is such (or any other) suggestion anywhere.
>> But since that was just an example, not a recommendation (not even a
>> suggestion), I think it doesn't matter what key binding to use there.
>> Do you have any preference?  What about "C-H-M-s-u"? :-)
>
> I agree it's not really important for advanced Emacs users who will have
> no problem choosing something adapted to their setup. Nonetheless IMHO
> consistency and simplicity helps newcomers to understand, So I will be
> in favour of anything that follows this convention. :)
>
> (global-set-key (kbd "C-c <letter>") foo-function-callable-anywhere)
>
> (define-key bar-mode-map
>             (kbd "C-c C-<letter>")
>             'foo-function-for-bar-mode)

According to (info "(elisp) Key Binding Conventions"), 'C-c LETTER'
bindings are reserved for users, so I think using "C-c u" in that
example is absolutely fine, don't you agree?

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-26 18:11         ` Alex Kost
@ 2015-07-28  9:19           ` Mathieu Lirzin
  0 siblings, 0 replies; 49+ messages in thread
From: Mathieu Lirzin @ 2015-07-28  9:19 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> writes:

>>> Mathieu Lirzin (2015-07-25 21:51 +0300) wrote:
>>>
>>> I don't know whether there is such (or any other) suggestion anywhere.
>>> But since that was just an example, not a recommendation (not even a
>>> suggestion), I think it doesn't matter what key binding to use there.
>>> Do you have any preference?  What about "C-H-M-s-u"? :-)
>>
>> I agree it's not really important for advanced Emacs users who will have
>> no problem choosing something adapted to their setup. Nonetheless IMHO
>> consistency and simplicity helps newcomers to understand, So I will be
>> in favour of anything that follows this convention. :)
>>
>> (global-set-key (kbd "C-c <letter>") foo-function-callable-anywhere)
>>
>> (define-key bar-mode-map
>>             (kbd "C-c C-<letter>")
>>             'foo-function-for-bar-mode)
>
> According to (info "(elisp) Key Binding Conventions"), 'C-c LETTER'
> bindings are reserved for users, so I think using "C-c u" in that
> example is absolutely fine, don't you agree?

I agree.  Sorry for the noise and thanks for retrieving this
reference. ;)

--
Mathieu Lirzin

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 0/7] Add "guix-devel-…" commands.
  2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
                   ` (6 preceding siblings ...)
  2015-07-25  8:49 ` [PATCH 7/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
@ 2015-08-18 13:50 ` Ludovic Courtès
  2015-08-19 20:47   ` Alex Kost
  7 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 13:50 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> And finally, I'm afraid building guix package in a Geiser REPL may not
> be very useful because of <https://github.com/jaor/geiser/issues/28>
> (you have wait for the REPL command to be finished before continuing to
> edit .scm-file).

Bummer, indeed.  I wonder if that could be worked around by spawning a
new Guile server thread that would be used to build the package, and
opening a new Geiser REPL connected to that thread?  Maybe too complex,
though.

> Anyway, Ludovic, is that what you meant?:
> <https://gnunet.org/bot/log/guix/2015-07-21#T704966>

Sounds like it yes, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 1/7] emacs: Move guile related code to "guix-guile.el".
  2015-07-25  8:49 ` [PATCH 1/7] emacs: Move guile related code to "guix-guile.el" Alex Kost
@ 2015-08-18 13:50   ` Ludovic Courtès
  2015-08-18 13:51   ` Ludovic Courtès
  1 sibling, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 13:50 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-backend.el (guix-make-guile-expression): Move to...
> * emacs/guix-guile.el: ... here.  New file.
> * emacs/guix-base.el: Use it.

OK

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 1/7] emacs: Move guile related code to "guix-guile.el".
  2015-07-25  8:49 ` [PATCH 1/7] emacs: Move guile related code to "guix-guile.el" Alex Kost
  2015-08-18 13:50   ` Ludovic Courtès
@ 2015-08-18 13:51   ` Ludovic Courtès
  1 sibling, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 13:51 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-backend.el (guix-make-guile-expression): Move to...
> * emacs/guix-guile.el: ... here.  New file.
> * emacs/guix-base.el: Use it.

Oh, make sure to add guix-guile.el to emacs.am.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el".
  2015-07-25  8:49 ` [PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el" Alex Kost
@ 2015-08-18 13:52   ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 13:52 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-backend.el: Adjust commentary. Move "eval" code to ...
>   (guix-eval): Remove.
>   (guix-eval-read, guix-eval-in-repl): Adjust to use new functions.
> * emacs/guix-geiser.el: ...here.  New file.
>   (guix-geiser-eval, guix-geiser-eval-read, guix-geiser-eval-in-repl):
>   New functions.

OK

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 3/7] emacs: Add code to call guile procedures.
  2015-07-25  8:49 ` [PATCH 3/7] emacs: Add code to call guile procedures Alex Kost
@ 2015-08-18 13:52   ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 13:52 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-guile.el (guix-guile-make-call-expression): New function.
> * emacs/guix-geiser.el (guix-geiser-call, guix-geiser-call-in-repl): New
>   functions.

OK

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-25  8:49 ` [PATCH 4/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
  2015-07-25 18:51   ` Mathieu Lirzin
@ 2015-08-18 14:05   ` Ludovic Courtès
  2015-08-19 20:47     ` Alex Kost
  1 sibling, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 14:05 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * emacs/guix-guile.el (guix-guile-current-module): New function.
> * emacs/guix-devel.el: New file.
>   (guix-devel-use-modules, guix-devel-use-current-module): New functions.
> * doc/emacs.texi (Emacs Development): New node.  Document
>   'guix-devel-use-current-module'.

[...]

> +@node Emacs Development
> +@subsection Development
> +
> +This section describes some additional commands for Guix developers who
> +use Geiser to work with guile code.

s/guile/Guile/

It’s fine to leave this section here, but there should be a sentence
under “Contributing” with a cross-reference to here.

> +@table @kbd
> +
> +@item M-x guix-devel-use-current-module
> +Use the current guile module.  Often after opening a scheme file, you

Capitalize “Guile” and “Scheme” here.

> +want to use a module it defines, so you switch to the Geiser REPL and
> +write @code{,use (some module)} there.  You may just use this command
> +instead.

Could you mention a use case here?  Like:

  For instance, you may call this command while visiting a file that
  defines packages; you can then switch to the associated REPL with
  @kbd{C-c C-z}, which will be in the current module, which is handy.

The “-devel” part might make it sound like it has an effect similar to
‘pre-inst-env’ though.  Perhaps we should explicitly remind developers
that they must set ‘guix-load-path’ appropriately?

Otherwise OK, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 5/7] ui: Add 'show-derivation-outputs'.
  2015-07-25  8:49 ` [PATCH 5/7] ui: Add 'show-derivation-outputs' Alex Kost
@ 2015-08-18 14:07   ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 14:07 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * guix/scripts/build.scm (guix-build): Extract code from here and move to...
> * guix/ui.scm (show-derivation-outputs): ... here.  New procedure.

[...]

> +(define (show-derivation-outputs derivation)
> +  "Show outputs of DERIVATION."

“Show the output file names of DERIVATION.”

OK!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-07-25  8:49 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
@ 2015-08-18 14:15   ` Ludovic Courtès
  2015-08-19 20:50     ` Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 14:15 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> * guix/scripts/build.scm (build-package): New procedure.

[...]

> +(define (build-package package . build-options)
> +  "Build PACKAGE using BUILD-OPTIONS."
> +  (with-store store
> +    (let* ((drv (run-with-store store
> +                  (package->derivation package)))
> +           (drvs (list drv)))
> +      (apply set-build-options store build-options)
> +      (show-what-to-build store drvs)
> +      (build-derivations store drvs)
> +      (show-derivation-outputs drv))))

I think this doesn’t fit here because it isn’t actually used by ‘guix
build’.  Maybe keep it in emacs/ for now?

Also, it’s best to call ‘set-build-options’ before anything else, to
make sure all the options are taken into account.

Bonus points for making it all monadic-style:

  (mbegin %store-monad
    (set-build-options* opts)
    (mlet* %store-monad ((drv  (package->derivation))
                         (drvs (list drv)))
      (mbegin %store-monad
        (show-what-to-build* drvs)
        (built-derivations drvs)
        (return (show-derivation-outputs drv)))))

and (define set-build-options* (store-lift set-build-options)) in
(guix store).

WDYT?

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 7/7] emacs: Add 'guix-devel-use-current-module'.
  2015-07-25  8:49 ` [PATCH 7/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
@ 2015-08-18 14:17   ` Ludovic Courtès
  2015-08-19 20:51     ` [PATCH 7/7] emacs: Add 'guix-devel-build-current-package-definition' Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-18 14:17 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Suggested by Ludovic Courtès <ludo@gnu.org>.
>
> * emacs/guix-guile.el (guix-guile-definition-regexp): New variable.
>   (guix-guile-current-definition): New function.
> * emacs/guix-devel.el (guix-devel-build-current-package-definition): New
>   command.
> * doc/emacs.texi (Emacs Development): Document it.

The subject line is incorrect.

> +@item M-x guix-devel-build-current-package-definition
> +Build package defined by the current variable definition.  If you
> +modified the current package definition, don't forget to reevaluate it
> +before calling this command (for example, with @kbd{C-M-x} (@pxref{To
> +eval or not to eval,,, geiser, Geiser User Manual})).

Maybe mention that, unfortunately, it will block until the command
completes?

Also, what about suggesting or even defining a key binding for this one?
It sounds very useful.

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 0/7] Add "guix-devel-…" commands.
  2015-08-18 13:50 ` [PATCH 0/7] Add "guix-devel-…" commands Ludovic Courtès
@ 2015-08-19 20:47   ` Alex Kost
  2015-08-25 20:59     ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-08-19 20:47 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-08-18 16:50 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> And finally, I'm afraid building guix package in a Geiser REPL may not
>> be very useful because of <https://github.com/jaor/geiser/issues/28>
>> (you have wait for the REPL command to be finished before continuing to
>> edit .scm-file).
>
> Bummer, indeed.  I wonder if that could be worked around by spawning a
> new Guile server thread that would be used to build the package, and
> opening a new Geiser REPL connected to that thread?  Maybe too complex,
> though.

That's what I did for *Guix REPL*: it is a server by default, and there
is *Guix Internal REPL* which connects to it (there is a commentary
about it in "emacs/guix-backend.el").

But I don't think it should be done here: as a user I expect that the
building will be performed in the current Geiser REPL, so it's up to me
(as a user) to decide what repl it is.

Also to avoid that limitation, a user can just run another Geiser REPL
after the building begins, and can continue to edit a scheme file with
the help of the current REPL, while the building will continue in the
previous one.  (I will mention this in the manual)

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-08-18 14:05   ` Ludovic Courtès
@ 2015-08-19 20:47     ` Alex Kost
  2015-08-26 11:07       ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-08-19 20:47 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-08-18 17:05 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> * emacs/guix-guile.el (guix-guile-current-module): New function.
>> * emacs/guix-devel.el: New file.
>>   (guix-devel-use-modules, guix-devel-use-current-module): New functions.
>> * doc/emacs.texi (Emacs Development): New node.  Document
>>   'guix-devel-use-current-module'.
>
> [...]
>
>> +@node Emacs Development
>> +@subsection Development
>> +
>> +This section describes some additional commands for Guix developers who
>> +use Geiser to work with guile code.
>
> s/guile/Guile/
>
> It’s fine to leave this section here, but there should be a sentence
> under “Contributing” with a cross-reference to here.

OK.

>> +@table @kbd
>> +
>> +@item M-x guix-devel-use-current-module
>> +Use the current guile module.  Often after opening a scheme file, you
>
> Capitalize “Guile” and “Scheme” here.
>
>> +want to use a module it defines, so you switch to the Geiser REPL and
>> +write @code{,use (some module)} there.  You may just use this command
>> +instead.
>
> Could you mention a use case here?  Like:
>
>   For instance, you may call this command while visiting a file that
>   defines packages; you can then switch to the associated REPL with
>   @kbd{C-c C-z}, which will be in the current module, which is handy.

The REPL will not be in the current module.  "M-x
guix-devel-use-current-module" is the equivalent of ",use", not
",module".  I thought the documentation was clear about that, no?

For switching to the current module, Geiser provides "C-c C-a" or
"C-u C-c C-z".

> The “-devel” part might make it sound like it has an effect similar to
> ‘pre-inst-env’ though.  Perhaps we should explicitly remind developers
> that they must set ‘guix-load-path’ appropriately?

Setting ‘guix-load-path’ will not take any effect here.  The whole point
of this guix-devel stuff is to provide additional commands for
scheme-mode, like Geiser does.  And these additional commands are
independent from Guix REPL; they are called in the current Geiser REPL
the same way you would use other Geiser commands.

So, for example, you open some guile file, you press some key bound to
‘guix-devel-use-current-module’ command to use this module in the
current Geiser REPL.  Then (if it's a module with guix packages), you
press another key to build the current package, or (in future) to
download the current package source, etc.

> Otherwise OK, thanks!

Thank you!

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-08-18 14:15   ` Ludovic Courtès
@ 2015-08-19 20:50     ` Alex Kost
  2015-08-26 11:12       ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-08-19 20:50 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-08-18 17:15 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> * guix/scripts/build.scm (build-package): New procedure.
>
> [...]
>
>> +(define (build-package package . build-options)
>> +  "Build PACKAGE using BUILD-OPTIONS."
>> +  (with-store store
>> +    (let* ((drv (run-with-store store
>> +                  (package->derivation package)))
>> +           (drvs (list drv)))
>> +      (apply set-build-options store build-options)
>> +      (show-what-to-build store drvs)
>> +      (build-derivations store drvs)
>> +      (show-derivation-outputs drv))))
>
> I think this doesn’t fit here because it isn’t actually used by ‘guix
> build’.  Maybe keep it in emacs/ for now?

If you mean "guix-main.scm", I don't think it's the right place either,
as all this guix-devel stuff does not depend on Guix REPL (or on any
code from "guix-main.scm" in general).  Besides, "guix-main.scm" doesn't
provide a module.

What about making some additional module?: (guix devel) or something.
Other similar code may be put there in future.  For example, you are
editing a package definition and you may want to download the current
origin source.  It will probably also require some specific scheme code,
which may be added to that module.

> Also, it’s best to call ‘set-build-options’ before anything else, to
> make sure all the options are taken into account.

OK

> Bonus points for making it all monadic-style:
>
>   (mbegin %store-monad
>     (set-build-options* opts)
>     (mlet* %store-monad ((drv  (package->derivation))
>                          (drvs (list drv)))
>       (mbegin %store-monad
>         (show-what-to-build* drvs)
>         (built-derivations drvs)
>         (return (show-derivation-outputs drv)))))
>
> and (define set-build-options* (store-lift set-build-options)) in
> (guix store).
>
> WDYT?

OK, I'll look at it.  I suppose adding 'set-build-options*' to (guix
store) should be done in a separate commit, right?

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 7/7] emacs: Add 'guix-devel-build-current-package-definition'.
  2015-08-18 14:17   ` Ludovic Courtès
@ 2015-08-19 20:51     ` Alex Kost
  2015-08-26 11:14       ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-08-19 20:51 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-08-18 17:17 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Suggested by Ludovic Courtès <ludo@gnu.org>.
>>
>> * emacs/guix-guile.el (guix-guile-definition-regexp): New variable.
>>   (guix-guile-current-definition): New function.
>> * emacs/guix-devel.el (guix-devel-build-current-package-definition): New
>>   command.
>> * doc/emacs.texi (Emacs Development): Document it.
>
> The subject line is incorrect.

Ah, indeed!  It should be:

  emacs: Add 'guix-devel-build-current-package-definition'.

Is that OK?

>> +@item M-x guix-devel-build-current-package-definition
>> +Build package defined by the current variable definition.  If you
>> +modified the current package definition, don't forget to reevaluate it
>> +before calling this command (for example, with @kbd{C-M-x} (@pxref{To
>> +eval or not to eval,,, geiser, Geiser User Manual})).
>
> Maybe mention that, unfortunately, it will block until the command
> completes?

Yes, sure.

> Also, what about suggesting or even defining a key binding for this one?
> It sounds very useful.

There is an example of defining a key binding for a command in this
section.  As for the real defining, not sure if it is worth, but yeah,
why not.  We may define 'guix-minor-mode', for example, with
guix-specific key bindings.  But I don't know what bindings to use:
'geiser-mode' already binds many commands to [C-c …].  Perhaps to put
the additional keys in [C-c g …]?

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 0/7] Add "guix-devel-…" commands.
  2015-08-19 20:47   ` Alex Kost
@ 2015-08-25 20:59     ` Ludovic Courtès
  2015-09-22 19:11       ` [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition' Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-25 20:59 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-08-18 16:50 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> And finally, I'm afraid building guix package in a Geiser REPL may not
>>> be very useful because of <https://github.com/jaor/geiser/issues/28>
>>> (you have wait for the REPL command to be finished before continuing to
>>> edit .scm-file).
>>
>> Bummer, indeed.  I wonder if that could be worked around by spawning a
>> new Guile server thread that would be used to build the package, and
>> opening a new Geiser REPL connected to that thread?  Maybe too complex,
>> though.
>
> That's what I did for *Guix REPL*: it is a server by default, and there
> is *Guix Internal REPL* which connects to it (there is a commentary
> about it in "emacs/guix-backend.el").
>
> But I don't think it should be done here: as a user I expect that the
> building will be performed in the current Geiser REPL, so it's up to me
> (as a user) to decide what repl it is.
>
> Also to avoid that limitation, a user can just run another Geiser REPL
> after the building begins, and can continue to edit a scheme file with
> the help of the current REPL, while the building will continue in the
> previous one.  (I will mention this in the manual)

OK, sounds good!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 4/7] emacs: Add 'guix-devel-use-current-module'.
  2015-08-19 20:47     ` Alex Kost
@ 2015-08-26 11:07       ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-26 11:07 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-08-18 17:05 +0300) wrote:

[...]

>>> +want to use a module it defines, so you switch to the Geiser REPL and
>>> +write @code{,use (some module)} there.  You may just use this command
>>> +instead.
>>
>> Could you mention a use case here?  Like:
>>
>>   For instance, you may call this command while visiting a file that
>>   defines packages; you can then switch to the associated REPL with
>>   @kbd{C-c C-z}, which will be in the current module, which is handy.
>
> The REPL will not be in the current module.  "M-x
> guix-devel-use-current-module" is the equivalent of ",use", not
> ",module".  I thought the documentation was clear about that, no?

Now that I reread it, it seems clear, indeed.  Forget my previous
comment.

>> The “-devel” part might make it sound like it has an effect similar to
>> ‘pre-inst-env’ though.  Perhaps we should explicitly remind developers
>> that they must set ‘guix-load-path’ appropriately?
>
> Setting ‘guix-load-path’ will not take any effect here.  The whole point
> of this guix-devel stuff is to provide additional commands for
> scheme-mode, like Geiser does.  And these additional commands are
> independent from Guix REPL; they are called in the current Geiser REPL
> the same way you would use other Geiser commands.

Right, sorry for messing things up!

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-08-19 20:50     ` Alex Kost
@ 2015-08-26 11:12       ` Ludovic Courtès
  2015-08-26 17:44         ` Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-26 11:12 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-08-18 17:15 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> * guix/scripts/build.scm (build-package): New procedure.
>>
>> [...]
>>
>>> +(define (build-package package . build-options)
>>> +  "Build PACKAGE using BUILD-OPTIONS."
>>> +  (with-store store
>>> +    (let* ((drv (run-with-store store
>>> +                  (package->derivation package)))
>>> +           (drvs (list drv)))
>>> +      (apply set-build-options store build-options)
>>> +      (show-what-to-build store drvs)
>>> +      (build-derivations store drvs)
>>> +      (show-derivation-outputs drv))))
>>
>> I think this doesn’t fit here because it isn’t actually used by ‘guix
>> build’.  Maybe keep it in emacs/ for now?
>
> If you mean "guix-main.scm", I don't think it's the right place either,
> as all this guix-devel stuff does not depend on Guix REPL (or on any
> code from "guix-main.scm" in general).  Besides, "guix-main.scm" doesn't
> provide a module.
>
> What about making some additional module?: (guix devel) or something.
> Other similar code may be put there in future.  For example, you are
> editing a package definition and you may want to download the current
> origin source.  It will probably also require some specific scheme code,
> which may be added to that module.

Maybe ‘build-package’ could go to (guix packages)?

>> Bonus points for making it all monadic-style:
>>
>>   (mbegin %store-monad
>>     (set-build-options* opts)
>>     (mlet* %store-monad ((drv  (package->derivation))
>>                          (drvs (list drv)))
>>       (mbegin %store-monad
>>         (show-what-to-build* drvs)
>>         (built-derivations drvs)
>>         (return (show-derivation-outputs drv)))))
>>
>> and (define set-build-options* (store-lift set-build-options)) in
>> (guix store).
>>
>> WDYT?
>
> OK, I'll look at it.  I suppose adding 'set-build-options*' to (guix
> store) should be done in a separate commit, right?

Yes please.

Thank you,
Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 7/7] emacs: Add 'guix-devel-build-current-package-definition'.
  2015-08-19 20:51     ` [PATCH 7/7] emacs: Add 'guix-devel-build-current-package-definition' Alex Kost
@ 2015-08-26 11:14       ` Ludovic Courtès
  2015-09-22 19:10         ` [PATCH 1/2] emacs: Add development utils Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-26 11:14 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-08-18 17:17 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> Suggested by Ludovic Courtès <ludo@gnu.org>.
>>>
>>> * emacs/guix-guile.el (guix-guile-definition-regexp): New variable.
>>>   (guix-guile-current-definition): New function.
>>> * emacs/guix-devel.el (guix-devel-build-current-package-definition): New
>>>   command.
>>> * doc/emacs.texi (Emacs Development): Document it.
>>
>> The subject line is incorrect.
>
> Ah, indeed!  It should be:
>
>   emacs: Add 'guix-devel-build-current-package-definition'.
>
> Is that OK?

Yes.

>> Also, what about suggesting or even defining a key binding for this one?
>> It sounds very useful.
>
> There is an example of defining a key binding for a command in this
> section.  As for the real defining, not sure if it is worth, but yeah,
> why not.  We may define 'guix-minor-mode', for example, with
> guix-specific key bindings.  But I don't know what bindings to use:
> 'geiser-mode' already binds many commands to [C-c …].  Perhaps to put
> the additional keys in [C-c g …]?

Yes, ‘guix-minor-mode’ and C-c g both sound like good ideas to me.

Thank you,
Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-08-26 11:12       ` Ludovic Courtès
@ 2015-08-26 17:44         ` Alex Kost
  2015-08-28  9:24           ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-08-26 17:44 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-08-26 14:12 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2015-08-18 17:15 +0300) wrote:
>>
>>> Alex Kost <alezost@gmail.com> skribis:
>>>
>>>> * guix/scripts/build.scm (build-package): New procedure.
>>>
>>> [...]
>>>
>>>> +(define (build-package package . build-options)
>>>> +  "Build PACKAGE using BUILD-OPTIONS."
>>>> +  (with-store store
>>>> +    (let* ((drv (run-with-store store
>>>> +                  (package->derivation package)))
>>>> +           (drvs (list drv)))
>>>> +      (apply set-build-options store build-options)
>>>> +      (show-what-to-build store drvs)
>>>> +      (build-derivations store drvs)
>>>> +      (show-derivation-outputs drv))))
>>>
>>> I think this doesn’t fit here because it isn’t actually used by ‘guix
>>> build’.  Maybe keep it in emacs/ for now?
>>
>> If you mean "guix-main.scm", I don't think it's the right place either,
>> as all this guix-devel stuff does not depend on Guix REPL (or on any
>> code from "guix-main.scm" in general).  Besides, "guix-main.scm" doesn't
>> provide a module.
>>
>> What about making some additional module?: (guix devel) or something.
>> Other similar code may be put there in future.  For example, you are
>> editing a package definition and you may want to download the current
>> origin source.  It will probably also require some specific scheme code,
>> which may be added to that module.
>
> Maybe ‘build-package’ could go to (guix packages)?

‘build-package’ uses ‘show-…’ procedures from (guix ui) module.  I
thought that adding this module to (guix packages) was not desired, or
is it OK?

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-08-26 17:44         ` Alex Kost
@ 2015-08-28  9:24           ` Ludovic Courtès
  2015-09-06  9:03             ` Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-08-28  9:24 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-08-26 14:12 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> Ludovic Courtès (2015-08-18 17:15 +0300) wrote:
>>>
>>>> Alex Kost <alezost@gmail.com> skribis:
>>>>
>>>>> * guix/scripts/build.scm (build-package): New procedure.
>>>>
>>>> [...]
>>>>
>>>>> +(define (build-package package . build-options)
>>>>> +  "Build PACKAGE using BUILD-OPTIONS."
>>>>> +  (with-store store
>>>>> +    (let* ((drv (run-with-store store
>>>>> +                  (package->derivation package)))
>>>>> +           (drvs (list drv)))
>>>>> +      (apply set-build-options store build-options)
>>>>> +      (show-what-to-build store drvs)
>>>>> +      (build-derivations store drvs)
>>>>> +      (show-derivation-outputs drv))))
>>>>
>>>> I think this doesn’t fit here because it isn’t actually used by ‘guix
>>>> build’.  Maybe keep it in emacs/ for now?
>>>
>>> If you mean "guix-main.scm", I don't think it's the right place either,
>>> as all this guix-devel stuff does not depend on Guix REPL (or on any
>>> code from "guix-main.scm" in general).  Besides, "guix-main.scm" doesn't
>>> provide a module.
>>>
>>> What about making some additional module?: (guix devel) or something.
>>> Other similar code may be put there in future.  For example, you are
>>> editing a package definition and you may want to download the current
>>> origin source.  It will probably also require some specific scheme code,
>>> which may be added to that module.
>>
>> Maybe ‘build-package’ could go to (guix packages)?
>
> ‘build-package’ uses ‘show-…’ procedures from (guix ui) module.  I
> thought that adding this module to (guix packages) was not desired, or
> is it OK?

Right, sorry.  So maybe leave in (guix build scripts) with a comment
explaining that it doesn’t have a better place and is for use by the
Emacs UI.  (Make sure to use the monadic style as suggested in a
previous message.)

Could you send an updated patch?

Sorry for the delay and round trips!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-08-28  9:24           ` Ludovic Courtès
@ 2015-09-06  9:03             ` Alex Kost
  2015-09-06  9:32               ` Alex Kost
  2015-09-08 20:10               ` Ludovic Courtès
  0 siblings, 2 replies; 49+ messages in thread
From: Alex Kost @ 2015-09-06  9:03 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 3566 bytes --]

Ludovic Courtès (2015-08-28 12:24 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2015-08-26 14:12 +0300) wrote:
>>
>>> Alex Kost <alezost@gmail.com> skribis:
>>>
>>>> Ludovic Courtès (2015-08-18 17:15 +0300) wrote:
>>>>
>>>>> Alex Kost <alezost@gmail.com> skribis:
>>>>>
>>>>>> * guix/scripts/build.scm (build-package): New procedure.
>>>>>
>>>>> [...]
>>>>>
>>>>>> +(define (build-package package . build-options)
>>>>>> +  "Build PACKAGE using BUILD-OPTIONS."
>>>>>> +  (with-store store
>>>>>> +    (let* ((drv (run-with-store store
>>>>>> +                  (package->derivation package)))
>>>>>> +           (drvs (list drv)))
>>>>>> +      (apply set-build-options store build-options)
>>>>>> +      (show-what-to-build store drvs)
>>>>>> +      (build-derivations store drvs)
>>>>>> +      (show-derivation-outputs drv))))
>>>>>
>>>>> I think this doesn’t fit here because it isn’t actually used by ‘guix
>>>>> build’.  Maybe keep it in emacs/ for now?
>>>>
>>>> If you mean "guix-main.scm", I don't think it's the right place either,
>>>> as all this guix-devel stuff does not depend on Guix REPL (or on any
>>>> code from "guix-main.scm" in general).  Besides, "guix-main.scm" doesn't
>>>> provide a module.
>>>>
>>>> What about making some additional module?: (guix devel) or something.
>>>> Other similar code may be put there in future.  For example, you are
>>>> editing a package definition and you may want to download the current
>>>> origin source.  It will probably also require some specific scheme code,
>>>> which may be added to that module.
>>>
>>> Maybe ‘build-package’ could go to (guix packages)?
>>
>> ‘build-package’ uses ‘show-…’ procedures from (guix ui) module.  I
>> thought that adding this module to (guix packages) was not desired, or
>> is it OK?
>
> Right, sorry.  So maybe leave in (guix build scripts) with a comment
> explaining that it doesn’t have a better place and is for use by the
> Emacs UI.  (Make sure to use the monadic style as suggested in a
> previous message.)
>
> Could you send an updated patch?

Yes, sorry for the delay.  At some point I noticed that ‘build-package’
doesn't show any build output, and I had a hard time trying to find out
what's wrong.  Eventually it appeared to be totally unrelated to the
code itself.  I think it's a Geiser bug, but I don't know how to make a
guix independent recipe — I have sent a message describing it in details
to guix-devel — I hope you could help with it :-)

So I am attaching 2 patches here: for adding ‘set-build-options*’ and
for adding ‘build-package’.

Now about the second patch.  At first, I don't agree with it :-).  I
added #:dry-run? to ‘build-package’ procedure as I think it may be
useful, then I found a nice ‘maybe-build’ procedure in (guix scripts
system), and I just moved it to (guix scripts build) which doesn't seem
right.

We have some code in (guix scripts …) that is rather common (I mean not
specific to the current module), but there is no better place for it,
usually because it uses (guix ui).

So what about making (guix scripts) module for such general stuff?
I think we can move there ‘maybe-build’, ‘%standard-build-options’,
‘set-build-options-from-command-line(*)’, ‘show-build-options-help’,
perhaps exported procedures from (guix scripts package).  And
‘build-package’ may also go there, WDYT?

Or maybe just put those things into (guix ui)?


[-- Attachment #2: 0001-store-Add-set-build-options.patch --]
[-- Type: text/x-patch, Size: 1157 bytes --]

From fd38fdae6e66effeba346e7bc863fc5348ec9b9a Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 3 Sep 2015 18:33:51 +0300
Subject: [PATCH 1/2] store: Add 'set-build-options*'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by: Ludovic Courtès <ludo@gnu.org>

* guix/store.scm (set-build-options*): New procedure.
---
 guix/store.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/guix/store.scm b/guix/store.scm
index 132b8a3..93f2c77 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -58,6 +58,7 @@
             close-connection
             with-store
             set-build-options
+            set-build-options*
             valid-path?
             query-path-hash
             hash-part->path
@@ -535,6 +536,9 @@ encoding conversion errors."
     (let loop ((done? (process-stderr server)))
       (or done? (process-stderr server)))))
 
+(define set-build-options*
+  (store-lift set-build-options))
+
 (define-syntax operation
   (syntax-rules ()
     "Define a client-side RPC stub for the given operation."
-- 
2.5.0


[-- Attachment #3: 0002-guix-build-Add-build-package.patch --]
[-- Type: text/x-patch, Size: 4120 bytes --]

From 9ffc27f7a076e4213ef3bee00e5cebad501685ac Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 23 Jul 2015 16:16:41 +0300
Subject: [PATCH 2/2] guix build: Add 'build-package'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* guix/scripts/system.scm (maybe-build): Move to ...
* guix/scripts/build.scm: ...here.
  (build-package): New procedure.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 guix/scripts/build.scm  | 41 ++++++++++++++++++++++++++++++++++++++++-
 guix/scripts/system.scm | 13 -------------
 2 files changed, 40 insertions(+), 14 deletions(-)

diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index f169853..ee4a3d6 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -39,9 +40,47 @@
             set-build-options-from-command-line
             set-build-options-from-command-line*
             show-build-options-help
-
+            maybe-build
+            build-package
             guix-build))
 
+;; XXX This procedure does not belong this module: it is used by
+;; 'build-package' and (guix scripts system).
+(define* (maybe-build drvs
+                      #:key dry-run? use-substitutes?)
+  "Show what will/would be built, and actually build DRVS, unless DRY-RUN? is
+true."
+  (with-monad %store-monad
+    (>>= (show-what-to-build* drvs
+                              #:dry-run? dry-run?
+                              #:use-substitutes? use-substitutes?)
+         (lambda (_)
+           (if dry-run?
+               (return #f)
+               (built-derivations drvs))))))
+
+;; XXX This procedure does not belong this module, but currently there
+;; is no better place for it.  It is used by Emacs development tools
+;; ("emacs/guix-devel.el").
+(define* (build-package package
+                        #:key (use-substitutes? #t) (dry-run? #f)
+                        #:allow-other-keys
+                        #:rest build-options)
+  "Build PACKAGE using BUILD-OPTIONS.
+Show what and how will/would be built."
+  (with-store store
+    (run-with-store store
+      (mbegin %store-monad
+        (apply set-build-options*
+               #:use-substitutes? use-substitutes?
+               (strip-keyword-arguments '(#:dry-run?) build-options))
+        (mlet %store-monad ((derivation (package->derivation package)))
+          (mbegin %store-monad
+            (maybe-build (list derivation)
+                         #:use-substitutes? use-substitutes?
+                         #:dry-run? dry-run?)
+            (return (show-derivation-outputs derivation))))))))
+
 (define (register-root store paths root)
   "Register ROOT as an indirect GC root for all of PATHS."
   (let* ((root (string-append (canonicalize-path (dirname root))
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 45f5982..0db4953 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -298,19 +298,6 @@ it atomically, and then run OS's activation script."
     ((disk-image)
      (system-disk-image os #:disk-image-size image-size))))
 
-(define* (maybe-build drvs
-                      #:key dry-run? use-substitutes?)
-  "Show what will/would be built, and actually build DRVS, unless DRY-RUN? is
-true."
-  (with-monad %store-monad
-    (>>= (show-what-to-build* drvs
-                              #:dry-run? dry-run?
-                              #:use-substitutes? use-substitutes?)
-         (lambda (_)
-           (if dry-run?
-               (return #f)
-               (built-derivations drvs))))))
-
 (define* (perform-action action os
                          #:key grub? dry-run?
                          use-substitutes? device target
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-09-06  9:03             ` Alex Kost
@ 2015-09-06  9:32               ` Alex Kost
  2015-09-08 19:59                 ` Ludovic Courtès
  2015-09-08 20:10               ` Ludovic Courtès
  1 sibling, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-09-06  9:32 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 828 bytes --]

Alex Kost (2015-09-06 12:03 +0300) wrote:

[...]
> diff --git a/guix/store.scm b/guix/store.scm
> index 132b8a3..93f2c77 100644
> --- a/guix/store.scm
> +++ b/guix/store.scm
> @@ -58,6 +58,7 @@
>              close-connection
>              with-store
>              set-build-options
> +            set-build-options*
>              valid-path?
>              query-path-hash
>              hash-part->path
> @@ -535,6 +536,9 @@ encoding conversion errors."
>      (let loop ((done? (process-stderr server)))
>        (or done? (process-stderr server)))))
>  
> +(define set-build-options*
> +  (store-lift set-build-options))

Arr, sorry, I sent the wrong patch: ‘set-build-options*’ should be moved
after ‘store-lift’ is defined.  In the current patch I put it after
‘build’ procedure.


[-- Attachment #2: 0001-store-Add-set-build-options.patch --]
[-- Type: text/x-patch, Size: 1165 bytes --]

From 4569ff4868a01e205b9b13b41dc587f8b8d67f76 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 3 Sep 2015 18:33:51 +0300
Subject: [PATCH] store: Add 'set-build-options*'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by: Ludovic Courtès <ludo@gnu.org>

* guix/store.scm (set-build-options*): New procedure.
---
 guix/store.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/guix/store.scm b/guix/store.scm
index 132b8a3..5f37e72 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -58,6 +58,7 @@
             close-connection
             with-store
             set-build-options
+            set-build-options*
             valid-path?
             query-path-hash
             hash-part->path
@@ -986,6 +987,9 @@ permission bits are kept."
   ;; Monadic variant of 'build-things'.
   (store-lift build-things))
 
+(define set-build-options*
+  (store-lift set-build-options))
+
 (define %guile-for-build
   ;; The derivation of the Guile to be used within the build environment,
   ;; when using 'gexp->derivation' and co.
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-09-06  9:32               ` Alex Kost
@ 2015-09-08 19:59                 ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-08 19:59 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From 4569ff4868a01e205b9b13b41dc587f8b8d67f76 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Thu, 3 Sep 2015 18:33:51 +0300
> Subject: [PATCH] store: Add 'set-build-options*'.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Suggested by: Ludovic Courtès <ludo@gnu.org>
>
> * guix/store.scm (set-build-options*): New procedure.

OK, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-09-06  9:03             ` Alex Kost
  2015-09-06  9:32               ` Alex Kost
@ 2015-09-08 20:10               ` Ludovic Courtès
  2015-09-10 10:25                 ` [PATCH] Add (guix scripts) Alex Kost
  2015-09-18 18:51                 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
  1 sibling, 2 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-08 20:10 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Now about the second patch.  At first, I don't agree with it :-).  I
> added #:dry-run? to ‘build-package’ procedure as I think it may be
> useful, then I found a nice ‘maybe-build’ procedure in (guix scripts
> system), and I just moved it to (guix scripts build) which doesn't seem
> right.
>
> We have some code in (guix scripts …) that is rather common (I mean not
> specific to the current module), but there is no better place for it,
> usually because it uses (guix ui).
>
> So what about making (guix scripts) module for such general stuff?
> I think we can move there ‘maybe-build’, ‘%standard-build-options’,
> ‘set-build-options-from-command-line(*)’, ‘show-build-options-help’,
> perhaps exported procedures from (guix scripts package).  And
> ‘build-package’ may also go there, WDYT?
>
> Or maybe just put those things into (guix ui)?

(guix ui) has become fat; (guix scripts) sounds like a good idea.  Then
things like ‘args-fold*’, ‘parse-command-line’, ‘run-guix-command’,
‘run-guix’, ‘guix-main’, and ‘program-name’ should probably move there
as well (unless I’m overlooking something that would prevent this),
along with ‘maybe-build’ and ‘build-package’.

How does that sound?

> From 9ffc27f7a076e4213ef3bee00e5cebad501685ac Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Thu, 23 Jul 2015 16:16:41 +0300
> Subject: [PATCH 2/2] guix build: Add 'build-package'.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> * guix/scripts/system.scm (maybe-build): Move to ...
> * guix/scripts/build.scm: ...here.
>   (build-package): New procedure.
>
> Co-authored-by: Ludovic Courtès <ludo@gnu.org>

[...]

> +(define* (build-package package
> +                        #:key (use-substitutes? #t) (dry-run? #f)
> +                        #:allow-other-keys
> +                        #:rest build-options)
> +  "Build PACKAGE using BUILD-OPTIONS.
> +Show what and how will/would be built."
> +  (with-store store
> +    (run-with-store store
> +      (mbegin %store-monad
> +        (apply set-build-options*

Please remove ‘with-store’ and ‘run-with-store’.  This should be done on
the Emacs side (maybe via the ,run-in-store meta-command?).

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH] Add (guix scripts).
  2015-09-08 20:10               ` Ludovic Courtès
@ 2015-09-10 10:25                 ` Alex Kost
  2015-09-14 13:34                   ` Ludovic Courtès
  2015-09-18 18:51                 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
  1 sibling, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-09-10 10:25 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1905 bytes --]

Ludovic Courtès (2015-09-08 23:10 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> We have some code in (guix scripts …) that is rather common (I mean not
>> specific to the current module), but there is no better place for it,
>> usually because it uses (guix ui).
>>
>> So what about making (guix scripts) module for such general stuff?
>> I think we can move there ‘maybe-build’, ‘%standard-build-options’,
>> ‘set-build-options-from-command-line(*)’, ‘show-build-options-help’,
>> perhaps exported procedures from (guix scripts package).  And
>> ‘build-package’ may also go there, WDYT?
>>
>> Or maybe just put those things into (guix ui)?
>
> (guix ui) has become fat; (guix scripts) sounds like a good idea.  Then
> things like ‘args-fold*’, ‘parse-command-line’, ‘run-guix-command’,
> ‘run-guix’, ‘guix-main’, and ‘program-name’ should probably move there
> as well (unless I’m overlooking something that would prevent this),
> along with ‘maybe-build’ and ‘build-package’.
>
> How does that sound?

I like it.  I hope I missed nothing in this patch (it appeared to be a
big change).  At least "make check" was passed successfully.

I think ‘maybe-build’ may move later when ‘build-package’
will be added, ok?

Some notes:

- ‘program-name’ is used by ‘define-diagnostic’ macro, so I left it in
  (guix ui).

- ‘guix-main’ uses ‘initialize-guix’, so I exported it from (guix ui) or
  should it be moved to (guix scripts) instead and export
  ‘%gettext-domain’?

- I studied the commit log related to guix/ui.scm, and adjusted the
  copyright lines accordingly.

Also our 'guix' executable will be changed, I'm not sure what
consequences it will lead to.  Perhaps after this commit, the
‘guix-devel’ package should be updated, or is it not necessary?


[-- Attachment #2: 0001-Add-guix-scripts.patch --]
[-- Type: text/x-patch, Size: 29971 bytes --]

From 7d86c3fff02351b7b6bc02b74fb77684c8187693 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 10 Sep 2015 12:37:36 +0300
Subject: [PATCH] Add (guix scripts).

* guix/ui.scm: Add missing copyright lines.
  (program-name, show-guix-help, show-guix-usage, initialize-guix): Export.
  (args-fold*, environment-build-options, %default-argument-handler,
  parse-command-line, run-guix-command, run-guix, guix-main): Move to ...
* guix/scripts.scm: ...here.  New file.
* emacs/guix-main.scm: Use it.
* guix/scripts/archive.scm: Likewise.
* guix/scripts/build.scm: Likewise.
* guix/scripts/download.scm: Likewise.
* guix/scripts/edit.scm: Likewise.
* guix/scripts/environment.scm: Likewise.
* guix/scripts/gc.scm: Likewise.
* guix/scripts/graph.scm: Likewise.
* guix/scripts/hash.scm: Likewise.
* guix/scripts/import/cpan.scm: Likewise.
* guix/scripts/import/cran.scm: Likewise.
* guix/scripts/import/elpa.scm: Likewise.
* guix/scripts/import/gem.scm: Likewise.
* guix/scripts/import/gnu.scm: Likewise.
* guix/scripts/import/hackage.scm: Likewise.
* guix/scripts/import/nix.scm: Likewise.
* guix/scripts/import/pypi.scm: Likewise.
* guix/scripts/lint.scm: Likewise.
* guix/scripts/package.scm: Likewise.
* guix/scripts/publish.scm: Likewise.
* guix/scripts/pull.scm: Likewise.
* guix/scripts/refresh.scm: Likewise.
* guix/scripts/size.scm: Likewise.
* guix/scripts/system.scm: Likewise.
* tests/ui.scm (with-environment-variable, "parse-command-line",
  "parse-command-line and --no options"): Move to ...
* tests/scripts.scm: ...here.  New file.
* scripts/guix.in (run-guix-main): Use (guix scripts).
* Makefile.am (MODULES): Add guix/scripts.scm.
  (SCM_TESTS): Add tests/scripts.scm.
---
 Makefile.am                     |   2 +
 emacs/guix-main.scm             |   1 +
 guix/scripts.scm                | 134 ++++++++++++++++++++++++++++++++++++++++
 guix/scripts/archive.scm        |   1 +
 guix/scripts/build.scm          |   1 +
 guix/scripts/download.scm       |   1 +
 guix/scripts/edit.scm           |   1 +
 guix/scripts/environment.scm    |   1 +
 guix/scripts/gc.scm             |   1 +
 guix/scripts/graph.scm          |   1 +
 guix/scripts/hash.scm           |   1 +
 guix/scripts/import/cpan.scm    |   1 +
 guix/scripts/import/cran.scm    |   1 +
 guix/scripts/import/elpa.scm    |   1 +
 guix/scripts/import/gem.scm     |   1 +
 guix/scripts/import/gnu.scm     |   1 +
 guix/scripts/import/hackage.scm |   3 +-
 guix/scripts/import/nix.scm     |   1 +
 guix/scripts/import/pypi.scm    |   1 +
 guix/scripts/lint.scm           |   1 +
 guix/scripts/package.scm        |   1 +
 guix/scripts/publish.scm        |   1 +
 guix/scripts/pull.scm           |   1 +
 guix/scripts/refresh.scm        |   1 +
 guix/scripts/size.scm           |   1 +
 guix/scripts/system.scm         |   1 +
 guix/ui.scm                     | 109 +++-----------------------------
 scripts/guix.in                 |   2 +-
 tests/scripts.scm               |  72 +++++++++++++++++++++
 tests/ui.scm                    |  40 ------------
 30 files changed, 241 insertions(+), 144 deletions(-)
 create mode 100644 guix/scripts.scm
 create mode 100644 tests/scripts.scm

diff --git a/Makefile.am b/Makefile.am
index 9a810e4..a8dab5d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,6 +102,7 @@ MODULES =					\
   guix/import/cran.scm				\
   guix/import/hackage.scm			\
   guix/import/elpa.scm   			\
+  guix/scripts.scm				\
   guix/scripts/download.scm			\
   guix/scripts/build.scm			\
   guix/scripts/archive.scm			\
@@ -214,6 +215,7 @@ SCM_TESTS =					\
   tests/gremlin.scm				\
   tests/lint.scm				\
   tests/publish.scm				\
+  tests/scripts.scm				\
   tests/size.scm				\
   tests/graph.scm				\
   tests/file-systems.scm			\
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index c9b84d3..3bde121 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -58,6 +58,7 @@
  (guix licenses)
  (guix utils)
  (guix ui)
+ (guix scripts)
  (guix scripts graph)
  (guix scripts lint)
  (guix scripts package)
diff --git a/guix/scripts.scm b/guix/scripts.scm
new file mode 100644
index 0000000..6bbe266
--- /dev/null
+++ b/guix/scripts.scm
@@ -0,0 +1,134 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix scripts)
+  #:use-module (guix utils)
+  #:use-module (guix ui)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-26)
+  #:use-module (srfi srfi-37)
+  #:use-module (ice-9 match)
+  #:export (args-fold*
+            parse-command-line
+            run-guix-command
+            run-guix
+            guix-main))
+
+;;; Commentary:
+;;;
+;;; General code for Guix scripts.
+;;;
+;;; Code:
+
+(define (args-fold* options unrecognized-option-proc operand-proc . seeds)
+  "A wrapper on top of `args-fold' that does proper user-facing error
+reporting."
+  (catch 'misc-error
+    (lambda ()
+      (apply args-fold options unrecognized-option-proc
+             operand-proc seeds))
+    (lambda (key proc msg args . rest)
+      ;; XXX: MSG is not i18n'd.
+      (leave (_ "invalid argument: ~a~%")
+             (apply format #f msg args)))))
+
+(define (environment-build-options)
+  "Return additional build options passed as environment variables."
+  (arguments-from-environment-variable "GUIX_BUILD_OPTIONS"))
+
+(define %default-argument-handler
+  ;; The default handler for non-option command-line arguments.
+  (lambda (arg result)
+    (alist-cons 'argument arg result)))
+
+(define* (parse-command-line args options seeds
+                             #:key
+                             (argument-handler %default-argument-handler))
+  "Parse the command-line arguments ARGS as well as arguments passed via the
+'GUIX_BUILD_OPTIONS' environment variable according to OPTIONS (a list of
+SRFI-37 options) and return the result, seeded by SEEDS.
+Command-line options take precedence those passed via 'GUIX_BUILD_OPTIONS'.
+
+ARGUMENT-HANDLER is called for non-option arguments, like the 'operand-proc'
+parameter of 'args-fold'."
+  (define (parse-options-from args seeds)
+    ;; Actual parsing takes place here.
+    (apply args-fold* args options
+           (lambda (opt name arg . rest)
+             (leave (_ "~A: unrecognized option~%") name))
+           argument-handler
+           seeds))
+
+  (call-with-values
+      (lambda ()
+        (parse-options-from (environment-build-options) seeds))
+    (lambda seeds
+      ;; ARGS take precedence over what the environment variable specifies.
+      (parse-options-from args seeds))))
+
+(define (run-guix-command command . args)
+  "Run COMMAND with the given ARGS.  Report an error when COMMAND is not
+found."
+  (define module
+    (catch 'misc-error
+      (lambda ()
+        (resolve-interface `(guix scripts ,command)))
+      (lambda -
+        (format (current-error-port)
+                (_ "guix: ~a: command not found~%") command)
+        (show-guix-usage))))
+
+  (let ((command-main (module-ref module
+                                  (symbol-append 'guix- command))))
+    (parameterize ((program-name command))
+      (apply command-main args))))
+
+(define (run-guix . args)
+  "Run the 'guix' command defined by command line ARGS.
+Unlike 'guix-main', this procedure assumes that locale, i18n support,
+and signal handling has already been set up."
+  (define option? (cut string-prefix? "-" <>))
+
+  (match args
+    (()
+     (format (current-error-port)
+             (_ "guix: missing command name~%"))
+     (show-guix-usage))
+    ((or ("-h") ("--help"))
+     (show-guix-help))
+    (("--version")
+     (show-version-and-exit "guix"))
+    (((? option? o) args ...)
+     (format (current-error-port)
+             (_ "guix: unrecognized option '~a'~%") o)
+     (show-guix-usage))
+    (("help" args ...)
+     (show-guix-help))
+    ((command args ...)
+     (apply run-guix-command
+            (string->symbol command)
+            args))))
+
+(define (guix-main arg0 . args)
+  (initialize-guix)
+  (apply run-guix args))
+
+;;; scripts.scm ends here
diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index ab2fc46..b120c55 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -27,6 +27,7 @@
   #:use-module (guix ui)
   #:use-module (guix pki)
   #:use-module (guix pk-crypto)
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module (gnu packages)
   #:use-module (ice-9 match)
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index d593b5a..03a9d67 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -19,6 +19,7 @@
 
 (define-module (guix scripts build)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix derivations)
   #:use-module (guix packages)
diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index 87b4204..533970f 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts download)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix hash)
   #:use-module (guix utils)
diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index fc453ac..30146af 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts edit)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (gnu packages)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index ecdbc7a..7aa52e8 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -27,6 +27,7 @@
   #:use-module (guix utils)
   #:use-module (guix monads)
   #:use-module ((guix gexp) #:select (lower-inputs))
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module (gnu packages)
   #:use-module (ice-9 format)
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 6403893..7e06c72 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts gc)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 2b671be..da02973 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts graph)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (guix monads)
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index e2305d7..d440953 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -22,6 +22,7 @@
   #:use-module (guix hash)
   #:use-module (guix serialization)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (rnrs io ports)
   #:use-module (rnrs files)
diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm
index 1f4dedf..3d470f6 100644
--- a/guix/scripts/import/cpan.scm
+++ b/guix/scripts/import/cpan.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import cpan)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import cpan)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm
index f11fa10..8d001ac 100644
--- a/guix/scripts/import/cran.scm
+++ b/guix/scripts/import/cran.scm
@@ -20,6 +20,7 @@
 (define-module (guix scripts import cran)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import cran)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm
index c72aaf0..b22a7c4 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import elpa)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import elpa)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm
index 9f8094f..a5dd2a7 100644
--- a/guix/scripts/import/gem.scm
+++ b/guix/scripts/import/gem.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import gem)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import gem)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/gnu.scm b/guix/scripts/import/gnu.scm
index 5fac6db..92bd830 100644
--- a/guix/scripts/import/gnu.scm
+++ b/guix/scripts/import/gnu.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import gnu)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import gnu)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm
index 1e33556..8d31128 100644
--- a/guix/scripts/import/hackage.scm
+++ b/guix/scripts/import/hackage.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import hackage)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import hackage)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
@@ -47,7 +48,7 @@ package will be generated.  If no version suffix is pecified, then the
 generated package definition will correspond to the latest available
 version.\n"))
   (display (_ "
-  -e ALIST, --cabal-environment=ALIST   
+  -e ALIST, --cabal-environment=ALIST
                                specify environment for Cabal evaluation"))
   (display (_ "
   -h, --help                   display this help and exit"))
diff --git a/guix/scripts/import/nix.scm b/guix/scripts/import/nix.scm
index 2dc2677..dba053b 100644
--- a/guix/scripts/import/nix.scm
+++ b/guix/scripts/import/nix.scm
@@ -20,6 +20,7 @@
 (define-module (guix scripts import nix)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import snix)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/pypi.scm b/guix/scripts/import/pypi.scm
index 1e03843..7166b01 100644
--- a/guix/scripts/import/pypi.scm
+++ b/guix/scripts/import/pypi.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import pypi)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import pypi)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 2a618c9..f6f5aec 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -28,6 +28,7 @@
   #:use-module (guix records)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix gnu-maintenance)
   #:use-module (guix monads)
   #:use-module (gnu packages)
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 23f1597..e0fe1dd 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -29,6 +29,7 @@
   #:use-module (guix monads)
   #:use-module (guix utils)
   #:use-module (guix config)
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module ((guix build utils)
                 #:select (directory-exists? mkdir-p search-path-as-list))
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index cc96355..e352090 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -45,6 +45,7 @@
   #:use-module (guix store)
   #:use-module (guix serialization)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:export (guix-publish))
 
 (define (show-help)
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index e8459e5..56ee9ac 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts pull)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix config)
   #:use-module (guix packages)
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index e7980a9..097059e 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -21,6 +21,7 @@
 (define-module (guix scripts refresh)
   #:use-module (guix ui)
   #:use-module (guix hash)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
diff --git a/guix/scripts/size.scm b/guix/scripts/size.scm
index ee070f1..44ff926 100644
--- a/guix/scripts/size.scm
+++ b/guix/scripts/size.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts size)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix utils)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 45f5982..c9dbd99 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -26,6 +26,7 @@
   #:use-module (guix utils)
   #:use-module (guix monads)
   #:use-module (guix profiles)
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module (guix build utils)
   #:use-module (gnu build install)
diff --git a/guix/ui.scm b/guix/ui.scm
index ca5b844..c8bf5ab 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2,9 +2,10 @@
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
+;;; Copyright © 2014 Cyrill Schenkel <cyrill.schenkel@gmail.com>
 ;;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
 ;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
-;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -39,7 +40,6 @@
   #:use-module (srfi srfi-31)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
-  #:use-module (srfi srfi-37)
   #:autoload   (ice-9 ftw)  (scandir)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
@@ -57,6 +57,9 @@
             make-user-module
             load*
             warn-about-load-error
+            program-name
+            show-guix-help
+            show-guix-usage
             show-version-and-exit
             show-bug-report-information
             string->number*
@@ -79,14 +82,9 @@
             package-specification->name+version+output
             string->generations
             string->duration
-            args-fold*
-            parse-command-line
-            run-guix-command
-            run-guix
-            program-name
+            initialize-guix
             guix-warning-port
-            warning
-            guix-main))
+            warning))
 
 ;;; Commentary:
 ;;;
@@ -959,52 +957,6 @@ optionally contain a version number and an output name, as in these examples:
 ;;; Command-line option processing.
 ;;;
 
-(define (args-fold* options unrecognized-option-proc operand-proc . seeds)
-  "A wrapper on top of `args-fold' that does proper user-facing error
-reporting."
-  (catch 'misc-error
-    (lambda ()
-      (apply args-fold options unrecognized-option-proc
-             operand-proc seeds))
-    (lambda (key proc msg args . rest)
-      ;; XXX: MSG is not i18n'd.
-      (leave (_ "invalid argument: ~a~%")
-             (apply format #f msg args)))))
-
-(define (environment-build-options)
-  "Return additional build options passed as environment variables."
-  (arguments-from-environment-variable "GUIX_BUILD_OPTIONS"))
-
-(define %default-argument-handler
-  ;; The default handler for non-option command-line arguments.
-  (lambda (arg result)
-    (alist-cons 'argument arg result)))
-
-(define* (parse-command-line args options seeds
-                             #:key
-                             (argument-handler %default-argument-handler))
-  "Parse the command-line arguments ARGS as well as arguments passed via the
-'GUIX_BUILD_OPTIONS' environment variable according to OPTIONS (a list of
-SRFI-37 options) and return the result, seeded by SEEDS.
-Command-line options take precedence those passed via 'GUIX_BUILD_OPTIONS'.
-
-ARGUMENT-HANDLER is called for non-option arguments, like the 'operand-proc'
-parameter of 'args-fold'."
-  (define (parse-options-from args seeds)
-    ;; Actual parsing takes place here.
-    (apply args-fold* args options
-           (lambda (opt name arg . rest)
-             (leave (_ "~A: unrecognized option~%") name))
-           argument-handler
-           seeds))
-
-  (call-with-values
-      (lambda ()
-        (parse-options-from (environment-build-options) seeds))
-    (lambda seeds
-      ;; ARGS take precedence over what the environment variable specifies.
-      (parse-options-from args seeds))))
-
 (define (show-guix-usage)
   (format (current-error-port)
           (_ "Try `guix --help' for more information.~%"))
@@ -1048,54 +1000,7 @@ Run COMMAND with ARGS.\n"))
   ;; Name of the command-line program currently executing, or #f.
   (make-parameter #f))
 
-(define (run-guix-command command . args)
-  "Run COMMAND with the given ARGS.  Report an error when COMMAND is not
-found."
-  (define module
-    (catch 'misc-error
-      (lambda ()
-        (resolve-interface `(guix scripts ,command)))
-      (lambda -
-        (format (current-error-port)
-                (_ "guix: ~a: command not found~%") command)
-        (show-guix-usage))))
-
-  (let ((command-main (module-ref module
-                                  (symbol-append 'guix- command))))
-    (parameterize ((program-name command))
-      (apply command-main args))))
-
-(define (run-guix . args)
-  "Run the 'guix' command defined by command line ARGS.
-Unlike 'guix-main', this procedure assumes that locale, i18n support,
-and signal handling has already been set up."
-  (define option? (cut string-prefix? "-" <>))
-
-  (match args
-    (()
-     (format (current-error-port)
-             (_ "guix: missing command name~%"))
-     (show-guix-usage))
-    ((or ("-h") ("--help"))
-     (show-guix-help))
-    (("--version")
-     (show-version-and-exit "guix"))
-    (((? option? o) args ...)
-     (format (current-error-port)
-             (_ "guix: unrecognized option '~a'~%") o)
-     (show-guix-usage))
-    (("help" args ...)
-     (show-guix-help))
-    ((command args ...)
-     (apply run-guix-command
-            (string->symbol command)
-            args))))
-
 (define guix-warning-port
   (make-parameter (current-warning-port)))
 
-(define (guix-main arg0 . args)
-  (initialize-guix)
-  (apply run-guix args))
-
 ;;; ui.scm ends here
diff --git a/scripts/guix.in b/scripts/guix.in
index 8f2d8a6..91a5fd1 100644
--- a/scripts/guix.in
+++ b/scripts/guix.in
@@ -57,7 +57,7 @@
           (push! updates-dir %load-compiled-path)))))
 
   (define (run-guix-main)
-    (let ((guix-main (module-ref (resolve-interface '(guix ui))
+    (let ((guix-main (module-ref (resolve-interface '(guix scripts))
                                  'guix-main)))
       (bindtextdomain "guix" (config-lookup "localedir"))
       (bindtextdomain "guix-packages" (config-lookup "localedir"))
diff --git a/tests/scripts.scm b/tests/scripts.scm
new file mode 100644
index 0000000..3bf41ae
--- /dev/null
+++ b/tests/scripts.scm
@@ -0,0 +1,72 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (test-scripts)
+  #:use-module (guix scripts)
+  #:use-module ((guix scripts build)
+                #:select (%standard-build-options))
+  #:use-module (srfi srfi-64))
+
+;; Test the (guix scripts) module.
+
+(define-syntax-rule (with-environment-variable variable value body ...)
+  "Run BODY with VARIABLE set to VALUE."
+  (let ((orig (getenv variable)))
+    (dynamic-wind
+      (lambda ()
+        (setenv variable value))
+      (lambda ()
+        body ...)
+      (lambda ()
+        (if orig
+            (setenv variable orig)
+            (unsetenv variable))))))
+
+\f
+(test-begin "scripts")
+
+(test-equal "parse-command-line"
+  '((argument . "bar") (argument . "foo")
+    (cores . 10)                                  ;takes precedence
+    (substitutes? . #f) (keep-failed? . #t)
+    (max-jobs . 77) (cores . 42))
+
+  (with-environment-variable "GUIX_BUILD_OPTIONS" "-c 42 -M 77"
+    (parse-command-line '("--keep-failed" "--no-substitutes"
+                          "--cores=10" "foo" "bar")
+                        %standard-build-options
+                        (list '()))))
+
+(test-equal "parse-command-line and --no options"
+  '((argument . "foo")
+    (substitutes? . #f))                          ;takes precedence
+
+  (with-environment-variable "GUIX_BUILD_OPTIONS" "--no-substitutes"
+    (parse-command-line '("foo")
+                        %standard-build-options
+                        (list '((substitutes? . #t))))))
+
+(test-end "scripts")
+
+\f
+(exit (= (test-runner-fail-count (test-runner-current)) 0))
+
+;;; Local Variables:
+;;; eval: (put 'with-environment-variable 'scheme-indent-function 2)
+;;; End:
diff --git a/tests/ui.scm b/tests/ui.scm
index 1478fe2..25fc709 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -22,8 +22,6 @@
   #:use-module (guix profiles)
   #:use-module (guix store)
   #:use-module (guix derivations)
-  #:use-module ((guix scripts build)
-                #:select (%standard-build-options))
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-19)
@@ -54,43 +52,9 @@ interface, and powerful string processing.")
     (item "/gnu/store/...")
     (output "out")))
 
-(define-syntax-rule (with-environment-variable variable value body ...)
-  "Run BODY with VARIABLE set to VALUE."
-  (let ((orig (getenv variable)))
-    (dynamic-wind
-      (lambda ()
-        (setenv variable value))
-      (lambda ()
-        body ...)
-      (lambda ()
-        (if orig
-            (setenv variable orig)
-            (unsetenv variable))))))
-
 \f
 (test-begin "ui")
 
-(test-equal "parse-command-line"
-  '((argument . "bar") (argument . "foo")
-    (cores . 10)                                  ;takes precedence
-    (substitutes? . #f) (keep-failed? . #t)
-    (max-jobs . 77) (cores . 42))
-
-  (with-environment-variable "GUIX_BUILD_OPTIONS" "-c 42 -M 77"
-    (parse-command-line '("--keep-failed" "--no-substitutes"
-                          "--cores=10" "foo" "bar")
-                        %standard-build-options
-                        (list '()))))
-
-(test-equal "parse-command-line and --no options"
-  '((argument . "foo")
-    (substitutes? . #f))                          ;takes precedence
-
-  (with-environment-variable "GUIX_BUILD_OPTIONS" "--no-substitutes"
-    (parse-command-line '("foo")
-                        %standard-build-options
-                        (list '((substitutes? . #t))))))
-
 (test-assert "fill-paragraph"
   (every (lambda (column)
            (every (lambda (width)
@@ -282,7 +246,3 @@ Second line" 24))
 
 \f
 (exit (= (test-runner-fail-count (test-runner-current)) 0))
-
-;;; Local Variables:
-;;; eval: (put 'with-environment-variable 'scheme-indent-function 2)
-;;; End:
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH] Add (guix scripts).
  2015-09-10 10:25                 ` [PATCH] Add (guix scripts) Alex Kost
@ 2015-09-14 13:34                   ` Ludovic Courtès
  2015-09-14 18:39                     ` Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-14 13:34 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-09-08 23:10 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> We have some code in (guix scripts …) that is rather common (I mean not
>>> specific to the current module), but there is no better place for it,
>>> usually because it uses (guix ui).
>>>
>>> So what about making (guix scripts) module for such general stuff?
>>> I think we can move there ‘maybe-build’, ‘%standard-build-options’,
>>> ‘set-build-options-from-command-line(*)’, ‘show-build-options-help’,
>>> perhaps exported procedures from (guix scripts package).  And
>>> ‘build-package’ may also go there, WDYT?
>>>
>>> Or maybe just put those things into (guix ui)?
>>
>> (guix ui) has become fat; (guix scripts) sounds like a good idea.  Then
>> things like ‘args-fold*’, ‘parse-command-line’, ‘run-guix-command’,
>> ‘run-guix’, ‘guix-main’, and ‘program-name’ should probably move there
>> as well (unless I’m overlooking something that would prevent this),
>> along with ‘maybe-build’ and ‘build-package’.
>>
>> How does that sound?
>
> I like it.  I hope I missed nothing in this patch (it appeared to be a
> big change).  At least "make check" was passed successfully.
>
> I think ‘maybe-build’ may move later when ‘build-package’
> will be added, ok?

Yes.

> Some notes:
>
> - ‘program-name’ is used by ‘define-diagnostic’ macro, so I left it in
>   (guix ui).
>
> - ‘guix-main’ uses ‘initialize-guix’, so I exported it from (guix ui) or
>   should it be moved to (guix scripts) instead and export
>   ‘%gettext-domain’?
>
> - I studied the commit log related to guix/ui.scm, and adjusted the
>   copyright lines accordingly.
>
> Also our 'guix' executable will be changed, I'm not sure what
> consequences it will lead to.

I knew I’d overlook something: That’s a showstopper.  Basically, ‘guix
pull’ assumes that ‘guix’ is immutable.  Maybe we can break it once
before 1.0, but in the meantime, I’d rather avoid it.

That means ‘guix-main’ must remain in (guix ui).  Consequently, a bunch
of other procedures (show-*, run-guix-command, commands) should remain
there, to avoid a circular dependency between (guix scripts) and (guix
ui).

WDYT?  Could you try to adjust the patch accordingly?

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH] Add (guix scripts).
  2015-09-14 13:34                   ` Ludovic Courtès
@ 2015-09-14 18:39                     ` Alex Kost
  2015-09-16 20:21                       ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-09-14 18:39 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 766 bytes --]

Ludovic Courtès (2015-09-14 16:34 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
[...]
>> Also our 'guix' executable will be changed, I'm not sure what
>> consequences it will lead to.
>
> I knew I’d overlook something: That’s a showstopper.  Basically, ‘guix
> pull’ assumes that ‘guix’ is immutable.  Maybe we can break it once
> before 1.0, but in the meantime, I’d rather avoid it.
>
> That means ‘guix-main’ must remain in (guix ui).  Consequently, a bunch
> of other procedures (show-*, run-guix-command, commands) should remain
> there, to avoid a circular dependency between (guix scripts) and (guix
> ui).
>
> WDYT?  Could you try to adjust the patch accordingly?

OK, the updated patch is attached, thanks.


[-- Attachment #2: 0001-Add-guix-scripts.patch --]
[-- Type: text/x-patch, Size: 24909 bytes --]

From b5484f43c429e283284033f4adb6097034a60418 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 10 Sep 2015 12:37:36 +0300
Subject: [PATCH] Add (guix scripts).

* guix/ui.scm: Add missing copyright lines.
  (args-fold*, environment-build-options, %default-argument-handler,
  parse-command-line): Move to ...
* guix/scripts.scm: ...here.  New file.
* guix/scripts/archive.scm: Use it.
* guix/scripts/build.scm: Likewise.
* guix/scripts/download.scm: Likewise.
* guix/scripts/edit.scm: Likewise.
* guix/scripts/environment.scm: Likewise.
* guix/scripts/gc.scm: Likewise.
* guix/scripts/graph.scm: Likewise.
* guix/scripts/hash.scm: Likewise.
* guix/scripts/import/cpan.scm: Likewise.
* guix/scripts/import/cran.scm: Likewise.
* guix/scripts/import/elpa.scm: Likewise.
* guix/scripts/import/gem.scm: Likewise.
* guix/scripts/import/gnu.scm: Likewise.
* guix/scripts/import/hackage.scm: Likewise.
* guix/scripts/import/nix.scm: Likewise.
* guix/scripts/import/pypi.scm: Likewise.
* guix/scripts/lint.scm: Likewise.
* guix/scripts/package.scm: Likewise.
* guix/scripts/publish.scm: Likewise.
* guix/scripts/pull.scm: Likewise.
* guix/scripts/refresh.scm: Likewise.
* guix/scripts/size.scm: Likewise.
* guix/scripts/system.scm: Likewise.
* tests/ui.scm (with-environment-variable, "parse-command-line",
  "parse-command-line and --no options"): Move to ...
* tests/scripts.scm: ...here.  New file.
* Makefile.am (MODULES): Add guix/scripts.scm.
  (SCM_TESTS): Add tests/scripts.scm.
---
 Makefile.am                     |  2 +
 guix/scripts.scm                | 81 +++++++++++++++++++++++++++++++++++++++++
 guix/scripts/archive.scm        |  1 +
 guix/scripts/build.scm          |  1 +
 guix/scripts/download.scm       |  1 +
 guix/scripts/edit.scm           |  1 +
 guix/scripts/environment.scm    |  1 +
 guix/scripts/gc.scm             |  1 +
 guix/scripts/graph.scm          |  1 +
 guix/scripts/hash.scm           |  1 +
 guix/scripts/import/cpan.scm    |  1 +
 guix/scripts/import/cran.scm    |  1 +
 guix/scripts/import/elpa.scm    |  1 +
 guix/scripts/import/gem.scm     |  1 +
 guix/scripts/import/gnu.scm     |  1 +
 guix/scripts/import/hackage.scm |  3 +-
 guix/scripts/import/nix.scm     |  1 +
 guix/scripts/import/pypi.scm    |  1 +
 guix/scripts/lint.scm           |  1 +
 guix/scripts/package.scm        |  1 +
 guix/scripts/publish.scm        |  1 +
 guix/scripts/pull.scm           |  1 +
 guix/scripts/refresh.scm        |  1 +
 guix/scripts/size.scm           |  1 +
 guix/scripts/system.scm         |  1 +
 guix/ui.scm                     | 53 ++-------------------------
 tests/scripts.scm               | 72 ++++++++++++++++++++++++++++++++++++
 tests/ui.scm                    | 40 --------------------
 28 files changed, 182 insertions(+), 91 deletions(-)
 create mode 100644 guix/scripts.scm
 create mode 100644 tests/scripts.scm

diff --git a/Makefile.am b/Makefile.am
index 9a810e4..a8dab5d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,6 +102,7 @@ MODULES =					\
   guix/import/cran.scm				\
   guix/import/hackage.scm			\
   guix/import/elpa.scm   			\
+  guix/scripts.scm				\
   guix/scripts/download.scm			\
   guix/scripts/build.scm			\
   guix/scripts/archive.scm			\
@@ -214,6 +215,7 @@ SCM_TESTS =					\
   tests/gremlin.scm				\
   tests/lint.scm				\
   tests/publish.scm				\
+  tests/scripts.scm				\
   tests/size.scm				\
   tests/graph.scm				\
   tests/file-systems.scm			\
diff --git a/guix/scripts.scm b/guix/scripts.scm
new file mode 100644
index 0000000..6bb3e21
--- /dev/null
+++ b/guix/scripts.scm
@@ -0,0 +1,81 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix scripts)
+  #:use-module (guix utils)
+  #:use-module (guix ui)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-37)
+  #:use-module (ice-9 match)
+  #:export (args-fold*
+            parse-command-line))
+
+;;; Commentary:
+;;;
+;;; General code for Guix scripts.
+;;;
+;;; Code:
+
+(define (args-fold* options unrecognized-option-proc operand-proc . seeds)
+  "A wrapper on top of `args-fold' that does proper user-facing error
+reporting."
+  (catch 'misc-error
+    (lambda ()
+      (apply args-fold options unrecognized-option-proc
+             operand-proc seeds))
+    (lambda (key proc msg args . rest)
+      ;; XXX: MSG is not i18n'd.
+      (leave (_ "invalid argument: ~a~%")
+             (apply format #f msg args)))))
+
+(define (environment-build-options)
+  "Return additional build options passed as environment variables."
+  (arguments-from-environment-variable "GUIX_BUILD_OPTIONS"))
+
+(define %default-argument-handler
+  ;; The default handler for non-option command-line arguments.
+  (lambda (arg result)
+    (alist-cons 'argument arg result)))
+
+(define* (parse-command-line args options seeds
+                             #:key
+                             (argument-handler %default-argument-handler))
+  "Parse the command-line arguments ARGS as well as arguments passed via the
+'GUIX_BUILD_OPTIONS' environment variable according to OPTIONS (a list of
+SRFI-37 options) and return the result, seeded by SEEDS.
+Command-line options take precedence those passed via 'GUIX_BUILD_OPTIONS'.
+
+ARGUMENT-HANDLER is called for non-option arguments, like the 'operand-proc'
+parameter of 'args-fold'."
+  (define (parse-options-from args seeds)
+    ;; Actual parsing takes place here.
+    (apply args-fold* args options
+           (lambda (opt name arg . rest)
+             (leave (_ "~A: unrecognized option~%") name))
+           argument-handler
+           seeds))
+
+  (call-with-values
+      (lambda ()
+        (parse-options-from (environment-build-options) seeds))
+    (lambda seeds
+      ;; ARGS take precedence over what the environment variable specifies.
+      (parse-options-from args seeds))))
+
+;;; scripts.scm ends here
diff --git a/guix/scripts/archive.scm b/guix/scripts/archive.scm
index ab2fc46..b120c55 100644
--- a/guix/scripts/archive.scm
+++ b/guix/scripts/archive.scm
@@ -27,6 +27,7 @@
   #:use-module (guix ui)
   #:use-module (guix pki)
   #:use-module (guix pk-crypto)
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module (gnu packages)
   #:use-module (ice-9 match)
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index ab2a39b..1d766c0 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -19,6 +19,7 @@
 
 (define-module (guix scripts build)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix derivations)
   #:use-module (guix packages)
diff --git a/guix/scripts/download.scm b/guix/scripts/download.scm
index 87b4204..533970f 100644
--- a/guix/scripts/download.scm
+++ b/guix/scripts/download.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts download)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix hash)
   #:use-module (guix utils)
diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index fc453ac..30146af 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts edit)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (gnu packages)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index ecdbc7a..7aa52e8 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -27,6 +27,7 @@
   #:use-module (guix utils)
   #:use-module (guix monads)
   #:use-module ((guix gexp) #:select (lower-inputs))
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module (gnu packages)
   #:use-module (ice-9 format)
diff --git a/guix/scripts/gc.scm b/guix/scripts/gc.scm
index 6403893..7e06c72 100644
--- a/guix/scripts/gc.scm
+++ b/guix/scripts/gc.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts gc)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm
index 2b671be..da02973 100644
--- a/guix/scripts/graph.scm
+++ b/guix/scripts/graph.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts graph)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (guix packages)
   #:use-module (guix monads)
diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index e2305d7..d440953 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -22,6 +22,7 @@
   #:use-module (guix hash)
   #:use-module (guix serialization)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (rnrs io ports)
   #:use-module (rnrs files)
diff --git a/guix/scripts/import/cpan.scm b/guix/scripts/import/cpan.scm
index 1f4dedf..3d470f6 100644
--- a/guix/scripts/import/cpan.scm
+++ b/guix/scripts/import/cpan.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import cpan)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import cpan)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/cran.scm b/guix/scripts/import/cran.scm
index f11fa10..8d001ac 100644
--- a/guix/scripts/import/cran.scm
+++ b/guix/scripts/import/cran.scm
@@ -20,6 +20,7 @@
 (define-module (guix scripts import cran)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import cran)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/elpa.scm b/guix/scripts/import/elpa.scm
index c72aaf0..b22a7c4 100644
--- a/guix/scripts/import/elpa.scm
+++ b/guix/scripts/import/elpa.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import elpa)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import elpa)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/gem.scm b/guix/scripts/import/gem.scm
index 9f8094f..a5dd2a7 100644
--- a/guix/scripts/import/gem.scm
+++ b/guix/scripts/import/gem.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import gem)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import gem)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/gnu.scm b/guix/scripts/import/gnu.scm
index 5fac6db..92bd830 100644
--- a/guix/scripts/import/gnu.scm
+++ b/guix/scripts/import/gnu.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import gnu)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import gnu)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/hackage.scm b/guix/scripts/import/hackage.scm
index 1e33556..8d31128 100644
--- a/guix/scripts/import/hackage.scm
+++ b/guix/scripts/import/hackage.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import hackage)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import hackage)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
@@ -47,7 +48,7 @@ package will be generated.  If no version suffix is pecified, then the
 generated package definition will correspond to the latest available
 version.\n"))
   (display (_ "
-  -e ALIST, --cabal-environment=ALIST   
+  -e ALIST, --cabal-environment=ALIST
                                specify environment for Cabal evaluation"))
   (display (_ "
   -h, --help                   display this help and exit"))
diff --git a/guix/scripts/import/nix.scm b/guix/scripts/import/nix.scm
index 2dc2677..dba053b 100644
--- a/guix/scripts/import/nix.scm
+++ b/guix/scripts/import/nix.scm
@@ -20,6 +20,7 @@
 (define-module (guix scripts import nix)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import snix)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/import/pypi.scm b/guix/scripts/import/pypi.scm
index 1e03843..7166b01 100644
--- a/guix/scripts/import/pypi.scm
+++ b/guix/scripts/import/pypi.scm
@@ -19,6 +19,7 @@
 (define-module (guix scripts import pypi)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix import pypi)
   #:use-module (guix scripts import)
   #:use-module (srfi srfi-1)
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 2a618c9..f6f5aec 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -28,6 +28,7 @@
   #:use-module (guix records)
   #:use-module (guix ui)
   #:use-module (guix utils)
+  #:use-module (guix scripts)
   #:use-module (guix gnu-maintenance)
   #:use-module (guix monads)
   #:use-module (gnu packages)
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 23f1597..e0fe1dd 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -29,6 +29,7 @@
   #:use-module (guix monads)
   #:use-module (guix utils)
   #:use-module (guix config)
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module ((guix build utils)
                 #:select (directory-exists? mkdir-p search-path-as-list))
diff --git a/guix/scripts/publish.scm b/guix/scripts/publish.scm
index cc96355..e352090 100644
--- a/guix/scripts/publish.scm
+++ b/guix/scripts/publish.scm
@@ -45,6 +45,7 @@
   #:use-module (guix store)
   #:use-module (guix serialization)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:export (guix-publish))
 
 (define (show-help)
diff --git a/guix/scripts/pull.scm b/guix/scripts/pull.scm
index e8459e5..56ee9ac 100644
--- a/guix/scripts/pull.scm
+++ b/guix/scripts/pull.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts pull)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix config)
   #:use-module (guix packages)
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index e7980a9..097059e 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -21,6 +21,7 @@
 (define-module (guix scripts refresh)
   #:use-module (guix ui)
   #:use-module (guix hash)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix utils)
   #:use-module (guix packages)
diff --git a/guix/scripts/size.scm b/guix/scripts/size.scm
index ee070f1..44ff926 100644
--- a/guix/scripts/size.scm
+++ b/guix/scripts/size.scm
@@ -18,6 +18,7 @@
 
 (define-module (guix scripts size)
   #:use-module (guix ui)
+  #:use-module (guix scripts)
   #:use-module (guix store)
   #:use-module (guix monads)
   #:use-module (guix utils)
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 45f5982..c9dbd99 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -26,6 +26,7 @@
   #:use-module (guix utils)
   #:use-module (guix monads)
   #:use-module (guix profiles)
+  #:use-module (guix scripts)
   #:use-module (guix scripts build)
   #:use-module (guix build utils)
   #:use-module (gnu build install)
diff --git a/guix/ui.scm b/guix/ui.scm
index ca5b844..e028e40 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -2,9 +2,11 @@
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
+;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com>
+;;; Copyright © 2014 Cyrill Schenkel <cyrill.schenkel@gmail.com>
 ;;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2015 David Thompson <davet@gnu.org>
 ;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
-;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -39,7 +41,6 @@
   #:use-module (srfi srfi-31)
   #:use-module (srfi srfi-34)
   #:use-module (srfi srfi-35)
-  #:use-module (srfi srfi-37)
   #:autoload   (ice-9 ftw)  (scandir)
   #:use-module (ice-9 match)
   #:use-module (ice-9 format)
@@ -79,8 +80,6 @@
             package-specification->name+version+output
             string->generations
             string->duration
-            args-fold*
-            parse-command-line
             run-guix-command
             run-guix
             program-name
@@ -959,52 +958,6 @@ optionally contain a version number and an output name, as in these examples:
 ;;; Command-line option processing.
 ;;;
 
-(define (args-fold* options unrecognized-option-proc operand-proc . seeds)
-  "A wrapper on top of `args-fold' that does proper user-facing error
-reporting."
-  (catch 'misc-error
-    (lambda ()
-      (apply args-fold options unrecognized-option-proc
-             operand-proc seeds))
-    (lambda (key proc msg args . rest)
-      ;; XXX: MSG is not i18n'd.
-      (leave (_ "invalid argument: ~a~%")
-             (apply format #f msg args)))))
-
-(define (environment-build-options)
-  "Return additional build options passed as environment variables."
-  (arguments-from-environment-variable "GUIX_BUILD_OPTIONS"))
-
-(define %default-argument-handler
-  ;; The default handler for non-option command-line arguments.
-  (lambda (arg result)
-    (alist-cons 'argument arg result)))
-
-(define* (parse-command-line args options seeds
-                             #:key
-                             (argument-handler %default-argument-handler))
-  "Parse the command-line arguments ARGS as well as arguments passed via the
-'GUIX_BUILD_OPTIONS' environment variable according to OPTIONS (a list of
-SRFI-37 options) and return the result, seeded by SEEDS.
-Command-line options take precedence those passed via 'GUIX_BUILD_OPTIONS'.
-
-ARGUMENT-HANDLER is called for non-option arguments, like the 'operand-proc'
-parameter of 'args-fold'."
-  (define (parse-options-from args seeds)
-    ;; Actual parsing takes place here.
-    (apply args-fold* args options
-           (lambda (opt name arg . rest)
-             (leave (_ "~A: unrecognized option~%") name))
-           argument-handler
-           seeds))
-
-  (call-with-values
-      (lambda ()
-        (parse-options-from (environment-build-options) seeds))
-    (lambda seeds
-      ;; ARGS take precedence over what the environment variable specifies.
-      (parse-options-from args seeds))))
-
 (define (show-guix-usage)
   (format (current-error-port)
           (_ "Try `guix --help' for more information.~%"))
diff --git a/tests/scripts.scm b/tests/scripts.scm
new file mode 100644
index 0000000..3bf41ae
--- /dev/null
+++ b/tests/scripts.scm
@@ -0,0 +1,72 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+
+(define-module (test-scripts)
+  #:use-module (guix scripts)
+  #:use-module ((guix scripts build)
+                #:select (%standard-build-options))
+  #:use-module (srfi srfi-64))
+
+;; Test the (guix scripts) module.
+
+(define-syntax-rule (with-environment-variable variable value body ...)
+  "Run BODY with VARIABLE set to VALUE."
+  (let ((orig (getenv variable)))
+    (dynamic-wind
+      (lambda ()
+        (setenv variable value))
+      (lambda ()
+        body ...)
+      (lambda ()
+        (if orig
+            (setenv variable orig)
+            (unsetenv variable))))))
+
+\f
+(test-begin "scripts")
+
+(test-equal "parse-command-line"
+  '((argument . "bar") (argument . "foo")
+    (cores . 10)                                  ;takes precedence
+    (substitutes? . #f) (keep-failed? . #t)
+    (max-jobs . 77) (cores . 42))
+
+  (with-environment-variable "GUIX_BUILD_OPTIONS" "-c 42 -M 77"
+    (parse-command-line '("--keep-failed" "--no-substitutes"
+                          "--cores=10" "foo" "bar")
+                        %standard-build-options
+                        (list '()))))
+
+(test-equal "parse-command-line and --no options"
+  '((argument . "foo")
+    (substitutes? . #f))                          ;takes precedence
+
+  (with-environment-variable "GUIX_BUILD_OPTIONS" "--no-substitutes"
+    (parse-command-line '("foo")
+                        %standard-build-options
+                        (list '((substitutes? . #t))))))
+
+(test-end "scripts")
+
+\f
+(exit (= (test-runner-fail-count (test-runner-current)) 0))
+
+;;; Local Variables:
+;;; eval: (put 'with-environment-variable 'scheme-indent-function 2)
+;;; End:
diff --git a/tests/ui.scm b/tests/ui.scm
index 1478fe2..25fc709 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -22,8 +22,6 @@
   #:use-module (guix profiles)
   #:use-module (guix store)
   #:use-module (guix derivations)
-  #:use-module ((guix scripts build)
-                #:select (%standard-build-options))
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-19)
@@ -54,43 +52,9 @@ interface, and powerful string processing.")
     (item "/gnu/store/...")
     (output "out")))
 
-(define-syntax-rule (with-environment-variable variable value body ...)
-  "Run BODY with VARIABLE set to VALUE."
-  (let ((orig (getenv variable)))
-    (dynamic-wind
-      (lambda ()
-        (setenv variable value))
-      (lambda ()
-        body ...)
-      (lambda ()
-        (if orig
-            (setenv variable orig)
-            (unsetenv variable))))))
-
 \f
 (test-begin "ui")
 
-(test-equal "parse-command-line"
-  '((argument . "bar") (argument . "foo")
-    (cores . 10)                                  ;takes precedence
-    (substitutes? . #f) (keep-failed? . #t)
-    (max-jobs . 77) (cores . 42))
-
-  (with-environment-variable "GUIX_BUILD_OPTIONS" "-c 42 -M 77"
-    (parse-command-line '("--keep-failed" "--no-substitutes"
-                          "--cores=10" "foo" "bar")
-                        %standard-build-options
-                        (list '()))))
-
-(test-equal "parse-command-line and --no options"
-  '((argument . "foo")
-    (substitutes? . #f))                          ;takes precedence
-
-  (with-environment-variable "GUIX_BUILD_OPTIONS" "--no-substitutes"
-    (parse-command-line '("foo")
-                        %standard-build-options
-                        (list '((substitutes? . #t))))))
-
 (test-assert "fill-paragraph"
   (every (lambda (column)
            (every (lambda (width)
@@ -282,7 +246,3 @@ Second line" 24))
 
 \f
 (exit (= (test-runner-fail-count (test-runner-current)) 0))
-
-;;; Local Variables:
-;;; eval: (put 'with-environment-variable 'scheme-indent-function 2)
-;;; End:
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH] Add (guix scripts).
  2015-09-14 18:39                     ` Alex Kost
@ 2015-09-16 20:21                       ` Ludovic Courtès
  2015-09-18 18:52                         ` Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-16 20:21 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From b5484f43c429e283284033f4adb6097034a60418 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Thu, 10 Sep 2015 12:37:36 +0300
> Subject: [PATCH] Add (guix scripts).
>
> * guix/ui.scm: Add missing copyright lines.
>   (args-fold*, environment-build-options, %default-argument-handler,
>   parse-command-line): Move to ...
> * guix/scripts.scm: ...here.  New file.
> * guix/scripts/archive.scm: Use it.
> * guix/scripts/build.scm: Likewise.
> * guix/scripts/download.scm: Likewise.
> * guix/scripts/edit.scm: Likewise.
> * guix/scripts/environment.scm: Likewise.
> * guix/scripts/gc.scm: Likewise.
> * guix/scripts/graph.scm: Likewise.
> * guix/scripts/hash.scm: Likewise.
> * guix/scripts/import/cpan.scm: Likewise.
> * guix/scripts/import/cran.scm: Likewise.
> * guix/scripts/import/elpa.scm: Likewise.
> * guix/scripts/import/gem.scm: Likewise.
> * guix/scripts/import/gnu.scm: Likewise.
> * guix/scripts/import/hackage.scm: Likewise.
> * guix/scripts/import/nix.scm: Likewise.
> * guix/scripts/import/pypi.scm: Likewise.
> * guix/scripts/lint.scm: Likewise.
> * guix/scripts/package.scm: Likewise.
> * guix/scripts/publish.scm: Likewise.
> * guix/scripts/pull.scm: Likewise.
> * guix/scripts/refresh.scm: Likewise.
> * guix/scripts/size.scm: Likewise.
> * guix/scripts/system.scm: Likewise.
> * tests/ui.scm (with-environment-variable, "parse-command-line",
>   "parse-command-line and --no options"): Move to ...
> * tests/scripts.scm: ...here.  New file.
> * Makefile.am (MODULES): Add guix/scripts.scm.
>   (SCM_TESTS): Add tests/scripts.scm.

Also add guix/scripts.scm to po/guix/POTFILES.in.

OK with this change, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-09-08 20:10               ` Ludovic Courtès
  2015-09-10 10:25                 ` [PATCH] Add (guix scripts) Alex Kost
@ 2015-09-18 18:51                 ` Alex Kost
  2015-09-22 15:12                   ` Ludovic Courtès
  1 sibling, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-09-18 18:51 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2340 bytes --]

Ludovic Courtès (2015-09-08 23:10 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
[...]
>> From 9ffc27f7a076e4213ef3bee00e5cebad501685ac Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Thu, 23 Jul 2015 16:16:41 +0300
>> Subject: [PATCH 2/2] guix build: Add 'build-package'.
>> MIME-Version: 1.0
>> Content-Type: text/plain; charset=UTF-8
>> Content-Transfer-Encoding: 8bit
>>
>> * guix/scripts/system.scm (maybe-build): Move to ...
>> * guix/scripts/build.scm: ...here.
>>   (build-package): New procedure.
>
> [...]
>
>> +(define* (build-package package
>> +                        #:key (use-substitutes? #t) (dry-run? #f)
>> +                        #:allow-other-keys
>> +                        #:rest build-options)
>> +  "Build PACKAGE using BUILD-OPTIONS.
>> +Show what and how will/would be built."
>> +  (with-store store
>> +    (run-with-store store
>> +      (mbegin %store-monad
>> +        (apply set-build-options*
>
> Please remove ‘with-store’ and ‘run-with-store’.  This should be done on
> the Emacs side (maybe via the ,run-in-store meta-command?).

Sure, ",run-in-store" sounds great.  I have pushed the patches for
adding (guix scripts), 'set-build-options*' and
'show-derivation-outputs', so the attached patch (for adding
'build-package') is applied cleanly to master.

Ludovic Courtès (2015-08-28 12:24 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2015-08-26 14:12 +0300) wrote:
>>
>>> Maybe ‘build-package’ could go to (guix packages)?
>>
>> ‘build-package’ uses ‘show-…’ procedures from (guix ui) module.  I
>> thought that adding this module to (guix packages) was not desired, or
>> is it OK?
>
> Right, sorry.  So maybe leave in (guix build scripts) with a comment
> explaining that it doesn’t have a better place and is for use by the
> Emacs UI.  (Make sure to use the monadic style as suggested in a
> previous message.)

So I suppose this comment is not needed anymore (right?) as
'build-package' will beplaced in (guix scripts), and it looks like a
rather general procedure.  For example, it may be used for something
like ‘guix build --package-from-file’ suggested by David:
<http://lists.gnu.org/archive/html/guix-devel/2015-08/msg00107.html>.


[-- Attachment #2: 0001-scripts-Add-build-package.patch --]
[-- Type: text/x-patch, Size: 4024 bytes --]

From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Thu, 23 Jul 2015 16:16:41 +0300
Subject: [PATCH] scripts: Add 'build-package'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* guix/scripts/system.scm (maybe-build): Move to ...
* guix/scripts.scm: ...here.
  (build-package): New procedure.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 guix/scripts.scm        | 39 ++++++++++++++++++++++++++++++++++++++-
 guix/scripts/system.scm | 13 -------------
 2 files changed, 38 insertions(+), 14 deletions(-)

diff --git a/guix/scripts.scm b/guix/scripts.scm
index 6bb3e21..e34d389 100644
--- a/guix/scripts.scm
+++ b/guix/scripts.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
+;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,11 +21,17 @@
 (define-module (guix scripts)
   #:use-module (guix utils)
   #:use-module (guix ui)
+  #:use-module (guix store)
+  #:use-module (guix monads)
+  #:use-module (guix packages)
+  #:use-module (guix derivations)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 match)
   #:export (args-fold*
-            parse-command-line))
+            parse-command-line
+            maybe-build
+            build-package))
 
 ;;; Commentary:
 ;;;
@@ -78,4 +85,34 @@ parameter of 'args-fold'."
       ;; ARGS take precedence over what the environment variable specifies.
       (parse-options-from args seeds))))
 
+(define* (maybe-build drvs
+                      #:key dry-run? use-substitutes?)
+  "Show what will/would be built, and actually build DRVS, unless DRY-RUN? is
+true."
+  (with-monad %store-monad
+    (>>= (show-what-to-build* drvs
+                              #:dry-run? dry-run?
+                              #:use-substitutes? use-substitutes?)
+         (lambda (_)
+           (if dry-run?
+               (return #f)
+               (built-derivations drvs))))))
+
+(define* (build-package package
+                        #:key dry-run? (use-substitutes? #t)
+                        #:allow-other-keys
+                        #:rest build-options)
+  "Build PACKAGE using BUILD-OPTIONS acceptable by 'set-build-options'.
+Show what and how will/would be built."
+  (mbegin %store-monad
+    (apply set-build-options*
+           #:use-substitutes? use-substitutes?
+           (strip-keyword-arguments '(#:dry-run?) build-options))
+    (mlet %store-monad ((derivation (package->derivation package)))
+      (mbegin %store-monad
+        (maybe-build (list derivation)
+                     #:use-substitutes? use-substitutes?
+                     #:dry-run? dry-run?)
+        (return (show-derivation-outputs derivation))))))
+
 ;;; scripts.scm ends here
diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm
index 32d4057..5e2d226 100644
--- a/guix/scripts/system.scm
+++ b/guix/scripts/system.scm
@@ -299,19 +299,6 @@ it atomically, and then run OS's activation script."
     ((disk-image)
      (system-disk-image os #:disk-image-size image-size))))
 
-(define* (maybe-build drvs
-                      #:key dry-run? use-substitutes?)
-  "Show what will/would be built, and actually build DRVS, unless DRY-RUN? is
-true."
-  (with-monad %store-monad
-    (>>= (show-what-to-build* drvs
-                              #:dry-run? dry-run?
-                              #:use-substitutes? use-substitutes?)
-         (lambda (_)
-           (if dry-run?
-               (return #f)
-               (built-derivations drvs))))))
-
 (define* (perform-action action os
                          #:key grub? dry-run?
                          use-substitutes? device target
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH] Add (guix scripts).
  2015-09-16 20:21                       ` Ludovic Courtès
@ 2015-09-18 18:52                         ` Alex Kost
  0 siblings, 0 replies; 49+ messages in thread
From: Alex Kost @ 2015-09-18 18:52 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-09-16 23:21 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> From b5484f43c429e283284033f4adb6097034a60418 Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Thu, 10 Sep 2015 12:37:36 +0300
>> Subject: [PATCH] Add (guix scripts).
[...]
> Also add guix/scripts.scm to po/guix/POTFILES.in.
>
> OK with this change, thanks!

Fixed and pushed, thank you!

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-09-18 18:51                 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
@ 2015-09-22 15:12                   ` Ludovic Courtès
  2015-09-22 19:10                     ` Alex Kost
  0 siblings, 1 reply; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-22 15:12 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-09-08 23:10 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:

[...]

>>> Ludovic Courtès (2015-08-26 14:12 +0300) wrote:
>>>
>>>> Maybe ‘build-package’ could go to (guix packages)?
>>>
>>> ‘build-package’ uses ‘show-…’ procedures from (guix ui) module.  I
>>> thought that adding this module to (guix packages) was not desired, or
>>> is it OK?
>>
>> Right, sorry.  So maybe leave in (guix build scripts) with a comment
>> explaining that it doesn’t have a better place and is for use by the
>> Emacs UI.  (Make sure to use the monadic style as suggested in a
>> previous message.)
>
> So I suppose this comment is not needed anymore (right?) as

Correct.

> 'build-package' will beplaced in (guix scripts), and it looks like a
> rather general procedure.  For example, it may be used for something
> like ‘guix build --package-from-file’ suggested by David:
> <http://lists.gnu.org/archive/html/guix-devel/2015-08/msg00107.html>.

‘guix package --install-from-file’ was committed but I don’t think it
actually needs ‘build-package’.

> From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Thu, 23 Jul 2015 16:16:41 +0300
> Subject: [PATCH] scripts: Add 'build-package'.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> * guix/scripts/system.scm (maybe-build): Move to ...
> * guix/scripts.scm: ...here.
>   (build-package): New procedure.
>
> Co-authored-by: Ludovic Courtès <ludo@gnu.org>

OK!

Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-09-22 15:12                   ` Ludovic Courtès
@ 2015-09-22 19:10                     ` Alex Kost
  2015-09-22 21:39                       ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-09-22 19:10 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Ludovic Courtès (2015-09-22 18:12 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
[...]
>> 'build-package' will be placed in (guix scripts), and it looks like a
>> rather general procedure.  For example, it may be used for something
>> like ‘guix build --package-from-file’ suggested by David:
>> <http://lists.gnu.org/archive/html/guix-devel/2015-08/msg00107.html>.
>
> ‘guix package --install-from-file’ was committed but I don’t think it
> actually needs ‘build-package’.

David also suggested the same option for ‘guix build’, and that's what I
talked about (not ‘guix package’) — it wasn't implemented (presumably
because there was no ‘build-package’ analog).

>> From ce35de1359ae11a2e73f129db4f7685985f3d041 Mon Sep 17 00:00:00 2001
>> From: Alex Kost <alezost@gmail.com>
>> Date: Thu, 23 Jul 2015 16:16:41 +0300
>> Subject: [PATCH] scripts: Add 'build-package'.
>> MIME-Version: 1.0
>> Content-Type: text/plain; charset=UTF-8
>> Content-Transfer-Encoding: 8bit
>>
>> * guix/scripts/system.scm (maybe-build): Move to ...
>> * guix/scripts.scm: ...here.
>>   (build-package): New procedure.
>>
>> Co-authored-by: Ludovic Courtès <ludo@gnu.org>
>
> OK!

Thank you, I have pushed this patch and the commits for the elisp side
you OKeyed a month ago.  So I also send the rest patches to finish this
"guix-devel.el" stuff.

-- 
Alex

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH 1/2] emacs: Add development utils.
  2015-08-26 11:14       ` Ludovic Courtès
@ 2015-09-22 19:10         ` Alex Kost
  2015-09-22 21:44           ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-09-22 19:10 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1133 bytes --]

Ludovic Courtès (2015-08-26 14:14 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2015-08-18 17:17 +0300) wrote:
>>
[...]
>>> Also, what about suggesting or even defining a key binding for this one?
>>> It sounds very useful.
>>
>> There is an example of defining a key binding for a command in this
>> section.  As for the real defining, not sure if it is worth, but yeah,
>> why not.  We may define 'guix-minor-mode', for example, with
>> guix-specific key bindings.  But I don't know what bindings to use:
>> 'geiser-mode' already binds many commands to [C-c …].  Perhaps to put
>> the additional keys in [C-c g …]?
>
> Yes, ‘guix-minor-mode’ and C-c g both sound like good ideas to me.

Eventually I named it ‘guix-devel-mode’, and I made it enabled by
default (in "emacs/guix-init.el"), as it just provides some keys and
won't do any harm.  Is it OK?

As for the keys, I put them in [C-c .] "group", because according to
(info "(elisp) Key Binding Conventions"), [C-c <letter>] bindings are
reserved for users.  Do you have other suggestions for the keys?


[-- Attachment #2: 0001-emacs-Add-development-utils.patch --]
[-- Type: text/x-patch, Size: 8459 bytes --]

From 9e0541abe206e1e7409ea575acc824a26c2f62d5 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 24 Jul 2015 18:33:14 +0300
Subject: [PATCH 1/2] emacs: Add development utils.

* emacs/guix-guile.el (guix-guile-current-module): New function.
* emacs/guix-devel.el: New file.
* emacs.am (ELFILES): Add it.
* doc/emacs.texi (Emacs Development): New node.
  (Emacs Interface): Add it.
* doc/contributing.texi (The Perfect Setup): Mention it.
* doc/guix.texi (Top): Add it.
* emacs/guix-init.el: Add 'guix-devel-activate-mode-maybe' to
  'scheme-mode-hook'.
---
 doc/contributing.texi |  3 ++
 doc/emacs.texi        | 25 +++++++++++++-
 doc/guix.texi         |  3 +-
 emacs.am              |  1 +
 emacs/guix-devel.el   | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++
 emacs/guix-guile.el   | 13 +++++++
 emacs/guix-init.el    |  2 ++
 7 files changed, 141 insertions(+), 2 deletions(-)
 create mode 100644 emacs/guix-devel.el

diff --git a/doc/contributing.texi b/doc/contributing.texi
index ded5434..b2d097d 100644
--- a/doc/contributing.texi
+++ b/doc/contributing.texi
@@ -121,6 +121,9 @@ facilities to directly operate on the syntax tree, such as raising an
 s-expression or wrapping it, swallowing or rejecting the following
 s-expression, etc.
 
+GNU Guix also comes with a minor mode that provides some additional
+functionality for Scheme buffers (@pxref{Emacs Development}).
+
 
 @node Coding Style
 @section Coding Style
diff --git a/doc/emacs.texi b/doc/emacs.texi
index 6777346..d44d329 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -12,7 +12,8 @@ Guix convenient and fun.
 * Popup Interface: Emacs Popup Interface.	Magit-like interface for guix commands.
 * Prettify Mode: Emacs Prettify.	Abbreviating @file{/gnu/store/@dots{}} file names.
 * Build Log Mode: Emacs Build Log.	Highlighting Guix build logs.
-* Completions: Emacs Completions.       Completing @command{guix} shell command.
+* Completions: Emacs Completions.	Completing @command{guix} shell command.
+* Development: Emacs Development.	Tools for Guix developers.
 @end menu
 
 
@@ -637,3 +638,25 @@ something:
 @item @code{guix lint --checkers=synopsis,des}@key{TAB}
 
 @end itemize
+
+
+@node Emacs Development
+@section Development
+
+By default, when you open a Scheme file, @code{guix-devel-mode} will be
+activated (if you don't want it, set @code{guix-devel-activate-mode} to
+nil).  This minor mode provides the following key bindings:
+
+@table @kbd
+
+@item C-c . k
+Copy the name of the current Guile module into kill ring
+(@code{guix-devel-copy-module-as-kill}).
+
+@item C-c . u
+Use the current Guile module.  Often after opening a Scheme file, you
+want to use a module it defines, so you switch to the Geiser REPL and
+write @code{,use (some module)} there.  You may just use this command
+instead (@code{guix-devel-use-module}).
+
+@end table
diff --git a/doc/guix.texi b/doc/guix.texi
index 3ca4cef..eec2821 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -113,7 +113,8 @@ Emacs Interface
 * Popup Interface: Emacs Popup Interface.	Magit-like interface for guix commands.
 * Prettify Mode: Emacs Prettify.	Abbreviating @file{/gnu/store/@dots{}} file names.
 * Build Log Mode: Emacs Build Log.	Highlighting Guix build logs.
-* Completions: Emacs Completions.       Completing @command{guix} shell command.
+* Completions: Emacs Completions.	Completing @command{guix} shell command.
+* Development: Emacs Development.	Tools for Guix developers.
 
 Programming Interface
 
diff --git a/emacs.am b/emacs.am
index 5d403b2..9f300bf 100644
--- a/emacs.am
+++ b/emacs.am
@@ -23,6 +23,7 @@ ELFILES =					\
   emacs/guix-base.el				\
   emacs/guix-build-log.el			\
   emacs/guix-command.el				\
+  emacs/guix-devel.el				\
   emacs/guix-emacs.el				\
   emacs/guix-external.el			\
   emacs/guix-geiser.el				\
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
new file mode 100644
index 0000000..ed82e33
--- /dev/null
+++ b/emacs/guix-devel.el
@@ -0,0 +1,96 @@
+;;; guix-devel.el --- Development tools   -*- lexical-binding: t -*-
+
+;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+
+;; This file is part of GNU Guix.
+
+;; GNU Guix is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; GNU Guix is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; This file provides commands useful for developing Guix (or even
+;; arbitrary Guile code) with Geiser.
+
+;;; Code:
+
+(require 'guix-guile)
+(require 'guix-geiser)
+(require 'guix-utils)
+
+(defgroup guix-devel nil
+  "Settings for Guix development utils."
+  :group 'guix)
+
+(defcustom guix-devel-activate-mode t
+  "If non-nil, then `guix-devel-mode' is automatically activated
+in Scheme buffers."
+  :type 'boolean
+  :group 'guix-devel)
+
+(defun guix-devel-use-modules (&rest modules)
+  "Use guile MODULES."
+  (apply #'guix-geiser-call "use-modules" modules))
+
+(defun guix-devel-use-module (&optional module)
+  "Use guile MODULE in the current Geiser REPL.
+MODULE is a string with the module name - e.g., \"(ice-9 match)\".
+Interactively, use the module defined by the current scheme file."
+  (interactive (list (guix-guile-current-module)))
+  (guix-devel-use-modules module)
+  (message "Using %s module." module))
+
+(defun guix-devel-copy-module-as-kill ()
+  "Put the name of the current guile module into `kill-ring'."
+  (interactive)
+  (guix-copy-as-kill (guix-guile-current-module)))
+
+(defvar guix-devel-keys-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "k") 'guix-devel-copy-module-as-kill)
+    (define-key map (kbd "u") 'guix-devel-use-module)
+    map)
+  "Keymap with subkeys for `guix-devel-mode-map'.")
+
+(defvar guix-devel-mode-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "C-c .") guix-devel-keys-map)
+    map)
+  "Keymap for `guix-devel-mode'.")
+
+;;;###autoload
+(define-minor-mode guix-devel-mode
+  "Minor mode for `scheme-mode' buffers.
+
+With a prefix argument ARG, enable the mode if ARG is positive,
+and disable it otherwise.  If called from Lisp, enable the mode
+if ARG is omitted or nil.
+
+When Guix Devel mode is enabled, it provides the following key
+bindings:
+
+\\{guix-devel-mode-map}"
+  :init-value nil
+  :lighter " Guix"
+  :keymap guix-devel-mode-map)
+
+;;;###autoload
+(defun guix-devel-activate-mode-maybe ()
+  "Activate `guix-devel-mode' depending on
+`guix-devel-activate-mode' variable."
+  (when guix-devel-activate-mode
+    (guix-devel-mode)))
+
+(provide 'guix-devel)
+
+;;; guix-devel.el ends here
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
index cff9bd4..c21d27f 100644
--- a/emacs/guix-guile.el
+++ b/emacs/guix-guile.el
@@ -24,6 +24,19 @@
 
 ;;; Code:
 
+(require 'geiser-guile)
+
+(defun guix-guile-current-module ()
+  "Return a string with the current guile module.
+Return nil, if current buffer does not define a module."
+  ;; Modified version of `geiser-guile--get-module'.
+  (save-excursion
+    (geiser-syntax--pop-to-top)
+    (when (or (re-search-backward geiser-guile--module-re nil t)
+              (looking-at geiser-guile--library-re)
+              (re-search-forward geiser-guile--module-re nil t))
+      (match-string-no-properties 1))))
+
 (defun guix-guile-make-call-expression (proc &rest args)
   "Return \"(PROC ARGS ...)\" string.
 PROC and ARGS should be strings."
diff --git a/emacs/guix-init.el b/emacs/guix-init.el
index 3a727c7..96aa0c2 100644
--- a/emacs/guix-init.el
+++ b/emacs/guix-init.el
@@ -12,4 +12,6 @@ avoid loading autoloads of Emacs packages installed in
   (require 'guix-emacs)
   (guix-emacs-load-autoloads 'all))
 
+(add-hook 'scheme-mode-hook 'guix-devel-activate-mode-maybe)
+
 (provide 'guix-init)
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition'.
  2015-08-25 20:59     ` Ludovic Courtès
@ 2015-09-22 19:11       ` Alex Kost
  2015-09-22 21:47         ` Ludovic Courtès
  0 siblings, 1 reply; 49+ messages in thread
From: Alex Kost @ 2015-09-22 19:11 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 2257 bytes --]

Ludovic Courtès (2015-08-25 23:59 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> Ludovic Courtès (2015-08-18 16:50 +0300) wrote:
>>
>>> Alex Kost <alezost@gmail.com> skribis:
>>>
>>>> And finally, I'm afraid building guix package in a Geiser REPL may not
>>>> be very useful because of <https://github.com/jaor/geiser/issues/28>
>>>> (you have wait for the REPL command to be finished before continuing to
>>>> edit .scm-file).
>>>
>>> Bummer, indeed.  I wonder if that could be worked around by spawning a
>>> new Guile server thread that would be used to build the package, and
>>> opening a new Geiser REPL connected to that thread?  Maybe too complex,
>>> though.
>>
>> That's what I did for *Guix REPL*: it is a server by default, and there
>> is *Guix Internal REPL* which connects to it (there is a commentary
>> about it in "emacs/guix-backend.el").
>>
>> But I don't think it should be done here: as a user I expect that the
>> building will be performed in the current Geiser REPL, so it's up to me
>> (as a user) to decide what repl it is.
>>
>> Also to avoid that limitation, a user can just run another Geiser REPL
>> after the building begins, and can continue to edit a scheme file with
>> the help of the current REPL, while the building will continue in the
>> previous one.  (I will mention this in the manual)
>
> OK, sounds good!

Done.

Ludovic Courtès (2015-09-09 23:11 +0300) wrote:

> Alex Kost <alezost@gmail.com> skribis:
>
>> As a workaround for this issue it was proposed¹ to transform
>> ‘current-build-output-port’ into a procedure (I have checked that it
>> solves the problem).  What do you think about it?  Perhaps to make sure
>> that the port will be always the same define it like this:
>>
>> (define current-build-output-port (memoize current-error-port))
>>
>> Is it acceptable?
>
> No, ‘current-build-output-port’ should remain a SRFI-39 parameter so
> that callers can easily rebind it.
>
> However, perhaps the guix.el code could do:
>
>   (current-build-output-port (current-error-port))
>
> at startup; would that be doable?

Also done.  The workaround appeared to be not so ugly as I thought at
first, thanks for the pointer!


[-- Attachment #2: 0002-emacs-Add-guix-devel-build-package-definition.patch --]
[-- Type: text/x-patch, Size: 6591 bytes --]

From 8011d1c62b49c309ddba933d27fc4c86eabf60a2 Mon Sep 17 00:00:00 2001
From: Alex Kost <alezost@gmail.com>
Date: Fri, 24 Jul 2015 20:31:11 +0300
Subject: [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition'.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Suggested by Ludovic Courtès <ludo@gnu.org>.

* emacs/guix-guile.el (guix-guile-definition-regexp): New variable.
  (guix-guile-current-definition, guix-guile-boolean): New functions.
* emacs/guix-devel.el: Require 'guix-base'.
  (guix-devel-repl-processes): New variable.
  (guix-devel-setup-repl, guix-devel-setup-repl-maybe): New functions.
  (guix-devel-build-package-definition): New command.
* doc/emacs.texi (Emacs Development): Document it.
---
 doc/emacs.texi      | 24 ++++++++++++++++++++++++
 emacs/guix-devel.el | 40 ++++++++++++++++++++++++++++++++++++++++
 emacs/guix-guile.el | 22 ++++++++++++++++++++++
 3 files changed, 86 insertions(+)

diff --git a/doc/emacs.texi b/doc/emacs.texi
index d44d329..b6f2701 100644
--- a/doc/emacs.texi
+++ b/doc/emacs.texi
@@ -659,4 +659,28 @@ want to use a module it defines, so you switch to the Geiser REPL and
 write @code{,use (some module)} there.  You may just use this command
 instead (@code{guix-devel-use-module}).
 
+@item C-c . b
+Build a package defined by the current variable definition.  The
+building process is run in the current Geiser REPL.  If you modified the
+current package definition, don't forget to reevaluate it before calling
+this command---for example, with @kbd{C-M-x} (@pxref{To eval or not to
+eval,,, geiser, Geiser User Manual})
+(@code{guix-devel-build-package-definition}).
+
 @end table
+
+Unluckily, there is a limitation related to long-running REPL commands.
+When there is a running process in a Geiser REPL, you are not supposed
+to evaluate anything in a scheme buffer, because this will ``freeze''
+the REPL: it will stop producing any output (however, the evaluating
+process will continue---you will just not see any progress anymore).  Be
+aware: even moving the point in a scheme buffer may ``break'' the REPL
+if Autodoc (@pxref{Autodoc and friends,,, geiser, Geiser User Manual})
+is enabled (which is the default).
+
+So you have to postpone editing your scheme buffers until the running
+evaluation will be finished in the REPL.
+
+Alternatively, to avoid this limitation, you may just run another Geiser
+REPL, and while something is being evaluated in the previous REPL, you
+can continue editing a scheme file with the help of the current one.
diff --git a/emacs/guix-devel.el b/emacs/guix-devel.el
index ed82e33..6de49be 100644
--- a/emacs/guix-devel.el
+++ b/emacs/guix-devel.el
@@ -27,6 +27,7 @@
 (require 'guix-guile)
 (require 'guix-geiser)
 (require 'guix-utils)
+(require 'guix-base)
 
 (defgroup guix-devel nil
   "Settings for Guix development utils."
@@ -55,8 +56,47 @@ Interactively, use the module defined by the current scheme file."
   (interactive)
   (guix-copy-as-kill (guix-guile-current-module)))
 
+(defun guix-devel-setup-repl (&optional repl)
+  "Setup REPL for using `guix-devel-...' commands."
+  (guix-devel-use-modules "(guix monad-repl)"
+                          "(guix scripts)"
+                          "(guix store)")
+  ;; Without this workaround, the build output disappears.  See
+  ;; <https://github.com/jaor/geiser/issues/83> for details.
+  (guix-geiser-eval-in-repl
+   "(current-build-output-port (current-error-port))"
+   repl 'no-history 'no-display))
+
+(defvar guix-devel-repl-processes nil
+  "List of REPL processes configured by `guix-devel-setup-repl'.")
+
+(defun guix-devel-setup-repl-maybe (&optional repl)
+  "Setup (if needed) REPL for using `guix-devel-...' commands."
+  (let ((process (get-buffer-process (or repl (guix-geiser-repl)))))
+    (when (and process
+               (not (memq process guix-devel-repl-processes)))
+      (guix-devel-setup-repl repl)
+      (push process guix-devel-repl-processes))))
+
+(defun guix-devel-build-package-definition ()
+  "Build a package defined by the current top-level variable definition."
+  (interactive)
+  (let ((def (guix-guile-current-definition)))
+    (guix-devel-setup-repl-maybe)
+    (guix-devel-use-modules (guix-guile-current-module))
+    (when (or (not guix-operation-confirm)
+              (guix-operation-prompt (format "Build '%s'?" def)))
+      (guix-geiser-eval-in-repl
+       (concat ",run-in-store "
+               (guix-guile-make-call-expression
+                "build-package" def
+                "#:use-substitutes?" (guix-guile-boolean
+                                      guix-use-substitutes)
+                "#:dry-run?" (guix-guile-boolean guix-dry-run)))))))
+
 (defvar guix-devel-keys-map
   (let ((map (make-sparse-keymap)))
+    (define-key map (kbd "b") 'guix-devel-build-package-definition)
     (define-key map (kbd "k") 'guix-devel-copy-module-as-kill)
     (define-key map (kbd "u") 'guix-devel-use-module)
     map)
diff --git a/emacs/guix-guile.el b/emacs/guix-guile.el
index c21d27f..35a97d7 100644
--- a/emacs/guix-guile.el
+++ b/emacs/guix-guile.el
@@ -26,6 +26,23 @@
 
 (require 'geiser-guile)
 
+(defvar guix-guile-definition-regexp
+  (rx bol "(define"
+      (zero-or-one "*")
+      (zero-or-one "-public")
+      (one-or-more space)
+      (zero-or-one "(")
+      (group (one-or-more (or word (syntax symbol)))))
+  "Regexp used to find the guile definition.")
+
+(defun guix-guile-current-definition ()
+  "Return string with name of the current top-level guile definition."
+  (save-excursion
+    (beginning-of-defun)
+    (if (looking-at guix-guile-definition-regexp)
+        (match-string-no-properties 1)
+      (error "Couldn't find the current definition"))))
+
 (defun guix-guile-current-module ()
   "Return a string with the current guile module.
 Return nil, if current buffer does not define a module."
@@ -37,6 +54,11 @@ Return nil, if current buffer does not define a module."
               (re-search-forward geiser-guile--module-re nil t))
       (match-string-no-properties 1))))
 
+(defun guix-guile-boolean (arg)
+  "Return a string with guile boolean value.
+Transform elisp ARG (nil or non-nil) to the guile boolean (#f or #t)."
+  (concat "#" (prin1-to-string (if arg 't 'f))))
+
 (defun guix-guile-make-call-expression (proc &rest args)
   "Return \"(PROC ARGS ...)\" string.
 PROC and ARGS should be strings."
-- 
2.5.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 6/7] guix build: Add 'build-package'.
  2015-09-22 19:10                     ` Alex Kost
@ 2015-09-22 21:39                       ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-22 21:39 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-09-22 18:12 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
> [...]
>>> 'build-package' will be placed in (guix scripts), and it looks like a
>>> rather general procedure.  For example, it may be used for something
>>> like ‘guix build --package-from-file’ suggested by David:
>>> <http://lists.gnu.org/archive/html/guix-devel/2015-08/msg00107.html>.
>>
>> ‘guix package --install-from-file’ was committed but I don’t think it
>> actually needs ‘build-package’.
>
> David also suggested the same option for ‘guix build’, and that's what I
> talked about (not ‘guix package’) — it wasn't implemented (presumably
> because there was no ‘build-package’ analog).

I see, I had overlooked that part of Dave’s message.

> Thank you, I have pushed this patch and the commits for the elisp side
> you OKeyed a month ago.  So I also send the rest patches to finish this
> "guix-devel.el" stuff.

Oops, one month already!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 1/2] emacs: Add development utils.
  2015-09-22 19:10         ` [PATCH 1/2] emacs: Add development utils Alex Kost
@ 2015-09-22 21:44           ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-22 21:44 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> Ludovic Courtès (2015-08-26 14:14 +0300) wrote:
>
>> Alex Kost <alezost@gmail.com> skribis:
>>
>>> Ludovic Courtès (2015-08-18 17:17 +0300) wrote:
>>>
> [...]
>>>> Also, what about suggesting or even defining a key binding for this one?
>>>> It sounds very useful.
>>>
>>> There is an example of defining a key binding for a command in this
>>> section.  As for the real defining, not sure if it is worth, but yeah,
>>> why not.  We may define 'guix-minor-mode', for example, with
>>> guix-specific key bindings.  But I don't know what bindings to use:
>>> 'geiser-mode' already binds many commands to [C-c …].  Perhaps to put
>>> the additional keys in [C-c g …]?
>>
>> Yes, ‘guix-minor-mode’ and C-c g both sound like good ideas to me.
>
> Eventually I named it ‘guix-devel-mode’, and I made it enabled by
> default (in "emacs/guix-init.el"), as it just provides some keys and
> won't do any harm.  Is it OK?

Sounds good to me.

> As for the keys, I put them in [C-c .] "group", because according to
> (info "(elisp) Key Binding Conventions"), [C-c <letter>] bindings are
> reserved for users.  Do you have other suggestions for the keys?

No, I think it’s fine and it matches the elisp manual recommendations.

> From 9e0541abe206e1e7409ea575acc824a26c2f62d5 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Fri, 24 Jul 2015 18:33:14 +0300
> Subject: [PATCH 1/2] emacs: Add development utils.
>
> * emacs/guix-guile.el (guix-guile-current-module): New function.
> * emacs/guix-devel.el: New file.
> * emacs.am (ELFILES): Add it.
> * doc/emacs.texi (Emacs Development): New node.
>   (Emacs Interface): Add it.
> * doc/contributing.texi (The Perfect Setup): Mention it.
> * doc/guix.texi (Top): Add it.
> * emacs/guix-init.el: Add 'guix-devel-activate-mode-maybe' to
>   'scheme-mode-hook'.

LGTM, thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition'.
  2015-09-22 19:11       ` [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition' Alex Kost
@ 2015-09-22 21:47         ` Ludovic Courtès
  0 siblings, 0 replies; 49+ messages in thread
From: Ludovic Courtès @ 2015-09-22 21:47 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost <alezost@gmail.com> skribis:

> From 8011d1c62b49c309ddba933d27fc4c86eabf60a2 Mon Sep 17 00:00:00 2001
> From: Alex Kost <alezost@gmail.com>
> Date: Fri, 24 Jul 2015 20:31:11 +0300
> Subject: [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition'.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> Suggested by Ludovic Courtès <ludo@gnu.org>.
>
> * emacs/guix-guile.el (guix-guile-definition-regexp): New variable.
>   (guix-guile-current-definition, guix-guile-boolean): New functions.
> * emacs/guix-devel.el: Require 'guix-base'.
>   (guix-devel-repl-processes): New variable.
>   (guix-devel-setup-repl, guix-devel-setup-repl-maybe): New functions.
>   (guix-devel-build-package-definition): New command.
> * doc/emacs.texi (Emacs Development): Document it.

OK, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2015-09-22 21:47 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-25  8:49 [PATCH 0/7] Add "guix-devel-…" commands Alex Kost
2015-07-25  8:49 ` [PATCH 1/7] emacs: Move guile related code to "guix-guile.el" Alex Kost
2015-08-18 13:50   ` Ludovic Courtès
2015-08-18 13:51   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 2/7] emacs: Move code for evaluating to "guix-geiser.el" Alex Kost
2015-08-18 13:52   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 3/7] emacs: Add code to call guile procedures Alex Kost
2015-08-18 13:52   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 4/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
2015-07-25 18:51   ` Mathieu Lirzin
2015-07-26  8:29     ` Alex Kost
2015-07-26 14:00       ` Mathieu Lirzin
2015-07-26 18:11         ` Alex Kost
2015-07-28  9:19           ` Mathieu Lirzin
2015-08-18 14:05   ` Ludovic Courtès
2015-08-19 20:47     ` Alex Kost
2015-08-26 11:07       ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 5/7] ui: Add 'show-derivation-outputs' Alex Kost
2015-08-18 14:07   ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
2015-08-18 14:15   ` Ludovic Courtès
2015-08-19 20:50     ` Alex Kost
2015-08-26 11:12       ` Ludovic Courtès
2015-08-26 17:44         ` Alex Kost
2015-08-28  9:24           ` Ludovic Courtès
2015-09-06  9:03             ` Alex Kost
2015-09-06  9:32               ` Alex Kost
2015-09-08 19:59                 ` Ludovic Courtès
2015-09-08 20:10               ` Ludovic Courtès
2015-09-10 10:25                 ` [PATCH] Add (guix scripts) Alex Kost
2015-09-14 13:34                   ` Ludovic Courtès
2015-09-14 18:39                     ` Alex Kost
2015-09-16 20:21                       ` Ludovic Courtès
2015-09-18 18:52                         ` Alex Kost
2015-09-18 18:51                 ` [PATCH 6/7] guix build: Add 'build-package' Alex Kost
2015-09-22 15:12                   ` Ludovic Courtès
2015-09-22 19:10                     ` Alex Kost
2015-09-22 21:39                       ` Ludovic Courtès
2015-07-25  8:49 ` [PATCH 7/7] emacs: Add 'guix-devel-use-current-module' Alex Kost
2015-08-18 14:17   ` Ludovic Courtès
2015-08-19 20:51     ` [PATCH 7/7] emacs: Add 'guix-devel-build-current-package-definition' Alex Kost
2015-08-26 11:14       ` Ludovic Courtès
2015-09-22 19:10         ` [PATCH 1/2] emacs: Add development utils Alex Kost
2015-09-22 21:44           ` Ludovic Courtès
2015-08-18 13:50 ` [PATCH 0/7] Add "guix-devel-…" commands Ludovic Courtès
2015-08-19 20:47   ` Alex Kost
2015-08-25 20:59     ` Ludovic Courtès
2015-09-22 19:11       ` [PATCH 2/2] emacs: Add 'guix-devel-build-package-definition' Alex Kost
2015-09-22 21:47         ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.