elp-revive / origami.el

A folding minor mode for Emacs
MIT License
32 stars 5 forks source link

Different parser for each on org source block? #47

Open mgraham opened 1 year ago

mgraham commented 1 year ago

I have an org file that has json documents and ruby snippets:

#begin_src js
{
  "some": "json"
}
#end_src
#begin_src ruby
def somefunction
   print "hello"
end
#end_src

I would like origami to be able to use the json parser within the js source block and the ruby parser within the ruby block.

Is that possible?

jcs090218 commented 1 year ago

Is that possible?

No, this is not possible at the moment. 😓

FYI, origami is semi-deprecated; I preferred TreeSitter base solution like ts-fold. It has everything from origami but is more accurate and faster.

mgraham commented 1 year ago

Thanks, @jcs090218 !

Using treesitter does seem to be the correct approach for folding!

I'm not using Emacs 29 yet, so I installed tree-sitter and ts-fold and gave it a try. However it looks like tree sitter doesn't like org mode with source blocks either. So I'm back to origami for now!

Eventually I would like to use folding for everything, but right now my main use case is folding large JSON responses in ob-restclient So even though origami doesn't technically work with org source blocks, I just tell it to use the c-style parser for all org files.

(use-package origami)
(require 'origami)
(add-to-list 'origami-parser-alist
             '(org-mode . origami-c-style-parser))