* bug#18985: 24.3; cperl-mode misindents hash keys that start with an auto-quoted keyword
@ 2014-11-07 10:24 Ævar Arnfjörð Bjarmason
2019-07-05 20:04 ` Stefan Kangas
2020-08-27 21:13 ` bug#18985: [PATCH] Fix indent-region for identifiers with underscores Harald Jörg
0 siblings, 2 replies; 4+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2014-11-07 10:24 UTC (permalink / raw)
To: 18985
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)
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18985: 24.3; cperl-mode misindents hash keys that start with an auto-quoted keyword
2014-11-07 10:24 bug#18985: 24.3; cperl-mode misindents hash keys that start with an auto-quoted keyword Ævar Arnfjörð Bjarmason
@ 2019-07-05 20:04 ` Stefan Kangas
2020-08-27 21:13 ` bug#18985: [PATCH] Fix indent-region for identifiers with underscores Harald Jörg
1 sibling, 0 replies; 4+ messages in thread
From: Stefan Kangas @ 2019-07-05 20:04 UTC (permalink / raw)
To: avarab; +Cc: 18985
avarab@gmail.com (Ævar Arnfjörð Bjarmason) writes:
> 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".
I can reproduce this on Emacs 26.2.
Best regards,
Stefan Kangas
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#18985: [PATCH] Fix indent-region for identifiers with underscores
2014-11-07 10:24 bug#18985: 24.3; cperl-mode misindents hash keys that start with an auto-quoted keyword Ævar Arnfjörð Bjarmason
2019-07-05 20:04 ` Stefan Kangas
@ 2020-08-27 21:13 ` Harald Jörg
2020-08-28 14:31 ` Lars Ingebrigtsen
1 sibling, 1 reply; 4+ messages in thread
From: Harald Jörg @ 2020-08-27 21:13 UTC (permalink / raw)
To: 18985
[-- Attachment #1: Type: text/plain, Size: 87 bytes --]
Another bug report from 2014 caught my attention.
A patch is attached.
--
Cheers,
haj
[-- Attachment #2: 0001-2020-08-27-Harald-J-rg-haj-posteo.de.patch --]
[-- Type: text/x-patch, Size: 2381 bytes --]
From c3b3c7b8a2105d39e81c6f8ccf19a1600659bcce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20J=C3=B6rg?= <haj@posteo.de>
Date: Thu, 27 Aug 2020 22:57:53 +0200
Subject: [PATCH] =?UTF-8?q?2020-08-27=20=20Harald=20J=C3=B6rg=20=20<haj@po?=
=?UTF-8?q?steo.de>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* lisp/progmodes/cperl-mode.el (cperl-fix-line-spacing): Fix Bug#18985.
Hash keys or function names starting with a Perl keyword followed
by an underscore (as in "for_me" are no longer split into two words
by M-x indent-region.
---
lisp/progmodes/cperl-mode.el | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index c47aa2ea8c..44579cfd38 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -4876,7 +4876,7 @@ cperl-fix-line-spacing
;; }? continue
;; blah; }
(if (not
- (or (looking-at "[ \t]*\\(els\\(e\\|if\\)\\|continue\\|if\\|while\\|for\\(each\\)?\\|until\\)")
+ (or (looking-at "[ \t]*\\(els\\(e\\|if\\)\\|continue\\|if\\|while\\|for\\(each\\)?\\|unless\\|until\\)\\_>")
(setq have-brace (save-excursion (search-forward "}" ee t)))))
nil ; Do not need to do anything
;; Looking at:
@@ -4884,7 +4884,7 @@ cperl-fix-line-spacing
;; else
(if cperl-merge-trailing-else
(if (looking-at
- "[ \t]*}[ \t]*\n[ \t\n]*\\(els\\(e\\|if\\)\\|continue\\)\\>")
+ "[ \t]*}[ \t]*\n[ \t\n]*\\(els\\(e\\|if\\)\\|continue\\)\\_>")
(progn
(search-forward "}")
(setq p (point))
@@ -4892,7 +4892,7 @@ cperl-fix-line-spacing
(delete-region p (point))
(insert (make-string cperl-indent-region-fix-constructs ?\s))
(beginning-of-line)))
- (if (looking-at "[ \t]*}[ \t]*\\(els\\(e\\|if\\)\\|continue\\)\\>")
+ (if (looking-at "[ \t]*}[ \t]*\\(els\\(e\\|if\\)\\|continue\\)\\_>")
(save-excursion
(search-forward "}")
(delete-horizontal-space)
@@ -4904,7 +4904,7 @@ cperl-fix-line-spacing
(setq ret (point)))))))
;; Looking at:
;; } else
- (if (looking-at "[ \t]*}\\(\t*\\|[ \t][ \t]+\\)\\<\\(els\\(e\\|if\\)\\|continue\\)\\>")
+ (if (looking-at "[ \t]*}\\(\t*\\|[ \t][ \t]+\\)\\<\\(els\\(e\\|if\\)\\|continue\\)\\_>")
(progn
(search-forward "}")
(delete-horizontal-space)
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#18985: [PATCH] Fix indent-region for identifiers with underscores
2020-08-27 21:13 ` bug#18985: [PATCH] Fix indent-region for identifiers with underscores Harald Jörg
@ 2020-08-28 14:31 ` Lars Ingebrigtsen
0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-08-28 14:31 UTC (permalink / raw)
To: Harald Jörg; +Cc: 18985
Harald Jörg <haj@posteo.de> writes:
> Another bug report from 2014 caught my attention.
> A patch is attached.
Thanks; applied to Emacs 28.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-28 14:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 10:24 bug#18985: 24.3; cperl-mode misindents hash keys that start with an auto-quoted keyword Ævar Arnfjörð Bjarmason
2019-07-05 20:04 ` Stefan Kangas
2020-08-27 21:13 ` bug#18985: [PATCH] Fix indent-region for identifiers with underscores Harald Jörg
2020-08-28 14:31 ` 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).