From f307c7059744b28b26f5c3b8dd4a0f563b22e586 Mon Sep 17 00:00:00 2001 From: Max Nikulin Date: Sat, 6 Nov 2021 18:23:25 +0700 Subject: [PATCH 3/3] ol.el: Avoid links like "[[target][file:~/org/test.org::target]]" * lisp/ol.el (org-store-link): Do not set description for "<>" links to avoid case when it is more detailed than link target. While inserting to the same file, file part of the link target is stripped, description is inserted without modification. I do not think, file path adds real value in comparison to "[[target]]" link to some point in the same file. A side effect is user prompt for description since link and description are not identical any more. --- lisp/ol.el | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lisp/ol.el b/lisp/ol.el index 5e1f1f2d2..ec5427e7c 100644 --- a/lisp/ol.el +++ b/lisp/ol.el @@ -1617,12 +1617,17 @@ non-nil." (cond ;; Store a link using the target at point ((org-in-regexp "[^<]<<\\([^<>]+\\)>>[^>]" 1) - (setq cpltxt + (setq link (concat "file:" (abbreviate-file-name (buffer-file-name (buffer-base-buffer))) "::" (match-string 1)) - link cpltxt + ;; 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'. + cpltxt nil + desc nil ;; Do not append #CUSTOM_ID link below. custom-id nil)) ((and (featurep 'org-id) -- 2.25.1