From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Lirzin Subject: [PATCHES] Fix some =?utf-8?B?4oCYZ3VpeCBlZGl04oCZ?= bad assumptions. Date: Sat, 21 Nov 2015 16:31:19 +0100 Message-ID: <87egfj5pyw.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:59872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0A8N-0004S4-RV for guix-devel@gnu.org; Sat, 21 Nov 2015 10:31:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a0A8I-0005Id-RR for guix-devel@gnu.org; Sat, 21 Nov 2015 10:31:27 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:57252) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a0A8I-0005IZ-N2 for guix-devel@gnu.org; Sat, 21 Nov 2015 10:31:22 -0500 Received: from mek33-4-82-236-46-88.fbx.proxad.net ([82.236.46.88]:37270 helo=godel) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1a0A8I-0002vo-5t for guix-devel@gnu.org; Sat, 21 Nov 2015 10:31:22 -0500 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 Hi, As every sane person I use Emacs for my editing. In order to have the features of =E2=80=98emacsclient=E2=80=99 (fast startup + buffer sharing) a= nd the simplicity of =E2=80=98emacs=E2=80=99 (no daemon management), I have in my = environment: export VISUAL=3D"emacsclient --alternate-editor=3D''" this automatically starts the daemon if it is not already running and then launches =E2=80=98emacsclient=E2=80=99. However, this does not work w= ith =E2=80=98guix edit=E2=80=99 because a single word command is assumed for $VISUAL and $EDI= TOR. so here is a fix: --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-edit-Allow-command-line-arguments-in-VISUAL-and-EDIT.patch Content-Transfer-Encoding: quoted-printable >From 9252f698348db42431264441a5e97fd5a414c001 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 21 Nov 2015 14:37:54 +0100 Subject: [PATCH 1/2] edit: Allow command line arguments in $VISUAL and $EDITOR. * guix/scripts/edit.scm (guix-edit): Fix the assumption that %editor is a one word command. --- guix/scripts/edit.scm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm index 73a5bb7..f894953 100644 --- a/guix/scripts/edit.scm +++ b/guix/scripts/edit.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2015 Ludovic Court=C3=A8s +;;; Copyright =C2=A9 2015 Mathieu Lirzin ;;; ;;; This file is part of GNU Guix. ;;; @@ -22,6 +23,7 @@ #:use-module (guix utils) #:use-module (guix packages) #:use-module (gnu packages) + #:use-module (ice-9 match) #:use-module (srfi srfi-1) #:use-module (srfi srfi-37) #:export (%editor @@ -83,8 +85,13 @@ line." =20 (catch 'system-error (lambda () - (apply execlp (%editor) (%editor) - (append-map package->location-specification packages))) + (let ((editor-args (string-split (%editor) #\space)) + (file-names (append-map package->location-specification + packages))) + (match editor-args + ((editor . args) + (apply execlp editor (append editor-args file-names))) + (_ #f)))) (lambda args (let ((errno (system-error-errno args))) (leave (_ "failed to launch '~a': ~a~%") --=20 2.6.2 --=-=-= Content-Type: text/plain Moreover I think that assuming a running emacs daemon by default if $VISUAL and $EDITOR are not set is not an obvious decision. My first intuition would be to use GNU Nano which is often installed on GNU systems. But after trying to edit a package with it... I have come to the conclusion that it was more reasonable to use 'emacs' instead. I have no strong opinion on this (other than being against defaulting to VI of course). ;) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-edit-Don-t-assume-that-an-emacs-daemon-is-running.patch >From 7988fd52a23811720c82f20b5b65eb527564a7f6 Mon Sep 17 00:00:00 2001 From: Mathieu Lirzin Date: Sat, 21 Nov 2015 15:05:07 +0100 Subject: [PATCH 2/2] edit: Don't assume that an emacs daemon is running. * guix/scripts/edit.scm (%editor): Use Emacs as a default value. --- guix/scripts/edit.scm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm index f894953..5dbb58d 100644 --- a/guix/scripts/edit.scm +++ b/guix/scripts/edit.scm @@ -50,8 +50,10 @@ Start $VISUAL or $EDITOR to edit the definitions of PACKAGE...\n")) (show-bug-report-information)) (define %editor - (make-parameter (or (getenv "VISUAL") (getenv "EDITOR") - "emacsclient"))) + ;; XXX: It would be better to default to something more likely to be + ;; pre-installed on an average GNU system. Since Nano is not suited for + ;; editing Scheme, Emacs is used instead. + (make-parameter (or (getenv "VISUAL") (getenv "EDITOR") "emacs"))) (define (search-path* path file) "Like 'search-path' but exit if FILE is not found." -- 2.6.2 --=-=-= Content-Type: text/plain TIA, -- Mathieu Lirzin --=-=-=--