Browse Source

Limit creation of ID links only in Org mode buffers

* lisp/org-id.el (org-id-store-link): Test for org-mode before checking for
IDs.

Reporte and fix suggestion by Liam Healy
Carsten Dominik 14 years ago
parent
commit
aeaf05238c
1 changed files with 12 additions and 9 deletions
  1. 12 9
      lisp/org-id.el

+ 12 - 9
lisp/org-id.el

@@ -600,15 +600,18 @@ optional argument MARKERP, return the position as a new marker."
 (defun org-id-store-link ()
 (defun org-id-store-link ()
   "Store a link to the current entry, using its ID."
   "Store a link to the current entry, using its ID."
   (interactive)
   (interactive)
-  (let* ((link (org-make-link "id:" (org-id-get-create)))
-	 (case-fold-search nil)
-	 (desc (save-excursion
-		 (org-back-to-heading t)
-		 (or (and (looking-at org-complex-heading-regexp)
-			  (if (match-end 4) (match-string 4) (match-string 0)))
-		     link))))
-    (org-store-link-props :link link :description desc :type "id")
-    link))
+  (when (org-mode-p)
+    (let* ((link (org-make-link "id:" (org-id-get-create)))
+	   (case-fold-search nil)
+	   (desc (save-excursion
+		   (org-back-to-heading t)
+		   (or (and (looking-at org-complex-heading-regexp)
+			    (if (match-end 4)
+				(match-string 4)
+			      (match-string 0)))
+		       link))))
+      (org-store-link-props :link link :description desc :type "id")
+      link)))
 
 
 (defun org-id-open (id)
 (defun org-id-open (id)
   "Go to the entry with id ID."
   "Go to the entry with id ID."