Subject: bug#18985: 24.3; cperl-mode misindents hash keys that start with an auto-quoted keyword

From: [email-masked] (Ævar Arnfjörð Bjarmason)
Date: Fri, 07 Nov 2014 10:24:13 +0000

cperl-mode has a nasty bug in M-x indent-region, if you write this to a
file:
    
    my %x = (
        for_me => "cookie",
    );

And indent it you end up with:

    my %x = (
	 for _me => "cookie",
    );

Note the space between the "for" and "_me", the indenter falsely thought
that "for" was a keyword and suffixed it with a space, changing the
semantics of the code.

The same issue happens with some other keywords, e.g. "if" and "until",
but interestingly not "unless".

In GNU Emacs 24.3.1 (x86_64-pc-linux-gnu)
 of 2014-09-08 on binet, modified by Debian
System Description:	Debian GNU/Linux testing (jessie)

Configured using:
 `configure '--build' 'x86_64-linux-gnu' '--build' 'x86_64-linux-gnu'
 '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib'
 '--localstatedir=/var/lib' '--infodir=/usr/share/info'
 '--mandir=/usr/share/man' '--with-pop=yes'
 '--enable-locallisppath=/etc/emacs24:/etc/emacs:/usr/local/share/emacs/24.3/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/24.3/site-lisp:/usr/share/emacs/site-lisp'
 '--with-crt-dir=/usr/lib/x86_64-linux-gnu' '--with-x=no'
 '--without-gconf' '--without-gsettings' 'build_alias=x86_64-linux-gnu'
 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat
 -Werror=format-security -Wall' 'LDFLAGS=-Wl,-z,relro'
 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LANG: en_US.utf8
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: CPerl

Minor modes in effect:
  menu-bar-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:
C-@ C-x h C-w i f SPC ( DEL DEL DEL DEL f o r _ m e 
SPC = > SPC " c o o k i e " ; DEL , C-a C-@ C-e ESC 
x i n d e n t - r e g TAB RET ESC x c p e r l - m o 
d e RET C-a C-p RET C-p m y SPC % x SPC = SPC ( C-n 
TAB C-e RET ) TAB ; C-@ C-p C-p C-a ESC x i n d e n 
t - r e g TAB RET C-_ C-@ C-n C-g C-@ C-p C-p C-a ESC 
w C-x b C-g ESC x r e p o r t - e m a TAB RET

Recent messages:
Mark set [3 times]
Mark activated
You can run the command `indent-region' with C-M-\
byte-code: Beginning of buffer
End of `mf ... f' string/RE not found: (scan-error Unbalanced parentheses 3 22)
Mark set
Undo!
Mark set
Quit
Mark set
Quit

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail regexp-opt rfc2047 rfc2045 ietf-drums
mm-util mail-prsvr mail-utils cperl-mode easymenu time-date ediff-hook
vc-hooks lisp-float-type tabulated-list newcomment lisp-mode register
page menu-bar rfn-eshadow timer select 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 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 multi-tty emacs)