Preview-refs package and internal preview of *local* links

Dear all,

Often, I find myself referring to the location of another file. Say I am teaching in week 5, and I refer to the slides from last week, located in lec04.tm. For example, I may write: “As we saw in \hlink{Proposition 4}{lec04.tm#prop:maxima} …”, and when activated and clicked, opens the appropriate location of Proposition 4 in the file lec04.tm.

I wonder if there is some simple hack to enhance the capabilities of preview-refs package to display the above info as a tool-tip when the mouse hovers on the hyperlink.

I know how to save lec04.tm to a tree, say T. (search-labels T) immediately gives me the list of labels. But then, how do I give one of those labels as an argument, and search through T to create a snippet?

For the user interface, we could have a command \xref{fname}{labelname}, the first argument creates the tree to search in, and the labelname creates the snippet with the preview context.

Thanks for any help. Preview-ref is a very useful package, and extending it to allow for an internal preview of local links (not just the buffer) would be, I imagine, of considerable interest to many of us.

Kind regards,
Murali

@murali: do you already know this blog post? Does it help?

Yes, I had read through that post before posting my message. Working through the label-preview command was beyond me. In any case, it has far greater functionality than what I am looking for, as it appears to dynamically construct the snippet from the current-buffer. It would be great to get that to operate on any given tree, instead of the (buffer-tree), but that would be beyond me.

I believe all I need for the present purpose is the following tree-search command: Given a tree T, and a (tree `label “name”), find the proposition/theorem/corollary etc. that contains it.

Thanks.
Murali

Perhaps

(tree-search-upwards t 'theorem)

rewritten so to find also the other environments in a list of environments.
I skimmed the post and that looks different, but I did not understand why.