1

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 :)

Lucas Lam
  • 21
  • 4
  • Thanks for reporting this. For the first line with (for example the last `use constant CR => qw( ...`, if the cursor is at the first line with 87800, when you press `` `cperl-mode` will be checking the indent of the line above as seen on [line #3092](https://github.com/jrockway/cperl-mode/blob/master/cperl-mode.el#L3092) of the source code. Note that `(current-column)` on this line will give the indent position on the line above (the position after the `(` in `qw(` due to the `goto` at line 3089. I will look further to try to understand why it does this... – Håkon Hægland Nov 15 '19 at 07:02
  • ... I also agree with you that the indent you suggest looks much better :) – Håkon Hægland Nov 15 '19 at 07:04
  • I have added a [pull request](https://github.com/jrockway/cperl-mode/pull/54), can you check if it works for you? – Håkon Hægland Nov 16 '19 at 21:25

2 Answers2

1

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). E.g.:

my @tutu = qw[
    tata
    titi
    ];
Stefan
  • 27,908
  • 4
  • 53
  • 82
  • Thanks for this commit, but this is not what I am seeking. I personally do not use `perl-mode` since it is fairly outclassed by `cperl-mode` these days.Isn't the fix the same for `perl-mode` and `cperl-mode` ? – Lucas Lam Nov 15 '19 at 21:44
  • @LucasLam: The code for `cperl-mode` is quite different so "the same fix" may be possible, but only if you consider a very loose definition of "same". I can't resist mentioning that I find your your "these days" very perplexing: `perl-mode` used to be lightyears behind `cperl-mode`, but AFAIK the distance has tended to shrink rather than increase over the years. – Stefan Nov 15 '19 at 22:29
1

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

Lucas Lam
  • 21
  • 4