GNU bug report logs - #44272
guix edit doesn't work when $EDITOR is set to "kate"

Previous Next

Package: guix;

Reported by: Nathan Dehnel <ncdehnel <at> gmail.com>

Date: Wed, 28 Oct 2020 06:14:01 UTC

Severity: normal

Done: zimoun <zimon.toutoune <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 44272 in the body.
You can then email your comments to 44272 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#44272; Package guix. (Wed, 28 Oct 2020 06:14:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nathan Dehnel <ncdehnel <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Wed, 28 Oct 2020 06:14:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nathan Dehnel <ncdehnel <at> gmail.com>
To: Tobias Geerinckx-Rice via Bug reports for GNU Guix <bug-guix <at> gnu.org>
Subject: guix edit doesn't work when $EDITOR is set to "kate"
Date: Wed, 28 Oct 2020 01:13:22 -0500
[Message part 1 (text/plain, inline)]
kate opens an empty file.
[Message part 2 (text/html, inline)]

Information forwarded to bug-guix <at> gnu.org:
bug#44272; Package guix. (Wed, 28 Oct 2020 13:06:02 GMT) Full text and rfc822 format available.

Message #8 received at 44272 <at> debbugs.gnu.org (full text, mbox):

From: Leo Prikler <leo.prikler <at> student.tugraz.at>
To: ncdehnel <at> gmail.com
Cc: 44272 <at> debbugs.gnu.org
Subject: bug#44272: guix edit doesn't work when $EDITOR is set to "kate"
Date: Wed, 28 Oct 2020 14:05:27 +0100
Easy solution, set $EDITOR to "gedit" ;)

The reason why kate "doesn't work" when opening files as specified by
`guix edit`, is that kate apparently can't handle the "$EDITOR +$N
$FILE" syntax, where $N is the number of lines to skip.  It instead
opens two files, one of which will likely always be empty.  This should
probably be reported as bug to kate unless that works upstream and
somehow guix messes up this feature.





Information forwarded to bug-guix <at> gnu.org:
bug#44272; Package guix. (Wed, 28 Oct 2020 14:53:01 GMT) Full text and rfc822 format available.

Message #11 received at 44272 <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>, ncdehnel <at> gmail.com
Cc: 44272 <at> debbugs.gnu.org
Subject: Re: bug#44272: guix edit doesn't work when $EDITOR is set to "kate"
Date: Wed, 28 Oct 2020 15:52:18 +0100
Dear Nathan,

> Easy solution, set $EDITOR to "gedit" ;)

Or Emacs. ;-)


> The reason why kate "doesn't work" when opening files as specified by
> `guix edit`, is that kate apparently can't handle the "$EDITOR +$N
> $FILE" syntax, where $N is the number of lines to skip.  It instead
> opens two files, one of which will likely always be empty.  This should
> probably be reported as bug to kate unless that works upstream and
> somehow guix messes up this feature.

Instead ’kate’ use ’--line/-l’ and not ’+N’.  You could wrap, something
along these lines:

--8<---------------cut here---------------start------------->8---
#!/bin/sh

kate -l $(echo "$*" | tr "+" " ")
--8<---------------cut here---------------end--------------->8---

then:

  export EDITOR=/path/to/kate-wrapper.sh
  guix edit emacs

works (with ’/path/to/kate-wrapper.sh’ executable).  Well, the wrapper
could be better, obviously. :-)

As Leo said, it does not seem a bug on the Guix side.  Well, what could
be done on the Guix side?  What do you suggest?


All the best,
simon




Information forwarded to bug-guix <at> gnu.org:
bug#44272; Package guix. (Wed, 28 Oct 2020 22:29:01 GMT) Full text and rfc822 format available.

Message #14 received at 44272 <at> debbugs.gnu.org (full text, mbox):

