Selaa lähdekoodia

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.
Bastien 5 vuotta sitten
vanhempi
commit
6d62c76d2c
1 muutettua tiedostoa jossa 5 lisäystä ja 6 poistoa
  1. 5 6
      lisp/ol.el

+ 5 - 6
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.