• RFC: Sensible-editor sensible-utils alternative and update

    From Bastien =?ISO-8859-1?Q?Roucari=E8s?@21:1/5 to All on Sun Aug 11 22:06:12 2024
    Hi

    Sensible-editor could now use EDITOR="emacsclient -n -c" and accept that sh -c accept

    My goal is to create a sensible-editor.desktop that will lauch by default the sensible-editor of choice

    For this I plan:
    - to allow by alternative mechanism to have an sensible-editor-tty (may be better wording) sensible-editor-$XDG_CURRENT_DESKTOP
    in order to allow default customization
    - SENSIBLE_EDITOR is not set, sensible-editor will first try sensible-editor-$XDG_CURRENT_DESKTOP XDG_CURRENT_DESKTOP (if $XDG_CURRENT_DESKTOP
    is set) then sensible-editor-tty (using if needed sensible-terminal)

    I will also like to allow sensible-editor-STUFF to support +4:3 FILE command line, so
    editor +4:3 somefile.txt will open somefile.txt and if possible go to line 4 column 3 (and silently ignore if not possible)

    Any comments ?

    rouca
    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAma5NdQACgkQADoaLapB CF+fjBAAqKqaSLXvAxhR6Wd9fbnNbe7PuD0Eald5FX8N2mhss0VIXMusD3FQRKWL 77XBbFg5J2UUYnfrO21DFU38JuLtD+SmdPKy/DVwAvBSR2AS5lPQFmowivfIsw8G K2ng3z7d3fis4dhj3uS1mnc/eQlsXnVwRHhkyIbW+e/kJtUr6S73LPQSdU4nUEK5 9z2giKLTV9v/Q/78+2PMiY5IFKduIXeex5V5IRoufuF6w+RAAqSk/7af6wxU/LYE 6CHqJwEMdjVLV0GVbM9du6hr6XZ+jukxx0h9aTHP9JetUf5H2BwbsYdelF6/vgkj x7KzinHDycu9J8GQnBzZgQih3P+zfzXvlRbLOQ9WJlywa41tL2RgJDrXjwffpfuy DM5oWL5bMd9HMUPVzS6a/aUlAwBfsNOtF84bgaeABKUpk0Ce0OJZqOC+nI/fcZxo xYNLpVOMhGa4SpxveQ+69ZxcxIJlV24bDnI567qzC05FbScIe/fgkM4+a+19eJ3Y NBfv1Jm2sqvF7wTFE76DfO/wZUeRMPEs2gHBn9L2C5DJvFrFajTNATqXW/eIxhPf yAyHrhAx2V4gggfHhU4Wp6pAzxTsO6ZpSK66eKoW8lR8i5s+XD2psXEBRWCXKFYK 1RKpc4FLdY3Up4AHyWi/08D8UmoI4q+gkrW+qYGvyXcZ6N1aqkA=
    =xOFO
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Lewis@21:1/5 to [email protected] on Mon Aug 12 13:40:01 2024
    Bastien Roucariès <[email protected]> writes:

    Sensible-editor could now use EDITOR="emacsclient -n -c" and accept
    that sh -c accept

    My goal is to create a sensible-editor.desktop that will lauch by
    default the sensible-editor of choice

    For this I plan:
    - to allow by alternative mechanism to have an sensible-editor-tty
    (may be better wording) sensible-editor-$XDG_CURRENT_DESKTOP
    in order to allow default customization
    - SENSIBLE_EDITOR is not set, sensible-editor will first try sensible-editor-$XDG_CURRENT_DESKTOP XDG_CURRENT_DESKTOP (if $XDG_CURRENT_DESKTOP
    is set) then sensible-editor-tty (using if needed sensible-terminal)


    Can you set out how this affects users

    If i am using gnome, i want something pretty simple

    a) opening a file with the mouse should use gnome's default (which can
    change in settings)

    b) but if im in a terminal (even if running in gnome) then i want a
    terminal-based editor (based on what i installed)

    (b) also means no failures if i get a dpkg "edit conffile" situation
    while upgrading -- graphical editors may fail to start, or i might be on
    the linux console when dist-upgrading.


    i think this all works great today, will it still work with your
    proposal? what extra cases are you proposing to support?

    I will also like to allow sensible-editor-STUFF to support +4:3 FILE
    command line, so
    editor +4:3 somefile.txt will open somefile.txt and if possible go to
    line 4 column 3 (and silently ignore if not possible)


    sounds great (and separate to the above), although i wonder how you will
    tell whether the underlying editor supports it.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon McVittie@21:1/5 to Richard Lewis on Mon Aug 12 15:00:01 2024
    On Mon, 12 Aug 2024 at 12:36:37 +0100, Richard Lewis wrote:
    Bastien Roucari�s <[email protected]> writes:
    Sensible-editor could now use EDITOR="emacsclient -n -c" and accept
    that sh -c accept

    My goal is to create a sensible-editor.desktop that will lauch by
    default the sensible-editor of choice

    Echoing what Richard asked: what problem are you aiming to solve with
    this? I think designs need to start by stating the problem that they
    are solving, instead of jumping directly to a solution.

    The way to open any existing file, in a GUI environment, is to look
    up the preferred handler for the MIME type of the file (which might
    be text/plain or might be something else), and then launch it. This is
    equally true for text files and non-text files.

    This is a general mechanism across all Linux distributions (and other
    Unixes such as *BSD), using the freedesktop.org Desktop Entry and
    MIME Apps specifications: <https://specifications.freedesktop.org/desktop-entry-spec/latest/>, <https://specifications.freedesktop.org/mime-apps-spec/latest/>.

    This is also not specific to text files, and doesn't require creating
    one .desktop file per desktop environment per file type (which would
    scale poorly); it's a generic mechanism that can work for any MIME type,
    and includes a concept of fallbacks like "prefer gnome-text-editor if installed, or try gedit as a second preference, or fall back to any
    other editor".

    If there's a use-case for which these are insufficient, please talk to
    these specifications' upstreams and get consensus on an improvement that
    can be adopted upstream by everything that participates in the MIME apps
    spec (GLib, Qt, xdg-open, ...), instead of inventing a Debian-specific mechanism that we would have to patch into various packages against
    upstreams' objections.

    a) opening a file with the mouse should use gnome's default (which can
    change in settings)

    One important point here is that if you have (for example) both GNOME and
    KDE Plasma installed on the same machine, and you have not customized
    settings, then clicking on a text file in a GNOME session will open it in GNOME's default text editor, but clicking on the same text file in a
    Plasma session will open it in KDE's default text editor.

    This is a desirable feature, particularly for shared machines (for example Gerald and Karen share a computer, Gerald prefers to use GNOME, Karen
    prefers to use KDE, and by default they should both get an editor whose appearance and behaviour matches their preferred desktop environment).

    I will also like to allow sensible-editor-STUFF to support +4:3 FILE command line, so
    editor +4:3 somefile.txt will open somefile.txt and if possible go to
    line 4 column 3 (and silently ignore if not possible)

    sounds great (and separate to the above), although i wonder how you will
    tell whether the underlying editor supports it.

    This convention is somewhat common in (mainly older) CLI-focused, programmer-oriented text editors, but rare in GUI editors, and I'm not
    aware of any way to discover programmatically whether a particular editor supports that syntax. In editors that don't support that syntax, the result
    is not "silently ignore": instead, the most likely result is a confusing
    erorr message about being unable to open a file named "+4:3".

    We shouldn't adopt new features for the benefit of "power users" if they
    come at the expense of making it appear to less experienced users that
    the overall system is broken, because first impressions matter.

    In principle it would be possible to *define* a way to discover whether
    an editor supports that syntax - for instance defining a new field in
    .desktop files, with the default being "assume it's unsupported" - but
    if that's done, it should be done in a cross-desktop and cross-distro environment like freedesktop.org, rather than as a "weird Debianism".

    I am particularly wary about Debian-specific things in this area because
    we already have several examples of identifying a problem, inventing
    a Debian-specific solution, investing significant effort over several
    years into keeping that solution alive, and eventually deciding that we
    have to deprecate it in favour of something cross-distribution (often
    against bitter objections from its proponents, who might have got very
    used to a particular feature or quirk of the Debian-specific solution).
    If we go "upstream first" and help to solve non-Debian-specific problems
    for the whole freedesktop ecosystem, then everyone benefits, both inside
    and outside Debian.

    Thanks,
    smcv

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bastien =?ISO-8859-1?Q?Roucari=E8s?@21:1/5 to All on Mon Aug 12 14:23:35 2024
    Copy: [email protected] (Simon McVittie)

    Le lundi 12 août 2024, 12:52:43 UTC Simon McVittie a écrit :
    On Mon, 12 Aug 2024 at 12:36:37 +0100, Richard Lewis wrote:
    Bastien Roucariès <[email protected]> writes:
    Sensible-editor could now use EDITOR="emacsclient -n -c" and accept
    that sh -c accept

    My goal is to create a sensible-editor.desktop that will lauch by
    default the sensible-editor of choice

    Echoing what Richard asked: what problem are you aiming to solve with
    this? I think designs need to start by stating the problem that they
    are solving, instead of jumping directly to a solution.

    The way to open any existing file, in a GUI environment, is to look
    up the preferred handler for the MIME type of the file (which might
    be text/plain or might be something else), and then launch it. This is equally true for text files and non-text files.

    This is a general mechanism across all Linux distributions (and other
    Unixes such as *BSD), using the freedesktop.org Desktop Entry and
    MIME Apps specifications: <https://specifications.freedesktop.org/desktop-entry-spec/latest/>, <https://specifications.freedesktop.org/mime-apps-spec/latest/>.

    This is also not specific to text files, and doesn't require creating
    one .desktop file per desktop environment per file type (which would
    scale poorly); it's a generic mechanism that can work for any MIME type,
    and includes a concept of fallbacks like "prefer gnome-text-editor if installed, or try gedit as a second preference, or fall back to any
    other editor".

    If there's a use-case for which these are insufficient, please talk to
    these specifications' upstreams and get consensus on an improvement that
    can be adopted upstream by everything that participates in the MIME apps
    spec (GLib, Qt, xdg-open, ...), instead of inventing a Debian-specific mechanism that we would have to patch into various packages against upstreams' objections.

    a) opening a file with the mouse should use gnome's default (which can
    change in settings)

    One important point here is that if you have (for example) both GNOME and
    KDE Plasma installed on the same machine, and you have not customized settings, then clicking on a text file in a GNOME session will open it in GNOME's default text editor, but clicking on the same text file in a
    Plasma session will open it in KDE's default text editor.

    This is a desirable feature, particularly for shared machines (for example Gerald and Karen share a computer, Gerald prefers to use GNOME, Karen
    prefers to use KDE, and by default they should both get an editor whose appearance and behaviour matches their preferred desktop environment).

    Yes I want sensible-editor to open kate on kde and gnome-editor on gnome.

    Thinks about running latex and typing e for editing, it should run the desktop editor of choice.

    I do not want to change desktop user choice


    I will also like to allow sensible-editor-STUFF to support +4:3 FILE command line, so
    editor +4:3 somefile.txt will open somefile.txt and if possible go to line 4 column 3 (and silently ignore if not possible)

    sounds great (and separate to the above), although i wonder how you will tell whether the underlying editor supports it.

    This convention is somewhat common in (mainly older) CLI-focused, programmer-oriented text editors, but rare in GUI editors, and I'm not
    aware of any way to discover programmatically whether a particular editor supports that syntax. In editors that don't support that syntax, the result is not "silently ignore": instead, the most likely result is a confusing erorr message about being unable to open a file named "+4:3".

    Yes that why I ask for creating shell wrapper.
    kate for instance could open line column if you pass --line --column

    I have other problem with unsupported terminal that fail... Even nano does not fail gracefully on some terminal (try dumb terminal)

    kate does not fallback nicely to other editor on linux console for instance. Try it. kate for instance return 0
    gedit block


    We shouldn't adopt new features for the benefit of "power users" if they
    come at the expense of making it appear to less experienced users that
    the overall system is broken, because first impressions matter.

    In principle it would be possible to *define* a way to discover whether
    an editor supports that syntax - for instance defining a new field in .desktop files, with the default being "assume it's unsupported" - but
    if that's done, it should be done in a cross-desktop and cross-distro environment like freedesktop.org, rather than as a "weird Debianism".

    I am particularly wary about Debian-specific things in this area because
    we already have several examples of identifying a problem, inventing
    a Debian-specific solution, investing significant effort over several
    years into keeping that solution alive, and eventually deciding that we
    have to deprecate it in favour of something cross-distribution (often
    against bitter objections from its proponents, who might have got very
    used to a particular feature or quirk of the Debian-specific solution).
    If we go "upstream first" and help to solve non-Debian-specific problems
    for the whole freedesktop ecosystem, then everyone benefits, both inside
    and outside Debian.

    Agreed but here it is only for getting something consistant for desktop user

    Bastien

    Thanks,
    smcv




    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAma6GucACgkQADoaLapB CF8ZHQ//WF4ASbKThzMEknGJNksLAMrDC4u0rmv3H6pn8jNF3YHXOuFjcxkYMg5O jMZsVrGzXF32duypN7RBnJ8D3b4GY0VTZvqEdRa32SXBqkTgRJ6cRn1lAqKgrX6J tK/wDtl1Kx4uExCJ9QFQBnTanGsQa1XFDjlVOUx+HF54UwGLy6ieRGnZQ1o/d6Tb Cd4x1QHrIEGvu0UyHfYUGzYsKbLNvKPQwqVPIm1wMElGvGDAedEPn5u/SbAK6gu6 dqgM4h6c/9/6i/kfKYlEp8KZcuVMj9kcm1Td8bDuxalvTk0TgKzZIlyydxh+dieq VYjeAqlLdGKQxLuegZezgnaTxyt8jAgceO79e5I120/SFOrWFzgLmzqCw44atsaC w8WcLOnFsgfqOJpVQ57Pl6c13a4EOnw798+tNg8a9NST7Ioz2UIXO+WU3EagrbeC F/LR4Z/OTvCu79zYic+6zdX5wUbT38nzoSxCmq9XvO4Kt0xrVgw+tLPrbfAJ6vxE Aoxokw5UVmBI+2E5kQJ7VkdewUOdnzOVmoeKo/Y79/X9HO7jQWJR4dhFnVr2+ozG mkzyylHQGLLjRWIRaUIQHmnTKiE6VUDSg0WqqEKNR2HWsdb6U5coBPl7DO4J4jZ0 Z2WkjDAu7EBmIN9+OPob+X9NlDAaadeBRquyG628kMVSjI5pG5s=
    =ZZDD
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bastien =?ISO-8859-1?Q?Roucari=E8s?@21:1/5 to so I should on Mon Aug 12 14:12:45 2024
    Le lundi 12 août 2024, 11:36:37 UTC Richard Lewis a écrit :
    Bastien Roucariès <[email protected]> writes:

    Sensible-editor could now use EDITOR="emacsclient -n -c" and accept
    that sh -c accept

    My goal is to create a sensible-editor.desktop that will lauch by
    default the sensible-editor of choice

    For this I plan:
    - to allow by alternative mechanism to have an sensible-editor-tty
    (may be better wording) sensible-editor-$XDG_CURRENT_DESKTOP
    in order to allow default customization
    - SENSIBLE_EDITOR is not set, sensible-editor will first try sensible-editor-$XDG_CURRENT_DESKTOP XDG_CURRENT_DESKTOP (if $XDG_CURRENT_DESKTOP
    is set) then sensible-editor-tty (using if needed sensible-terminal)


    Can you set out how this affects users

    If i am using gnome, i want something pretty simple

    a) opening a file with the mouse should use gnome's default (which can
    change in settings)

    No change except if you associate to sensible-editor

    b) but if im in a terminal (even if running in gnome) then i want a
    terminal-based editor (based on what i installed)

    depends for me I prefer to run under emacsclient so you could do something like SENSIBLE_EDITOR='if [ -t 0 ]; then sensible-editor-GNOME ; else sensible-editor-tty; fi;'

    For now I have some gui program that try to run editor from gui and fail, because you should attach a console.


    (b) also means no failures if i get a dpkg "edit conffile" situation
    while upgrading -- graphical editors may fail to start, or i might be on
    the linux console when dist-upgrading.

    Yes and sensible editor will try fallback, I do for now for nano that fail on DUMP terminal, and I have also corner case with other editor
    so I should write wrapper...



    i think this all works great today, will it still work with your
    proposal? what extra cases are you proposing to support?

    do not fail to run sensible-editor from a GUI, and if run a console of choice before with the editor on it.

    I will also like to allow sensible-editor-STUFF to support +4:3 FILE command line, so
    editor +4:3 somefile.txt will open somefile.txt and if possible go to
    line 4 column 3 (and silently ignore if not possible)


    sounds great (and separate to the above), although i wonder how you will
    tell whether the underlying editor supports it.

    Yes that why I propose wrapper

    editor in a POSIX sense is a wrapper against vi. minimal command line is documented for ex.

    It could only open one file passed as last argument

    so for me editor is
    editor [file]

    I only propose to add

    editor [+line[:column]] [file] for the wrapper

    bastien






    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAma6GF0ACgkQADoaLapB CF8j8A/9FZvZZkoOr1aKbo2Zrrzeesl+mPmZgHt3wGLQ88p1oDx2flO77T2/G1Sn p3CR1VznE5cjj+ME79CpW65baezWRE4Fh0XbOkAnek41evLbDPW2b4ZYdHzTcVy1 PpjicF55ibJK9pkJ4wclV/dcFMUB+VjPDXSFXP4g0P+WllcYBR+PevzZBzjxqi75 4pPnwA8LRGTeuOyNU0usa3dashuXMdTlfxC+QZ+ewaLNvHKfArfGakl5EhM1EVxp CJzR8lJsgU+L0uZLM0kKTeUBoxjg7nBr8D3cMqUcAXWNO0S/YtL9djrG38wtkdRQ 9RaSZEa7axJy0twBpdaYsAJS6LPunocvaCPMr96x9ZXkilbhAu5SFrHc4kLPvpf5 KCYJiBa1vnPoPHuwS8g/ZRtcM9pCbEPLP30FRfKxusxVrU7H5ym8+VrQZXZbaJqH DgzXr8zNtRuYgnCHDn9JHWQJIhibgSWMQOswawd7xnfnCL1BIEkLZFq51FRziMk9 Jc7HLZBPgszkhPAkhl8y1LK30wZmiIPuR8ZPg/H9wuVGTfT0fcgXp/6NV2im8XN+ UCnYi6dOdqJuKoGmoll5juQhBbw/tc9Wf8OG7ZmIUwiAjYnvZ4V09wxtdlf1PNgV yPpRJDVHmO3rCA1kxEizpdAg93YOs+DVyRaua0YXvV9rptxFwdE=
    =fUQc
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon McVittie@21:1/5 to All on Mon Aug 12 17:20:01 2024
    On Mon, 12 Aug 2024 at 14:23:51 +0000, Bastien Roucari�s wrote:
    Yes I want sensible-editor to open kate on kde and gnome-editor on gnome.

    Thinks about running latex and typing e for editing, it should run the desktop editor of choice.

    I do not want to change desktop user choice

    This use-case doesn't need a Debian-specific mechanism, because there
    are already many implementations of the Desktop Entry and MIME App specifications, such as:

    xdg-open "$document" # from xdg-utils
    gio open "$document" # from libglib2.0-bin

    or, ideally, calling into a library in your implementation language
    that implements those specifications without needing a CLI layer
    in between. (For example `gio open` is basically a CLI wrapper
    around g_app_info_launch_default_for_uri_async(), so in C code that
    already depends on GLib for some other reason, it's better to call g_app_info_launch_default_for_uri_async() directly.)

    One limitation of this (which is unsolvable in anything based on .desktop files) is that it's considered equally valid for the handler to daemonize,
    run in the background and exit immediately (like `gvim $file`), or to
    run "in the foreground" until the user exits, and then exit (like
    `gvim -f $file`). So you can't rely on using something like this if
    you want your process to block until the user has saved the file and
    exited. But that isn't something you can rely on from GUI editors anyway, because not all GUI editors even have that as a concept - some are "single-instance" and expect to open all files in one instance of the
    editor app.

    The approach to this that will work consistently is to launch the handler asynchronously (in the background), and not attempt to find out whether
    it has exited or not. So for example an interactive shell script might
    do something like this:

    #!/bin/bash
    # note that disown is a bashism

    xdg-open "$document" &
    disown $!
    echo "Press Enter when you have finished editing $document..."
    read

    I have other problem with unsupported terminal that fail... Even nano does not
    fail gracefully on some terminal (try dumb terminal)

    Yes, running a text editor in an environment that is not supported by
    that text editor will not work. I don't see why that would be unexpected.

    kate does not fallback nicely to other editor on linux console for instance.

    No: falling back from the implementation of some class of application
    that you asked for to a different implementation is not behaviour that
    I would expect. If you run a GUI file manager like Nautilus or Dolphin
    from a Linux virtual console, it doesn't try to "do what you mean"
    and run mc instead. Text editors are no different.

    smcv

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bastien =?ISO-8859-1?Q?Roucari=E8s?@21:1/5 to Simon McVittie on Mon Aug 12 15:25:58 2024
    Copy: [email protected]

    Le lundi 12 août 2024, 15:17:00 UTC Simon McVittie a écrit :
    On Mon, 12 Aug 2024 at 14:23:51 +0000, Bastien Roucariès wrote:
    Yes I want sensible-editor to open kate on kde and gnome-editor on gnome.

    Thinks about running latex and typing e for editing, it should run the desktop editor of choice.

    I do not want to change desktop user choice

    This use-case doesn't need a Debian-specific mechanism, because there
    are already many implementations of the Desktop Entry and MIME App specifications, such as:

    xdg-open "$document" # from xdg-utils
    gio open "$document" # from libglib2.0-bin

    or, ideally, calling into a library in your implementation language
    that implements those specifications without needing a CLI layer
    in between. (For example `gio open` is basically a CLI wrapper
    around g_app_info_launch_default_for_uri_async(), so in C code that
    already depends on GLib for some other reason, it's better to call g_app_info_launch_default_for_uri_async() directly.)

    Yes it will work but legacy code exist and run EDITOR therefore sensible-editor is here...

    SENSIBLE_EDITOR="xdg-open" will work


    One limitation of this (which is unsolvable in anything based on .desktop files) is that it's considered equally valid for the handler to daemonize, run in the background and exit immediately (like `gvim $file`), or to
    run "in the foreground" until the user exits, and then exit (like
    `gvim -f $file`). So you can't rely on using something like this if
    you want your process to block until the user has saved the file and
    exited. But that isn't something you can rely on from GUI editors anyway, because not all GUI editors even have that as a concept - some are "single-instance" and expect to open all files in one instance of the
    editor app.

    The approach to this that will work consistently is to launch the handler asynchronously (in the background), and not attempt to find out whether
    it has exited or not. So for example an interactive shell script might
    do something like this:

    #!/bin/bash
    # note that disown is a bashism

    xdg-open "$document" &
    disown $!
    echo "Press Enter when you have finished editing $document..."
    read

    Yes so If I do EDITOR= xdg-open" git commit it give some interesting result

    note that EDITOR="kate -b" git commit will work


    I have other problem with unsupported terminal that fail... Even nano does not
    fail gracefully on some terminal (try dumb terminal)

    Yes, running a text editor in an environment that is not supported by
    that text editor will not work. I don't see why that would be unexpected.

    kate does not fallback nicely to other editor on linux console for instance.

    No: falling back from the implementation of some class of application
    that you asked for to a different implementation is not behaviour that
    I would expect. If you run a GUI file manager like Nautilus or Dolphin
    from a Linux virtual console, it doesn't try to "do what you mean"
    and run mc instead. Text editors are no different.

    It is the spec of sensible editor fallback gracefully...

    Bastien

    smcv



    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAma6KYYACgkQADoaLapB CF/RpQ//aAoi6d72ifRUvbLYvETQubzhjJlB753wOCBmDI8TKwIbJW/gXdAG3Mdb MBqek260VmMKZ+CLMVVmwn+DXKZSgGlAhk96oosRq+A9k43rBD0QL5MwCSHiki3C F47TTW+v9d6TC38vOXH8bW6ktZ07qCQHg2X2dixGXZOKLFRVmRyL5NQLEiUwKN02 59GP2TAY9kIrvVp+ZPVM/uTILhbZM5zcIVu5moieg5qJ+2fLZ6u0QhfXg9vM80HK FjcjRBrpr/KJxhno6Jfi1SKHiBBCzr4RyRZik/wPf4PSsFYYugHvFS0N1wsTtl3o i1N0EI9w1Ksv2JWxkLFreUKHq9l39hdPYn52UlXJxM6qpM+2fuSV95KlFJfphnLy Kh+Wzz/YCWQveVrgdQaflEU+8I9nx80b2TvW8mcbkUHw6VRrJX8uWbCetg/CAQHg 8fUJ/QEmxfjA9aGBYSvdU84Q+zAaUTAqhyvnAD14JLWTbWM9F7VzfhUJSjSFMqYN P2gn9alMB3AC0KeRFeTsRDZxPQxPSlIg+n2guIQIXtxY1BAkxb+W4sXk56bOCKiu /KA2ca+/OqUnriaGmYC4ZalGg7/Duh89tqce7JZupRymKVjIf1hU9a00GUsVikM8 zcVCHYUKYKswGysc71T7j8EwauGPdY8jpqUIUnP6Q7/Q7tR1mbU=
    =ghK6
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Russ Allbery@21:1/5 to Simon McVittie on Mon Aug 12 17:50:01 2024
    Simon McVittie <[email protected]> writes:

    The approach to this that will work consistently is to launch the
    handler asynchronously (in the background), and not attempt to find out whether it has exited or not. So for example an interactive shell script might do something like this:

    #!/bin/bash
    # note that disown is a bashism

    xdg-open "$document" &
    disown $!
    echo "Press Enter when you have finished editing $document..."
    read

    What this is telling me is that ideally someone should tighten the
    definition of EDITOR in Policy 11.4, which is the specification satisfied
    by sensible-editor, to make it clear that GUI editors with these sorts of properties are not valid things to set EDITOR to point to unless flags are present to make them behave in a way that satisfies the expectations of programs that use EDITOR.

    I don't have any strong opinion on the merits of trying to figure out how
    to invoke the editor with the proper flags to make it follow the
    expectations of EDITOR if EDITOR is not set, but we do need to be careful
    to not invoke programs that would cause, e.g., git commit --amend to immediately exit with no changes to the commit message, and to do that we probably need to write down what those expectations are. I think the
    Policy language was written in a time where we just assumed there was an obvious way for editors to behave that didn't include things like
    backgrounding themselves.

    --
    Russ Allbery ([email protected]) <https://www.eyrie.org/~eagle/>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon McVittie@21:1/5 to Russ Allbery on Mon Aug 12 18:10:01 2024
    On Mon, 12 Aug 2024 at 08:44:51 -0700, Russ Allbery wrote:
    What this is telling me is that ideally someone should tighten the
    definition of EDITOR in Policy 11.4, which is the specification satisfied
    by sensible-editor, to make it clear that GUI editors with these sorts of properties are not valid things to set EDITOR to point to unless flags are present to make them behave in a way that satisfies the expectations of programs that use EDITOR.

    I agree. A backgrounding editor like `gvim` shouldn't be considered to be
    a suitable EDITOR (but `gvim -f` would be).

    Many other GUI editors behave like `gvim` and not like `gvim -f`, so they
    are also perfectly reasonable text editors in general, but not suitable
    to be the value of EDITOR; and I suspect quite a lot of GUI editors have
    no equivalent of gvim's -f option at all.

    The Desktop Entry and MIME Apps specifications leave it unspecified which
    way a MIME handler will behave, so anything that is an implementation
    of those specifications (like `xdg-open` or `gio open`) is not suitable
    as an EDITOR either, because the caller can't know whether the resulting application is going to wait or not.

    I think the
    Policy language was written in a time where we just assumed there was an obvious way for editors to behave that didn't include things like backgrounding themselves.

    Yes, I think so. Not backgrounding makes a lot of sense for a
    line-oriented editor (ed, ex) or a TUI editor (nano, vi) which will
    typically occupy the terminal[1] and prevent it from being used for other purposes *anyway*, but is a lot less obviously desirable for a GUI
    editor that will appear elsewhere in a windowing system and can be used
    in parallel with the terminal.

    smcv

    [1] yes I know about screen(1) and similar, but interacting with those
    would require special setup that a typical TUI editor doesn't do

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bastien =?ISO-8859-1?Q?Roucari=E8s?@21:1/5 to All on Mon Aug 12 17:10:45 2024
    Copy: [email protected] (Russ Allbery)

    Le lundi 12 août 2024, 15:44:51 UTC Russ Allbery a écrit :
    Simon McVittie <[email protected]> writes:

    The approach to this that will work consistently is to launch the
    handler asynchronously (in the background), and not attempt to find out whether it has exited or not. So for example an interactive shell script might do something like this:

    #!/bin/bash
    # note that disown is a bashism

    xdg-open "$document" &
    disown $!
    echo "Press Enter when you have finished editing $document..."
    read

    What this is telling me is that ideally someone should tighten the
    definition of EDITOR in Policy 11.4, which is the specification satisfied
    by sensible-editor, to make it clear that GUI editors with these sorts of properties are not valid things to set EDITOR to point to unless flags are present to make them behave in a way that satisfies the expectations of programs that use EDITOR.

    Yes and what why I ask to add sensible-editor wrapper. At least it will do something
    sensible and it is optional

    Bastien

    I don't have any strong opinion on the merits of trying to figure out how
    to invoke the editor with the proper flags to make it follow the
    expectations of EDITOR if EDITOR is not set, but we do need to be careful
    to not invoke programs that would cause, e.g., git commit --amend to immediately exit with no changes to the commit message, and to do that we probably need to write down what those expectations are. I think the
    Policy language was written in a time where we just assumed there was an obvious way for editors to behave that didn't include things like backgrounding themselves.




    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAma6QhUACgkQADoaLapB CF8m9w//fjTdWqd4NI23dYmMvUTXFfDw1FzBMPdpcnnFP5gKhrHLGDd01cE7O4mB 0P7qFbPU97479w0v1RX8noPJjhu98EeWdvMHbiAvKQJcbgRU+d3f+M0D25HMDnUM 5oO/eB8MQpn7B6VZBbW7wDhCY5+s2civzpxddQgMEQNeqZcRtVdryddZKpoPHywZ EuABoHRAhn8FoGCTYmDO6rsUWPsCfmqfbbTPRu28a6C8UBImqJe6MPLbC20QbQrm IMJtHhcZMWGiGwu0wOv/B2OSQopr+chpFe5YBuclKlXBfAUBgrDRUm10CAWMnwwD 71MnGAUOTOIsQJxE0nUPbfZMdFDp7sa1q1HVoViNaRE1yliR7cQw5HeM2g9WnP7J +hnw+N0Qv/U0H4ddpZhbHf4l1Ho1sSWEBKCMqJormBt2pLpso6HOVbWsCGo4NZnG FYaGl9J82CMkeLRsZ09Sb4hXkYmVI0ab4zU7OuRv7Idk/Nnwaa6+obF6kpuy117c dSW2Poolch5QQqxZuODjjpgpC/WL7F2pT98sinkqGRsae02VhREt1APFBnb1ZueF LXIctzQRUZWNeKbkZPFuxUdLay+K45ULXFsdOEJvKAltlZUt5UOZlAgJK6sDioTe 0mYR4VtEcVNOMtKaHgffHzh8UOXqlr8p/KPJFjUNdqaDxCeuRwc=
    =REb4
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bastien =?ISO-8859-1?Q?Roucari=E8s?@21:1/5 to All on Mon Aug 12 17:12:33 2024
    Copy: [email protected] (Simon McVittie)

    Le lundi 12 août 2024, 16:04:30 UTC Simon McVittie a écrit :
    On Mon, 12 Aug 2024 at 08:44:51 -0700, Russ Allbery wrote:
    What this is telling me is that ideally someone should tighten the definition of EDITOR in Policy 11.4, which is the specification satisfied by sensible-editor, to make it clear that GUI editors with these sorts of properties are not valid things to set EDITOR to point to unless flags are present to make them behave in a way that satisfies the expectations of programs that use EDITOR.

    I agree. A backgrounding editor like `gvim` shouldn't be considered to be
    a suitable EDITOR (but `gvim -f` would be).

    Yes and wrapper sensible-editor-gvim will do for you



    Many other GUI editors behave like `gvim` and not like `gvim -f`, so they
    are also perfectly reasonable text editors in general, but not suitable
    to be the value of EDITOR; and I suspect quite a lot of GUI editors have
    no equivalent of gvim's -f option at all.

    I have checked quite a few have some flag to do the intended behavior


    The Desktop Entry and MIME Apps specifications leave it unspecified which
    way a MIME handler will behave, so anything that is an implementation
    of those specifications (like `xdg-open` or `gio open`) is not suitable
    as an EDITOR either, because the caller can't know whether the resulting application is going to wait or not.

    I think the
    Policy language was written in a time where we just assumed there was an obvious way for editors to behave that didn't include things like backgrounding themselves.

    Yes, I think so. Not backgrounding makes a lot of sense for a
    line-oriented editor (ed, ex) or a TUI editor (nano, vi) which will
    typically occupy the terminal[1] and prevent it from being used for other purposes *anyway*, but is a lot less obviously desirable for a GUI
    editor that will appear elsewhere in a windowing system and can be used
    in parallel with the terminal.

    Yes

    Bastien

    smcv

    [1] yes I know about screen(1) and similar, but interacting with those
    would require special setup that a typical TUI editor doesn't do




    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAma6QoEACgkQADoaLapB CF93Vg//SKzNV188xwyRpZLqyGkqNW5L7pgNMfsToj3QDoUNkNeKL82fb5LN9XWv z8RM8ZRAJdmXyQLgMsvxZMIt6cofwfSSM37nCVcmJJUsp9dPAkwTRRw2fkKPckuE RrBVeXbevoK5D2aZioBuyYrbyhiQaISJTCuow13qR4iJ2fm6MQXgpdWwdNIHZiOc T2O1jsgi5XH5Ig6JTovUp+agP2Bx/Ca1s3plpN1DG92mVBrl67dO1MQZ3GfNpiqA vFU5nGSling5tbBuwVo2id6gLuknII7xuF62YYQbtfufFbiZT44L1/LRPHYohI2X B/NfaXDlXzNguG4bJR9l9vEgssbns1kZ2z1eG3zzt9tp30tap/7qfrbS0To5RS8w eEbdYDJD0shGTfFoAdMbcuEa8QBRoSm8vTlQbgxBQSNucnj8amhPE829+1878xAY L9V6zww6p0Va42m/oNPLNT45EXRJ8yX6B2qxxsuA26s7bPwLT2ZKsoBbclW/36P7 X9TcpyucRcNHv0GBkQ8Wcv4LBg0LO1HB1eBcpNwLqibUSCprdmx95X25f4KAYQ4k r2tIdXsQnSn9LsILhU2DYzKrjKaXq6zTpWkWrjzVTNk/47JwqRKGFYsCn9JG7uMF k7rF+hyNmFJtOJ0nlhq8sSRKiSlG696UK7vuhIJ3VovyrCIkosU=
    =S095
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Lewis@21:1/5 to [email protected] on Mon Aug 12 23:10:01 2024
    Bastien Roucariès <[email protected]> writes:

    b) but if im in a terminal (even if running in gnome) then i want a
    terminal-based editor (based on what i installed)

    depends for me I prefer to run under emacsclient so you could do
    something like
    SENSIBLE_EDITOR='if [ -t 0 ]; then sensible-editor-GNOME ; else sensible-editor-tty; fi;'

    Couldnt i already put that it in ~/bin/editor and set
    EDITOR to that script?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Bastien =?ISO-8859-1?Q?Roucari=E8s?@21:1/5 to All on Tue Aug 13 07:50:41 2024
    Le lundi 12 août 2024, 21:05:17 UTC Richard Lewis a écrit :
    Bastien Roucariès <[email protected]> writes:

    b) but if im in a terminal (even if running in gnome) then i want a
    terminal-based editor (based on what i installed)

    depends for me I prefer to run under emacsclient so you could do
    something like
    SENSIBLE_EDITOR='if [ -t 0 ]; then sensible-editor-GNOME ; else sensible-editor-tty; fi;'

    Couldnt i already put that it in ~/bin/editor and set
    EDITOR to that script?
    Yes but it does not change the need that the editor called should block and be more like ex or vi

    BTW it is better on debian system to set both EDITOR and SENSIBLE_EDITOR to ~/bin/editor in this case

    Bastien






    -----BEGIN PGP SIGNATURE-----

    iQIzBAABCgAdFiEEXQGHuUCiRbrXsPVqADoaLapBCF8FAma7EFEACgkQADoaLapB CF/DOA//ezGZ219XMfLPqtOEQxw3QUIsgkKSBjWS6IP5921sU5wmnqQfr0aoElJO t3SjQhYmXgyd8DV8pQD+y/qybu5L24hdP97Ax3GBQSI5DMLDU2N88AMwLqv1WDvj lByva54qaIMC3JkM09xAKeAsELDRESfdgm+vlCTo6eRF07zKKiFCObdUpB3qNYs9 cYciFOx+32+Uq56HoP8Ydb3atiWsDnfnRWZGOigo08s/z/laTi4czH6Q+59r+W51 h4R50UEEp8pdjRtyJE6vr7JSBMLOoBjLTx+zVe/WqujPloEOElVBbWd60iivMeWK zF3mtarYwyoP6LaYFrGpKDcTUXMZhteu8CgkekEurMwi6ybU2aai2A1WjqNL4V3M mboA3ZIVFQLsCVLF4+CzFUilZF6/9u7dwIUwe6OUfmoaToMV83EPL4vq8AGQW/Sr 1fCmPK/T3wahMwOqKWan01/DnDUK1xVBNn6N6Hu2450wA0IP1aOra3weR0ui2pyg L5pey0tRBPX0X8KnoEnRoou17D9rXJQaQfhqxzAX3QGOHj+ZVo+bqhfup5JsbX8w WByKdzx5NlRmNXepfp47wJb4GFnD29Sk85YXmV2TYX4kIIcS5YX69YDxR6/M372H FpaPor/F3KO4YlmL5VOYV9CmGD6OKObP6rzlxmvnknlC7Ho09E0=
    =qcj3
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)