From: Nathan Dehnel <ncdehnel <at> gmail.com>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 44272 <at> debbugs.gnu.org
Subject: Re: bug#44272: guix edit doesn't work when $EDITOR is set to "kate"
Date: Wed, 28 Oct 2020 17:28:38 -0500
[Message part 1 (text/plain, inline)]
>As Leo said, it does not seem a bug on the Guix side.  Well, what could
be done on the Guix side?  What do you suggest?

Well, guix could pass different flags if EDITOR is set to "kate". Somehow I
doubt kate would change their command line flags just because an extremely
obscure distro-specific tool treats it the same as other text editors.

But, whatever. The wrapper works well enough. Thanks.

On Wed, Oct 28, 2020 at 9:52 AM zimoun <zimon.toutoune <at> gmail.com> wrote:

> Dear Nathan,
>
> > Easy solution, set $EDITOR to "gedit" ;)
>
> Or Emacs. ;-)
>
>
> > The reason why kate "doesn't work" when opening files as specified by
> > `guix edit`, is that kate apparently can't handle the "$EDITOR +$N
> > $FILE" syntax, where $N is the number of lines to skip.  It instead
> > opens two files, one of which will likely always be empty.  This should
> > probably be reported as bug to kate unless that works upstream and
> > somehow guix messes up this feature.
>
> Instead ’kate’ use ’--line/-l’ and not ’+N’.  You could wrap, something
> along these lines:
>
> --8<---------------cut here---------------start------------->8---
> #!/bin/sh
>
> kate -l $(echo "$*" | tr "+" " ")
> --8<---------------cut here---------------end--------------->8---
>
> then:
>
>   export EDITOR=/path/to/kate-wrapper.sh
>   guix edit emacs
>
> works (with ’/path/to/kate-wrapper.sh’ executable).  Well, the wrapper
> could be better, obviously. :-)
>
> As Leo said, it does not seem a bug on the Guix side.  Well, what could
> be done on the Guix side?  What do you suggest?
>
>
> All the best,
> simon
>
[Message part 2 (text/html, inline)]

Reply sent to zimoun <zimon.toutoune <at> gmail.com>:
You have taken responsibility. (Wed, 28 Oct 2020 22:56:01 GMT) Full text and rfc822 format available.

Notification sent to Nathan Dehnel <ncdehnel <at> gmail.com>:
bug acknowledged by developer. (Wed, 28 Oct 2020 22:56:01 GMT) Full text and rfc822 format available.

Message #19 received at 44272-done <at> debbugs.gnu.org (full text, mbox):

From: zimoun <zimon.toutoune <at> gmail.com>
To: Nathan Dehnel <ncdehnel <at> gmail.com>
Cc: Leo Prikler <leo.prikler <at> student.tugraz.at>, 44272-done <at> debbugs.gnu.org
Subject: Re: bug#44272: guix edit doesn't work when $EDITOR is set to "kate"
Date: Wed, 28 Oct 2020 23:55:31 +0100
Dear,

On Wed, 28 Oct 2020 at 17:28, Nathan Dehnel <ncdehnel <at> gmail.com> wrote:
>>As Leo said, it does not seem a bug on the Guix side.  Well, what could
>> be done on the Guix side?  What do you suggest?

> Well, guix could pass different flags if EDITOR is set to "kate". Somehow I
> doubt kate would change their command line flags just because an extremely
> obscure distro-specific tool treats it the same as other text editors.

« Special cases aren't special enough to break the rules. »
Especially when all the other text editors use the same convention.

Well, thank you for the report.  If many “kate” users request, then
maybe « Although practicality beats purity. »

– from The Zen of Python, by Tim Peters – :-)

> But, whatever. The wrapper works well enough. Thanks.

So closing!

Thanks,
simon




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 26 Nov 2020 12:24:06 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Simon Tournier <zimon.toutoune <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 02 Nov 2023 09:24:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-guix <at> gnu.org:
bug#44272; Package guix. (Thu, 02 Nov 2023 09:34:02 GMT) Full text and rfc822 format available.

