From 7960f763f4c66ed3dfa56238e9af52a31a12c10f Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Wed, 12 May 2021 18:20:18 +0200 Subject: [PATCH] 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. --- site-lisp/db-org.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 5db1c4b..057d70e 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -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)))