diff options
author | Bastien <bzg@gnu.org> | 2020-05-23 17:07:35 +0200 |
---|---|---|
committer | Bastien <bzg@gnu.org> | 2020-05-23 17:07:35 +0200 |
commit | 6d62c76d2c99f5998bbae865db65206f70a9679f (patch) | |
tree | ab71a37ece141df94485f21f9fd715ed1e4bd0d6 | |
parent | 412f0406da6366b0d956a8c45ed8433eea5ab09a (diff) | |
download | org-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.el | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -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. |