Macaulay2 / M2-emacs

Macaulay2 emacs files
GNU General Public License v3.0
5 stars 3 forks source link

Newline and indent updates #18

Closed d-torrance closed 3 years ago

d-torrance commented 3 years ago

It is currently bound to M2-newline-and-indent, which calls newline and then indents. However, newline by itself already indents the next line (provided that the user has electric-indent-mode enabled, which is the default), and so calling this specialized function is unnecessary. Furthermore, C-m is already bound to newline in global-map, so there's no reason to bind it again.

Also, if the user has turned off electric-indent-mode, then C-m will have the desired behavior -- no electric indents.

d-torrance commented 3 years ago

Hrm, this isn't so simple after all. newline doesn't properly indent past the first level:

Using m2-newline-and-indent

(
    (
    (
        (

Using newline

(
    (
    (
    (
d-torrance commented 3 years ago

Getting this to work required changing the behavior of M2-electric-indent. From the corresponding commit message:

We now always tab electrically, even when not at the beginning of a line or on a blank line. This has several advantages:

  • The function is now idempotent.
  • The "newline" function (when electric-indent-mode is on, the default) will do the correct thing, so we can deprecate "M2-newline-and-indent".
  • The new behavior is consistent with other common major modes.

We also always delete leading whitespace and re-indent to clean up tabs and spaces.

These changes make M2-newline-and-indent obsolete.

DanGrayson commented 3 years ago

Thanks, it seems to work.