Open hpgisler opened 1 year ago
I suggest you try this below. It automatically inserts a level property relative to the current level. It does not change the property once it's inserted. It works on my end.
I feel that this should be rather personal configuration specific to your use case than generic enough to be part of the code base. But that's just my gut feel. Other people may also want something similar.
(defun my/org-transclusion-add ()
"`org-transsclusion' +1 relative to current level."
(interactive)
(org-transclusion-check-add)
(let ((level (1+ (or (org-current-level) 0))))
(end-of-line)
(insert (format " :level %d" level))
(org-transclusion-add)))
You can also try "P" and "D" keys to promote and demote subtree transcluded headlines once they are added: org-transclusion-promote-subtree
and org-transclusion-demote-subtree
. That might be also useful for you perhaps.
Thank you very much for the code sample. I fear, I didn't make my self clear above.
If I have:
** My including section
#+transclude: [[id:abc20b2a-5e86-49c8-9433-38bd4e25612d][The transcluded (included) section]] :level 3
and I then for example demote ** My including section
with normal org-demote-subtree
, then I would like to have the option such that :level 3
is demoted automatically in the same step as well to :level 4
, like so:
*** My including section
#+transclude: [[id:abc20b2a-5e86-49c8-9433-38bd4e25612d][The transcluded (included) section]] :level 4
(regardless, of whether transclusion-mode was on or off.)
Thank you. That sounds like a good idea for a new feature.
However, unfortunately, I cannot promise when I can get to it. I spend some time thinking about the design; it will be time consuming, if not difficult to achieve. The suitable hooks seem available from Org: org-after-promote-entry-hook
and org-after-demote-entry-hook
. Going through each entry (and only the entry) for both active and inactive transclusions may require regexp-search-forward
twice. For active ones, it's probably as easy as calling org-transclusion-[promote|demote]-subtree
. For inactive ones, I'd need to create some functions to add +1 to the :level
prop. There are cases where there is no :level
-- I think I'd ignore this. All this together, it will require a lot of testing.
Looking at this year, I think I will have less than 15 weekends left for programming, so I don't think it will be this year.
I will be happy to receive a PR from you or someone interested, if you prefer to have it sooner.
Thank you very much for considering this.
Unfortunately, I am not very proficient in elisp, i.e. the chances to get a usable PR from me are not very high - unfortunately..
However, do you think it would perhaps simplify matters if :level
would not only accept absolute numbers - as is the case right now - but also relative numbers?
i.e. in the example from above, instead of writing :level 3
as an absolute indentation value, one would provide a value that indicates an indentation relative to the including section, e.g. like so :level +1
, i.e.:
** My including section
#+transclude: [[id:abc20b2a-5e86-49c8-9433-38bd4e25612d][The transcluded (included) section]] :level +1
This would (perhaps) have the following advantages in comparison to denoting the level in an absolute way:
**
in the example) the #+trasclusion
line would not require modification, if the transclusion-mode was inactive :level +n
(n
being an integer number >= 0) would require interpretation (not sure, whether n should also be allowed to get negative..?)n
needs modified (de-/incremented) as well.What do you think?
I stopped using org-transclusion because I found that having to repeatedly set the indentation level manually didn't work well for much of my constantly fluctuating knowledgebase of nested headlines.
I really want to love this package but, without the ability to inherit indentation, I find using plain org-links to be a more efficient solution. Nowhere near as powerful, but practical.
Most of the time, I would like to transclude a org headline (and its subsections) by id into an existing headline. Later I might want to move around / pomote / demote that headline. In such cases I would like the transcluded id-links to automatically keep their relative levels to the including headline. i.e. w/o requiring me to manually correct / fix a :level property.