* [PATCH] do not open editor in dumb terminal @ 2006-02-03 11:41 Amos Waterland 2006-02-03 19:56 ` Junio C Hamano 2006-02-05 17:44 ` Petr Baudis 0 siblings, 2 replies; 9+ messages in thread From: Amos Waterland @ 2006-02-03 11:41 UTC (permalink / raw) To: junkio; +Cc: git, boutcher Many people run git from a shell in emacs (obtained by M-x shell). When they try to do a commit without specifying a log message on the command line with -m, git opens vi inside emacs, with unpleasant results. I think the right answer is to just refuse to open an editor in any dumb terminal. Signed-off-by: Amos Waterland <apw@us.ibm.com> Cc: Dave C Boutcher <boutcher@cs.umn.edu> --- git-commit.sh | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) c0ee93460521c1cbf9d3fe86a08b41295a79ebb1 diff --git a/git-commit.sh b/git-commit.sh index 193feeb..fef8f96 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -207,6 +207,12 @@ then fi case "$no_edit" in '') + if [ "$TERM" = "dumb" ]; then + printf "%s: %s: %s\n" "git-commit" \ + "cannot open editor in a dumb terminal" \ + "use -m to supply message" >&2 + exit 1 + fi ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR/COMMIT_EDITMSG" ;; esac -- 1.1.6.g46dc-dirty ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-03 11:41 [PATCH] do not open editor in dumb terminal Amos Waterland @ 2006-02-03 19:56 ` Junio C Hamano 2006-02-05 0:37 ` Amos Waterland 2006-02-05 17:44 ` Petr Baudis 1 sibling, 1 reply; 9+ messages in thread From: Junio C Hamano @ 2006-02-03 19:56 UTC (permalink / raw) To: Amos Waterland; +Cc: git, boutcher Amos Waterland <apw@us.ibm.com> writes: > Many people run git from a shell in emacs (obtained by M-x shell). When > they try to do a commit without specifying a log message on the command > line with -m, git opens vi inside emacs, with unpleasant results. I > think the right answer is to just refuse to open an editor in any dumb > terminal. No, please don't. I run 'git commit' from M-x shell or M-x compile. My EDITOR is set to 'emacsclient' while inside Emacs. As a matter of fact, I do almost all my work inside Emacs and this setting works rather well for not only git but for other people's commands (like 'cvs commit'). It might be an option not to fall back on vi and instead to fall back on ed/ex when neither EDITOR nor VISUAL is specified and the terminal is dumb. But the patch as-is is unacceptable. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-03 19:56 ` Junio C Hamano @ 2006-02-05 0:37 ` Amos Waterland 2006-02-05 1:58 ` H. Peter Anvin 2006-02-05 2:54 ` Junio C Hamano 0 siblings, 2 replies; 9+ messages in thread From: Amos Waterland @ 2006-02-05 0:37 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, boutcher On Fri, Feb 03, 2006 at 11:56:54AM -0800, Junio C Hamano wrote: > Amos Waterland <apw@us.ibm.com> writes: > > Many people run git from a shell in emacs (obtained by M-x shell). When > > they try to do a commit without specifying a log message on the command > > line with -m, git opens vi inside emacs, with unpleasant results. I > > think the right answer is to just refuse to open an editor in any dumb > > terminal. > > No, please don't. > > I run 'git commit' from M-x shell or M-x compile. My EDITOR is > set to 'emacsclient' while inside Emacs. If your TERM is set to `emacs' then that is fine. If it is set to `dumb' however, that seems a bit strange. A dumb terminal is usually understood to be one that does not have the ability to interpret control sequences. The reason I sent the patch is that people get a rather unpleasant introduction to git when vi splatters control characters all over their emacs session when they do their first commit. I agree that people probably should have their EDITOR set to emacsclient though, so if you want to just leave the code as is that's cool with me. ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-05 0:37 ` Amos Waterland @ 2006-02-05 1:58 ` H. Peter Anvin 2006-02-05 2:54 ` Junio C Hamano 1 sibling, 0 replies; 9+ messages in thread From: H. Peter Anvin @ 2006-02-05 1:58 UTC (permalink / raw) To: Amos Waterland; +Cc: Junio C Hamano, git, boutcher Amos Waterland wrote: > > If your TERM is set to `emacs' then that is fine. If it is set to > `dumb' however, that seems a bit strange. A dumb terminal is usually > understood to be one that does not have the ability to interpret control > sequences. > > The reason I sent the patch is that people get a rather unpleasant > introduction to git when vi splatters control characters all over their > emacs session when they do their first commit. I agree that people > probably should have their EDITOR set to emacsclient though, so if you > want to just leave the code as is that's cool with me. > Sounds more like an unpleasant introduction to emacs. -hpa ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-05 0:37 ` Amos Waterland 2006-02-05 1:58 ` H. Peter Anvin @ 2006-02-05 2:54 ` Junio C Hamano 2006-02-05 5:04 ` Daniel Barkalow 1 sibling, 1 reply; 9+ messages in thread From: Junio C Hamano @ 2006-02-05 2:54 UTC (permalink / raw) To: Amos Waterland; +Cc: git, boutcher Amos Waterland <apw@us.ibm.com> writes: > If your TERM is set to `emacs' then that is fine. If it is set to > `dumb' however, that seems a bit strange. A dumb terminal is usually > understood to be one that does not have the ability to interpret control > sequences. I am not talking about M-x terminal that uses TERM=emacs-*. I am talking about M-x shell and M-x compile. In those modes, the default TERM is "dumb". I could live with something like this (untested) patch, though. Instead of falling back on ed (or ex), you could error out and give the error message if you want. I know of an editor that works fine even when invoked with TERM=dumb, and I explicitly told programs to use it by exporting EDITOR environment variable with the name of that editor. I am entitled to expect that programs honor that wish, instead of insulting me by saying "Hey dummy, you cannot run any editor on a dumb terminal". Be the editor "emacsclient" or "ed", they both work fine for me, thank you ;-). The user, at least the ones who understand what your program does, always knows a lot better about his enviornment and his needs than your program will ever do. You can try to be helpful (e.g. refuse to spawn the editor when you feel it is not appropriate), but you can never be perfect. Just in case your helpfulness turns out to be misguided inconvenience, you should leave a way for the user to override it. I was unhappy about your patch because it errored out only after checking TERM without checking EDITOR or VISUAL. Although you did not bring this up, there is a same issue for ${PAGER:-less} elsewhere. Inside Emacs I usually set it to "cat". I do not want the program to be helpful by just checking TERM=dumb to error that out, either. > The reason I sent the patch is that people get a rather > unpleasant introduction to git when vi splatters control > characters all over their emacs session when they do their > first commit. It's been quite a while since I used the real "vi" the last time, but I think the real vi was not _that_ dumb as you described. If the termcap said that the $TERM cannot do a reasonable visual mode, it sensibly fell back to a line editor mode ex, if I recall correctly. Maybe popular vi clones these days are poorly emulated in that respect. I dunno. --- diff --git a/git-commit.sh b/git-commit.sh index 193feeb..c4a9dc3 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -207,6 +207,10 @@ then fi case "$no_edit" in '') + case "$VISUAL$EDITOR,$TERM" in + ',dumb') + EDITOR=ed ;; + esac ${VISUAL:-${EDITOR:-vi}} "$GIT_DIR/COMMIT_EDITMSG" ;; esac ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-05 2:54 ` Junio C Hamano @ 2006-02-05 5:04 ` Daniel Barkalow 2006-02-05 5:48 ` Junio C Hamano 0 siblings, 1 reply; 9+ messages in thread From: Daniel Barkalow @ 2006-02-05 5:04 UTC (permalink / raw) To: Junio C Hamano; +Cc: Amos Waterland, git, boutcher On Sat, 4 Feb 2006, Junio C Hamano wrote: > I know of an editor that works fine even when invoked with > TERM=dumb, and I explicitly told programs to use it by exporting > EDITOR environment variable with the name of that editor. I am > entitled to expect that programs honor that wish, instead of > insulting me by saying "Hey dummy, you cannot run any editor on > a dumb terminal". Be the editor "emacsclient" or "ed", they > both work fine for me, thank you ;-). I think that "ed" is a bit too obscure as something for people to use interactively, and emacsclient is obviously not a sane default (since people might not be using emacs in server mode). Probably the right thing is to have it supply a default if the terminal isn't dumb, and abort with an error if there is no editor set after defaults are supplied. (I think the only editors people use in dumb terminals these days are ones that do the editing somewhere else, although I'm not sure of that.) -Daniel *This .sig left intentionally blank* ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-05 5:04 ` Daniel Barkalow @ 2006-02-05 5:48 ` Junio C Hamano 0 siblings, 0 replies; 9+ messages in thread From: Junio C Hamano @ 2006-02-05 5:48 UTC (permalink / raw) To: Daniel Barkalow; +Cc: Amos Waterland, git, boutcher Daniel Barkalow <barkalow@iabervon.org> writes: > I think that "ed" is a bit too obscure as something for people to use > interactively, and emacsclient is obviously not a sane default (since > people might not be using emacs in server mode). Probably the right thing > is to have it supply a default if the terminal isn't dumb, and abort with > an error if there is no editor set after defaults are supplied. I tend to agree (I am a minority who used ed for a long time, but I am well aware that I _am_ a minority). If somebody wants to send in a tested patch to be applied, I would suggest to replace EDITOR=ed in the one I sent out with an error message and exit(1). ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-03 11:41 [PATCH] do not open editor in dumb terminal Amos Waterland 2006-02-03 19:56 ` Junio C Hamano @ 2006-02-05 17:44 ` Petr Baudis 2006-02-06 0:56 ` Junio C Hamano 1 sibling, 1 reply; 9+ messages in thread From: Petr Baudis @ 2006-02-05 17:44 UTC (permalink / raw) To: Amos Waterland; +Cc: junkio, git, boutcher Dear diary, on Fri, Feb 03, 2006 at 12:41:33PM CET, I got a letter where Amos Waterland <apw@us.ibm.com> said that... > Many people run git from a shell in emacs (obtained by M-x shell). When > they try to do a commit without specifying a log message on the command > line with -m, git opens vi inside emacs, with unpleasant results. I > think the right answer is to just refuse to open an editor in any dumb > terminal. > > Signed-off-by: Amos Waterland <apw@us.ibm.com> > Cc: Dave C Boutcher <boutcher@cs.umn.edu> Cogito solves this by [ -t ] and just doing cat instead of $EDITOR if the input is not a terminal. Couldn't Junio just do emacsclient | cg^H^Hgit commit in that case? (Note that I'm totally clueless about what emacsclient's usage actually is.) -- Petr "Pasky" Baudis Stuff: http://pasky.or.cz/ Of the 3 great composers Mozart tells us what it's like to be human, Beethoven tells us what it's like to be Beethoven and Bach tells us what it's like to be the universe. -- Douglas Adams ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] do not open editor in dumb terminal 2006-02-05 17:44 ` Petr Baudis @ 2006-02-06 0:56 ` Junio C Hamano 0 siblings, 0 replies; 9+ messages in thread From: Junio C Hamano @ 2006-02-06 0:56 UTC (permalink / raw) To: Petr Baudis; +Cc: Amos Waterland, junkio, git, boutcher Petr Baudis <pasky@suse.cz> writes: > Cogito solves this by [ -t ] and just doing cat instead of $EDITOR if > the input is not a terminal. Couldn't Junio just do > > emacsclient | cg^H^Hgit commit > > in that case? (Note that I'm totally clueless about what emacsclient's > usage actually is.) It works just like other editors you can sanely use as EDITOR or VISUAL. Takes list of files to edit on the command line, lets the user interact with it and modify the files, writes out the results to the files and exits. So you could have suggested something like this: $ ( $EDITOR tmpfile && cat tmpfile ) | cg commit I think "git commit -F -" reads from stdin so an equilvalent can be done with "git commit", but I suspect a sane user would rather do this instead if he uses a temporary file: $ $EDITOR tmpfile $ git commit -F tmpfile ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2006-02-06 0:56 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2006-02-03 11:41 [PATCH] do not open editor in dumb terminal Amos Waterland 2006-02-03 19:56 ` Junio C Hamano 2006-02-05 0:37 ` Amos Waterland 2006-02-05 1:58 ` H. Peter Anvin 2006-02-05 2:54 ` Junio C Hamano 2006-02-05 5:04 ` Daniel Barkalow 2006-02-05 5:48 ` Junio C Hamano 2006-02-05 17:44 ` Petr Baudis 2006-02-06 0:56 ` Junio C Hamano
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).