* bug#18944: 24.4; perl-mode electric-indent inside here documents
@ 2014-11-04 15:50 Ed Avis
2019-09-20 23:12 ` Stefan Kangas
0 siblings, 1 reply; 7+ messages in thread
From: Ed Avis @ 2014-11-04 15:50 UTC (permalink / raw)
To: 18944
In Perl (as in the Unix shell), a "here document" is a string that
begins with a marker such as <<END and continues until a line containing
just END. The text between these markers is part of the string, not
tokenized Perl code; in particular, it doesn't need to be indented
as if it were part of the program itself.
However, at the moment perl-mode doesn't fully recognize these strings
and attempts to indent their content somehow. I think this is a long-
standing problem but it has recently become more visible now that
electric-indent-mode is enabled by default.
Start a new buffer and M-x perl-mode. Enter this text:
my $x = <<END
and hit Return. The cursor is positioned on the next line indented by
four spaces (depending on your default indent level). This is not
really correct; most of the time you don't want your quoted string to
start with four literal space characters, so it would be more helpful
for Emacs not to indent.
But even if you delete the four spaces and enter a line of text
foo
followed by Return, it will jump and indent itself. This is
frustrating.
Now, perl-mode does understand strings quoted with "" and '', and knows
that the contents of them should not be automatically indented, even
when the string contains embedded newlines. It needs to extend that
understanding to here documents beginning <<WHATEVER.
If this is not practical, perhaps the indentation could be kept (so
if you hit Tab inside the here document it will still do something
weird) but the electric-indent behaviour will be temporarily disabled
while the user is entering the content of a here document.
In GNU Emacs 24.4.1 (x86_64-redhat-linux-gnu, GTK+ Version 3.10.9)
of 2014-11-03 on wcl-linux04.wcl.local
Configured using:
`configure --build=x86_64-redhat-linux-gnu
--host=x86_64-redhat-linux-gnu --program-prefix=
--disable-dependency-tracking --prefix=/usr --exec-prefix=/usr
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc
--datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64
--libexecdir=/usr/libexec --localstatedir=/var
--sharedstatedir=/var/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-dbus --with-gif --with-jpeg --with-png
--with-rsvg --with-tiff --with-xft --with-xpm --with-x-toolkit=gtk3
--with-gpm=no build_alias=x86_64-redhat-linux-gnu
host_alias=x86_64-redhat-linux-gnu 'CFLAGS=-DMAIL_USE_LOCKF -O2 -g
-pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector-strong --param=ssp-buffer-size=4
-grecord-gcc-switches -m64 -mtune=generic' 'LDFLAGS=-Wl,-z,relro ''
Important settings:
value of $LC_COLLATE: C
value of $LC_CTYPE: en_GB.UTF-8
value of $LC_MESSAGES: en_GB.UTF-8
value of $LC_MONETARY: en_GB.UTF-8
value of $LC_NUMERIC: en_GB.UTF-8
value of $LC_TIME: en_GB.UTF-8
value of $LANG: en_GB.UTF-8
locale-coding-system: utf-8-unix
Major mode: Perl
Minor modes in effect:
diff-auto-refine-mode: t
shell-dirtrack-mode: t
tooltip-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
l l RET ESC > ESC p RET . / f e TAB g r TAB RET ESC
p - - m a i l RET C-p C-p C-p C-p C-p C-p C-p C-p C-n
C-c v RET C-x 1 ESC > C-x 2 C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-n
C-n C-n C-n C-x o C-x b RET C-x p C-x o C-x C-g C-p
C-p C-p C-p C-n C-n C-n C-n C-n C-n C-n C-n RET C-_
C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p RET
RET C-p TAB i f SPC ( $ o p t _ r e p l a c e ) SPC
{ RET TAB $ s q l SPC = SPC < < E N D RET C-a C-k C-k
C-k RET C-p C-p C-p C-p C-n C-n C-n u p d a t e SPC
a l r e a d y RET s e t SPC C-a C-p C-d C-d C-d C-d
C-d C-d C-d C-d C-d C-d C-d C-d C-n C-d C-d C-d C-d
C-d C-d C-d C-d C-d C-d C-d C-d C-e C-k C-k RET E N
D RET ; C-p C-p C-e RET C-a C-p C-p TAB C-n TAB C-a
C-p C-d C-d C-d C-d C-d C-d C-d C-d C-d C-d C-d C-d
C-d e DEL C-e RET C-_ C-_ C-a C-k ESC x r e p l a c
e DEL DEL DEL DEL o r - SPC DEL SPC RET
Recent messages:
Auto-saving...done
Auto-saving...done
Saving file /home/eda/svn_working/repos/sql/WCL-SQL-LIVE/tradingsystemsprod/vwTradingSystemsRunRiskCapitalByFund.sql...
Wrote /home/eda/svn_working/repos/sql/WCL-SQL-LIVE/tradingsystemsprod/vwTradingSystemsRunRiskCapitalByFund.sql
Saving file /home/eda/svn_working/repos/sql/WCL-SQL-LIVE/tradingsystemsprod/vwTradingSystemsRunRiskCapitalByFund.sql...
Wrote /home/eda/svn_working/repos/sql/WCL-SQL-LIVE/tradingsystemsprod/vwTradingSystemsRunRiskCapitalByFund.sql
Mark set [2 times]
C-x p is undefined
C-x C-g is undefined
Undo! [3 times]
Load-path shadows:
None found.
Features:
(shadow sort mail-extr emacsbug sendmail sql view ffap thingatpt
url-parse auth-source eieio eieio-core gnus-util password-cache url-vars
nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc
rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok
misearch multi-isearch help-mode dabbrev diff-mode vc vc-dispatcher
vc-svn cus-edit wid-edit cus-start cus-load perl-mode pcmpl-unix dired
xterm time-date log-edit easy-mmode message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mm-util mail-prsvr mailabbrev mail-utils gmm-utils mailheader
pcvs-util add-log server csharp-mode advice help-fns byte-opt bytecomp
byte-compile cconv cc-langs cc-mode cc-fonts easymenu cc-guess cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs zoom-frm frame-cmds
frame-fns cl-macs avoid cl gv cl-loaddefs cl-lib compile shell pcomplete
comint ring ansi-color tooltip electric uniquify ediff-hook vc-hooks
lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt
fringe tabulated-list newcomment lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)
Memory information:
((conses 16 357122 49889)
(symbols 48 28025 0)
(miscs 40 271 1603)
(strings 32 50592 4464)
(string-bytes 1 2568677)
(vectors 16 26047)
(vector-slots 8 1283877 223538)
(floats 8 269 645)
(intervals 56 27624 0)
(buffers 960 44)
(heap 1024 32251 1650))
______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18944: 24.4; perl-mode electric-indent inside here documents
2014-11-04 15:50 bug#18944: 24.4; perl-mode electric-indent inside here documents Ed Avis
@ 2019-09-20 23:12 ` Stefan Kangas
2019-09-23 8:35 ` Ed Avis
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2019-09-20 23:12 UTC (permalink / raw)
To: Ed Avis; +Cc: 18944
Ed Avis <eda@waniasset.com> writes:
> Start a new buffer and M-x perl-mode. Enter this text:
>
> my $x = <<END
>
> and hit Return. The cursor is positioned on the next line indented by
> four spaces (depending on your default indent level). This is not
> really correct; most of the time you don't want your quoted string to
> start with four literal space characters, so it would be more helpful
> for Emacs not to indent.
I can't reproduce this on Emacs 26.1. Are you still seeing this on a
more recent version of Emacs, for example the latest version 26.3?
If I don't hear back from you in a couple of weeks, I'll just assume
that this has been fixed while you were waiting for a reply and close
this as unreproducible.
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18944: 24.4; perl-mode electric-indent inside here documents
2019-09-20 23:12 ` Stefan Kangas
@ 2019-09-23 8:35 ` Ed Avis
2019-09-23 9:15 ` Stefan Kangas
2022-01-25 14:08 ` Lars Ingebrigtsen
0 siblings, 2 replies; 7+ messages in thread
From: Ed Avis @ 2019-09-23 8:35 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 18944@debbugs.gnu.org
With 26.1 the way to reproduce is a bit different. Make a new buffer, M-x perl-mode, and enter
my $x = <<END
END
hitting Return at the end of each line. But when you hit Return on the second line, the END becomes indented by four spaces. That's not right since a here-document terminator should be at the left margin.
(please ignore confidentiality gunk below... can we have a web interface to reply to bugs please?)
To learn how we protect privacy, please use this link (https://www.qma.com/gdpr.html) to read our Privacy Notice.
This email and any files transmitted with it are CONFIDENTIAL and are intended solely for the use of the individual(s) or entity to whom they are addressed. Any unauthorised copying, disclosure or distribution of the material within this email is strictly forbidden. Any views or opinions presented within this email are solely those of the author and do not necessarily represent those of QMA Wadhwani (QMAW) unless otherwise specifically stated. An electronic message is not binding on its sender. Any message referring to a binding agreement must be confirmed in writing and duly signed. If you have received this email in error, please notify the sender immediately and delete the original. Telephone, electronic and other communications and conversations with QMAW and/or its associated persons may be recorded and retained.
Please note that your personal information may be stored and processed in any country where we have facilities or in which we engage service providers. If you provide personal information to us by email or otherwise, you consent to the transfer of that information to countries outside of your country of residence and these countries may have different data protection rules than your country.
This email is intended only for the person to whom it is addressed and may contain confidential information. Any retransmission, copying, disclosure or other use of, this information by persons other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the material. This email is for information only and is not intended as an offer or solicitation for the purchase or sale of any financial instrument. QMA Wadhwani LLP is a Limited Liability Partnership registered in England (OC303168) with registered office at 9th Floor Orion House, 5 Upper St Martin’s Lane, London, WC2H 9EA.
To learn how we protect privacy, please use this link (https://www.qma.com/gdpr.html) to read our Privacy Notice.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18944: 24.4; perl-mode electric-indent inside here documents
2019-09-23 8:35 ` Ed Avis
@ 2019-09-23 9:15 ` Stefan Kangas
2019-09-23 9:23 ` Ed Avis
2022-01-25 14:08 ` Lars Ingebrigtsen
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Kangas @ 2019-09-23 9:15 UTC (permalink / raw)
To: Ed Avis; +Cc: 18944@debbugs.gnu.org
Ed Avis <eda@waniasset.com> writes:
> With 26.1 the way to reproduce is a bit different. Make a new buffer, M-x perl-mode, and enter
>
> my $x = <<END
> END
>
> hitting Return at the end of each line. But when you hit Return on the second line, the END becomes indented by four spaces. That's not right since a here-document terminator should be at the left margin.
Thanks for reporting back. I can reproduce this bug with the above
recipe on current master and Emacs 26.3.
A workaround is to add a semi-colon to END:
my $x = <<END;
END;
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18944: 24.4; perl-mode electric-indent inside here documents
2019-09-23 9:15 ` Stefan Kangas
@ 2019-09-23 9:23 ` Ed Avis
0 siblings, 0 replies; 7+ messages in thread
From: Ed Avis @ 2019-09-23 9:23 UTC (permalink / raw)
To: Stefan Kangas; +Cc: 18944@debbugs.gnu.org
When you look at this, if you want to widen the scope of the bug, note that recent Perl versions allow indented here-documents using <<~ syntax.
#!/usr/bin/perl
my $x = <<~END
Here is some indented stuff.
Because the terminator END is also indented by four spaces,
those spaces will be stripped off the resulting string.
END
;
print $x;
That's an example of where Emacs really should indent the content of the 'here document', including the terminator.
But for the older style without ~ it really has to be at the left margin, and most likely the content of the string will start from the left margin too.
To learn how we protect privacy, please use this link (https://www.qma.com/gdpr.html) to read our Privacy Notice.
This email and any files transmitted with it are CONFIDENTIAL and are intended solely for the use of the individual(s) or entity to whom they are addressed. Any unauthorised copying, disclosure or distribution of the material within this email is strictly forbidden. Any views or opinions presented within this email are solely those of the author and do not necessarily represent those of QMA Wadhwani (QMAW) unless otherwise specifically stated. An electronic message is not binding on its sender. Any message referring to a binding agreement must be confirmed in writing and duly signed. If you have received this email in error, please notify the sender immediately and delete the original. Telephone, electronic and other communications and conversations with QMAW and/or its associated persons may be recorded and retained.
Please note that your personal information may be stored and processed in any country where we have facilities or in which we engage service providers. If you provide personal information to us by email or otherwise, you consent to the transfer of that information to countries outside of your country of residence and these countries may have different data protection rules than your country.
This email is intended only for the person to whom it is addressed and may contain confidential information. Any retransmission, copying, disclosure or other use of, this information by persons other than the intended recipient is prohibited. If you received this email in error, please contact the sender and delete the material. This email is for information only and is not intended as an offer or solicitation for the purchase or sale of any financial instrument. QMA Wadhwani LLP is a Limited Liability Partnership registered in England (OC303168) with registered office at 9th Floor Orion House, 5 Upper St Martin’s Lane, London, WC2H 9EA.
To learn how we protect privacy, please use this link (https://www.qma.com/gdpr.html) to read our Privacy Notice.
^ permalink raw reply [flat|nested] 7+ messages in thread
* bug#18944: 24.4; perl-mode electric-indent inside here documents
2019-09-23 8:35 ` Ed Avis
2019-09-23 9:15 ` Stefan Kangas
@ 2022-01-25 14:08 ` Lars Ingebrigtsen
[not found] ` <PH0PR11MB56117AD63C236DE5DC7E4743845F9@PH0PR11MB5611.namprd11.prod.outlook.com>
1 sibling, 1 reply; 7+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-25 14:08 UTC (permalink / raw)
To: Ed Avis; +Cc: Stefan Kangas, 18944@debbugs.gnu.org
[-- Attachment #1: Type: text/plain, Size: 550 bytes --]
Ed Avis <eda@waniasset.com> writes:
> With 26.1 the way to reproduce is a bit different. Make a new buffer,
> M-x perl-mode, and enter
>
> my $x = <<END
> END
>
> hitting Return at the end of each line. But when you hit Return on
> the second line, the END becomes indented by four spaces. That's not
> right since a here-document terminator should be at the left margin.
This is apparently fixed in Emacs 29, but another related bug has
appeared:
my $x = <<END
END
If you hit RET after the second line, Emacs will then indent the next
line:
[-- Attachment #2: Type: image/png, Size: 5986 bytes --]
[-- Attachment #3: Type: text/plain, Size: 31 bytes --]
I.e., indented by four chars.
[-- Attachment #4: Type: image/png, Size: 11419 bytes --]
[-- Attachment #5: Type: text/plain, Size: 106 bytes --]
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-01-25 14:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-04 15:50 bug#18944: 24.4; perl-mode electric-indent inside here documents Ed Avis
2019-09-20 23:12 ` Stefan Kangas
2019-09-23 8:35 ` Ed Avis
2019-09-23 9:15 ` Stefan Kangas
2019-09-23 9:23 ` Ed Avis
2022-01-25 14:08 ` Lars Ingebrigtsen
[not found] ` <PH0PR11MB56117AD63C236DE5DC7E4743845F9@PH0PR11MB5611.namprd11.prod.outlook.com>
2022-01-25 14:23 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.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).