git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Lars Schneider <larsxschneider@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Lars Schneider <lars.schneider@autodesk.com>,
	Git List <git@vger.kernel.org>,
	Junio C Hamano <gitster@pobox.com>,
	Stefan Beller <sbeller@google.com>
Subject: Re: [PATCH v2] launch_editor(): indicate that Git waits for user input
Date: Wed, 22 Nov 2017 17:53:32 +0100	[thread overview]
Message-ID: <919EA31C-FDC5-4694-9614-157042D2DA82@gmail.com> (raw)
In-Reply-To: <CAPig+cQ3a0guJUhnbktrjs6fL6mSrUXmPqR0BafEAOhVr7Sy-w@mail.gmail.com>


> On 17 Nov 2017, at 20:41, Eric Sunshine <sunshine@sunshineco.com> wrote:
> 
> On Fri, Nov 17, 2017 at 8:51 AM,  <lars.schneider@autodesk.com> wrote:
> 
>> +                       char *term = getenv("TERM");
>> +
>> +                       if (term && strcmp(term, "dumb"))
>> +                               /*
>> +                                * go back to the beginning and erase the
>> +                                * entire line if the terminal is capable
>> +                                * to do so, to avoid wasting the vertical
>> +                                * space.
>> +                                */
>> +                               close_notice = "\r\033[K";
>> +                       else
>> +                               /* otherwise, complete and waste the line */
>> +                               close_notice = "done.\n";
>> +               }
>> +
>> +               if (close_notice) {
>> +                       fprintf(
>> +                               stderr,
>> +                               "Launched your editor ('%s'). Adjust, save, and close the "
>> +                               "file to continue. Waiting for your input... ", editor
>> +                       );
> 
> Here's what this looks like for me:
> 
> --- 8< ---
> Launched your editor
> ('/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'). Adjust,
> save, and close the file to continue. Waiting for your input...
> Waiting for Emacs...
> --- 8< ---
> 
> Very, very noisy, so much so that it's almost unreadable. There are at
> least three reasons for the noise:
> 
> * The raw message itself is already overly long. Do we really need to
> assume that newcomers are so clueless that they need it spelled out to
> such a level of detail? "Launched editor" should be enough for most
> people, and one would hope that "Launched editor; waiting for
> input..." would be enough for the rest.
> 
> * Does not take into consideration that EDITOR might be very long;
> perhaps you could just print the basename and strip arguments (i.e.
> "/my/long/path/edit -x --foo --zap" becomes "edit"). Or, just omit the
> editor altogether.

Agreed already in another reply here:
https://public-inbox.org/git/0DD1EE8A-47F1-41AA-8F86-C9FDF99D22A0@gmail.com/

> 
> * emacsclient already prints its own message ("Waiting for Emacs...",
> which runs together with Git's message). Perhaps treat emacsclient as
> a special case and skip printing this message if emacsclient is in
> use: if (strstr(...,"emacsclient"))

If Junio et al. are ok with the special handling of emacs, then I am happy 
to add this change in v3. If we look for "emacsclient", then would this 
cover emacs on Linux and Windows, too? (I am no emacs user)


> 
> And, of course, with a "dumb" terminal, it's even noisier with the
> extra "done." at the end:
> 
> --- 8< ---
> Launched your editor
> ('/Applications/Emacs.app/Contents/MacOS/bin/emacsclient'). Adjust,
> save, and close the file to continue. Waiting for your input...
> Waiting for Emacs...
> done.
> --- 8< ---
> 
> As Junio pointed out in [1], emacsclient has already emitted a
> newline, so the clear-line sequence is ineffective; likewise, for a
> dumb terminal, "done." ends up on its own line. Aside from the noise,
> this also suggests making a special case for emacsclient.
> 
> And, as Junio pointed out in [2], with a message so long, once it has
> wrapped, the clear-line sequence does not work as intended. For those
> of us with 80-column terminals, we're left with a bunch of noise on
> the screen.
> 
>> +                       fflush(stderr);
>> +               }
>> 
>>                p.argv = args;
>>                p.env = env;
>> @@ -53,11 +79,14 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
>>                sig = ret - 128;
>>                sigchain_pop(SIGINT);
>>                sigchain_pop(SIGQUIT);
>> +
>>                if (sig == SIGINT || sig == SIGQUIT)
>>                        raise(sig);
>>                if (ret)
>>                        return error("There was a problem with the editor '%s'.",
>>                                        editor);
>> +               if (close_notice)
>> +                       fputs(close_notice, stderr);
> 
> Should printing of close_notice be done before the error()? Otherwise,
> you get this:
> 
> --- 8< ---
> Launched your editor (...) ...There was a problem...
> --- 8< ---

I think we should keep it as I agree with Junio's argument here:
https://public-inbox.org/git/xmqqh8tsqs83.fsf@gitster.mtv.corp.google.com/

- Lars

  parent reply	other threads:[~2017-11-22 16:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 13:51 [PATCH v2] launch_editor(): indicate that Git waits for user input lars.schneider
2017-11-17 18:40 ` Junio C Hamano
2017-11-22 16:47   ` Lars Schneider
2017-11-17 19:41 ` Eric Sunshine
2017-11-18  1:40   ` Junio C Hamano
2017-11-19 17:49     ` Kaartic Sivaraam
2017-11-20  0:11       ` Junio C Hamano
2017-11-22 16:55         ` Lars Schneider
2017-11-22 17:58           ` Kaartic Sivaraam
2017-11-24  6:38           ` Junio C Hamano
2017-11-22 16:53   ` Lars Schneider [this message]
2017-11-22 17:33     ` Eric Sunshine

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=919EA31C-FDC5-4694-9614-157042D2DA82@gmail.com \
    --to=larsxschneider@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lars.schneider@autodesk.com \
    --cc=sbeller@google.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).