emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Buffers with buffers (transclusion)


From: Vladimir Kazanov
Subject: Re: Buffers with buffers (transclusion)
Date: Fri, 18 Oct 2024 10:25:03 +0100

Hi Eli,

On Thu, 17 Oct 2024 at 18:18, Eli Zaretskii <eliz@gnu.org> wrote:
> What bothers me in this entire discussion is that people are
> discussing implementation without first describing the use cases,
> requirements, and expectations in enough detail to think about both
> the need/importance and possible implementations.

My bad, I should have expanded on the use cases further. So let's come
back to motivating examples.

People have been trying to implement something like we want here for
quite some time. When I wrote that little mode
(https://github.com/vkazanov/chunk-edit), I wasn't aware of all the
previous attempts so it makes sense to cover these in one email.

So let's work from questions. What use could there be for a
buffers-in-buffers function? Or at least an easy way to sync
text/properties between buffers?

Here are some examples of buffer synchronisation as a user-visible feature:

0. chunk-edit.el (https://github.com/vkazanov/chunk-edit) - my humble
prototype that led to this discussion. I know that windows cover this
feature but I also want to point out that people find it inconvenient
when there are more than 3-4 windows to manage.

1. org-transclusion (https://github.com/nobiot/org-transclusion/) is a
popular (1000 stars on Github) org-mode expansion that makes it
possible to mix and match within a single org-mode file chunks of
other org-mode files. It's like chunk-edit.el but focuses on org-mode
only. It provides a live buffer sync feature.

2. Interestingly, subr.el (part of Emacs) has a function called
(text-clone-create) that uses overlays to sync text between regions of
a single buffer. I couldn't find any uses within Emacs, probably
because lack of cross buffer sync limits its usefulness.
org-transclusion contains an expanded version that does support
cross-buffer sync.

Other examples use buffer synchronisation indirectly, as an underlying
mechanism to provide higher level features:

3. In org-mode there is a popular feature called source blocks. Code
within those source blocks needs fontification specific to the
language used in the block. To make fontification possible, org-mode
creates an indirect buffer with the text in the block, enables a
language major mode and copies back relevant properties.

4. polymode (https://github.com/polymode/polymode), a popular
multimode package, famously uses a similar approach by using indirect
buffers and synchronizing both state and *behaviour* back to the host
buffer.

There were multiple discussions in emacs-devel and org-mode mailing
lists around various forms of transclusion that could be helped by
buffers-in-buffers or advanced buffer synchronization mechanisms:

5. A proposal for buffers-in-buffers made by  Dmitrii Korobeinikov
(https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00141.html).
The author sees this as a way to expand org-mode and computational
notebooks.

6. A brief discussion of something like chunk-edit.el
(https://lists.gnu.org/archive/html/emacs-devel/2018-07/msg00863.html).

7. org-mode transclusion proposal by John Kitchin
(https://lists.gnu.org/archive/html/emacs-orgmode/2016-12/msg00183.html),
which probably lead to creation of the org-transclusion package listed
above.

8. Many other links in a bookmark collection created by Adam Porter
(https://github.com/alphapapa/transclusion-in-emacs). Thanks Adam,
btw, this is an amazing doc!

There are many more examples accumulated over the years which might
benefit from cross-buffer state synchronization support, be it
buffers-in-buffers, or some kind of text/property sync.

Hope this helps with understanding where I come from with this discussion.

For me personally, this gives enough material for inspiration and I am
more than happy to provide a prototype implementation for further
discussion.


-- 
Regards,

Vladimir Kazanov



reply via email to

[Prev in Thread] Current Thread [Next in Thread]