GNU bug report logs - #68412
[PATCH] scripts: edit: Accept generic formatting parameter.

Previous Next

Package: guix-patches;

Reported by: Liliana Marie Prikler <liliana.prikler <at> gmail.com>

Date: Fri, 12 Jan 2024 23:47:01 UTC

Severity: normal

Tags: patch

Full log


View this message in rfc822 format

From: Ludovic Courtès <ludo <at> gnu.org>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Cc: 68412 <at> debbugs.gnu.org, Simon Tournier <zimon.toutoune <at> gmail.com>
Subject: [bug#68412] [PATCH] scripts: edit: Accept generic formatting parameter.
Date: Sat, 27 Jan 2024 15:07:38 +0100
Hi Liliana,

Liliana Marie Prikler <liliana.prikler <at> gmail.com> 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’ <https://bugs.gnu.org/44272#14>

Rather: “Fixes <https://issues.guix.gnu.org/44272>.”

> +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.

I’d word it slightly differently, like:

  @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 example, when using Kate, you
  should set:

  @example
  # Convention for ‘kate’.
  export GUIX_EDITOR_LOCATION_FORMAT='--whatever ${FILE}'
  @end example

  Likewise, for @command{guix edit} to invoke VSCode, you must specify
  this setting:

  @example
  # Settings for VSCode.
  export GUIX_EDITOR_LOCATION_FORMAT='--whatever ${FILE}'
  @end example
  
> +  (let* ((spec (peek (%location-format)))

Leftover debugging statement?

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 based on
the basename of $EDITOR, but I don’t have a strong opinion.

Otherwise LGTM, thanks!

Ludo’.




This bug report was last modified 1 year and 120 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.