summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am1
-rw-r--r--doc.am1
-rw-r--r--doc/guix.texi29
-rw-r--r--guix/scripts/edit.scm79
-rw-r--r--po/guix/POTFILES.in1
5 files changed, 110 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index c8d701b3bad..784848d3640 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -113,6 +113,7 @@ MODULES = \
113 guix/scripts/import/hackage.scm \ 113 guix/scripts/import/hackage.scm \
114 guix/scripts/environment.scm \ 114 guix/scripts/environment.scm \
115 guix/scripts/publish.scm \ 115 guix/scripts/publish.scm \
116 guix/scripts/edit.scm \
116 guix.scm \ 117 guix.scm \
117 $(GNU_SYSTEM_MODULES) 118 $(GNU_SYSTEM_MODULES)
118 119
diff --git a/doc.am b/doc.am
index d4ca0fc4a58..1c52066aa0d 100644
--- a/doc.am
+++ b/doc.am
@@ -90,6 +90,7 @@ SUBCOMMANDS := \
90 archive \ 90 archive \
91 build \ 91 build \
92 download \ 92 download \
93 edit \
93 environment \ 94 environment \
94 gc \ 95 gc \
95 hash \ 96 hash \
diff --git a/doc/guix.texi b/doc/guix.texi
index 1c7f4e12325..a93003d625b 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -124,6 +124,7 @@ Defining Packages
124Utilities 124Utilities
125 125
126* Invoking guix build:: Building packages from the command line. 126* Invoking guix build:: Building packages from the command line.
127* Invoking guix edit::
127* Invoking guix download:: Downloading a file and printing its hash. 128* Invoking guix download:: Downloading a file and printing its hash.
128* Invoking guix hash:: Computing the cryptographic hash of a file. 129* Invoking guix hash:: Computing the cryptographic hash of a file.
129* Invoking guix import:: Importing package definitions. 130* Invoking guix import:: Importing package definitions.
@@ -1931,7 +1932,10 @@ unavailable to the build process, possibly leading to a build failure.
1931 1932
1932Once a package definition is in place, the 1933Once a package definition is in place, the
1933package may actually be built using the @code{guix build} command-line 1934package may actually be built using the @code{guix build} command-line
1934tool (@pxref{Invoking guix build}). @xref{Packaging Guidelines}, for 1935tool (@pxref{Invoking guix build}). You can easily jump back to the
1936package definition using the @command{guix edit} command
1937(@pxref{Invoking guix edit}).
1938@xref{Packaging Guidelines}, for
1935more information on how to test package definitions, and 1939more information on how to test package definitions, and
1936@ref{Invoking guix lint}, for information on how to check a definition 1940@ref{Invoking guix lint}, for information on how to check a definition
1937for style conformance. 1941for style conformance.
@@ -3261,6 +3265,7 @@ programming interface of Guix in a convenient way.
3261 3265
3262@menu 3266@menu
3263* Invoking guix build:: Building packages from the command line. 3267* Invoking guix build:: Building packages from the command line.
3268* Invoking guix edit:: Editing package definitions.
3264* Invoking guix download:: Downloading a file and printing its hash. 3269* Invoking guix download:: Downloading a file and printing its hash.
3265* Invoking guix hash:: Computing the cryptographic hash of a file. 3270* Invoking guix hash:: Computing the cryptographic hash of a file.
3266* Invoking guix import:: Importing package definitions. 3271* Invoking guix import:: Importing package definitions.
@@ -3548,6 +3553,28 @@ the parsed command-line options.
3548@end defvr 3553@end defvr
3549 3554
3550 3555
3556@node Invoking guix edit
3557@section Invoking @command{guix edit}
3558
3559@cindex package definition, editing
3560So many packages, so many source files! The @command{guix edit} command
3561facilitates the life of packagers by pointing their editor at the source
3562file containing the definition of the specified packages. For instance:
3563
3564@example
3565guix edit gcc-4.8 vim
3566@end example
3567
3568@noindent
3569launches the program specified in the @code{EDITOR} environment variable
3570to edit the recipe of GCC@tie{}4.8.4 and that of Vim.
3571
3572If you are using Emacs, note that the Emacs user interface provides
3573similar functionality in the ``package info'' buffers created by
3574@kbd{M-x guix-search-by-name} and similar commands (@pxref{Emacs
3575Commands}).
3576
3577
3551@node Invoking guix download 3578@node Invoking guix download
3552@section Invoking @command{guix download} 3579@section Invoking @command{guix download}
3553 3580
diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
new file mode 100644
index 00000000000..fc453ac38dc
--- /dev/null
+++ b/guix/scripts/edit.scm
@@ -0,0 +1,79 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (guix scripts edit)
20 #:use-module (guix ui)
21 #:use-module (guix utils)
22 #:use-module (guix packages)
23 #:use-module (gnu packages)
24 #:use-module (srfi srfi-1)
25 #:use-module (srfi srfi-37)
26 #:export (%editor
27 guix-edit))
28
29(define %options
30 (list (option '(#\h "help") #f #f
31 (lambda args
32 (show-help)
33 (exit 0)))
34 (option '(#\V "version") #f #f
35 (lambda args
36 (show-version-and-exit "guix edit")))))
37
38(define (show-help)
39 (display (_ "Usage: guix edit PACKAGE...
40Start $EDITOR to edit the definitions of PACKAGE...\n"))
41 (newline)
42 (display (_ "
43 -h, --help display this help and exit"))
44 (display (_ "
45 -V, --version display version information and exit"))
46 (newline)
47 (show-bug-report-information))
48
49(define %editor
50 (make-parameter (or (getenv "EDITOR") "emacsclient")))
51
52(define (search-path* path file)
53 "Like 'search-path' but exit if FILE is not found."
54 (let ((absolute-file-name (search-path path file)))
55 (unless absolute-file-name
56 ;; Shouldn't happen unless somebody fiddled with the 'location' field.
57 (leave (_ "file '~a' not found in search path ~s~%")
58 file path))
59 absolute-file-name))
60
61
62(define (guix-edit . args)
63 (with-error-handling
64 (let* ((specs (parse-command-line args %options '(())
65 #:argument-handler cons))
66 (packages (map specification->package specs)))
67 (for-each (lambda (package)
68 (unless (package-location package)
69 (leave (_ "source location of package '~a' is unknown~%")
70 (package-full-name package))))
71 packages)
72 (apply execlp (%editor) (%editor)
73 (append-map (lambda (package)
74 (let ((loc (package-location package)))
75 (list (string-append "+"
76 (number->string
77 (location-line loc)))
78 (search-path* %load-path (location-file loc)))))
79 packages)))))
diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in
index 4f27f54d6c1..300486b6668 100644
--- a/po/guix/POTFILES.in
+++ b/po/guix/POTFILES.in
@@ -16,6 +16,7 @@ guix/scripts/authenticate.scm
16guix/scripts/system.scm 16guix/scripts/system.scm
17guix/scripts/lint.scm 17guix/scripts/lint.scm
18guix/scripts/publish.scm 18guix/scripts/publish.scm
19guix/scripts/edit.scm
19guix/gnu-maintenance.scm 20guix/gnu-maintenance.scm
20guix/ui.scm 21guix/ui.scm
21guix/http-client.scm 22guix/http-client.scm