From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id IBoGOIQzW2WwMAEAauVa8A:P1 (envelope-from ) for ; Mon, 20 Nov 2023 11:23:01 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id IBoGOIQzW2WwMAEAauVa8A (envelope-from ) for ; Mon, 20 Nov 2023 11:23:00 +0100 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 5C407233B1 for ; Mon, 20 Nov 2023 11:23:00 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NXNBpJFt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1700475780; a=rsa-sha256; cv=none; b=pbImFXqF/B88dAHbsyj7VTASiijDayO6gLbilVZIR/tmdUFInTh9eLFI0b2wO7JGWGID23 3YO58PL8iPO2V3wI8us2aSEl2XU7WbNxUSL4Pv+e/SpMAIrx/uhTtWMsVor6Oai5g8HT+B P5YLkgdfJMYvPWQokNt62Mo6W2o7qjOauC90hi5yysogiOdWo+ggNS0iwc2i7d3lgoNWWC CKEE3DQU7IaZzANfKVmcR1DLRlrJogoqhB47vK2Hsmd+27ZMjqTLmhwUk7xxPD9igIWSdS EdrUZ06Jkol1rF4/AfPu3oY0wCArQ6FL/KkgCBPOYBmCq1LwAig8wJDG7YQKWg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=NXNBpJFt; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1700475780; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=USS7O8uJ+LmdOHmEmbrRy+uVvyQ0PmubRDQBvGFQsLw=; b=UUiAVSMEXnFbWbsl2jGiXujrBWdNiRPSY1WstBNAFqOaeduVB1DhnI8sjki67IYhJrMh1U 4A7Bxlme0cdPXXZ5O5NwuBe7IziZnHwpP02cIG5XYJCh3O6lumlWLqRLtPh62XhZvxXoCP jkBCFz67HRJeEW7XWp9FUzicxHqsmgYwbcivyHGX7HriQaGOitpTexSDO73+Kp2QgKRGOF QrBxkndLS+Vq0pPqlcIpvm4NJ+KjX7R9YnS6N3l+2nhL8rK/OjHC4lesgxm5srHTXp9PKa LB1fGBWMD+9nqQuZABTydeYNCgEA9F7uing0Kik3mz2YIIFjfFS1OyAUKoiJeQ== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r51Q7-0000TX-02; Mon, 20 Nov 2023 05:22:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r51Q4-0000T7-RE for guix-devel@gnu.org; Mon, 20 Nov 2023 05:22:20 -0500 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r51Q2-0007f9-RQ; Mon, 20 Nov 2023 05:22:20 -0500 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3316db2c5c0so619190f8f.1; Mon, 20 Nov 2023 02:22:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700475736; x=1701080536; darn=gnu.org; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=USS7O8uJ+LmdOHmEmbrRy+uVvyQ0PmubRDQBvGFQsLw=; b=NXNBpJFtZaZ5FGyhRWc5xjGYC1CNfyo9WhOuTuHALWw7FjYpL01Y/+neeWua4sQmrs Jm2/UHLVhVpKD+I3VhTbwAbfsGpdnx3ILnb7HqyIRjpXfmC/t6eCN/FBbkSTnVOu47hm wnFNEmYk5exVp6+Anuixc6Xsn05+AaqjrBgVwSjASzl7YsSmJ+fd1MxNGlQLaWX6ctdn P5pNm4yuQ0HtxGy2D+Dn/UMswKpp/KHlysx0NZGicwjMddudV94XFQU9hr86Cyo0BWbP YhgnC9jXEseCyecLsVRfdXUsF656qKCxNKiZWmLkGcDQmWJC3gyQdVhwk0lhGTMFATba qJrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700475736; x=1701080536; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=USS7O8uJ+LmdOHmEmbrRy+uVvyQ0PmubRDQBvGFQsLw=; b=pHNEvl05NIZmgFMgyWzQtRZMg1497JTLfs7Ywmlm2ypOxLH6hup+rVVuvSf9sJwIHX qL5y0JJIjMDZ0NjsyT8VigJGoMu12TxRuTGWoQqybrND47arn908JHUgpGmwAvOGP0/N DDcp1o2IVHqJuZEPieV06iBzpN4IQTulsj7dQkax9jhh8x6TH6t7i9gVTetZWSg0qUww 451lRd0FH9+Fv4//OlW3u2kvG5JTk3705OydNoJqbVIuUaz2eWD4nuvDcsuZGRptrGeJ oGG1swzpGIyDUemKawgEfk79jQ8XwmMVCBidc2sb6HnHyf4r/mCBkk17b6evPib1Ityc rG3A== X-Gm-Message-State: AOJu0YymVk/dlhHZx76Yq1e8HNU9G7FYJaIlvQrFQl2aBkMmIVZH0hoi ymg3lAG/uVXtgU7SBGDypTMpjTp42PQ= X-Google-Smtp-Source: AGHT+IGBTq5MQMYSa5Aufd0CEdMBjlDh/Mx5ecqEJS1QGN+7AgzWS8dk1dEC4wo3nRGoVlfwuuJj1g== X-Received: by 2002:adf:e242:0:b0:32f:8a45:93a7 with SMTP id bl2-20020adfe242000000b0032f8a4593a7mr5272977wrb.0.1700475735927; Mon, 20 Nov 2023 02:22:15 -0800 (PST) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id p2-20020a5d4582000000b003316d1a3b05sm9377521wrq.78.2023.11.20.02.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 02:22:15 -0800 (PST) From: Simon Tournier To: Liliana Marie Prikler , Ludovic =?utf-8?Q?C?= =?utf-8?Q?ourt=C3=A8s?= Cc: Guix Devel Subject: Re: $EDITOR and =?utf-8?B?4oCcZ3VpeCBlZGl04oCd?= In-Reply-To: <246521d6a06ee6954372278b8507c346fcc068cb.camel@gmail.com> References: <86wmv0o5gi.fsf@gmail.com> <416a6472edf6d2123c47ea5b555bedd005f6ac6f.camel@gmail.com> <87r0kpu3d9.fsf@gnu.org> <246521d6a06ee6954372278b8507c346fcc068cb.camel@gmail.com> Date: Mon, 20 Nov 2023 10:40:39 +0100 Message-ID: <86h6lg3gq0.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=zimon.toutoune@gmail.com; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list 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+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Queue-Id: 5C407233B1 X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -8.42 X-Spam-Score: -8.42 X-TUID: ZuRnIJZCAlC6 Hi, On Thu, 16 Nov 2023 at 17:04, Liliana Marie Prikler wrote: >> It=E2=80=99d be nice to support these as well.=C2=A0 However, how do we = know we=E2=80=99re >> dealing with kate or VSCode?=C2=A0 By checking the basename of $EDITOR? >> Kinda ugly and brittle, but probably better than nothing. > > Maybe we can check for a guix_editor shell function and invoke that > rather than EDITOR if defined? Yeah, from my point of view, the two alternatives [1] are: 1. do we tweak =E2=80=9Cguix edit=E2=80=9D for behaving differently depen= ding on $EDITOR? or 2. do we provide some wrappers for the issues that already popped up? Where #1 is what Ludo suggests and #2 is what Liliana suggests. :-) Well, see below the code [2] that we concretely need for VSCode. The question is: 1. Do we put this code in guix/scripts/edit.scm? And trigger on the basename of EDITOR? or 2. Do we put this code in some etc/vscode-wrapper that user can install? (or that we could automatically installl) Or maybe revamp it for calling this code via some shell function? WDYT? Cheers, simon --8<---------------cut here---------------start------------->8--- #!/usr/bin/env -S guix repl -q -- ;; -*- mode: scheme -*- !# ;;; Copyright =C2=A9 2023 Simon Tournier ;;; ;;; ;;; VSCode does not respect the convention: ;;; ;;; $EDITOR +line file ;;; ;;; and instead relies on: ;;; ;;; code --goto file:line ;;; ;;; ;;; This wrapper is a workaround. It is Scheme but it could be whatever el= se ;;; as Bash, Python, etc. It uses "guix repl" although no Guix library is ;;; required. Because we assume the invokation, ;;; ;;; EDITOR=3D./vscode-wrapper guix edit foo bar ;;; ;;; relying on "guix repl" allows to easily get Guile. ;;; (use-modules (ice-9 match) ((ice-9 string-fun) #:select (string-replace-substring)) ((ice-9 ftw) #:select (scandir)) ) (define %vscode--goto (let* ((vscode-server (string-append (getenv "HOME") "/.vscode-server")) (code (if (file-exists? vscode-server) ;; Maybe Remote-SSH (let* ((vscode-server/bin (string-append vscode-server "= /bin")) (hash ;Guess the correct identifier (car (scandir vscode-server/bin (lambda (file) (not (member file (list "." "..")))) (lambda (x y) (> (stat:mtime (lstat (string-append vscode-ser= ver/bin "/" x))) (stat:mtime (lstat (string-append vscode-ser= ver/bin "/" y)))))))) (vscode (string-append vscode-server/bin "/" hash "/bin/remote-= cli/code")) (run/user/uid (string-append "/run/user/" (number->string (get= uid)))) (socket ;Guess the correct socket, if requi= red (car (scandir run/user/uid (lambda (file) (string-prefix? "vscode-ipc" file)) (lambda (x y) (< (stat:mtime (lstat (string-append run/user/u= id "/" x))) (stat:mtime (lstat (string-append run/user/u= id "/" y))))))))) ;; XXXX: Check VSCode API for something more robust (if (getenv "VSCODE_IPC_HOOK_CLI") vscode (string-append "VSCODE_IPC_HOOK_CLI=3D" socket " " vscode))) ;; No Remote-SSH, try to find the local one in PATH (search-path (string-split (getenv "PATH") #\:) "code")))) ;(format #t "~a~%" code) (string-append code " --goto "))) (define +line-files (match (command-line) ((wrapper rest ...) (if (eqv? 0 (modulo (length rest) 2)) rest (begin (write "Error with 'guix edit'") (exit 1)))))) (define files (let loop ((files:lines '()) (lst +line-files)) (if (null? lst) (reverse files:lines) (match lst ((n file rest ...) (loop (cons (string-append file ":" (string-replace-substring n "+" "")) files:lines) rest)))))) (catch 'system-error (lambda () (for-each (lambda (file) (system (string-append %vscode--goto file))) files)) (lambda _ (write "failed to launch!"))) --8<---------------cut here---------------end--------------->8--- 1: $EDITOR and =E2=80=9Cguix edit=E2=80=9D Simon Tournier Thu, 02 Nov 2023 10:43:57 +0100 id:86wmv0o5gi.fsf@gmail.com https://lists.gnu.org/archive/html/guix-devel/2023-11 https://yhetil.org/guix/86wmv0o5gi.fsf@gmail.com 2: https://gitlab.com/zimoun/advanced-packages-2023/-/blob/670b81e9321ee4af= 2407babd985222cc37f33e31/vscode-wrapper