Closed csantosb closed 5 years ago
Hey!
You, actually, got me on this one. I think the desire is legit, but there's no clean way to do this now.
As a workaround, it seems like you can get the buffer of the org file via (message (format "%s" (other-buffer (current-buffer) 1)))
.
For now, I'm not sure how a better solution should look like. I'll try to think about it =)
You're right, not obvious. I've been looking at the code, I see what you mean.
Maybe replacing toc-org-raw-toc
by an alist of headings and props, and then getting current behaviour from there, but still making the props accessible to the hrefify
function ?
alist of headings and props
Well, my main concern is that I'm not sure properties are enough. Some other guy would decide that it's a good idea to have different hrefs based on the text inside the heading, which means another change to the API =)
I'm thinking that if I just provide access to the whole buffer - then the user can do whatever he wants. As one thing - use org API to get the tree and properties and cookies and whatnot.
After a little thinking, I guess that giving the heading and the buffer name (not the whole buffer, think about very large files) should be enough for all purposes, as you say.
Then, what about duplicated headings ? One workaround would be providing the point, the hash and the buffer name. This works as the TOC gets updated only when you modify a heading, and not the text. From the point, one may get the heading, the properties and do any other fancy stuff I may think of.
I guess that giving the heading and the buffer name
That's more or less what you can do even now (with the other-buffer
call I provided)
Then, what about duplicated headings ?
You can figure out what heading is meant exactly having the hash table (e.g. if you have a heading 'About' and there's already #about
and #about-1
in the hash, then this 'About` is the third one). It's not very pretty, but can be done.
Ok, thanks, I'll proceed this way then.
Hi,
I try to develop a custom toc-org-hrefify-STYLE function, where I need to get the ID property of the heading. Is there a way to achieve that ? I mean, I only have access to the heading itself, not no any of its properties. Maybe extending
str
into include the whole heading might be great. Otherwise, a third argument
with
props
obtained fromorg-entry-properties
is also an option.Alternatively, any way to access to the current org file name ? When using
I get nil. If I had access to it, I would parse its contents to get the heading ID.
Thanks for your help,
C.