in reply to Re: How would you indent this?
in thread How would you indent this?
Generally speaking I don't indent code, so I use mark-whole-buffer and then indent-region. In Go code I actually use
(add-hook 'before-save-hook #'gofmt-before-save)
instead so the whole buffer is formatted for me.
I haven't been able to do that with Perl because of numerous oddities in cperl-mode. Probably the most annoying one is that it turns
};
into
} ;
So, if you don't need CPerl mode to reformat your code like this, then I suggest you just turn off that variable as a workaround (and, if you like, write a bug report).
Thanks. I have reported bugs in cperl-mode in the past but things don't seem to have improved, and in at least one case things have got much worse, the case where it immediately throws an error about unbalanced parentheses whenever one presses the m or s keys. That used to be annoying when it was just an error message, but with recent Emacs it also scrolls the window, so in cperl-mode each time I press "m" or "s" the Emacs window scrolls in a random direction. It is truly exhausting when reading a piece of code in one place and then writing in another, and then the Emacs suddenly scrolls due to typing my or sub
What I'm trying to do is to set up my own version of cperl-mode with better defaults and fewer bugs. In the case of this hash reference case, I wasn't sure what sort of indentation to use, although I was pretty sure I was going to use something other than the default behaviour, so I thought I'd ask here what people thought. It's been very interesting to get feedback from everyone, so thank you to all participants.
By the way: Emacs can help with aligning the keys as suggested by ikegami and GrandFather, unrelated to CPerl mode. It is hardly worth the effort for four lines, though: Mark the assignment as a region, and then
align-regexp<RET>name<RET> align-regexp<RET>class<RET>
Thank you, that is extremely useful to know about. This page has more.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: How would you indent this?
by haj (Vicar) on Mar 19, 2021 at 07:59 UTC | |
by no longer just digit (Beadle) on Mar 19, 2021 at 10:38 UTC | |
by haj (Vicar) on Mar 19, 2021 at 12:15 UTC | |
by no longer just digit (Beadle) on Mar 19, 2021 at 22:03 UTC | |
by haj (Vicar) on Mar 20, 2021 at 00:17 UTC | |
|
Re^3: How would you indent this?
by haj (Vicar) on Apr 04, 2021 at 23:43 UTC |