From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: guix edit Date: Tue, 16 Jun 2015 22:26:49 +0200 Message-ID: <87381rz9fa.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:33161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4xRg-0005UE-BC for guix-devel@gnu.org; Tue, 16 Jun 2015 16:26:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4xRd-000845-Ab for guix-devel@gnu.org; Tue, 16 Jun 2015 16:26:56 -0400 Received: from fencepost.gnu.org ([208.118.235.10]:56974) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4xRd-00083y-6W for guix-devel@gnu.org; Tue, 16 Jun 2015 16:26:53 -0400 Received: from reverse-83.fdn.fr ([80.67.176.83]:55050 helo=pluto) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1Z4xRc-0006EX-Ga for guix-devel@gnu.org; Tue, 16 Jun 2015 16:26:52 -0400 List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: guix-devel@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable While looking at another package manager for ideas to steal, I found this one to be a good candidate: guix edit gcc-4.8 will open $EDITOR (aka. =E2=80=9Cemacsclient=E2=80=9D) on the definition of= that package. This is pretty handy for developers (even when otherwise using Geiser, I think.) For =E2=80=9Cregular users,=E2=80=9D it=E2=80=99s less useful because most = of the time it will open an immutable file. However, I envision a --clone option that would create a file with a module declaration and a template like: (define my-gcc (package (inherit gcc) ;; Complete here... ) (This part is left as an exercise to the reader.) WDYT? If there are no objections, I=E2=80=99ll commit the attached version with appropriate documentation. Thanks, Ludo=E2=80=99. --=-=-= Content-Type: text/x-scheme; charset=utf-8 Content-Disposition: inline; filename=edit.scm Content-Transfer-Encoding: quoted-printable Content-Description: guix edit ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015 Ludovic Court=C3=A8s ;;; ;;; 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 . (define-module (guix scripts edit) #:use-module (guix ui) #:use-module (guix utils) #:use-module (guix packages) #:use-module (gnu packages) #:use-module (srfi srfi-1) #:use-module (srfi srfi-37) #:export (%editor guix-edit)) (define %options (list (option '(#\h "help") #f #f (lambda args (show-help) (exit 0))) (option '(#\V "version") #f #f (lambda args (show-version-and-exit "guix edit"))))) (define (show-help) (display (_ "Usage: guix edit PACKAGE... Start $EDITOR to edit the definitions of PACKAGE...\n")) (newline) (display (_ " -h, --help display this help and exit")) (display (_ " -V, --version display version information and exit")) (newline) (show-bug-report-information)) (define %editor (make-parameter (or (getenv "EDITOR") "emacsclient"))) (define (guix-edit . args) (with-error-handling (let* ((specs (parse-command-line args %options '(()) #:argument-handler cons)) (packages (map specification->package specs))) (for-each (lambda (package) (unless (package-location package) (leave (_ "source location of package '~a' is unknown~%= ") (package-full-name package)))) packages) (apply execlp (%editor) (%editor) (append-map (lambda (package) (let ((loc (package-location package))) (list (string-append "+" (number->string (location-line loc))) (location-file loc)))) packages))))) --=-=-=--