git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
To: lars.schneider@autodesk.com, git@vger.kernel.org
Cc: gitster@pobox.com, sbeller@google.com, sunshine@sunshineco.com,
	Lars Schneider <larsxschneider@gmail.com>
Subject: Re: [PATCH v3] launch_editor(): indicate that Git waits for user input
Date: Mon, 27 Nov 2017 22:47:59 +0530	[thread overview]
Message-ID: <1bb4eeb1-eaaf-11ec-8215-08d3490577a8@gmail.com> (raw)
In-Reply-To: <20171127134716.69471-1-lars.schneider@autodesk.com>

On Monday 27 November 2017 07:17 PM, lars.schneider@autodesk.com wrote:

> Show a message in the original terminal and get rid of it when the
> editor returns.
> 

"... except in the case when an error occurs." could  be included if needed.
> +		static const char *close_notice = NULL;
> +

IIRC, this variable is bound to be `static` for sake of future proofing. 
So, I guess you could use the following suggestion of Eric Sunshine in 
the below conditional.

     If you reverse this condition to say (!close_notice && isatty(2)),
     then you save an isatty() invocation each time if close_notice is
     already assigned.

> +		if (isatty(2) && !close_notice) {
> +			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 if (term && strstr(term, "emacsclient"))
> +				/*
> +				 * `emacsclient` (or `emacsclientw` on Windows) already prints
> +				 * ("Waiting for Emacs...") if a file is opened for editing.
> +				 * Therefore, we don't need to print the editor launch info.
> +				 */
> +				;
> +			else
> +				/* otherwise, complete and waste the line */
> +				close_notice = _("done.\n");
> +		}
> +
> +		if (close_notice) {
> +			fprintf(stderr, _("Launched editor. Waiting for your input... "));
> +			fflush(stderr);
> +		}
> 
>   		p.argv = args;
>   		p.env = env;
> @@ -53,11 +82,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);
>   	}
> 
>   	if (!buffer)
> --
> 2.15.0
> 


  reply	other threads:[~2017-11-27 17:18 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-27 13:47 [PATCH v3] launch_editor(): indicate that Git waits for user input lars.schneider
2017-11-27 17:17 ` Kaartic Sivaraam [this message]
2017-11-27 18:36 ` Eric Sunshine
2017-11-27 20:04   ` Lars Schneider
2017-11-27 20:09 ` brian m. carlson
2017-11-27 23:05   ` Jeff King
2017-11-28  4:29     ` Junio C Hamano
2017-11-28 12:31     ` Lars Schneider
2017-11-29  2:06     ` brian m. carlson
2017-11-27 23:18 ` Junio C Hamano
2017-11-28 12:39   ` Lars Schneider

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

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

  git send-email \
    --in-reply-to=1bb4eeb1-eaaf-11ec-8215-08d3490577a8@gmail.com \
    --to=kaartic.sivaraam@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=lars.schneider@autodesk.com \
    --cc=larsxschneider@gmail.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.
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 NNTP newsgroup(s).