├── README.org
└── index.html
/README.org:
--------------------------------------------------------------------------------
1 | #+TITLE: Transclusion in Emacs
2 |
3 | This file exists to gather resources related to implementing transclusion in Emacs.
4 |
5 | The topic frequently reappears in discussions on Reddit, the mailing lists, etc, and usually only a few of the existing resources are mentioned. It's time to gather them in one place.
6 |
7 | Please send additions as pull requests. When adding a resource, please add a summary as of the date it's added.
8 |
9 | * Contents
10 | :PROPERTIES:
11 | :TOC: :include siblings :depth 2 :ignore (this)
12 | :END:
13 | :CONTENTS:
14 | - [[#discussions][Discussions]]
15 | - [[#bug-reports--feature-requests][Bug reports / Feature requests]]
16 | - [[#mailing-lists][Mailing lists]]
17 | - [[#reddit][Reddit]]
18 | - [[#stackexchange][StackExchange]]
19 | - [[#packages][Packages]]
20 | :END:
21 |
22 | * Discussions
23 | :PROPERTIES:
24 | :CUSTOM_ID: discussions
25 | :END:
26 |
27 | ** Bug reports / Feature requests
28 | :PROPERTIES:
29 | :CUSTOM_ID: bug-reports--feature-requests
30 | :END:
31 |
32 | *** [[https://debbugs.gnu.org/cgi/bugreport.cgi?bug=35419][#35419 - {Proposal} Buffer Lenses and the Case of Org-Mode (also, Jupyter) - GNU bug report logs]]
33 |
34 | [2019-04-25 Thu] Dmitrii Korobeinikov's report is extensive. The discussion on the report continues into April of 2020.
35 |
36 | #+BEGIN_QUOTE
37 | *SUMMARY* /Buffer lens/ is an object inside a buffer which provides that
38 | buffer the lines to display and which is linked to another buffer (from
39 | which it can take and process data), while mapping the input back to that
40 | linked buffer. /Composite lens/ is the extension of this idea to interface
41 | any sources of data (for which text interface is possible). Some Org-mode
42 | problems are addressed, particularly those concerning source block editing
43 | and viewing, syntax checking, completion and reference expansion.
44 |
45 | This is a proposal for /lenses/. Hereby, I outline the general idea, the
46 | problems it solves, the features it introduces and its use cases.
47 | #+END_QUOTE
48 |
49 | See also [[https://www.reddit.com/r/emacs/comments/fu91nf/35419_proposal_buffer_lenses_and_the_case_of/?][Reddit discussion of the report]] from 2020, in which Ihor Radchenko mentions:
50 |
51 | #+BEGIN_QUOTE
52 | Here is my work-in-progress on the subject: https://github.com/yantar92/mirror-text. I have little time to work on it in near future, but hope the ideas and links could be useful.
53 | #+END_QUOTE
54 |
55 | ** Mailing lists
56 | :PROPERTIES:
57 | :CUSTOM_ID: mailing-lists
58 | :END:
59 |
60 | *** emacs-devel
61 |
62 | **** [[https://lists.gnu.org/archive/html/emacs-devel/2020-04/msg00141.html][Request for pointers and advice: displaying several buffers inside a single window]]
63 |
64 | [2020-04-03 Fri] Dmitrii Korobeinikov asks:
65 |
66 | #+BEGIN_QUOTE
67 | I want to explore the feasibility of displaying two (indirect) buffers
68 | inside a single window, one after another. Each buffer has to look
69 | like it's rendered in its own mode. For the starters, each buffer can
70 | start on its own new line in the window. No interaction w/ text is
71 | required for now.
72 |
73 | I have been entertaining the idea since my proposal for lenses [1],
74 | and now that I have some desire to get hacking a little, I want to see
75 | if I can get onto this first ladder step to the goal. What concerns me
76 | now is how to approach the problem. So, I come here to ask for your
77 | advice and comments. You know, "it's dangerous to go alone, take
78 | this!" sort of deal.
79 |
80 | I guess I would first have to learn how the renderer functions. Any
81 | good resources on that besides the source code?
82 |
83 | Eventually, I would have to explore beyond the renderer and get to
84 | play with the data structures, so I can do the interaction w/ text
85 | possible. But that doesn't concern me all that much until I get to
86 | actually draw some buffers together.
87 | #+END_QUOTE
88 |
89 | The discussion is extensive, including replies from Eli Zaretskii and Ihor Radchenko, and mentions modifying =xdisp.c=, the buffer data structure, associated functions, etc.
90 |
91 | **** [[https://lists.gnu.org/archive/html/emacs-devel/2018-07/msg00863.html][{Feature Discuss} Nested buffer]]
92 |
93 | [2018-07-23 Mon] fei xiaobo asks:
94 |
95 | #+BEGIN_QUOTE
96 | I am building a plan to implement *Nested buffer* in Emacs recently. Is it a good ideal?
97 |
98 | Nested buffer what I mean here is the sub-buffers which embedded in a host buffer.
99 |
100 | + Nested/Embed buffer's content is linked to an arbitrary buffer.
101 | + Host buffer's content consists of the content of all the nested buffers.
102 |
103 | If having this, we could embed multiple buffers' content into a host buffer to get one virtual buffer. And, after updating the nested buffer's content, the virtual host buffer's content is updated too. I think it will be helpful for many special plugins.
104 |
105 | Appreciated any comments or suggestion.
106 | #+END_QUOTE
107 |
108 | Includes responses by Stefan Monnier and Eli Zaretskii.
109 |
110 | *** org-mode
111 |
112 | **** [[https://lists.gnu.org/archive/html/emacs-orgmode/2016-12/msg00183.html][{O} transcluding some org-elements in multiple places]]
113 |
114 | [2016-12-09 Fri] John Kitchin asks:
115 |
116 | #+BEGIN_QUOTE
117 | I have an idea for how I could transclude "copies" or links to
118 | org-elements in multiple places and keep them up to date. A prototypical
119 | example of this is I have a set of org-contacts in one place, and I want
120 | to create a new list of people for a committee in a new place made of
121 | "copies" of the contact headlines. But I do not really want to duplicate
122 | the headlines, and if I modify one, I want it reflected in the other
123 | places. I do not want just links to those contacts, because then I can
124 | not do things with org-map-entries, and other org-machinery which needs
125 | the actual headlines/properties present. Another example might be I want
126 | a table in two places, but the contents of them should stay
127 | synchronized, ditto for a code block.
128 |
129 | This idea was inspired by https://github.com/gregdetre/emacs-freex.
130 |
131 | The idea starts with creating (wait for it...) a new link ;) In a
132 | document where I want to transclude a headline, I would enter something like:
133 |
134 | [[transclude:some-file.org::*headline title]]
135 |
136 | Then, I would rely on the font-lock system to replace that link with the
137 | headline and its contents (via the :activate-func link property), and to
138 | put an overlay on it with a bunch of useful properties, including
139 | modification hooks that would update the source if I change the the
140 | element in this document, and some visual indication that it is
141 | transcluded (e.g. light gray background/tooltip).
142 |
143 | I would create a kill-buffer hook function that would replace that
144 | transcluded content with the original link. A focus-in hook function
145 | would make sure the transcluded content is updated when you enter the
146 | frame. So when the file is not open, there is just a transclude link
147 | indicating what should be put there, and when it is open, the overlay
148 | modification hooks and focus hook should ensure everything stays
149 | synchronized (as long as external processes are not modifying the
150 | contents).
151 |
152 | It seems like this could work well for headlines, and named tables, src
153 | blocks, and probably any other element that can be addressed by a
154 | name/ID.
155 | #+END_QUOTE
156 |
157 | ** Reddit
158 | :PROPERTIES:
159 | :CUSTOM_ID: reddit
160 | :END:
161 |
162 | *** [[https://www.reddit.com/r/emacs/comments/10gc9u/can_i_have_multiple_parts_of_buffers_in_one_super/][Can I have multiple parts of buffers in one super buffer? : emacs]]
163 |
164 | *** [[https://www.reddit.com/r/emacs/comments/flxqei/cloningmirroring_a_region_to_some_other_location/][Cloning/mirroring a region to some other location : emacs]]
165 |
166 | [2020-03-20 Fri] Protesilaos Stavros comments:
167 |
168 | #+BEGIN_QUOTE
169 | Good to know! The Emacs manual also has a chapter on "accumulating text". Excerpt:
170 |
171 | - ‘M-x append-to-buffer’ :: Append region to the contents of a specified buffer.
172 | - ‘M-x prepend-to-buffer’ :: Prepend region to the contents of a specified buffer.
173 | - ‘M-x copy-to-buffer’ :: Copy region into a specified buffer, deleting that buffer’s old contents.
174 | - ‘M-x insert-buffer’ :: Insert the contents of a specified buffer into current buffer at point.
175 | - ‘M-x append-to-file’ :: Append region to the contents of a specified file, at the end.
176 | #+END_QUOTE
177 |
178 | *** [[https://www.reddit.com/r/emacs/comments/j6k2j8/orgmode_transclusionblockreference_prototype/][Org-mode Transclusion/Block-reference Prototype : emacs]] :video:demo:prototype:
179 | :PROPERTIES:
180 | :ID: 7bd62eda-5e00-42f2-9284-d96ff3eaa197
181 | :END:
182 |
183 | [2020-10-07 Wed 10:55] Discussion of this video demo posted by Noboru Nobiot: [[https://youtu.be/Wjk-otO2xrI][Transclusion / Block Reference with Emacs (Org Mode) - Prototype - YouTube]]
184 |
185 | ** StackExchange
186 | :PROPERTIES:
187 | :CUSTOM_ID: stackexchange
188 | :END:
189 |
190 | *** [[https://stackoverflow.com/questions/15328515/iso-transclusion-in-emacs-org-mode][include - ISO transclusion in emacs org-mode? - Stack Overflow]]
191 |
192 | [2013-03-10 Sun]
193 |
194 | #+BEGIN_QUOTE
195 | Q: is there any way to do transclusion in emacs org-mode?
196 |
197 | By "transclusion", I mean stuff like, at some point in fileA.org and fileB.org, "including" fileInc.org - and having the tree from fileInc.org appear in both places. Actually appear, not just be linked to. (Possibly with conditional inclusion, transformation, e.g. nesting depth (number of ***s)).
198 |
199 | I know about #setupfile, but that seems only to work for modes, not real text.
200 |
201 | I know about http://orgmode.org/manual/Include-files.html, but AFAIK they only work at export time.
202 |
203 | I am looking for something that works in a normal emacs org-mode buffer. (Actually, something that worked in non-org-mode buffers might be nice.)
204 |
205 | I have boiler plate that I want to include in multiple files.
206 |
207 | Does something like this exist?
208 | #+END_QUOTE
209 |
210 | [[https://stackoverflow.com/users/1617649/rob][Rob]] replies with an example of a simple Org dynamic block that provides read-only transclusion:
211 |
212 | #+BEGIN_QUOTE markdown
213 | Hmm... I don't think anything like this exists, but it was easy enough to write a dynamic block to do this. The following elisp works for me:
214 |
215 | (defun org-dblock-write:transclusion (params)
216 | (progn
217 | (with-temp-buffer
218 | (insert-file-contents (plist-get params :filename))
219 | (let ((range-start (or (plist-get params :min) (line-number-at-pos (point-min))))
220 | (range-end (or (plist-get params :max) (line-number-at-pos (point-max)))))
221 | (copy-region-as-kill (line-beginning-position range-start)
222 | (line-end-position range-end))))
223 | (yank)))
224 |
225 | Then to include a line range from a given file, you can create a dynamic block like so:
226 |
227 | #+BEGIN: transclusion :filename "~/testfile.org" :min 2 :max 4
228 | #+END:
229 |
230 | And auto-populate with `C-c C-x C-u`. Skip the min and max args to include the entire file. Note that you can bind `org-update-all-dblocks` to a hook, so that this range is updated whenever you visit the file or save.
231 |
232 | More info on dynamic blocks at http://orgmode.org/org.html#Dynamic-blocks. Hope this helps!
233 | #+END_QUOTE
234 |
235 | *** [[https://emacs.stackexchange.com/questions/56201/is-there-an-emacs-package-which-can-mirror-a-region/56202#56202][Is there an emacs package which can mirror a region? - Emacs Stack Exchange]]
236 |
237 | [2020-03-17 Tue]
238 |
239 | #+BEGIN_QUOTE
240 | Say, I have a buffer A in which there is a region of text from some position pos1 to an other position pos2.
241 |
242 | I switch to buffer B, call a function with buffer A, pos1 and pos2 as parameters and it copies the referred region to buffer B at point and lets me edit it at either place with all the edits made in buffer B's relevant region mirrored to buffer A's relevant region and vica versa.
243 | #+END_QUOTE
244 |
245 | Includes the following reply from [[https://emacs.stackexchange.com/users/2370/tobias][Tobias]], including some sample code (omitted here):
246 |
247 | #+BEGIN_QUOTE markdown
248 | The documentation string for the command `text-clone-create`:
249 |
250 | > (text-clone-create START END &optional SPREADP SYNTAX)
251 | >
252 | > Create a text clone of START...END at point.
253 | > Text clones are chunks of text that are automatically kept identical:
254 | > changes done to one of the clones will be immediately propagated to the other.
255 | >
256 | > The buffer’s content at point is assumed to be already identical to
257 | > the one between START and END.
258 | > If SYNTAX is provided it’s a regexp that describes the possible text of
259 | > the clones; the clone will be shrunk or killed if necessary to ensure that
260 | > its text matches the regexp.
261 | > If SPREADP is non-nil it indicates that text inserted before/after the
262 | > clone should be incorporated in the clone.
263 |
264 | Note, that you must copy the text as the first action yourself.
265 |
266 | Pityingly, the original version only works for one buffer. But it is easy to fix it for the case that original and clone do not have the same buffer. In the following Elisp code I marked the changed lines with `;;< Tobias`.
267 |
268 | There is also an interactive helper command `my-clone` in the code.
269 |
270 | 1. Mark the region you want to clone.
271 | 2. Call M-x `my-clone` RET. Emacs goes into `recursive-edit` state.
272 | 3. Navigate to the buffer and to the position where you want to clone the previously marked region.
273 | 4. Finish `recursive-edit` with C-M-c.
274 | 5. Now edit either the original region or the clone. The modifications are replicated in the other region.
275 | #+END_QUOTE
276 |
277 | *** [[https://emacs.stackexchange.com/questions/12562/org-mode-headings-in-multiple-places-at-once-transclusion][Org-mode headings in multiple places at once? (transclusion) - Emacs Stack Exchange]]
278 |
279 | [2015-05-20 Wed]
280 |
281 | #+BEGIN_QUOTE
282 | I'd like to organize my headings in multiple ways at once. (with the same degree of flexibility that I have when organizing things in any one place - e.g. more than the Agenda provides)
283 |
284 | Ideally I'd be able to make a heading in part of a document, and then create a "hard link" to the heading somewhere else, which would update both as the content of heading changed.
285 |
286 | Next best would be "soft links" which only store the heading content in one canonical location, and just show it in the other location (and if you edit it in either, it just updates in the canonical location).
287 |
288 | Right now the best I know how to do is just create normal links, which I need to manually follow to see the content. Is there any way to do better than this?
289 | #+END_QUOTE
290 |
291 | Replies point to =emacs-freex= and =transclusion-minor-mode=.
292 |
293 | * Packages
294 | :PROPERTIES:
295 | :TOC: :include descendants :depth 0 :force (depth)
296 | :CUSTOM_ID: packages
297 | :END:
298 |
299 | ** [[https://github.com/gregdetre/emacs-freex][GitHub - gregdetre/emacs-freex: Emacs Freex mode is a minor mode for organizing and editing a massively-hyperlinked database of your notes and ideas. It's a personal wiki on steroids.]]
300 |
301 | ** [[https://github.com/magnars/multifiles.el][GitHub - magnars/multifiles.el: Work in progress: View and edit parts of multiple files in one buffer]]
302 |
303 | ** [[https://github.com/nobiot/org-transclusion][GitHub - nobiot/org-transclusion: (prototype) Emacs package to enable transclusion with Org Mode]]
304 |
305 | + [[id:7bd62eda-5e00-42f2-9284-d96ff3eaa197][Discussion]]
306 |
307 | ** [[https://github.com/synchrony/smsn-why][GitHub - synchrony/smsn-why: Get psyched about mapping knowledge!]]
308 |
309 | ** [[https://github.com/whacked/transclusion-minor-mode][GitHub - whacked/transclusion-minor-mode: emacs minor mode for org-mode file transclusion using embedded overlays]]
310 |
311 | * COMMENT Config :noexport:
312 |
313 | ** File-local variables
314 |
315 | # Local Variables:
316 | # eval: (require 'org-make-toc)
317 | # eval: (unpackaged/org-export-html-with-useful-ids-mode 1)
318 | # before-save-hook: ((lambda () (unpackaged/org-fix-blank-lines t)) (lambda () (save-excursion (goto-char (point-min)))) org-make-toc)
319 | # after-save-hook: (lambda nil (when (org-html-export-to-html) (rename-file "README.html" "index.html" t)))
320 | # org-export-with-title: t
321 | # org-export-with-broken-links: mark
322 | # org-id-link-to-org-use-id: t
323 | # org-export-initial-scope: buffer
324 | # org-make-toc-insert-custom-ids: t
325 | # End:
326 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 | Transclusion in Emacs
10 |
11 |
12 |
196 |
197 |
198 |
199 |
Transclusion in Emacs
200 |
201 |
Table of Contents
202 |
245 |
246 |
247 | This file exists to gather resources related to implementing transclusion in Emacs.
248 |
249 |
250 |
251 | The topic frequently reappears in discussions on Reddit, the mailing lists, etc, and usually only a few of the existing resources are mentioned. It's time to gather them in one place.
252 |
253 |
254 |
255 | Please send additions as pull requests. When adding a resource, please add a summary as of the date it's added.
256 |
257 |
258 |
259 |
1. Contents
260 |
272 |
273 |
274 |
275 |
2. Discussions
276 |
277 |
278 |
279 |
280 |
2.1. Bug reports / Feature requests
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 | [2019-04-25 Thu] Dmitrii Korobeinikov's report is extensive. The discussion on the report continues into April of 2020.
289 |
290 |
291 |
292 |
293 | SUMMARY Buffer lens is an object inside a buffer which provides that
294 | buffer the lines to display and which is linked to another buffer (from
295 | which it can take and process data), while mapping the input back to that
296 | linked buffer. Composite lens is the extension of this idea to interface
297 | any sources of data (for which text interface is possible). Some Org-mode
298 | problems are addressed, particularly those concerning source block editing
299 | and viewing, syntax checking, completion and reference expansion.
300 |
301 |
302 |
303 | This is a proposal for lenses. Hereby, I outline the general idea, the
304 | problems it solves, the features it introduces and its use cases.
305 |
306 |
307 |
308 |
309 | See also Reddit discussion of the report from 2020, in which Ihor Radchenko mentions:
310 |
311 |
312 |
313 |
314 | Here is my work-in-progress on the subject: https://github.com/yantar92/mirror-text. I have little time to work on it in near future, but hope the ideas and links could be useful.
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
2.2. Mailing lists
323 |
324 |
325 |
326 |
327 |
2.2.1. emacs-devel
328 |
329 |
330 |
331 | - Request for pointers and advice: displaying several buffers inside a single window
332 |
333 |
334 | [2020-04-03 Fri] Dmitrii Korobeinikov asks:
335 |
336 |
337 |
338 |
339 | I want to explore the feasibility of displaying two (indirect) buffers
340 | inside a single window, one after another. Each buffer has to look
341 | like it's rendered in its own mode. For the starters, each buffer can
342 | start on its own new line in the window. No interaction w/ text is
343 | required for now.
344 |
345 |
346 |
347 | I have been entertaining the idea since my proposal for lenses [1],
348 | and now that I have some desire to get hacking a little, I want to see
349 | if I can get onto this first ladder step to the goal. What concerns me
350 | now is how to approach the problem. So, I come here to ask for your
351 | advice and comments. You know, "it's dangerous to go alone, take
352 | this!" sort of deal.
353 |
354 |
355 |
356 | I guess I would first have to learn how the renderer functions. Any
357 | good resources on that besides the source code?
358 |
359 |
360 |
361 | Eventually, I would have to explore beyond the renderer and get to
362 | play with the data structures, so I can do the interaction w/ text
363 | possible. But that doesn't concern me all that much until I get to
364 | actually draw some buffers together.
365 |
366 |
367 |
368 |
369 | The discussion is extensive, including replies from Eli Zaretskii and Ihor Radchenko, and mentions modifying xdisp.c
, the buffer data structure, associated functions, etc.
370 |
371 |
372 |
373 |
374 | - {Feature Discuss} Nested buffer
375 |
376 |
377 | [2018-07-23 Mon] fei xiaobo asks:
378 |
379 |
380 |
381 |
382 | I am building a plan to implement Nested buffer in Emacs recently. Is it a good ideal?
383 |
384 |
385 |
386 | Nested buffer what I mean here is the sub-buffers which embedded in a host buffer.
387 |
388 |
389 |
390 | - Nested/Embed buffer's content is linked to an arbitrary buffer.
391 | - Host buffer's content consists of the content of all the nested buffers.
392 |
393 |
394 |
395 | If having this, we could embed multiple buffers' content into a host buffer to get one virtual buffer. And, after updating the nested buffer's content, the virtual host buffer's content is updated too. I think it will be helpful for many special plugins.
396 |
397 |
398 |
399 | Appreciated any comments or suggestion.
400 |
401 |
402 |
403 |
404 | Includes responses by Stefan Monnier and Eli Zaretskii.
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
2.2.2. org-mode
413 |
414 |
415 |
416 | - {O} transcluding some org-elements in multiple places
417 |
418 |
419 | [2016-12-09 Fri] John Kitchin asks:
420 |
421 |
422 |
423 |
424 | I have an idea for how I could transclude "copies" or links to
425 | org-elements in multiple places and keep them up to date. A prototypical
426 | example of this is I have a set of org-contacts in one place, and I want
427 | to create a new list of people for a committee in a new place made of
428 | "copies" of the contact headlines. But I do not really want to duplicate
429 | the headlines, and if I modify one, I want it reflected in the other
430 | places. I do not want just links to those contacts, because then I can
431 | not do things with org-map-entries, and other org-machinery which needs
432 | the actual headlines/properties present. Another example might be I want
433 | a table in two places, but the contents of them should stay
434 | synchronized, ditto for a code block.
435 |
436 |
437 |
438 | This idea was inspired by https://github.com/gregdetre/emacs-freex.
439 |
440 |
441 |
442 | The idea starts with creating (wait for it…) a new link ;) In a
443 | document where I want to transclude a headline, I would enter something like:
444 |
445 |
446 |
447 | [BROKEN LINK: transclude:some-file.org::*headline title]
448 |
449 |
450 |
451 | Then, I would rely on the font-lock system to replace that link with the
452 | headline and its contents (via the :activate-func link property), and to
453 | put an overlay on it with a bunch of useful properties, including
454 | modification hooks that would update the source if I change the the
455 | element in this document, and some visual indication that it is
456 | transcluded (e.g. light gray background/tooltip).
457 |
458 |
459 |
460 | I would create a kill-buffer hook function that would replace that
461 | transcluded content with the original link. A focus-in hook function
462 | would make sure the transcluded content is updated when you enter the
463 | frame. So when the file is not open, there is just a transclude link
464 | indicating what should be put there, and when it is open, the overlay
465 | modification hooks and focus hook should ensure everything stays
466 | synchronized (as long as external processes are not modifying the
467 | contents).
468 |
469 |
470 |
471 | It seems like this could work well for headlines, and named tables, src
472 | blocks, and probably any other element that can be addressed by a
473 | name/ID.
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
2.3. Reddit
484 |
485 |
486 |
487 |
490 |
491 |
513 |
514 |
522 |
523 |
524 |
525 |
2.4. StackExchange
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 | [2013-03-10 Sun]
534 |
535 |
536 |
537 |
538 | Q: is there any way to do transclusion in emacs org-mode?
539 |
540 |
541 |
542 | By "transclusion", I mean stuff like, at some point in fileA.org and fileB.org, "including" fileInc.org - and having the tree from fileInc.org appear in both places. Actually appear, not just be linked to. (Possibly with conditional inclusion, transformation, e.g. nesting depth (number of ***s)).
543 |
544 |
545 |
546 | I know about #setupfile, but that seems only to work for modes, not real text.
547 |
548 |
549 |
550 | I know about http://orgmode.org/manual/Include-files.html, but AFAIK they only work at export time.
551 |
552 |
553 |
554 | I am looking for something that works in a normal emacs org-mode buffer. (Actually, something that worked in non-org-mode buffers might be nice.)
555 |
556 |
557 |
558 | I have boiler plate that I want to include in multiple files.
559 |
560 |
561 |
562 | Does something like this exist?
563 |
564 |
565 |
566 |
567 | Rob replies with an example of a simple Org dynamic block that provides read-only transclusion:
568 |
569 |
570 |
571 |
572 | Hmm… I don't think anything like this exists, but it was easy enough to write a dynamic block to do this. The following elisp works for me:
573 |
574 |
575 |
576 | (defun org-dblock-write:transclusion (params)
577 | (progn
578 | (with-temp-buffer
579 | (insert-file-contents (plist-get params :filename))
580 | (let ((range-start (or (plist-get params :min) (line-number-at-pos (point-min))))
581 | (range-end (or (plist-get params :max) (line-number-at-pos (point-max)))))
582 | (copy-region-as-kill (line-beginning-position range-start)
583 | (line-end-position range-end))))
584 | (yank)))
585 |
586 |
587 |
588 | Then to include a line range from a given file, you can create a dynamic block like so:
589 |
590 |
591 |
592 | And auto-populate with `C-c C-x C-u`. Skip the min and max args to include the entire file. Note that you can bind `org-update-all-dblocks` to a hook, so that this range is updated whenever you visit the file or save.
593 |
594 |
595 |
596 | More info on dynamic blocks at http://orgmode.org/org.html#Dynamic-blocks. Hope this helps!
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 | [2020-03-17 Tue]
607 |
608 |
609 |
610 |
611 | Say, I have a buffer A in which there is a region of text from some position pos1 to an other position pos2.
612 |
613 |
614 |
615 | I switch to buffer B, call a function with buffer A, pos1 and pos2 as parameters and it copies the referred region to buffer B at point and lets me edit it at either place with all the edits made in buffer B's relevant region mirrored to buffer A's relevant region and vica versa.
616 |
617 |
618 |
619 |
620 | Includes the following reply from Tobias, including some sample code (omitted here):
621 |
622 |
623 |
624 |
625 | The documentation string for the command `text-clone-create`:
626 |
627 |
628 |
629 | > (text-clone-create START END &optional SPREADP SYNTAX)
630 | >
631 | > Create a text clone of START…END at point.
632 | > Text clones are chunks of text that are automatically kept identical:
633 | > changes done to one of the clones will be immediately propagated to the other.
634 | >
635 | > The buffer’s content at point is assumed to be already identical to
636 | > the one between START and END.
637 | > If SYNTAX is provided it’s a regexp that describes the possible text of
638 | > the clones; the clone will be shrunk or killed if necessary to ensure that
639 | > its text matches the regexp.
640 | > If SPREADP is non-nil it indicates that text inserted before/after the
641 | > clone should be incorporated in the clone.
642 |
643 |
644 |
645 | Note, that you must copy the text as the first action yourself.
646 |
647 |
648 |
649 | Pityingly, the original version only works for one buffer. But it is easy to fix it for the case that original and clone do not have the same buffer. In the following Elisp code I marked the changed lines with `;;< Tobias`.
650 |
651 |
652 |
653 | There is also an interactive helper command `my-clone` in the code.
654 |
655 |
656 |
657 | - Mark the region you want to clone.
658 | - Call <kbd>M-x</kbd> `my-clone` <kbd>RET</kbd>. Emacs goes into `recursive-edit` state.
659 | - Navigate to the buffer and to the position where you want to clone the previously marked region.
660 | - Finish `recursive-edit` with <kbd>C-M-c</kbd>.
661 | - Now edit either the original region or the clone. The modifications are replicated in the other region.
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 | [2015-05-20 Wed]
672 |
673 |
674 |
675 |
676 | I'd like to organize my headings in multiple ways at once. (with the same degree of flexibility that I have when organizing things in any one place - e.g. more than the Agenda provides)
677 |
678 |
679 |
680 | Ideally I'd be able to make a heading in part of a document, and then create a "hard link" to the heading somewhere else, which would update both as the content of heading changed.
681 |
682 |
683 |
684 | Next best would be "soft links" which only store the heading content in one canonical location, and just show it in the other location (and if you edit it in either, it just updates in the canonical location).
685 |
686 |
687 |
688 | Right now the best I know how to do is just create normal links, which I need to manually follow to see the content. Is there any way to do better than this?
689 |
690 |
691 |
692 |
693 | Replies point to emacs-freex
and transclusion-minor-mode
.
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
3. Packages
702 |
703 |
704 |
705 |
708 |
709 |
712 |
713 |
721 |
722 |
725 |
726 |
729 |
730 |
731 |
732 |
Author: me
733 |
Created: 2024-10-16 Wed 19:57
734 |
Validate
735 |
736 |
737 |
738 |
--------------------------------------------------------------------------------