Open alphapapa opened 8 years ago
Thanks! It looks nice. I'm thinking about adding some default settings to different major modes. This might be a good use in org-mode. I'll give it a shot later today.
Cool. BTW, is your blog on Planet Emacsen? I just noticed it from your GitHub profile, but I don't think I've seen it on PE before.
No. It's not. I'm not good at writing articles :sob: Sometimes I write some Emacs stuffs on my blog, but I'm not aware whether people read it or not.
I must respectfully disagree. For example, this article is as good as anything else on Planet Emacsen: http://cute-jumper.github.io/emacs/2015/12/18/quick-summary-a-few-emacs-packages-ive-written You should definitely submit your blog for inclusion, at least for the Emacs-tagged posts. :)
Thanks for the nice words! I would consider adding it to Planet Emacsen next time I write something about Emacs.
Hi,
I've just pushed a quick fix to add org block support. Could you give some feedback if you have time to try out? To use it
(add-hook 'org-mode-hook 'embrace-org-mode-hook)
The key for the block is l
. If you bind C-, to embrace-commander
, you can use C-, c l l inside a org block to change the block type.
I'm closing this now. If any problems pop up, feel free to reopen this.
Hey, I'm sorry, I missed this! I just tried it and it works great!
One question, when I change to a src
block, it only offers emacs-lisp
as the language. Is this intended?
Hey, I'm sorry, I missed this!
No problem at all!
it only offers emacs-lisp as the language. Is this intended?
No. We use org-babel-load-languages
to determine the available languages. Have you checked the value of the org-babel-load-languages
?
Ah, yes, that's the issue. The problem is, users have to add languages to that manually, so it won't be an accurate representation of the language modes available in Emacs. And some language modes aren't suitable for Babel anyway (e.g. HTML).
I'm not aware of a good and reliable way to find out all the available major modes for programming languages. So I have to assume if users want to use BEGIN_SRC
, they would add the corresponding languages to that list (and I remember that's what the Org manual asks people to do, right?), and even if it is not in the list, you can just ignore the completing suggestions and enter a language identifier directly. Do you have any good solution to this problem?
And you remind me of the HTML, which has a different syntax for exporting after Org 9.0. I may need to update the code as well.
You're right, there's not a really clean solution. The best I can find at the moment is some combination of auto-mode-alist
and interpreter-mode-alist
, with the -mode
chopped off each symbol. That would leave some inappropriate modes in the list, but you could leave those in and it wouldn't be a big deal, or you could blacklist the few non-source-code modes and probably have fewer hardcoded modes than if you whitelisted the ones you want. Just an idea. :)
The best I can get right now is to extract information from the custom-type
of org-babel-load-languages
:
(mapcar (lambda (x) (car (last x)))
(cdr (plist-get
(cdr (get 'org-babel-load-languages 'custom-type))
:key-type)))
This should include all the languages that org-babel
supports.
Right, but source blocks can be used for languages that org-babel
doesn't support, i.e. they aren't always intended to be executed with Babel. :)
Are there many languages that can't be "executed", like HTML? If not too much, we could just maintain a list and allow users to customize that variable.
I don't have any numbers, but I'm pretty sure that there are far more language-specific major modes in "Emacsland" than languages supported by Babel. That's why I'd suggest using something like auto-mode-alist
and chopping the -mode
off each symbol. It won't be perfect, but I think it might be something like 70-80% accurate, and that'd be far better than only offering the languages that users have manually added to org-babel-load-languages
. For example, for me that is approximately one, elisp; I occasionally execute Python in Babel, and specifically enable it in a certain Org file. Other than that, my use of Org source blocks is not for Babel.
Just some ideas. I'm not trying to tell you what to do with your package. :)
I'm not trying to tell you what to do with your package
No offense taken. :) Personally, I almost always use src
blocks with Babel. That's why I'm wondering what other useful cases there will be.
I think the src
blocks are mainly used for programming languages, which are supposed to be executed. The extracted custom-type
values contain 44 languages that Babel currently supports, which should cover most common use cases (hopefully). But as you said, HTML could be an example that is not intended to be used for Babel. The problem of using auto-mode-alist
is that it may contain too many major modes that are not related to programming languages, and that makes me hesitant to take the approach.
Are you saying that the non-programming use cases could also be very common in src
blocks? I'm assuming the opposite, so adding things like HTML to a customizable variable by default and letting users add their special "languages" is the best compromise I could think of right now.
Are you saying that the non-programming use cases could also be very common in src blocks?
I think that is fairly common, yes. For example, non-executable formats can be shown in source blocks, like INI, YAML, JSON, etc, all of which have Emacs major modes. And while many types of languages can be executed in Babel, not all of them are generally suitable for that, e.g. C, Rust, etc., and I doubt many users would have languages like that in their Babel load list.
Hmm... In my Emacs, it has over 300 major modes, which seems too many. I guess I'll just combine auto-mode-alist
and the custom tags of org-babel-load-languages
. Should be able to cover most common cases.
Yeah, that is a lot, and it seems like way too many. I could live with it, using Helm for completion, but it probably wouldn't be a good default.
Combining org-bable-load-languages
and auto-mode-alist
produces 134 results in my Emacs. I guess it should be enough in most cases. I've pushed the changes and you could try it out. :-)
Thanks, I'll give it a try soon. :)
Hi there,
Just saw your post on /r/emacs, and this looks great! Can't wait to try it.
I have an idea: I have this code which I use to enclose regions in Org blocks and change Org block types, and it would seem to go very well with
embrace
. Maybe you'd like to integrate it? I can imagine a binding likeC-, a o
to enclose a region in an Org block...Here's the code, feel free to use however you like. :)