Skip to content
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

Add chruby support to Ruby layer #2321

Closed
wants to merge 1 commit into from
Closed

Conversation

bjeanes
Copy link
Contributor

@bjeanes bjeanes commented Jul 14, 2015

Tested locally (I use Chruby personally). I'm not sure how chruby.el fairs in other configurations as I've not used it much before. It seems closely modelled after rbenv.el.

@alindeman
Copy link
Contributor

LGTM 👍 I am currently using chruby in a private layer and it's just fine. The code is basically the same as what you have here.

@semmons99
Copy link

Any movement on getting this merged into develop @syl20bnr?

:defer t
:init (chruby)
:config (add-hook 'enh-ruby-mode-hook
(lambda () (chruby-use-corresponding)))))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the lambda expression here you can replace it by 'chruby-use-corresponding. The lambda expression (or a named function) is needed only when you have to pass arguments to the function to hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup I can change that, I was trying to be consistent with the rbenv expression directly above this.

@bjeanes
Copy link
Contributor Author

bjeanes commented Aug 30, 2015

@syl20bnr bump for the questions above so I can fix this up and have it be merged.

@nixmaniack
Copy link
Contributor

@bjeanes Take a look at documentation of use-package to understand more about :init and :config. syl20bnr already explained in brief actually, since :defer is t the package won't be loaded until ruby mode is invoked. :config is called after package is loaded. So you need to bind the hooks in :init so when you open ruby file for the first time, hooks will cause the package to autoload automagically.

One more thing to improve would be to only install/load the package when the binary is found on the system. Something like following should help in use-package
:if (executable-find "chruby")

@bjeanes
Copy link
Contributor Author

bjeanes commented Oct 28, 2015

@nixmaniack I have read those docs. My still-unanswered question is that rbenv directly above is structured exactly like my addition. What makes chruby different here, especially since the chruby script is a minimal fork of the rbenv one.

One more thing to improve would be to only install/load the package when the binary is found on the system. Something like following should help in use-package: :if (executable-find "chruby")

That does sound good. But, likewise, this is not being done in the case of the other ruby managers. Why not consistency first?

@nixmaniack
Copy link
Contributor

@bjeanes That as well needs to be fixed then. I'm not sure why it may have skipped from the review but one reason I see is that the use-package v2.0 has some major changes with respect :init and :config and it may have made much sense at that time but it breaks with current version. So any new code will be reviewed from that point of view. Hope I make sense. 😄

Right now we're aiming for correctness rather than consistency but yes we should definitely fix the other ruby-version-managers sooner.

@bjeanes
Copy link
Contributor Author

bjeanes commented Oct 29, 2015

@nixmaniack OK fair enough. I'll try to have a look at this again in a few days

@StreakyCobra
Copy link
Contributor

#4065 Is about chruby too, so if one get merged, the other should be closed.

@syl20bnr
Copy link
Owner

syl20bnr commented Dec 6, 2015

Thank you !
Sorry I forgot this PR.
I made some changes to it and fixed rbenv and rvm configuration accordingly, the documentation can be found here: https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Blang/ruby#ruby-version-management
Cherry-picked into develop branch, you can safely delete your branch.

@syl20bnr syl20bnr closed this Dec 6, 2015
@bjeanes bjeanes deleted the chruby branch December 6, 2015 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants