简体   繁体   中英

Emacs indent issue with qw keyword

I have Emacs 26.3 running on windows with cperl-mode 6.2 from the last commit of the cperl-mode repository of jrockway.

I have the following configuration for Emacs:

(setq-default tab-width 4)
(setq-default indent-tabs-mode nil)
(setq cperl-indent-level 4)
(setq cperl-indent-parens-as-block t)
(setq cperl-close-paren-offset -4)
(setq cperl-continued-statement-offset 4)
(setq cperl-tab-always-indent t)
(setq cperl-fix-hanging-brace-when-indent t)
(setq cperl-indent-subs-specially nil)

When I initialize an array with qw(), it gives me the following:

my @toto = qw(
                 toto
                 tutu
         );

my @tutu = qw[
                 tata
                 titi
         ];

use constant CR => qw(
                         87800
                         76400
                         80200
                         81000
                 );

This is not my guideline since I am following the 80 character rule... I do not know if it's a normal behavior or a bug. I have tried multiple configuration, looked at customize-group of cperl, but I can't find a way to make what I want. Here is what I would like to do:

my @toto = qw(
    toto
    tutu
);

my @tutu = qw[
    tata
    titi
];

use constant CR => qw(
    87800
    76400
    80200
    81000
);

Anyone has an idea or an Elisp hack to do that?

Thank you for your help:)

I just pushed a patch to Emacs's master branch to fix indentation of qw in perl-mode .
It now works almost like what you want (except for the closing paren). Eg:

my @tutu = qw[
    tata
    titi
    ];

Solved by https://github.com/jrockway/cperl-mode/pull/54 from @HåkonHægland.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM