reddit / emacs

How to create buffer for custom source code region (e.g for each function)?

Taaaaaooooo · 2022-11-09 06:34
Objective : Frame some areas in a source code file, with custom pattern (e.g "# - Name of Region - #"), and then having the choice to type the name of region to directly open a buffer containing only the region's inside text. Could someone puts the name of something (plugin, function) that could help for this feature ?
L-Szos · 2022-11-09 09:01
Its not exactly what youre looking for, but narrow-to-defun is somewhat similar.
papercatlol · 2022-11-09 09:15
Somewhat related things: clone-indirect-buffer + narrow-to-region (or narrow-to-defun) - you'd have to create an indirect buffer for every region, but all changes are synced both ways. edit-indirect.el - allows you to edit regions in separate buffers similar to how you edit org src blocks. Syncs on demand (edit-indirect-commit). There might be a better solution already from someone who likes the smalltalk programming experience.
bram85 · 2022-11-09 11:50
There's narrow-indirect which does the first suggestion in one go: https://github.com/emacsmirror/narrow-indirect.git
papercatlol · 2022-11-09 12:35
Oh, nice!
00-11 · 2022-11-09 16:49
Did you also submit the question here? https://emacs.stackexchange.com/q/74490 I answered there, pointing to library [Narrow Indirect](https://www.emacswiki.org/emacs/NarrowIndirect) ([`narrow-indirect.el`](https://www.emacswiki.org/emacs/download/narrow-indirect.el)), and to library [Bookmark+](https://www.emacswiki.org/emacs/BookmarkPlus) for bookmarking such cloned narrowed buffers.
Taaaaaooooo · 2022-11-10 11:23
Thank you very much, this was indeed me, thanks for sharing these libraries.