0
$defs = {
   "key1" => 1,       # indented correct with tab
       "key2" => 2,   # indented too much, should align with key1
       "key3" => 3,   # keeps indentation from here on
};

With regular perl-mode in Emacs 26.5 the indentation is "staggered" like above, where key2 and key3 are not aligned with key1 when tab is pressed, but should be. How to make perl-mode do that? (not cperl-mode).

  • Why do you not want to use cperl-mode? – nega Mar 20 at 0:52
  • I would have to learn it to get the same behaviour and face, which I set up some time in 1995 and have forgotten all about, because it works. – Niels Larsen Mar 20 at 7:52
  • Cool, I can understand that. I do recommend you give cperl-mode a try. Think of it as more of a superset of perl-mode. And, there's always emacs.SE to help smooth the transition. – nega Mar 20 at 17:41
1

Try setting perl-continued-statement-offset.

(setq perl-continued-statement-offset 0)

See it's documentation (via Ctrl-H v):

perl-continued-statement-offset is a variable defined in ‘perl-mode.el’.
Its value is 4

  This variable is safe as a file local variable if its value
  satisfies the predicate ‘integerp’.

Documentation:
Extra indent for lines not starting new statements.

You can customize this variable.

You'll notice its (default) value is "4"; the number of spaces your "key2" is indented. If you change this while a perl-mode buffer is active you'll have to manually re-indent the code in that buffer. Setting his may negatively change other indentation, so keep an eye out.

| improve this answer | |
  • Sure does .. gratitude. Cruisin' again, thanks. – Niels Larsen Mar 20 at 7:50
  • Great! Feel free to accept that answer. 😉 – nega Mar 20 at 17:42
  • I tried to press the up arrow, but I am one of low repute. – Niels Larsen Mar 21 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.