As title self-explains, I would like to show multiple regions in different places.

narrow-to-region could be a possible solution, but as documentation indicated, only one region from begin to end could be narrowed. Any thoughts?

  • Not with narrowing, no; but multiple regions of text could be made invisible. Is that equally good? – phils Sep 1 '20 at 11:10
  • Right, any more information? – Leu_Grady Sep 1 '20 at 11:28

You can hide multiple regions, or you can have separate indirect buffers for them (one per narrowing).

  1. If you want to hide multiple regions, e.g. make them invisible, you can use libraries zones.el (code)and isearch-prop.el (code).

    A set of zones is a set of regions, i.e., multiple regions.

    You can make a set of zones or its complement (the set of anti-zones) invisible, so that you do not see it at all, including while searching.

    The commands for this are isearchp-make-zones-invisible, isearchp-make-anti-zones-invisible, isearchp-toggle-zones-invisible, isearchp-toggle-anti-zones-invisible, and isearchp-toggle-zone/anti-zone-visibility.

    (You can do many more things with a set of zones, besides showing/hiding it or its complement.)

  2. If you want to have multiple different buffers, each corresponding to a different narrowing of some base buffer, then library narrow-indirect.el (code) can help.

    It lets you create an indirect buffer that's a clone of the current buffer and that is narrowed to a particular portion of it.

    Such an indirect buffer 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.

    See the Emacs manual, node Indirect Buffers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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