{"thread":{"id":"3228","subject":"[PATCH] do not open editor in dumb terminal","startedAt":"2006-02-03T11:41:33Z","lastAt":"2006-02-06T00:56:39Z","messageCount":9,"participants":["Amos Waterland","Junio C Hamano","H. Peter Anvin","Daniel Barkalow","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"15519","messageId":"20060203114133.GA11499@kvasir.watson.ibm.com","threadId":"3228","inReplyTo":null,"subject":"[PATCH] do not open editor in dumb terminal","fromName":"Amos Waterland","fromEmail":"apw@us.ibm.com","sentAt":"2006-02-03T11:41:33Z","receivedAt":"2006-02-03T11:41:33Z","isPatch":true,"sender":{"key":"apw@debian.org","avatar":null},"body":"Many people run git from a shell in emacs (obtained by M-x shell).  When\nthey try to do a commit without specifying a log message on the command\nline with -m, git opens vi inside emacs, with unpleasant results.  I\nthink the right answer is to just refuse to open an editor in any dumb\nterminal.\n\nSigned-off-by: Amos Waterland <apw@us.ibm.com>\nCc: Dave C Boutcher <boutcher@cs.umn.edu>\n\n---\n\n git-commit.sh |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\nc0ee93460521c1cbf9d3fe86a08b41295a79ebb1\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 193feeb..fef8f96 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -207,6 +207,12 @@ then\n fi\n case \"$no_edit\" in\n '')\n+\tif [ \"$TERM\" = \"dumb\" ]; then\n+\t\tprintf \"%s: %s: %s\\n\" \"git-commit\" \\\n+\t\t\t\"cannot open editor in a dumb terminal\" \\\n+\t\t\t\"use -m to supply message\" >&2\n+\t\texit 1\n+\tfi\n \t${VISUAL:-${EDITOR:-vi}} \"$GIT_DIR/COMMIT_EDITMSG\"\n \t;;\n esac\n-- \n1.1.6.g46dc-dirty\n"},{"id":"15526","messageId":"7vu0bgdxmh.fsf@assigned-by-dhcp.cox.net","threadId":"3228","inReplyTo":"20060203114133.GA11499@kvasir.watson.ibm.com","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-03T19:56:54Z","receivedAt":"2006-02-03T19:56:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amos Waterland <apw@us.ibm.com> writes:\n\n> Many people run git from a shell in emacs (obtained by M-x shell).  When\n> they try to do a commit without specifying a log message on the command\n> line with -m, git opens vi inside emacs, with unpleasant results.  I\n> think the right answer is to just refuse to open an editor in any dumb\n> terminal.\n\nNo, please don't.\n\nI run 'git commit' from M-x shell or M-x compile.  My EDITOR is\nset to 'emacsclient' while inside Emacs.\n\nAs a matter of fact, I do almost all my work inside Emacs and\nthis setting works rather well for not only git but for other\npeople's commands (like 'cvs commit').\n\nIt might be an option not to fall back on vi and instead to fall\nback on ed/ex when neither EDITOR nor VISUAL is specified and\nthe terminal is dumb.  But the patch as-is is unacceptable.\n"},{"id":"15594","messageId":"20060205003741.GB29021@kvasir.watson.ibm.com","threadId":"3228","inReplyTo":"7vu0bgdxmh.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"Amos Waterland","fromEmail":"apw@us.ibm.com","sentAt":"2006-02-05T00:37:41Z","receivedAt":"2006-02-05T00:37:41Z","isPatch":true,"sender":{"key":"apw@debian.org","avatar":null},"body":"On Fri, Feb 03, 2006 at 11:56:54AM -0800, Junio C Hamano wrote:\n> Amos Waterland <apw@us.ibm.com> writes:\n> > Many people run git from a shell in emacs (obtained by M-x shell).  When\n> > they try to do a commit without specifying a log message on the command\n> > line with -m, git opens vi inside emacs, with unpleasant results.  I\n> > think the right answer is to just refuse to open an editor in any dumb\n> > terminal.\n> \n> No, please don't.\n> \n> I run 'git commit' from M-x shell or M-x compile.  My EDITOR is\n> set to 'emacsclient' while inside Emacs.\n\nIf your TERM is set to `emacs' then that is fine.  If it is set to\n`dumb' however, that seems a bit strange.  A dumb terminal is usually\nunderstood to be one that does not have the ability to interpret control\nsequences.\n\nThe reason I sent the patch is that people get a rather unpleasant\nintroduction to git when vi splatters control characters all over their\nemacs session when they do their first commit.  I agree that people\nprobably should have their EDITOR set to emacsclient though, so if you\nwant to just leave the code as is that's cool with me.\n"},{"id":"15596","messageId":"43E55BC5.4010400@zytor.com","threadId":"3228","inReplyTo":"20060205003741.GB29021@kvasir.watson.ibm.com","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2006-02-05T01:58:29Z","receivedAt":"2006-02-05T01:58:29Z","isPatch":true,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Amos Waterland wrote:\n> \n> If your TERM is set to `emacs' then that is fine.  If it is set to\n> `dumb' however, that seems a bit strange.  A dumb terminal is usually\n> understood to be one that does not have the ability to interpret control\n> sequences.\n> \n> The reason I sent the patch is that people get a rather unpleasant\n> introduction to git when vi splatters control characters all over their\n> emacs session when they do their first commit.  I agree that people\n> probably should have their EDITOR set to emacsclient though, so if you\n> want to just leave the code as is that's cool with me.\n> \n\nSounds more like an unpleasant introduction to emacs.\n\n\t-hpa\n"},{"id":"15597","messageId":"7voe1msef0.fsf@assigned-by-dhcp.cox.net","threadId":"3228","inReplyTo":"20060205003741.GB29021@kvasir.watson.ibm.com","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-05T02:54:59Z","receivedAt":"2006-02-05T02:54:59Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Amos Waterland <apw@us.ibm.com> writes:\n\n> If your TERM is set to `emacs' then that is fine.  If it is set to\n> `dumb' however, that seems a bit strange.  A dumb terminal is usually\n> understood to be one that does not have the ability to interpret control\n> sequences.\n\nI am not talking about M-x terminal that uses TERM=emacs-*.  I\nam talking about M-x shell and M-x compile.  In those modes, the\ndefault TERM is \"dumb\".\n\nI could live with something like this (untested) patch, though.\nInstead of falling back on ed (or ex), you could error out and\ngive the error message if you want.\n\nI know of an editor that works fine even when invoked with\nTERM=dumb, and I explicitly told programs to use it by exporting\nEDITOR environment variable with the name of that editor.  I am\nentitled to expect that programs honor that wish, instead of\ninsulting me by saying \"Hey dummy, you cannot run any editor on\na dumb terminal\".  Be the editor \"emacsclient\" or \"ed\", they\nboth work fine for me, thank you ;-).\n\nThe user, at least the ones who understand what your program\ndoes, always knows a lot better about his enviornment and his\nneeds than your program will ever do.  You can try to be helpful\n(e.g. refuse to spawn the editor when you feel it is not\nappropriate), but you can never be perfect.  Just in case your\nhelpfulness turns out to be misguided inconvenience, you should\nleave a way for the user to override it.  I was unhappy about\nyour patch because it errored out only after checking TERM\nwithout checking EDITOR or VISUAL.\n\nAlthough you did not bring this up, there is a same issue for\n${PAGER:-less} elsewhere.  Inside Emacs I usually set it to\n\"cat\".  I do not want the program to be helpful by just checking\nTERM=dumb to error that out, either.\n\n> The reason I sent the patch is that people get a rather\n> unpleasant introduction to git when vi splatters control\n> characters all over their emacs session when they do their\n> first commit.\n\nIt's been quite a while since I used the real \"vi\" the last\ntime, but I think the real vi was not _that_ dumb as you\ndescribed.  If the termcap said that the $TERM cannot do a\nreasonable visual mode, it sensibly fell back to a line editor\nmode ex, if I recall correctly.  Maybe popular vi clones these\ndays are poorly emulated in that respect.  I dunno.\n\n---\ndiff --git a/git-commit.sh b/git-commit.sh\nindex 193feeb..c4a9dc3 100755\n--- a/git-commit.sh\n+++ b/git-commit.sh\n@@ -207,6 +207,10 @@ then\n fi\n case \"$no_edit\" in\n '')\n+\tcase \"$VISUAL$EDITOR,$TERM\" in\n+\t',dumb')\n+\t\tEDITOR=ed ;;\n+\tesac\n \t${VISUAL:-${EDITOR:-vi}} \"$GIT_DIR/COMMIT_EDITMSG\"\n \t;;\n esac\n"},{"id":"15599","messageId":"Pine.LNX.4.64.0602042346380.25300@iabervon.org","threadId":"3228","inReplyTo":"7voe1msef0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2006-02-05T05:04:40Z","receivedAt":"2006-02-05T05:04:40Z","isPatch":true,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Sat, 4 Feb 2006, Junio C Hamano wrote:\n\n> I know of an editor that works fine even when invoked with\n> TERM=dumb, and I explicitly told programs to use it by exporting\n> EDITOR environment variable with the name of that editor.  I am\n> entitled to expect that programs honor that wish, instead of\n> insulting me by saying \"Hey dummy, you cannot run any editor on\n> a dumb terminal\".  Be the editor \"emacsclient\" or \"ed\", they\n> both work fine for me, thank you ;-).\n\nI think that \"ed\" is a bit too obscure as something for people to use \ninteractively, and emacsclient is obviously not a sane default (since \npeople might not be using emacs in server mode). Probably the right thing \nis to have it supply a default if the terminal isn't dumb, and abort with \nan error if there is no editor set after defaults are supplied.\n\n(I think the only editors people use in dumb terminals these days are ones \nthat do the editing somewhere else, although I'm not sure of that.)\n\n\t-Daniel\n*This .sig left intentionally blank*\n"},{"id":"15601","messageId":"7vlkwqmk4d.fsf@assigned-by-dhcp.cox.net","threadId":"3228","inReplyTo":"Pine.LNX.4.64.0602042346380.25300@iabervon.org","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-05T05:48:18Z","receivedAt":"2006-02-05T05:48:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> I think that \"ed\" is a bit too obscure as something for people to use \n> interactively, and emacsclient is obviously not a sane default (since \n> people might not be using emacs in server mode). Probably the right thing \n> is to have it supply a default if the terminal isn't dumb, and abort with \n> an error if there is no editor set after defaults are supplied.\n\nI tend to agree (I am a minority who used ed for a long time,\nbut I am well aware that I _am_ a minority).  If somebody wants\nto send in a tested patch to be applied, I would suggest to\nreplace EDITOR=ed in the one I sent out with an error message\nand exit(1).\n"},{"id":"15611","messageId":"20060205174422.GG31278@pasky.or.cz","threadId":"3228","inReplyTo":"20060203114133.GA11499@kvasir.watson.ibm.com","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"Petr Baudis","fromEmail":"pasky@suse.cz","sentAt":"2006-02-05T17:44:22Z","receivedAt":"2006-02-05T17:44:22Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Fri, Feb 03, 2006 at 12:41:33PM CET, I got a letter\nwhere Amos Waterland <apw@us.ibm.com> said that...\n> Many people run git from a shell in emacs (obtained by M-x shell).  When\n> they try to do a commit without specifying a log message on the command\n> line with -m, git opens vi inside emacs, with unpleasant results.  I\n> think the right answer is to just refuse to open an editor in any dumb\n> terminal.\n> \n> Signed-off-by: Amos Waterland <apw@us.ibm.com>\n> Cc: Dave C Boutcher <boutcher@cs.umn.edu>\n\nCogito solves this by [ -t ] and just doing cat instead of $EDITOR if\nthe input is not a terminal. Couldn't Junio just do\n\n\temacsclient | cg^H^Hgit commit\n\nin that case? (Note that I'm totally clueless about what emacsclient's\nusage actually is.)\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nOf the 3 great composers Mozart tells us what it's like to be human,\nBeethoven tells us what it's like to be Beethoven and Bach tells us\nwhat it's like to be the universe.  -- Douglas Adams\n"},{"id":"15625","messageId":"7vek2hcnjs.fsf@assigned-by-dhcp.cox.net","threadId":"3228","inReplyTo":"20060205174422.GG31278@pasky.or.cz","subject":"Re: [PATCH] do not open editor in dumb terminal","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-02-06T00:56:39Z","receivedAt":"2006-02-06T00:56:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Petr Baudis <pasky@suse.cz> writes:\n\n> Cogito solves this by [ -t ] and just doing cat instead of $EDITOR if\n> the input is not a terminal. Couldn't Junio just do\n>\n> \temacsclient | cg^H^Hgit commit\n>\n> in that case? (Note that I'm totally clueless about what emacsclient's\n> usage actually is.)\n\nIt works just like other editors you can sanely use as EDITOR or\nVISUAL.  Takes list of files to edit on the command line, lets\nthe user interact with it and modify the files, writes out the\nresults to the files and exits.\n\nSo you could have suggested something like this:\n\n\t$ ( $EDITOR tmpfile && cat tmpfile ) | cg commit\n\nI think \"git commit -F -\" reads from stdin so an equilvalent can\nbe done with \"git commit\", but I suspect a sane user would\nrather do this instead if he uses a temporary file:\n\n\t$ $EDITOR tmpfile\n        $ git commit -F tmpfile\n"}]}