Skip to content

Commit

Permalink
ol.el: Avoid links like "[[target][file:~/org/test.org::target]]"
Browse files Browse the repository at this point in the history
* lisp/ol.el (org-store-link): Do not set description for "<<target>>"
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.
  • Loading branch information
maxnikulin authored and yantar92 committed Sep 13, 2022
1 parent f7b8510 commit c3d6672
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lisp/ol.el
Original file line number Diff line number Diff line change
Expand Up @@ -1663,12 +1663,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)
Expand Down

0 comments on commit c3d6672

Please sign in to comment.