From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.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 sJuWO2dntWV/YgEA62LTzQ:P1 (envelope-from ) for ; Sat, 27 Jan 2024 21:28:24 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id sJuWO2dntWV/YgEA62LTzQ (envelope-from ) for ; Sat, 27 Jan 2024 21:28:24 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="U/z0xl6D"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1706387303; 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=EGaMVwb1gwOvWEf42/JMqeLDVmey4lHs9+h8XkxFy1k=; b=rQPwzMsjhvJMsEveqxkAkVydpP0kEGJA88YaJazrKM0rE8pO5ry1Qd5iifA7bLPwfg1vhR fgiZMwU+tuTRfdnUWZVVnY3b7BVAd7aIOKKepajC4x1HTesS/WjcCvSj6wSM+6VPjrqG/3 6Y0dU8chrbrZycnJ77SrKeXPOlOYCh6l5ZPhOo0gDcce3o0B4aoD+CB8gqzocOMqoiaxrV TMNPQ/Iw9k7xiWrwLlU8b4Z6hLbboMCkmf6oxU6JNUo4MicUbORsk0YrWuKpJ/oWDT5UVn Q//w+kL0JWcEFhBv3mW9wXJX2ob7g77fVNCXoPNjmDSqo4xlzFeNOtQb3nw7xA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="U/z0xl6D"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1706387303; a=rsa-sha256; cv=none; b=flGGpnE7AkKFpWAnsrNdFoDS2W5TyJTnV+Ua8lb1g5xpBADhZXqbKuHnbDcFROrqZp9wk4 A0zSpOWzd/XO1kEtBvAVhQivNG5AqV3vJr797fgfJHgTR1BcfnKshMj9bVJUnImEVxQdli 5B1cOPbg3sdySNzZxsGOEjinNb1xqCW8Y1YsnmRJwZOWiIKOY5ykZQm9CCI4lxJTukEL0Z 8eeOfSzQOTaDMexWyV19KPfvCLL32u2nismYh8zOajkJRfGncrSGMQcvsODrQg3RQtJjWY RBjVVn7owMM5QjxQ+11ycbpZF8tS7j21ke1vvAae3qfyJt1LKbJWJiJmcDis5w== 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 BE8ED16492 for ; Sat, 27 Jan 2024 21:28:23 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTpHT-0006Og-QP; Sat, 27 Jan 2024 15:28:00 -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 1rTpHQ-0006O8-AL for guix-patches@gnu.org; Sat, 27 Jan 2024 15:27:56 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTpHQ-0000yb-2l for guix-patches@gnu.org; Sat, 27 Jan 2024 15:27:56 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rTpHX-0004FX-9o for guix-patches@gnu.org; Sat, 27 Jan 2024 15:28:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68412] [PATCH v2] scripts: edit: Accept generic formatting parameter. References: <9a666abbf1cb4b7548c1a117eaa04b0de02145ae.1705103171.git.liliana.prikler@gmail.com> In-Reply-To: <9a666abbf1cb4b7548c1a117eaa04b0de02145ae.1705103171.git.liliana.prikler@gmail.com> Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 27 Jan 2024 20:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68412 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68412@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Simon Tournier Received: via spool by 68412-submit@debbugs.gnu.org id=B68412.170638724216262 (code B ref 68412); Sat, 27 Jan 2024 20:28:03 +0000 Received: (at 68412) by debbugs.gnu.org; 27 Jan 2024 20:27:22 +0000 Received: from localhost ([127.0.0.1]:56002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTpGr-0004EC-U3 for submit@debbugs.gnu.org; Sat, 27 Jan 2024 15:27:22 -0500 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]:49166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rTpGo-0004Dk-Gs for 68412@debbugs.gnu.org; Sat, 27 Jan 2024 15:27:19 -0500 Received: by mail-ej1-x644.google.com with SMTP id a640c23a62f3a-a357cba4a32so7106666b.2 for <68412@debbugs.gnu.org>; Sat, 27 Jan 2024 12:27:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706387225; x=1706992025; darn=debbugs.gnu.org; h=cc:to:content-transfer-encoding:mime-version:subject:date:from :message-id:from:to:cc:subject:date:message-id:reply-to; bh=EGaMVwb1gwOvWEf42/JMqeLDVmey4lHs9+h8XkxFy1k=; b=U/z0xl6DNTRHT/eoylA/IGPMJtb4nMjFchGUbPnLkUwLlyNP+mXLO+2foh1jLjJyMY ZLWW/0s6nsX/GB6HlSYR+FNjhdf8+uM7y2C3PKoKpgJBbEGAFbG65fCpU9HuaWKxQIYm TRop1Jix8DqAOrMKwRDjGDutf6sgNkWq3g6xkzEMJthvR/FWcGCnHyotKKWz1mkHUYB2 mXMpmxpL76ecYBt+p4mjxRiCY9ZnhUDDDZYx9Yck34SG83WekpzbejfMXg25vWevnF61 cTjMpKQzOHA0gRApm6/304/TCm1MW7gyYMrqRlw8IxbE6ku+KncSjaaustfWQfGof40f GMcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706387225; x=1706992025; h=cc:to:content-transfer-encoding:mime-version:subject:date:from :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EGaMVwb1gwOvWEf42/JMqeLDVmey4lHs9+h8XkxFy1k=; b=bdP+c46+G+1m5OnU47BLjV+kpy7FEBXGjR+lf2J9ggqEJQ3pwtJf/odSzRD9rS//tL kMs3/dtT5AwalhUCAtR0XwU+TXffMIYb6rg5+LjJuexcWv/3omdYlt857JaYiQB61bzJ rIVs+PzKuCgJoWr/4Q6OF8pVXkPAztuwl7Dx18EfN9lRgkozGGFy44tDyRqZ3kOc0n4Z nveojUu6JWreF7ke9/Qu2sPtpLe5zHja4OROVUlPm6bGk0o80eWqe8XEOkxXgCQ9iolD jHW2rK/e+EpRxPzhXb5fASNB8uXRMWK8BsQ0vkcZW4UTkLk2Pn1YC0QPzG+H/vyaDLlA VsXA== X-Gm-Message-State: AOJu0YyNSeaS/BtnMzjMuChvtI3yQcbPQVlYucnh1O0e6l66ThMcmEx2 O8mMAwaQAqDULsw1AfpTcJ8zQ/KoJ9r6i0PAYO7ZTfG7BccKVkGydnwcrFn9PQE= X-Google-Smtp-Source: AGHT+IEAHLQwq9G/r7jfp0r2u5olLVqr0gADjiOwuuQ8UoSWaurgBfVcbfrKcjd1jozn7nzcHeSvFQ== X-Received: by 2002:a17:906:6953:b0:a34:af8a:ee3d with SMTP id c19-20020a170906695300b00a34af8aee3dmr1466685ejs.16.1706387225197; Sat, 27 Jan 2024 12:27:05 -0800 (PST) Received: from lumine.fritz.box (85-127-52-93.dsl.dynamic.surfer.at. [85.127.52.93]) by smtp.gmail.com with ESMTPSA id rs10-20020a170907036a00b00a316a652c6csm2069718ejb.70.2024.01.27.12.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 12:27:04 -0800 (PST) Message-ID: <86b13fd4916ffecb1947d0879805a6d0c32542bf.1706386650.git.liliana.prikler@gmail.com> From: Liliana Marie Prikler Date: Sat, 13 Jan 2024 00:35:29 +0100 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-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: 3.34 X-Spam-Score: 3.34 X-Migadu-Queue-Id: BE8ED16492 X-Migadu-Scanner: mx12.migadu.com X-TUID: sv3C8C+ylVAf This will hopefully end the opening of unwanted files. * guix/scripts/edit.scm (%location-format): New parameter. (location->location-specification): Use %location-format. (spawn-editor): Adjust accordingly. Fixes: Pass special flags to ‘kate’ --- Am Samstag, dem 27.01.2024 um 15:07 +0100 schrieb Ludovic Courtès: > Hi Liliana, > > Liliana Marie Prikler skribis: > > > This will hopefully end the opening of unwanted files. > > > > * guix/scripts/edit.scm (%location-format): New parameter. > > (location->location-specification): Use %location-format. > > (spawn-editor): Adjust accordingly. > > > > Fixes: Pass special flags to ‘kate’ > > Rather: “Fixes .” I'm using a convention that I've proposed earlier in [1]. Since we're currently adding ChangeIds without any of the supported infra (AFAIK), I think following my own proposal here is fair game. As for why I took the message instead of the bug itself, the bug was marked as done without resolving it, so I think linking to the message is more correct. > [...] > I’d word it slightly differently, like: > [...] I changed the wording. Let me know WDYT. > Leftover debugging statement? Yup. > I’m still wondering about the relative merits of this approach vs. > the less generic but ready-to-use special-casing of Kate and VSCode > [...] With every decade bringing a new hot editor, we'd be special-casing a lot. Cheers [1] https://lists.gnu.org/archive/html/guix-devel/2023-09/msg00225.html doc/guix.texi | 29 +++++++++++++++++++++++++++++ guix/scripts/edit.scm | 20 ++++++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index c458befb76..2ae3871464 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13989,6 +13989,35 @@ Invoking guix edit @var{directory}}) allows you to add @var{directory} to the front of the package module search path and so make your own packages visible. +@vindex GUIX_EDITOR_LOCATION_FORMAT +The default convention used by @code{guix edit} when invoking +@code{$EDITOR} is to pass it @code{+@var{line} @var{file}} to open +@var{file} at the given @var{line}. +You can change this convention for editors that do not support it +by setting @env{GUIX_EDITOR_LOCATION_FORMAT}. +For instance, to set things up with kate, use: + +@example +export VISUAL=kate +export GUIX_EDITOR_LOCATION_FORMAT='--line=$@{LINE@} $@{FILE@}' +# Assume you want to hack on kate +guix edit kate +@end example + +Alternatively, for gnome-text-editor, which has no such flag, simply +skip it: + +@example +export VISUAL=gnome-text-editor +export GUIX_EDITOR_LOCATION_FORMAT='$@{FILE@}' +# Assume you want to hack on gnome +guix edit gnome +@end example + +Note, that Guix only matches the literal strings @code{$@{LINE@}} and +@code{$@{FILE@}} here. These may look like shell parameters, but their +short form is currently not supported. + @node Invoking guix download @section Invoking @command{guix download} diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm index b7b4cd2514..130470dbc1 100644 --- a/guix/scripts/edit.scm +++ b/guix/scripts/edit.scm @@ -25,6 +25,7 @@ (define-module (guix scripts edit) #:use-module ((guix diagnostics) #:select (location-file location-line)) #:use-module (gnu packages) + #:use-module (ice-9 string-fun) #:use-module (srfi srfi-1) #:use-module (srfi srfi-37) #:export (%editor @@ -62,6 +63,10 @@ (define %editor ;; For development, user can set custom value for $EDITOR. (make-parameter (or (getenv "VISUAL") (getenv "EDITOR") "nano"))) +(define %location-format + (make-parameter (or (getenv "GUIX_EDITOR_LOCATION_FORMAT") + "+${LINE} ${FILE}"))) + (define (search-path* path file) "Like 'search-path' but exit if FILE is not found." (let ((absolute-file-name (or (search-path path file) @@ -78,18 +83,21 @@ (define (search-path* path file) (define (location->location-specification location) "Return the location specification for LOCATION for a typical editor command line." - (list (string-append "+" - (number->string - (location-line location))) - (search-path* %load-path (location-file location)))) + (let* ((spec (%location-format)) + (spec (string-replace-substring + spec "${LINE}" + (number->string (location-line location)))) + (spec (string-replace-substring + spec "${FILE}" + (search-path* %load-path (location-file location))))) + spec)) (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))) + (let ((file-names (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)))))) base-commit: dc8aa525174d25331d74576faf0643e45bc152c4 -- 2.41.0