From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thibaut Verron Newsgroups: gmane.emacs.devel Subject: Re: Default setting for sh-maybe-here-document-mode Date: Fri, 20 Feb 2015 16:49:27 +0100 Message-ID: References: Reply-To: thibaut.verron@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a113cd866876b6e050f870089 X-Trace: ger.gmane.org 1424447396 24602 80.91.229.3 (20 Feb 2015 15:49:56 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 20 Feb 2015 15:49:56 +0000 (UTC) Cc: emacs-devel To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Feb 20 16:49:55 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YOppy-0001rb-Vo for ged-emacs-devel@m.gmane.org; Fri, 20 Feb 2015 16:49:55 +0100 Original-Received: from localhost ([::1]:32820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOppy-0007Mt-9f for ged-emacs-devel@m.gmane.org; Fri, 20 Feb 2015 10:49:54 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOppu-0007LK-8D for emacs-devel@gnu.org; Fri, 20 Feb 2015 10:49:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOpps-00028q-8O for emacs-devel@gnu.org; Fri, 20 Feb 2015 10:49:50 -0500 Original-Received: from mail-ob0-x229.google.com ([2607:f8b0:4003:c01::229]:44271) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOpps-00028l-16 for emacs-devel@gnu.org; Fri, 20 Feb 2015 10:49:48 -0500 Original-Received: by mail-ob0-f169.google.com with SMTP id wp4so24949177obc.0 for ; Fri, 20 Feb 2015 07:49:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=OQSVabFYJ/klHW/hB9VWykyKaSbHlVUd5UQuzay0VGM=; b=wCYcjApKIufHNhqLZ/VYL0iSSK+gNP3KggRZLJNT2tqzqbT07zEtDn2iEbGwjKTBzZ jZA/xzNa4H1QPFz0HKDu2I7bu4TUYqS1oCLnsaJdrIEsIheXsYM7AJWCVXKGukJnQCop M95dTMQaofqDNH5bXl3HGHTSLIyRrMNS3JkVsRUDu3yDGxdJSbAm3/jGQnuJx6SIL4Za yArnMy8bugfNu2Bwev3WVUjHy/FjmwSio30WcmHQN6fUniUrzLKT2vBDg8+yiPEoYsTk u4hsgqJx9ljHmjQF8QTL28r+ec/pu3O/4Gmr2fBut3Z+k7XlNaaq4IK2JHJZcvv/firN aVwg== X-Received: by 10.202.58.8 with SMTP id h8mr6596719oia.93.1424447387428; Fri, 20 Feb 2015 07:49:47 -0800 (PST) Original-Received: by 10.202.216.85 with HTTP; Fri, 20 Feb 2015 07:49:27 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:4003:c01::229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:183326 Archived-At: --001a113cd866876b6e050f870089 Content-Type: text/plain; charset=UTF-8 2015-02-20 14:58 GMT+01:00 Stefan Monnier : > > I was wondering why is `sh-electric-here-document-mode` activated by > > default for new documents in `sh-mode`? > > IIRC I turned it into a minor mode and made it "enabled by default" > because the corresponding functionality was active by default before > (i.e. I just tried to preserve the previous behavior). > > > I was under the impression that in most cases, this kind of commands, > > inserting text beyond what the user types, without requiring anything > > besides text input, are disabled by default. > > We don't really have a clear policy on this. I generally tend to prefer > keeping those things disabled, indeed, but OTOH electric-indent-mode is > now enabled by default (which is a pretty major counter example). > Imo electric-indent-mode is way less intrusive than the electric here document, but maybe that's only because I'm used to it. At least, a lot of other editors implement a similar feature, so emacs won't stand out as an annoyance for auto-indenting. > > > And why is it so hard to disable it once you find out where the annoying > > behavior comes from? > > Hmm... indeed, maybe it should be a global minor mode? > And auto-loaded? This could work. Another option would be to reenable the binding on '<' (see just below), and let users who do not want the behavior use self-insert-command. > > > (Just see how many articles deal with this specific > > issue; and having changed the name of the mode in 24.3 doesn't help) > > I haven't noticed this, no. Neither on gnu.emacs.help nor on > stackoverflow. > See for example http://unix.stackexchange.com/q/20121/47331 Notice the number of different answers/workarounds! And the accepted answer (probably the most natural) does not even work anymore: on 24.3, < is bound to self-insert-command by default, yet it does trigger the behavior. Side note: this is the only case I can think of where self-insert-command does something else than inserting the character. It is probably a bug by itself. As another metric, you can google "sh-electric-here-document-mode" : I don't see a single link which is not either completely unrelated or asking how to disable it. (Sorry for biasing the measure with the present thread) > > I understand that changing defaults is sensible, but in this case, > wouldn't > > it be worth it? In my opinion, the only people who may appreciate this > > setting are people who know how to use C-q to work around it, and these > > people will know how to reactivate it. > > It should (supposedly) be very rare that it triggers by accident. > > If you have some sample scenarios where it triggers when it's undesired, > maybe we can fine-tune it to avoid those, > It is very easy: try to feed a single line to a command, using a here-string. In other words, try to enter command <<< "line of text" As an anecdote, I am TA in a course where students learn about emacs and shell scripting, and I have seen mainly two reactions to this feature: "I got back to gedit because it didn't have the issue" "I use 'echo ... | ... ' instead of here-line because it is easier to type on emacs" (And this work-around will lead to different problems, for example if command is supposed to change the environment) This use-case can be accommodated with this piece of code: http://emacs.stackexchange.com/a/5338/184 It still fails in case the here-document is supposed to start with a <, which is reasonable, but would probably be even more confusing as a default. Another use-case, even if you never use here-strings, is that you want to enter a single <, but enter << instead. You would expect this mistake to be corrected with a single backspace, but it's not. By the way, we could design it so that the feature is still accessible, but through more conventional entry points, for example by pressing TAB with point after << . Thibaut Verron --001a113cd866876b6e050f870089 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
2015= -02-20 14:58 GMT+01:00 Stefan Monnier <monnier@iro.umontreal.ca= >:
> I was wondering why = is `sh-electric-here-document-mode` activated by
> default for new documents in `sh-mode`?

IIRC I turned it into a minor mode and made it "enabled by defa= ult"
because the corresponding functionality was active by default before
(i.e. I just tried to preserve the previous behavior).

> I was under the impression that in most cases, this kind of commands,<= br> > inserting text beyond what the user types, without requiring anything<= br> > besides text input, are disabled by default.

We don't really have a clear policy on this.=C2=A0 I generally t= end to prefer
keeping those things disabled, indeed, but OTOH electric-indent-mode is
now enabled by default (which is a pretty major counter example).

Imo electric-indent-mode is way less intrusive t= han the electric here document, but maybe that's only because I'm u= sed to it. At least, a lot of other editors implement a similar feature, so= emacs won't stand out as an annoyance for auto-indenting.
= =C2=A0

> And why is it so hard to disable it once you find out where the annoyi= ng
> behavior comes from?

Hmm... indeed, maybe it should be a global minor mode?

And auto-loaded? This could work. Another option wou= ld be to reenable the binding on '<' (see just below), and let u= sers who do not want the behavior use self-insert-command.
=C2=A0=

> (Just see how many articles deal with this specific
> issue; and having changed the name of the mode in 24.3 doesn't hel= p)

I haven't noticed this, no.=C2=A0 Neither on gnu.emacs.help nor = on stackoverflow.


Notice the number of d= ifferent answers/workarounds! And the accepted answer (probably the most na= tural) does not even work anymore: on 24.3, < is bound to self-insert-co= mmand by default, yet it does trigger the behavior. Side note: this is the = only case I can think of where self-insert-command does something else than= inserting the character. It is probably a bug by itself.

As another metric, you can google "sh-electric-here-document-m= ode" : I don't see a single link which is not either completely un= related or asking how to disable it. (Sorry for biasing the measure with th= e present thread)



> I understand that changing defaults is sensible, but in this case, wou= ldn't
> it be worth it? In my opinion, the only people who may appreciate this=
> setting are people who know how to use C-q to work around it, and thes= e
> people will know how to reactivate it.

It should (supposedly) be very rare that it triggers by accident.
If you have some sample scenarios where it triggers when it's undesired= ,
maybe we can fine-tune it to avoid those,

It is very easy: try to feed a single line to a command, using a here-st= ring. In other words, try to enter

=C2=A0 =C2=A0 c= ommand <<< "line of text"

As an= anecdote, I am TA in a course where students learn about emacs and shell s= cripting, and I have seen mainly two reactions to this feature:
&= quot;I got back to gedit because it didn't have the issue"
"I use 'echo ... | ... ' instead of here-line because it is= easier to type on emacs" (And this work-around will lead to different= problems, for example if command is supposed to change the environment)

This use-case can be accommodated with this piece of= code: http://emacs.s= tackexchange.com/a/5338/184=C2=A0
It still fails in case the = here-document is supposed to start with a <, which is reasonable, but wo= uld probably be even more confusing as a default.

= Another use-case, even if you never use here-strings, is that you want to e= nter a single <, but enter << instead. You would expect this mista= ke to be corrected with a single backspace, but it's not.=C2=A0

By the way, we could design it so that the feature is sti= ll accessible, but through more conventional entry points, for example by p= ressing TAB with point after << .=C2=A0

Thib= aut Verron
--001a113cd866876b6e050f870089--