Keep headline around links when linking to them

So far, when a link is discovered in a headline, we only keep the description of
that link.  This will throw away the context of that link, which is
undesirable.  So let's keep it.
This commit is contained in:
dbo 2021-05-12 18:20:18 +02:00
parent 268ddeb1aa
commit 7960f763f4
No known key found for this signature in database
GPG Key ID: 1C7071A75BB72D64
1 changed files with 5 additions and 2 deletions

View File

@ -739,8 +739,11 @@ link."
;; use the link part
(save-match-data
(when (string-match org-link-bracket-re item)
(setq item (or (match-string-no-properties 2 item)
(match-string-no-properties 1 item)))))
(let ((desc (or (match-string-no-properties 2 item)
(match-string-no-properties 1 item))))
(setq item (concat (substring item 0 (match-beginning 0))
desc
(substring item (match-end 0)))))))
(org-insert-link nil (format "id:%s" id) item)))