GNU bug report logs - #55752
[PATCH 0/5] Add 'guix system edit' and 'guix home edit'

Previous Next

Package: guix-patches;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Wed, 1 Jun 2022 15:42:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: 55752 <at> debbugs.gnu.org
Cc: Ludovic Courtès <ludo <at> gnu.org>
Subject: [bug#55752] [PATCH 1/5] edit: Extract 'spawn-editor' procedure.
Date: Wed,  1 Jun 2022 17:42:58 +0200
* guix/scripts/edit.scm (spawn-editor): New procedure, with code from...
(guix-edit): ... here.  Use it.
---
 guix/scripts/edit.scm | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm
index a2e1ffb434..8e777d1405 100644
--- a/guix/scripts/edit.scm
+++ b/guix/scripts/edit.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2015, 2016, 2019, 2020, 2021 Ludovic Courtès <ludo <at> gnu.org>
+;;; Copyright © 2015-2016, 2019-2022 Ludovic Courtès <ludo <at> gnu.org>
 ;;; Copyright © 2015 Mathieu Lirzin <mthl <at> gnu.org>
 ;;; Copyright © 2020, 2021 Simon Tournier <zimon.toutoune <at> gmail.com>
 ;;;
@@ -27,6 +27,7 @@ (define-module (guix scripts edit)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-37)
   #:export (%editor
+            spawn-editor
             guix-edit))
 
 (define %options
@@ -77,6 +78,21 @@ (define (location->location-specification location)
                         (location-line location)))
         (search-path* %load-path (location-file location))))
 
+(define (spawn-editor locations)
+  "Spawn (%editor) to edit the code at LOCATIONS, a list of <location>
+records, and exit."
+  (catch 'system-error
+    (lambda ()
+      (let ((file-names (append-map location->location-specification
+                                    locations)))
+        ;; Use `system' instead of `exec' in order to sanely handle
+        ;; possible command line arguments in %EDITOR.
+        (exit (system (string-join (cons (%editor) file-names))))))
+    (lambda args
+      (let ((errno (system-error-errno args)))
+        (leave (G_ "failed to launch '~a': ~a~%")
+               (%editor) (strerror errno))))))
+
 
 (define-command (guix-edit . args)
   (category packaging)
@@ -94,14 +110,4 @@ (define (parse-arguments)
       (when (null? specs)
         (leave (G_ "no packages specified, nothing to edit~%")))
 
-      (catch 'system-error
-        (lambda ()
-          (let ((file-names (append-map location->location-specification
-                                        locations)))
-            ;; Use `system' instead of `exec' in order to sanely handle
-            ;; possible command line arguments in %EDITOR.
-            (exit (system (string-join (cons (%editor) file-names))))))
-        (lambda args
-          (let ((errno (system-error-errno args)))
-            (leave (G_ "failed to launch '~a': ~a~%")
-                   (%editor) (strerror errno))))))))
+      (spawn-editor locations))))
-- 
2.36.1





This bug report was last modified 3 years and 49 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.