4

For some tasks I prefer single big files over splitting a project (say: a LaTeX report, a medium-sized python script) into separate smaller files, e.g. for easier searching and search-and-replace. However for editing it is often preferable to have separate views of different parts of a project, favoring several small files.

Is the some mode/package for emacs that allows editing parts of files as if they were a separate file, while keeping the buffer synchronized with all other views of the file? I am aware of clone-indirect-buffer, but while it achieves part of the intent, I'd prefer a method that limits the indirect buffer to a specific section of the file. Think e.g. of org-modes C-c ' but implemented with an indirect buffer. Ideally the implementation would support some syntax to define sections.

I think the LEO editor is build around roughly the concept that I want for emacs, though I never tried it (didn't work on my system).

kdb
  • 2,451

1 Answers1

3

One library that provides such behavior is Narrow Indirect (narrow-indirect.el). It gives you a different view of a portion of the buffer, or even of the whole buffer (use C-x h C-x 4 n n).

It always has the same text and text properties, but otherwise it is pretty independent. In particular, you can kill an indirect buffer without affecting its base buffer. You will likely want to kill indirect narrowed buffers rather than widening them.

You can use indirect buffers for more than you might think. You can use clones taken from portions of Dired buffers, for example, to give you useful (active) views into a directory listing. There are only a few keys/commands (such as g to update the listing) that do not work, because they depend on a view of the whole Dired buffer. Experiment, and you will no doubt find interesting new uses for indirect buffers.

See also the Emacs manual, node Indirect Buffers.

Drew
  • 2,144