in reply to Re^6: How would you indent this?
in thread How would you indent this?

> Is it that it is emacs?
The OP is using a function which is not standard indenting, hitting TAB is.°

That's an oversimplification.

  1. <TAB> is equivalent to M-x cperl-indent-line if (as per default) tab-always-indent is set to a true value. It indents the current line.
  2. M-x cperl-indent-exp indents the current expression and reformats if (as per default) cperl-indent-region-fix-constructs is set to 1.
  3. M-x cperl-indent-region indents the current region and reformats if (as per default) cperl-indent-region-fix-constructs is set to 1.
  4. <RET> is, per default, equivalent to M-x newline which, also per default, indents the current and the new (empty) line.

None of these functions are more standard than the others, and with the current settings there's rarely the need to use <TAB> at all.

°) or activating auto-indent, which seems to be default now.

That's electric-indent-mode, which isn't actually overdocumented right now. One of the consequences of this mode is that the PBP recommendation to remap <RET> to M-x newline-and-indent is outdated and should no longer be used. Also, in Python buffers, where indentation can't be inferred from braces and such, Electric Indent mode is switched off.

Replies are listed 'Best First'.
Re^8: How would you indent this?
by LanX (Saint) on Mar 19, 2021 at 14:20 UTC
    > <RET> ... also per default, indents the current and the new (empty) line.

    do you happen to know since which version?

    It would be nice if the GNU folks published the emacs info with a version number.

    > That's electric-indent-mode, which isn't actually overdocumented right now

    I welcome freeing up TAB for completion, but this makes my setups even more complicated if they are supposed to work with different emacs versions.

    Which is why I'm still stuck on 24 btw :)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

      It would be nice if the GNU folks published the emacs info with a version number.

      Actually, they do, sort of, since Emacs 27:

      electric-indent-mode is an interactive compiled Lisp function in ‘electric.el’. (electric-indent-mode &optional ARG) Probably introduced at or before Emacs version 24.1. ...

      Note, however, that Probably indicates that this is based on guesswork (grepping NEWS files). We had cases where it was off by two versions, and the Emacs maintainers made clear that it is extremely unlikely that they'll spend the effort to make that exact.