From: "Ludovic Courtès" <ludo@gnu.org>
To: 55752@debbugs.gnu.org
Cc: "Ludovic Courtès" <ludo@gnu.org>
Subject: [bug#55752] [PATCH 1/5] edit: Extract 'spawn-editor' procedure.
Date: Wed, 1 Jun 2022 17:42:58 +0200 [thread overview]
Message-ID: <20220601154302.16222-1-ludo@gnu.org> (raw)
In-Reply-To: <20220601154140.16178-1-ludo@gnu.org>
* 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@gnu.org>
+;;; Copyright © 2015-2016, 2019-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2015 Mathieu Lirzin <mthl@gnu.org>
;;; Copyright © 2020, 2021 Simon Tournier <zimon.toutoune@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))))))
+
\f
(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
next prev parent reply other threads:[~2022-06-01 15:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 15:41 [bug#55752] [PATCH 0/5] Add 'guix system edit' and 'guix home edit' Ludovic Courtès
2022-06-01 15:42 ` Ludovic Courtès [this message]
2022-06-01 15:42 ` [bug#55752] [PATCH 2/5] guix system: Add 'edit' sub-command Ludovic Courtès
2022-06-01 15:43 ` [bug#55752] [PATCH 3/5] home: services: Add 'lookup-home-service-types' procedure Ludovic Courtès
2022-06-01 15:43 ` [bug#55752] [PATCH 4/5] guix home: Add 'edit' sub-command Ludovic Courtès
2022-06-01 15:43 ` [bug#55752] [PATCH 5/5] DRAFT news: Add entry for 'guix system edit' and 'guix home edit' Ludovic Courtès
2022-06-02 11:41 ` Maxime Devos
2022-06-02 13:26 ` Ludovic Courtès
2022-06-04 10:10 ` bug#55752: [PATCH 0/5] Add " Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220601154302.16222-1-ludo@gnu.org \
--to=ludo@gnu.org \
--cc=55752@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).