Message #26 received at 44272 <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>
Cc: ncdehnel <at> gmail.com, 44272 <at> debbugs.gnu.org
Subject: Re: bug#44272: guix edit doesn't work when $EDITOR is set to VSCode
Date: Thu, 02 Nov 2023 10:32:27 +0100
Hi,

PS: I write it here for later discovery.  The bug remains closed. :-)  I
will open another thread for discussing it.

On Wed, 28 Oct 2020 at 15:52, zimoun <zimon.toutoune <at> gmail.com> wrote:

> Instead ’kate’ use ’--line/-l’ and not ’+N’.  You could wrap, something
> along these lines:
>
> #!/bin/sh
>
> kate -l $(echo "$*" | tr "+" " ")
>
> then:
>
>   export EDITOR=/path/to/kate-wrapper.sh
>   guix edit emacs

VSCode does not respect the usual convention, too!  For instance,

    $ code +9 path/to/file

open files named “+9” and “path/to/file”.  Instead, VSCode expects:

    $ code --goto path/to/file:9

Therefore, it makes annoying to use VSCode with “guix edit”.  Here a
tiny wrapper to still be able to compose the both.  Well,

    $ EDITOR=vscode-wrapper guix edit hello

opens at the correct location.

Cheers,
simon

--8<---------------cut here---------------start------------->8---
#!/usr/bin/env -S guix repl -q --
;; -*- mode: scheme -*-
!#
;;; Copyright © 2023 Simon Tournier <zimon.toutoune <at> gmail.com>

;;;
;;; 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 else
;;; as Bash, Python, etc.  It uses "guix repl" although no Guix library is
;;; required.  Because we assume the invokation,
;;;
;;;     EDITOR=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)))

(define %vscode--goto "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---




Information forwarded to bug-guix <at> gnu.org:
bug#44272; Package guix. (Mon, 06 Nov 2023 17:43:02 GMT) Full text and rfc822 format available.

Message #29 received at 44272 <at> debbugs.gnu.org (full text, mbox):

From: Simon Tournier <zimon.toutoune <at> gmail.com>
To: Leo Prikler <leo.prikler <at> student.tugraz.at>
Cc: ncdehnel <at> gmail.com, 44272 <at> debbugs.gnu.org
Subject: Re: bug#44272: guix edit doesn't work when $EDITOR is set to VSCode
Date: Mon, 06 Nov 2023 18:41:20 +0100
Hi,

On Thu, 02 Nov 2023 at 10:32, Simon Tournier <zimon.toutoune <at> gmail.com> wrote:

> (define %vscode--goto "code --goto ")

In case, here an improvement when using Remote-SSH.

--8<---------------cut here---------------start------------->8---
(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-server/bin "/" x)))
                                          (stat:mtime
                                           (lstat (string-append vscode-server/bin "/" y))))))))
                          (vscode (string-append
                                   vscode-server/bin "/" hash "/bin/remote-cli/code"))
                          (run/user/uid (string-append "/run/user/"
                                                       (number->string (getuid))))
                          (socket       ;Guess the correct socket
                           (car
                            (scandir run/user/uid
                                     (lambda (file)
                                       (string-prefix? "vscode-ipc" file))
                                     (lambda (x y)
                                       (> (stat:mtime
                                           (lstat (string-append run/user/uid "/" x)))
                                          (stat:mtime
                                           (lstat (string-append run/user/uid "/" y)))))))))
                     (string-append
                      "VSCODE_IPC_HOOK_CLI=" socket " " vscode))
                   ;; No Remote-SSH, try to find the local one in PATH
                   (search-path (string-split (getenv "PATH") #\:)
                                "code"))))
    (string-append code " --goto ")))
--8<---------------cut here---------------end--------------->8---


Cheers,
simon




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 05 Dec 2023 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 163 days ago.

Previous Next


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