summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien <bzg@gnu.org>2020-05-23 17:07:35 +0200
committerBastien <bzg@gnu.org>2020-05-23 17:07:35 +0200
commit6d62c76d2c99f5998bbae865db65206f70a9679f (patch)
treeab71a37ece141df94485f21f9fd715ed1e4bd0d6
parent412f0406da6366b0d956a8c45ed8433eea5ab09a (diff)
downloadorg-mode-6d62c76d2c99f5998bbae865db65206f70a9679f.tar.gz
ol.el: Allow to remove the link part of a link
* lisp/ol.el (org-link-make-string): When trying to make a link with an empty link part, do not throw an error, just insert the description text.
-rw-r--r--lisp/ol.el11
1 files changed, 5 insertions, 6 deletions
diff --git a/lisp/ol.el b/lisp/ol.el
index 0cb1b0a..82fc697 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -947,9 +947,7 @@ E.g. \"%C3%B6\" becomes the german o-Umlaut."
(defun org-link-make-string (link &optional description)
"Make a bracket link, consisting of LINK and DESCRIPTION.
LINK is escaped with backslashes for inclusion in buffer."
- (unless (org-string-nw-p link) (error "Empty link"))
- (let* ((uri (org-link-escape link))
- (zero-width-space (string ?\x200B))
+ (let* ((zero-width-space (string ?\x200B))
(description
(and (org-string-nw-p description)
;; Description cannot contain two consecutive square
@@ -962,9 +960,10 @@ LINK is escaped with backslashes for inclusion in buffer."
(replace-regexp-in-string "]\\'"
(concat "\\&" zero-width-space)
(org-trim description))))))
- (format "[[%s]%s]"
- uri
- (if description (format "[%s]" description) ""))))
+ (if (not (org-string-nw-p link)) description
+ (format "[[%s]%s]"
+ (org-link-escape link)
+ (if description (format "[%s]" description) "")))))
(defun org-store-link-functions ()
"List of functions that are called to create and store a link.