Revert "lisp/ol.el: Fix bug when storing links"

This reverts commit b4b35fc92d.

Avoid duplication of CUSTOM_ID links.
This commit is contained in:
Max Nikulin 2021-11-05 19:03:59 +07:00 committed by Ihor Radchenko
parent 2737128aa7
commit 543a23a57d
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
1 changed files with 5 additions and 12 deletions

View File

@ -1659,8 +1659,9 @@ non-nil."
((and (buffer-file-name (buffer-base-buffer)) (derived-mode-p 'org-mode))
(org-with-limited-levels
(cond
;; Store a link using the target at point.
(setq custom-id (org-entry-get nil "CUSTOM_ID"))
(cond
;; Store a link using the target at point
((org-in-regexp "[^<]<<\\([^<>]+\\)>>[^>]" 1)
(setq cpltxt
(concat "file:"
@ -1668,15 +1669,6 @@ non-nil."
(buffer-file-name (buffer-base-buffer)))
"::" (match-string 1))
link cpltxt))
;; Store a link using the CUSTOM_ID property.
((setq custom-id (org-entry-get nil "CUSTOM_ID"))
(setq cpltxt
(concat "file:"
(abbreviate-file-name
(buffer-file-name (buffer-base-buffer)))
"::#" custom-id)
link cpltxt))
;; Store a link using (and perhaps creating) the ID property.
((and (featurep 'org-id)
(or (eq org-id-link-to-org-use-id t)
(and interactive?
@ -1685,13 +1677,14 @@ non-nil."
'create-if-interactive-and-no-custom-id)
(not custom-id))))
(and org-id-link-to-org-use-id (org-entry-get nil "ID"))))
;; Store a link using the ID at point
(setq link (condition-case nil
(prog1 (org-id-store-link)
(setq desc (or (plist-get org-store-link-plist
:description)
"")))
(error
;; Probably before first headline, link only to file.
;; Probably before first headline, link only to file
(concat "file:"
(abbreviate-file-name
(buffer-file-name (buffer-base-buffer))))))))