ds26gte / scmindent

87 stars 12 forks source link

Indenting forms nested inside FLET, MACROLET, and LABELS #8

Open iamFIREcracker opened 4 years ago

iamFIREcracker commented 4 years ago

I noticed lispindent is implicitly assigning a LIN value of 0 to FLET forms, while I would have expected a 1 instead; now, I understand that there is no right or wrong here, but I never seen FLET, MACROLET, or LABELS forms getting indented that way, so I thought about flagging this.

For example, let's take the following snippet:

(flet ((hello ()
         (format t "Hello, World!~&")))
  (hello))

Pass it to lispindent and you will get back:

(flet ((hello ()
              (format t "Hello, World!~&")))
  (hello))

Anyway, by adding the current word to LPAREN and inspecting the call stack to figure out what the surrounding form is (see: https://github.com/iamFIREcracker/scmindent/commit/4902a57cee74351ece72cc39191c4218d7b09935), I managed to fix the indentation of these forms; however, even though it all seems to be working fine, I don't think I quite like the fact that the solution relies on a new variable, *labels-keywords*, that users have no control over, but could not figure out a nice way to reuse the .lispwords.

Let me know you your thoughts.