From 5c5fef32b4690092bbc9e86a8cf6718288053596 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Fri, 5 May 2017 19:54:18 -0400 Subject: transport-next-link: Keep original description when on whitespace 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. --- org-link-edit.el | 7 ++++--- test-org-link-edit.el | 8 ++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/org-link-edit.el b/org-link-edit.el index 6e58155..193f8fa 100644 --- a/org-link-edit.el +++ b/org-link-edit.el @@ -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 diff --git a/test-org-link-edit.el b/test-org-link-edit.el index a5fecef..b88592d 100644 --- a/test-org-link-edit.el +++ b/test-org-link-edit.el @@ -552,6 +552,14 @@ website" "Here is 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 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 -- cgit v1.2.3