Sorry for waiting this long.. I am struggling a bit with
git.savannah.gnu.org and the emacs repository.  My repo is not
pulling newer changes.  So, this all is using emacs 30.2.  Is
there a document that describes how to use the newest org-mode
git repo?  How am I supposed to set up my emacs and which version
should it be (30.2?  head?) to follow org-mode head?

On Sunday, October 12, 2025, Ihor Radchenko wrote:

>> Ok sorry - one more attempt.  Is this patch going into the right
>> direction (defun: org-link-precise-link-target) ?
>
> Yup.
>
>> +               (context (org-element-context element))
>>                     (custom-id (org-entry-get heading "CUSTOM_ID")))
>>                (cond
>> +           ((org-element-type-p context 'target)
>> +            (list (org-element-property :value context)
>> +                  (org-element-property :value context)
>> +                  (org-element-begin element)))
>
> Maybe just (org-element-begin context).

Like this?

--8<---------------cut here---------------start------------->8---
diff -u /opt/emacs-30.2_testing/share/emacs/30.2/lisp/org/ol.el.orig 
/opt/emacs-30.2_testing/share/emacs/30.2/lisp/org/ol.el
--- /opt/emacs-30.2_testing/share/emacs/30.2/lisp/org/ol.el.orig        
2026-02-19 14:09:29.822005330 +0100
+++ /opt/emacs-30.2_testing/share/emacs/30.2/lisp/org/ol.el     2026-02-19 
14:31:14.817715964 +0100
@@ -1482,8 +1482,13 @@
             (let* ((element (org-element-at-point))
                    (name (org-element-property :name element))
                    (heading (org-element-lineage element '(headline 
inlinetask) t))
+                  (context (org-element-context element))
                    (custom-id (org-entry-get heading "CUSTOM_ID")))
               (cond
+              ((org-element-type-p context 'target)
+               (list (org-element-property :value context)
+                     (org-element-property :value context)
+                     (org-element-begin context)))
                (name
                 (list name
                       name

Diff finished.  Thu Feb 19 20:43:24 2026
--8<---------------cut here---------------end--------------->8---


> We return the position of target then. Your variant returns the
> position of the containing paragraph.
>
> Also, after your change, `org-link--file-link-to-here' will be able to
> handle target links. So, in org-store-link
>
> (cond
>         ;; Store a link using the target at point
>         ((org-in-regexp "[^<]<<\\([^<>]+\\)>>[^>]" 1)
>          (setq link
>                (concat "file:"
>                        (abbreviate-file-name
>                         (buffer-file-name (buffer-base-buffer)))
>                        "::" (match-string 1))
>                  ;; Target may be shortened when link is inserted.
>                  ;; Avoid [[target][file:~/org/test.org::target]]
>                  ;; links.  Maybe the case of identical target and
>                  ;; description should be handled by `org-insert-link'.
>                  desc nil))
>           (t
>          ;; Just link to current headline.
>            (let ((here (org-link--file-link-to-here)))
>              (setq link (car here))
>              (setq desc (cdr here)))))
>
> becomes redundant. The special clause for target at point will no longer
> be necessary.

I don’t know what becomes redundant at this place, sorry.


> And the final step will be testing. And adding tests to
> `test-org-link/precise-link-target' in the git repository.
>

This is what I figured out so far:

--8<---------------cut here---------------start------------->8---
  (let ((org-id-link-to-org-use-id t))
    (should
     (equal '("id:b82baea1-4203-4f97-a52d-6a0534873c92::myanchor" "myanchor")
            (test-ol-stored-link-with-text "* H1\n:PROPERTIES:\n:ID: 
b82baea1-4203-4f97-a52d-6a0534873c92\n:END:\n<point><<myanchor>>\n"
              (org-id-store-link))))
    )
--8<---------------cut here---------------end--------------->8---


> Let me know if you need any help with this.

-- 
Christian Barthel

Reply via email to