From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id WPMFDkqJl2JDtQAAbAwnHQ (envelope-from ) for ; Wed, 01 Jun 2022 17:44:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id aGPlDUqJl2JoCAAAauVa8A (envelope-from ) for ; Wed, 01 Jun 2022 17:44:10 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DA5643C621 for ; Wed, 1 Jun 2022 17:44:09 +0200 (CEST) Received: from localhost ([::1]:57780 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nwQW1-0004Dg-1e for larch@yhetil.org; Wed, 01 Jun 2022 11:44:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwQVu-0004CR-CP for guix-patches@gnu.org; Wed, 01 Jun 2022 11:44:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwQVu-00088r-3L for guix-patches@gnu.org; Wed, 01 Jun 2022 11:44:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nwQVu-0001WS-1X for guix-patches@gnu.org; Wed, 01 Jun 2022 11:44:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#55752] [PATCH 1/5] edit: Extract 'spawn-editor' procedure. References: <20220601154140.16178-1-ludo@gnu.org> In-Reply-To: <20220601154140.16178-1-ludo@gnu.org> Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 01 Jun 2022 15:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55752 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 55752@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 55752-submit@debbugs.gnu.org id=B55752.16540982015752 (code B ref 55752); Wed, 01 Jun 2022 15:44:01 +0000 Received: (at 55752) by debbugs.gnu.org; 1 Jun 2022 15:43:21 +0000 Received: from localhost ([127.0.0.1]:51640 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nwQVF-0001Uh-9Y for submit@debbugs.gnu.org; Wed, 01 Jun 2022 11:43:21 -0400 Received: from eggs.gnu.org ([209.51.188.92]:54956) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nwQVD-0001U8-1r for 55752@debbugs.gnu.org; Wed, 01 Jun 2022 11:43:19 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:37370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nwQV5-00083E-DL; Wed, 01 Jun 2022 11:43:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=q4GMJVRvZUusTmNcjc3CT9qCqODFhQBFpXZ+NWSBu/Y=; b=KSaWhV8euNZhIe Kj1OgQWNWTyn1+3JEjD6icSEoeQKf2npTSi3OIH8tpbJ6lQfpUM903byAggm8wwiIEti75N+qTbJC DBoAqHPsulWAkve4L3K6ivtCwOwcto/erb1CTTbiyfmGXLDrsRMHYImh+M9+dMXMzTLSl1jSklGPR F9V7JlZY7XBeKpX0nXDS0SL6SQ8mdvch9lCqpvzE1bSy7CAVACkTaCm+0dm2kNW1w7gipVHQGMysx K8pBqDjeWiojFznn2QHEJG92s+WaQaKGUlCgTZtqNEsjx+gL01reLCTW158YqZ/WgBcvRnutpCPvI VLKFoGdjkjUCSjN7LWCQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:55618 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nwQV5-0006Xy-0f; Wed, 01 Jun 2022 11:43:11 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Wed, 1 Jun 2022 17:42:58 +0200 Message-Id: <20220601154302.16222-1-ludo@gnu.org> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1654098249; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=sr3+Y589BmlDVKw36yPvC88Nvo+eBz8ifBsGl/d2BAk=; b=pfOJskOLKmsCJaM7x46fFyGcpbzpLR8E1058FbOi7iY6Nd9nHky6lPZcFuW1JJIH6Ptxu5 jMDRpj3iiuI+XTULb7WLxnuMkyoK/QoIUM0nnjOLELRTQYj1kc6hh8W2z4hLxk/ni+8vn/ nWtYeD73TuFDDy4w1YEsD5Fzr9je8+1yMRA7iq90EnsbOSlp1IAKHGIggwKhFQyEqubzUP q5kqBhWZ2r4G+n8ecQajLF9d2xpudyIie84/zVREF+eoPPctWGQlAPm0rv2VWGRc1qXt5c 909ZM0l+zRS9GsJIsR83mpULDvZWjHrck15SWd1jzD7r7r8uxsNGOA2RiKE9fQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1654098249; a=rsa-sha256; cv=none; b=CTTrLsAQANBwmDt2dv66u742gZnxDHg7STlnKKp8SePE2ghc2XaZbGOqWxIajvV8dXusMi UxIMgkeXAG58iphRIgScYJdWrpJpK2//62qINAWokCbsYXZxPk2+5BQjxPHKanzap3JA+w 4pXL7+xRZJ7zrDKiwBp3QAHArldaRBeH1lIWWtlo64IlG0qFYkyqIASP7Y5Y3qWiPmyCDo OBhTwlZ3eHqqWgh50gVF8CgqUxa1WY0A3O1B29Me6/ZrmfnoM+LFbRCMLlA5f2u+0tFOvS cmxl/SPirLp9x28mN53GK71HWMje7+WWKCdXxS8cqjvm8Njwb/hu656b+oSI6A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=KSaWhV8e; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.93 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gnu.org header.s=fencepost-gnu-org header.b=KSaWhV8e; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: DA5643C621 X-Spam-Score: -2.93 X-Migadu-Scanner: scn1.migadu.com X-TUID: kbDhnFl/XrBA * 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 +;;; Copyright © 2015-2016, 2019-2022 Ludovic Courtès ;;; Copyright © 2015 Mathieu Lirzin ;;; Copyright © 2020, 2021 Simon Tournier ;;; @@ -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 +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