voxpupuli / puppet-mode

Edit Puppet manifests with GNU Emacs 24
https://github.com/voxpupuli/puppet-mode
GNU General Public License v3.0
90 stars 60 forks source link

puppet-align-block confused by nested block #93

Closed darkfeline closed 7 years ago

darkfeline commented 7 years ago

When puppet-align-block searches for the beginning of a hash, it gets confused by a previous nested block. With cursor on metafalica:

Starting from:

class foo {
  $x = {
    'a'=>1,
    'foo'=>{
      'apples'=>1,
    },
    'metafalica'=>1,
  }
}

Current behavior:

class foo {
  $x = {
    'a'=>1,
    'foo'=>{
      'apples' => 1,
    },
    'metafalica'=>1,
  }
}

Desired:

class foo {
  $x = {
    'a'          => 1,
    'foo'        => {
      'apples'=>1,
    },
    'metafalica' => 1,
  }
}

Actual desired behavior can be debated, whether the nested block is aligned in the same command or it would require running puppet-align-block inside the nested block.

rski commented 7 years ago

huh i could have sworn this was raised somewhere but apparently not. Anyway, i spent a long afternoon once looking into this and all I can say is this is a pain. The alignment is done using the emacs align functions which as far as I could tell could not be made to understand scopes. There doesn't seem to be an easy built-in way to fix this, hence the pain.