Skip to content

Add a SMIE rule function for "def". Fixes #38. #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 5, 2014

Conversation

mattdeboard
Copy link
Contributor

This function now explicitly sets the indentation level of lines beginning with "def" to 2. Formerly, this token returned nil (the default, because there was no matching pattern in elixir-smie-rules), which caused SMIE to call smie-indent-after-keyword to calculate the indentation. This function was returning the incorrect value which was causing the inappropriate alignment to the ..

I have been working on this for quite a long time, many months. I was very undisciplined about staying focused on just #38. I hate big kludgy pull requests, but due to the fact I had to learn more about BNF grammars & emacs lisp than I ever thought I would this bug fix took on a life of its own. Half out of necessity.

In addition to fixing that, this PR also:

  1. Straightens out all tests. If a feature is broken in elixir-mode, and the test fails because of that test, I marked it as an expected failure. I added a comment to the top of the indentation tests module explaining my intent. This made running the tests far less confusing. Instead of a mix of "supposed to pass and does", "supposed to fail and does", "supposed to pass but fails", and "supposed to fail but passes", now only the first two categories exist.

  2. Broke up very long lines into <=79 columns, as much as I could. When learning how all this code works, readability was very important. Usually this meant breaking up compound conditionals and so forth into a line-per-condition.

  3. Fixed an issue with syntax highlighting for lines like:

    use Foo.Bar

    Previously, the .Bar did not get colored correctly. Now it does.

  4. This one is probably the sloppiest transgression: I put @tomterl's fix for Avoid indentation errors after 'end'. #41 in here as well, and added tests to boot. This is the only one where I threw in a bug fix for its own sake. Sorry.

  5. Fixed a deprecated keyword, changing function to def here. This was done while I was trying to get all the tests to get to a predictable state. A bug fix, but strictly in the interest of getting tests to pass with correct Elixir code in the test case.

There is a lot of change in here. Please let me know what I can do to help move the ball forward on this PR.

Thanks

Matt

@mattdeboard
Copy link
Contributor Author

Fixes #41

@dinedal
Copy link

dinedal commented Jun 30, 2014

👍 fixed my indentation issues. Thanks!

@mattdeboard
Copy link
Contributor Author

Great

`indents-last-commented-line' was passing unexpectedly. The example in
the test differs from the example given by
elixir-editors#27. The latter does
cause the expected failure in the test.
This function now explicitly sets the indentation level of lines
beginning with "def" to 2. Formerly, this token returned `nil` (the
default, because there was no matching pattern in `elixir-smie-rules`),
which caused SMIE to call `smie-indent-after-keyword` to calculate the
indentation. This function was returning the incorrect value which was
causing the inappropriate alignment to the `.`.
mattdeboard added a commit that referenced this pull request Jul 5, 2014
Add a SMIE rule function for "def". Fixes #38 and #41
@mattdeboard mattdeboard merged commit 0eb9724 into elixir-editors:master Jul 5, 2014
@mattdeboard mattdeboard deleted the fix-use-indentation branch July 5, 2014 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants