From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:700:3204::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id aJmtAIfPoWVncgEAkFu2QA (envelope-from ) for ; Sat, 13 Jan 2024 00:47:19 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id cLdINYbPoWW9JQEAe85BDQ (envelope-from ) for ; Sat, 13 Jan 2024 00:47:18 +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=aDFmkLoG; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1705103238; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=aQFypJtNcnrX8ub64gTq4EpPyf/AL36gfT1suiTftk8=; b=Rih410fuIMtoTsTiAtvBCcNArlQnnfno724zsqEow05AVbWY9GGato52n2AY05tl86LCGY 1r9H/YSVvieZcnrDbMKuqFSEDEd59n6Q4Duvap868nZI/4hwvW4co11tAEFzYCheQybF/v ubGaHUcVf4Jubl9WpfvpvwSR0BGb7qMD+zjlJBCz0jtUImKfTd1m+xpiHkaHcvFbwT8Sr7 YLn7PFVRD0hmJHQGVH4NE/Bh1u53ZrJbWAyMIbZhK6HupnpmkELdMMj9017cy1koaSiSEy syLCXwMbHKQMHDaTiZPzwqp+PcTjFu0Qu2Ypx60DQq3KVkiDgV3y/LGoAmBKjg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=aDFmkLoG; 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"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1705103238; a=rsa-sha256; cv=none; b=GR58Yo6iMqbJG3WKDBEW889yRqDpieKMg0LHBqG8jUasBdWIjwiBsvd507JIh4+AGh4LjY xdAUZYx7Z1mnBMJ5eRdWJfBlgAQ889wISyd/YXnOCHW/zJAZwKXyEwiu3oJVqnRluqzfjF d18yDMQHG4NblZTSX6hBuXBfN30bldSq2f0Jn13bmP+podifji0OBjjP3wJCv9v+rPiqxo cY8udFcSzMVCiOKZRR76eN0t95FBImQVsA+7CVzrC/OmeLXzBP47hgn/V3Fhn6YLM7LnIM jx791gWCgwdI23pEhOX/DKa0bbbeTB3hZPCKGTfK+qPbqLZCABRwa1meFnLU6g== 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 881B0507E6 for ; Sat, 13 Jan 2024 00:47:18 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rOREz-0007t3-3A; Fri, 12 Jan 2024 18:47:09 -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 1rOREv-0007sb-TC for guix-patches@gnu.org; Fri, 12 Jan 2024 18:47:05 -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 1rOREv-0002fb-Km for guix-patches@gnu.org; Fri, 12 Jan 2024 18:47:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rOREr-0006Xy-WC for guix-patches@gnu.org; Fri, 12 Jan 2024 18:47:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68412] [PATCH] scripts: edit: Accept generic formatting parameter. Resent-From: Liliana Marie Prikler Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 12 Jan 2024 23:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 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 X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170510320624807 (code B ref -1); Fri, 12 Jan 2024 23:47:01 +0000 Received: (at submit) by debbugs.gnu.org; 12 Jan 2024 23:46:46 +0000 Received: from localhost ([127.0.0.1]:37969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rOREb-0006Rt-4K for submit@debbugs.gnu.org; Fri, 12 Jan 2024 18:46:45 -0500 Received: from lists.gnu.org ([2001:470:142::17]:39148) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rOREX-0006KZ-Io for submit@debbugs.gnu.org; Fri, 12 Jan 2024 18:46:43 -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 1rORET-0007rq-3W for guix-patches@gnu.org; Fri, 12 Jan 2024 18:46:37 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rOREQ-0002Mt-7T; Fri, 12 Jan 2024 18:46:36 -0500 Received: by mail-wm1-x343.google.com with SMTP id 5b1f17b1804b1-40e68d836bcso7074315e9.2; Fri, 12 Jan 2024 15:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705103188; x=1705707988; darn=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=aQFypJtNcnrX8ub64gTq4EpPyf/AL36gfT1suiTftk8=; b=aDFmkLoGgj9ZPh/DkXhOBxFTUqY4P31gERT23BKbDgmcvfqlGtbrL3czLB49dS6FMR 3tr8BXn9TPdVyqlHL3J6zo03ptbLQ9vbyyOuXCI3/i3QkcdsWoUDJ6uRVBbDfs1ByXft DBMgyD/GwGTHiIFoCk2HGlzgL2KnSVVt5Yz8wErwMa2/vv1Xti9a7819kas7qZ9iQG8C VdPtC0LfGCaHo+6OyzhHun+MhwcOXB9G4UL3+MXW14CeNHA/G513ERcbDb0KSK4ANRCb VOlh/0aIFvcOPP+S6HtjdfbXlhFZkuSKaKxNCuoI5XDp1Q/ux0bDM7ZGHseLUjPv4SJH lJCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705103188; x=1705707988; 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=aQFypJtNcnrX8ub64gTq4EpPyf/AL36gfT1suiTftk8=; b=sKW09BeBlO79jhubv4Bp8zR5+3ss7dycw8g621EOFC9YD1fL6UJxWM3fkNOyVFrrhW /SSZGpvbdG6ROCMDXq2ZtCYiKXprF+pUu1FE/0Z3bHegoQdY6Psx4+K2eogVka61yQUi cN9mCZb0oVpaPC0s9tl02m/G+KnGc2zog4M1O2lREtMm04fK16KJCgH0D0+g6bVxQ3pB p2C7qLRvpnIuoamxRGTVXR9SaemUidn5Cjjz0f6u5vJ+HnlA6nBKcth1KH4cDFpPWvlP VakO8eGpFlF1gM+sZMO9jwAddjh5c+U6wYiCBHvENCBwxEjPgmeiI6xeaZCQSVrorrEf Sq7A== X-Gm-Message-State: AOJu0Yymk4+Klf1B7RbivzjF+8S1+o8PUWrylXBeiugHIjKYrsOT10bl sAYTDKK65Nm1Kmb46eAtUe3U7ucopzOffw== X-Google-Smtp-Source: AGHT+IHl3Ue5/hGkaP/brGiARSRz0irj35y8U8aSXM3KXw57vYE83OIpFb8+QQGIK+5K30fqgRynwA== X-Received: by 2002:a05:600c:474a:b0:40e:4afa:d398 with SMTP id w10-20020a05600c474a00b0040e4afad398mr1115600wmo.14.1705103188066; Fri, 12 Jan 2024 15:46:28 -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 r16-20020a056000015000b003376af392e5sm5056942wrx.38.2024.01.12.15.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 15:46:27 -0800 (PST) Message-ID: <9a666abbf1cb4b7548c1a117eaa04b0de02145ae.1705103171.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 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=liliana.prikler@gmail.com; helo=mail-wm1-x343.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: 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-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Queue-Id: 881B0507E6 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 4.19 X-Spam-Score: 4.19 X-TUID: CeewpN5TkBRL 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’ --- doc/guix.texi | 18 ++++++++++++++++++ guix/scripts/edit.scm | 20 ++++++++++++++------ 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 811edd0bf7..8dca1272a2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13987,6 +13987,24 @@ 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. +By default, Guix assumes that @env{EDITOR} uses the +``+@var{LINE} @var{FILE}'' convention to scroll to a particular line +within a file. However, not all editors use this convention. +For instance, @command{kate} instead wants you to use @code{--line}. +Some minimal editors may not even have an option to pass the line. +In both cases, an additional file named ``+@var{LINE}'' would be +opened instead. To prevent this from happening, you can customize +@env{GUIX_EDITOR_LOCATION_FORMAT}, using the literal strings +`${FILE}' to denote @var{FILE} and `${LINE}' to denote @var{LINE} +respectively. +For instance: + +@example +GUIX_EDITOR_LOCATION_FORMAT='${FILE}' guix edit gnome +# will open @var{directory}/gnu/packages/gnome.scm, but not scroll to +# the definition of gnome +@end example + @node Invoking guix download @section Invoking @command{guix download} diff --git a/guix/scripts/edit.scm b/guix/scripts/edit.scm index b7b4cd2514..13b8a4559c 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 (peek (%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: 3619dd7d059d1141acf39872f57e55b458dc8257 -- 2.41.0