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

Org babel support #1159

Closed
wants to merge 1 commit into from
Closed

Conversation

CestDiego
Copy link
Contributor

I wonder if there will be a way of configuring what packages to add to babel. Cannot think of any. Shall we just add all of the packages we can?

@cpaulik
Copy link
Contributor

cpaulik commented Apr 14, 2015

I would not enable all of those layers by default. Why not explain in the Readme how to enable them in the .spacemacs? Another way would be to introduce a variable that can be set in .spacemacs so that the users do not have to concern themselves with lazy loading issues.

@syl20bnr
Copy link
Owner

So what do we do about this ?

What is the impact of adding a bunch of language, does it slow down something ? I yes the we should enable less languages.

An approach would be to enable the languages that are used by the user and let her add additional languages in her dotfile. Ideally, the user should have just to add symbols to a variable.
Auto-loading of used languages may be confusing though.

A variable in the dotfile seems the best approach. Could be named org-enable-babel-languages and could be passed with :variables keyword when defining the used layers list.

@CestDiego
Copy link
Contributor Author

Being honest I don't see much overhead of adding a bunch of languages. Although I do think that at least the languages the user has installed should be suggested as default in org-babel.

Another approach could be that each language layer had a :variable org-babel-support but that is WAY messier.

I'm fine with the first approach, but I do not know how to implement it :( Some guidelines would be appreciated. thanks :)

@syl20bnr
Copy link
Owner

Mmmmh if a language is added, the major-mode is required right ? So the user has to enable the corresponding layer ?

@CestDiego
Copy link
Contributor Author

You can see the requirements here http://orgmode.org/worg/org-contrib/babel/languages.html.
Sometimes it's a layer, sometimes it's a program that needs to be in the path :( I think that maybe just giving instructions on how to do it in the readme would be ok.

@syl20bnr
Copy link
Owner

Indeed we go for the README solution for now.

I like the idea to enable automatically the support of babel for used layers though. It could be easily achievable by creating a function that any layer can use in its config.el file to add itself to the list of babel activated packages.
Or even in the init function of the required package.

@CestDiego
Copy link
Contributor Author

ok this works for me

On Sat, Apr 25, 2015 at 2:01 AM, Sylvain Benner notifications@github.com
wrote:

Indeed we go for the README solution for now.

I like the idea to enable automatically the support of babel for used
layers though. It could be easily achievable by creating a function that
any layer can use in its config.el file to add itself to the list of
babel activated packages.


Reply to this email directly or view it on GitHub
#1159 (comment).

@syl20bnr
Copy link
Owner

In fact to support it very cleanly we should add org in the package list of a layer and create a function <layer>/post-init-org where we activate the language.

@ghost
Copy link

ghost commented Jun 10, 2015

I'm not sure how necessary it is, in fact. The docs indicate that once an ob-xxx library was required, you should already be able to evaluate.

In my case, I can evaluate elixir even if I don't add it to org-babel-load-languagesorg-babel-load-languages`. I guess it's just an autoload feature provided by org-mode?

http://orgmode.org/manual/Languages.html

PS Sorry for the double commenting... meant to post at #1918

@CestDiego
Copy link
Contributor Author

@usharf can you SPC h d v org-babel-load-languages? elixir should be there even though you haven't setted it up, and the reason is that most ob-xxx packages automatically append to that variable when set.

@ghost
Copy link

ghost commented Jun 10, 2015

@CestDiego Not this one, I just checked and also looked at the source... but even so, no problem evaluating elixir code blocks once ob-elixir has been require, like noted.

@robbyoconnor
Copy link
Contributor

@CestDiego this is invalid -- it's against master -- should prolly close it :P

@CestDiego
Copy link
Contributor Author

oh man...The times I didn't know how to PR xD

@CestDiego CestDiego closed this Aug 27, 2015
@CestDiego CestDiego deleted the org-babel-support branch September 24, 2015 18:05
@robbyoconnor
Copy link
Contributor

Add this in a new PR <3 - I need it in my life <3

@CestDiego
Copy link
Contributor Author

I thought this was enabled by default in Spacemacs? D:

@CestDiego
Copy link
Contributor Author

I'm planning on reviving org babel. @syl20bnr Are there any more pointers to take in mind?

@syl20bnr
Copy link
Owner

syl20bnr commented Nov 5, 2015

@CestDiego Good idea, I started to use it for literate devops and I had to add some initialization stuff in my user-config, would be nice to support it out of the box.
I guess it could be automatically enabled given that org layer is used. This comment is a good pointer to start with: #1159 (comment)

@CharlesHD
Copy link
Contributor

I was wondering about that. Should we do like in that commit for every lang layer supported by babel ? 931652b
If it's the case I can PR that (a PR by layer or a global layer ?).

@d12frosted
Copy link
Contributor

Using <layer>/post-init-org is indeed good solution. Use only what is used 😸

@CharlesHD I believe it should be one PR.


I see two ways of enabling babel for supported languages. First one is to manually create post-init-org functions in all layers that support it. Second is to have a list of supported layers (languages) in org layer and just call spacemacs|use-package-add-hook for every layer in that list that is enabled.

I like second solution as it results in no code duplication. On the other hand it's breaking encapsulation a little bit. I mean, we let org layer to know about other layers. And more over - it creates post-init hook, which might sound really bad for some cases.

What do you guys think?

@cpaulik
Copy link
Contributor

cpaulik commented Jun 17, 2016

@d12frosted If we would want to centralize it shouldn't it be enough to just call (add-to-list 'org-babel-load-languages... for each enabled layer in the org config? Why is there a need to use use-package-add-hook?

@d12frosted
Copy link
Contributor

Ah. Good point, there is no need to make use-package hook. Just add to list. But yeah, only for enabled layers.

@CharlesHD
Copy link
Contributor

CharlesHD commented Jun 19, 2016

If we would want to centralize it shouldn't it be enough to just call (add-to-list 'org-babel-load-languages... for each enabled layer in the org config?

Is there a mechanism to get all current active layers ?

@d12frosted
Copy link
Contributor

@CharlesHD AFAIK there is no function to get all active layers, but you can easily fetch one using configuration-layer/get-layers-list and configuration-layer/layer-usedp - (-filter #'configuration-layer/layer-usedp (configuration-layer/get-layers-list)).

P. S. -filter is part of dash.el

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.

6 participants