Skip to content
This repository has been archived by the owner on May 18, 2020. It is now read-only.

Commit

Permalink
transport-next-link: Keep original description when on whitespace
Browse files Browse the repository at this point in the history
A to-be-transported link is allowed to have a description if a new
description isn't specified by the word at point or the selected text.
In this case, don't drop the original description during transport.
  • Loading branch information
kyleam committed May 6, 2017
1 parent 3650863 commit 5c5fef3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 4 additions & 3 deletions org-link-edit.el
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,10 @@ END."
(delete-region link-beg link-end)
(insert (org-make-link-string
link
(and desc-bounds
(delete-and-extract-region (car desc-bounds)
(cdr desc-bounds))))))))
(if desc-bounds
(delete-and-extract-region (car desc-bounds)
(cdr desc-bounds))
orig-desc))))))

(provide 'org-link-edit)
;;; org-link-edit.el ends here
8 changes: 8 additions & 0 deletions test-org-link-edit.el
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,14 @@ website"
"Here is<point> Org's website http://orgmode.org/"
(org-link-edit-transport-next-link)
(buffer-string))))
;; Transported links are allow to have an existing description when
;; point is on whitespace.
(should
(string= "Here is\[\[http://orgmode.org/\]\[descrption\]\] Org's website "
(org-test-with-temp-text
"Here is<point> Org's website \[\[http://orgmode.org/\]\[descrption\]\]"
(org-link-edit-transport-next-link)
(buffer-string))))
;; Fail if point is on a link.
(should-error
(org-test-with-temp-text
Expand Down

0 comments on commit 5c5fef3

Please sign in to comment.