"Rick Lupton" <m...@ricklupton.name> writes: > Here is a small new feature for org-id that I have been using and finding > useful. The patch adds the option to look for ancestors of the current > headline that have an ID defined and use that together with a link search > string to link to specific headlines, without needing every single headline > to have its own ID.
I think that it will be a reasonable addition. > Now, with `org-id-link-to-org-use-id' set to `inherit`, "H2" is not modified, > and the resulting link is `[[id:abc::*H2][H2]]`, which will still take you to > the same place as long as the sub-heading is unique within the parent heading > with an ID. What about inherited CUSTOM_ID? > Feedback on the patch welcome. If you would like to merge this I will (I > assume) need to sort out FSF copyright assignment and update ORG-NEWS and the > manual. Yes, on both questions. See https://orgmode.org/worg/org-contribute.html#copyright > + ((and (featurep 'org-id) > + (eq org-id-link-to-org-use-id 'inherit)) What if none of the parents have an ID? > + ;; Store a link using the inherited ID and search string > + (setq cpltxt (condition-case nil > + (prog1 (org-id-store-link 'inherit) > ... > + "NONE")))))) This is code duplication from another branch of the same function. Please, rewrite without copy-pasting large chunks of code. For example, you can extract the common parts of the code into a private helper function. > ;;;###autoload > -(defun org-id-store-link () > +(defun org-id-store-link (&optional inherit) > "Store a link to the current entry, using its ID. > > +If INHERIT is non-nil, consider also parents' IDs if the current > +entry does not have an ID. > + This will no longer store a link to current entry with INHERIT argument. The search string will be missing from the link path. Ideally, we should have all the necessary logic to store the link within `org-id-store-link' and then use `org-link-set-parameters' to configure id links. -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at <https://orgmode.org/>. Support Org development at <https://liberapay.com/org-mode>, or support my work at <https://liberapay.com/yantar92>