nobiot / org-transclusion

Emacs package to enable transclusion with Org Mode
https://nobiot.github.io/org-transclusion/
GNU General Public License v3.0
917 stars 44 forks source link

Is it possible to mirror a heading? #180

Open rickalex21 opened 1 year ago

rickalex21 commented 1 year ago

Hello, thanks for the package. I was wondering if it's possible to mirror a heading into another heading or a title live?

For example if I have this org file:

#+TITLE:    My Title
* My Title

If I update the heading My Title to My New Title, the text in #+TITLE: changes.

#+TITLE:    My New Title
* My New Title

If this is not possible in org-transclusion. The best thing I could think of is this, unless you have a better suggestion?

(add-to-list 'after-change-functions (lambda (beg end len) (message "Beg %s End %s len %s..."  beg end len)) )

One would have to:

  1. when re-search-forward Find the start and end points for the first heading. Account for entered text.
  2. when looking-back at first heading.
  3. Change the text in the title.
  4. Only enable for certain files: org-mode-hook when string-match bufer-name enable the function.
nobiot commented 1 year ago

This is not something org-transclusion does.

I am not sure of a better way; if your method works, I think that’s good enough.

For the example you are showing above, I would simply copy the new heading description manually over to the title. Changing a heading description, to me, is very specific (so is changing the title).

What is the reason for your need to sync them?

rickalex21 commented 1 year ago

Yea that's what I'm doing right now copying them over.

Every time I'm writing something on my diary/journal and I need to change the heading because something else happened in the day I have to go up to the title and change it as well in case I want to print it out or export it to a pdf. If 4 things happen I have to change it 3 times (e.g Dentist Appt Gym PR Mom Visit).

So if something happens during the day I want to change the title to Dentist Gym PR now I have to change it in two places, not a big deal I can copy and paste but you get the idea.

#+TITLE:    Dentist
#+SUBTITLE:
#+DATE:     04-04-2023
#+FILETAGS: April 2023 Journal
#+SETUPFILE: ~/notes-setup.org
#+OPTIONS: toc:nil num:nil html-style:nil author:nil

* Dentist
:PROPERTIES:
:DATE:     [2023-04-04 Tue 13:10]
:UPDATED:  [2023-04-04 Tue 13:10]
:PRO: 4
:WORKOUT: t
:END:

** Summary                                                       :summary:

Went to the dentist today.

** Dental Cleaning                                              :dental:

Some notes here about my visit.

** Gym

Had a great workout set a new PR on the Leg Press. I've noticed that using pin 3 on the
machine feels better on my back.

I do export big events like going to the dentist which requires me updating the entire file at two locations, that's where I may benefit from this package.

For example: If I needed to add something the dentist told me to my journal, I would have update the file ~/journal/2023-04-04.org and ~/docs/dental/2023/cleaning.org.

Why would I want two separate files? Because I don't want to keep confidential information in my journal. For example cleaning.org I could export it with additional things like a receipts or images of my xrays. Then I would have cleaning.pdf.