On Sat, 3 Feb 2024, at 1:10 PM, Ihor Radchenko wrote: > I'd prefer to avoid using global variables here. > `org-entry-property-inherited-from' dates to pre-lexical binding times > and is a potential source of subtle bugs if several `org-entry-get' > calls happen unexpectedly to the code, changing > `org-entry-property-inherited-from' multiple times. > > Instead, I suggest changing the return value of > `org-link-precise-link-target' to a list that includes marker in > addition to search string and description. Makes sense -- I changed it to work that way and it is neater. I returned simply the buffer position rather than a marker, since it is always in the current buffer, and avoids needing to worry about cleaning up the marker when finished or if not of interest. > It looks like we cannot simply rely on narrowing to determine the > created heading level. I think you're right. I have extended `org-link-search' to accept an optional argument describing the org element where newly created headings should go as subheadings. My thought was that this was not significantly more complicated than just passing the numeric level for new headings, but actually more flexible (e.g. you could if you wanted (with additional future elisp) create missing headings as part of a "To be filed" subtree within the file, rather than always at the end). Does that look ok? [is it useful to keep attaching the unchanged first patch so they are available as a set?] Thanks Rick