Whats the best way to do achieve something like code folding, or the type of cycling that org-mode uses. What would be the best solution in elisp to create this type of behavior?
EDIT: I'm sorry I was not clear. I want to program something in elisp that does things very similar to code folding, or actually most like org-mode with the hierarchy that can be expanded. I am wondering the best way to achieve this affect. I think I have heard emacs overlays are a good solution, but I dont know.
As far as folding I just use the builtin set-selective-display
EDIT NUMBER 2:
Thanks for the answers but I think I am asking the wrong question so let me try to be more clear on what I am trying to do. I would like to create the following
When you put your point on a function and call this elisp function it will put the function definition from wherever it is (I am thinking of just using find-tag for this) and unfold it in the current buffer. The idea is if you have to jump to a different buffer to read the function definition I feel like its a context switch to another file. So I would like it to behave like code folding only it pulls in code external from the buffer. This presents some problems as it can not acutally paste the code into the buffer or if someone saves it it will save the pulled in code. So I am wondering if there is a way to create an area inside a buffer that is also not part of the buffer. I think that makes sense.
Again sorry for not being very clear before.