1

How to fold arbitrary blocks of text?

Something like #BEGIN_SRC org .. but don't edit in another mode... using <language> 'org' doesn't really work, for example, enter on a [[link]] fails. Drawers don't seem to work except after a heading. BEGIN _EXAMPLE, or _VERSE _QUOTE all have issues. I want something like a heading with an end marker (that isn't another header).

#+BEGIN_SRC org
whatever text... edit etc the same as all other org text
but allow folding this block 
(and enter on '[[link]]' should still work)
#+END_SRC
2
  • 1
    There are several hits on Google search for folding an org-mode source code block (including ones that I have previously answered) -- have you looked at any of those previous threads to see if those answer your question? My recollection is that org-mode may also have something built-in to support this.
    – lawlist
    Commented May 5, 2016 at 19:52
  • Just in case it's useful for others: At least in recent versions of emacs (I'm runing 28.2) org-mode will fold arbitrary blocks. e.g #+BEGIN_myblock ... #+END_myblock and stuff inside the block is treated as normal org text.
    – ttb
    Commented Feb 21 at 14:40

2 Answers 2

1

The quote block will do some of what you want. You can get a quote block through the templating system -- type <q, then hit <TAB>, to make a quote block. Quote blocks are foldable and respect org's markup syntax, so links still work. They do get incredibly strange if you try to insert a header inside one, so maybe give that a miss.

1
  • 1
    #+BEGIN_QUOTE ... #+END_QUOTE ... <qTAB is a quick way to create one (I learned 2 new things there). Now I see #+BEGIN_CENTER and #+BEGIN_JUSTIFYLEFT and #+BEGIN_JUSTIFYRIGHT work too (though QUOTE seems best). This is what I wanted.
    – 9mjb
    Commented May 22, 2016 at 20:58
2

You can use vimish-fold package to achieve arbitrary code folding in any mode in Emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.