Browse Source

Make the link properties from org-protocol work in capture

Carsten Dominik 14 years ago
parent
commit
fb46cf11d3
2 changed files with 9 additions and 1 deletions
  1. 7 1
      lisp/org-capture.el
  2. 2 0
      lisp/org-protocol.el

+ 7 - 1
lisp/org-capture.el

@@ -64,6 +64,10 @@
 (defvar org-capture-last-stored-marker (make-marker)
   "Marker pointing to the entry most recently stored with `org-capture'.")
 
+;; The following variable is scoped dynamically by org-protocol
+;; to indicate that the link properties have already been stored
+(defvar org-capture-link-is-already-stored nil)
+
 (defgroup org-capture nil
   "Options concerning capturing new entries."
   :tag "Org Capture"
@@ -348,7 +352,9 @@ bypassed."
     ;; set temporary variables that will be needed in
     ;; `org-select-remember-template'
     (let* ((orig-buf (current-buffer))
-	   (annotation (org-store-link nil))
+	   (annotation (if org-capture-link-is-already-stored
+			   (plist-get org-store-link-plist :annotation)
+			 (org-store-link nil)))
 	   (initial (and (org-region-active-p)
 			 (buffer-substring (point) (mark))))
 	   (entry (org-capture-select-template keys)))

+ 2 - 0
lisp/org-protocol.el

@@ -503,6 +503,7 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
 	 (region (or (caddr parts) ""))
 	 (orglink (org-make-link-string
 		   url (if (string-match "[^[:space:]]" title) title url)))
+	 (org-capture-link-is-already-stored t) ;; avoid call to org-store-link
 	 remember-annotation-functions)
     (setq org-stored-links
 	  (cons (list url title) org-stored-links))
@@ -510,6 +511,7 @@ CAPTURE-FUNC is either the symbol `org-remember' or `org-capture'."
     (org-store-link-props :type type
 			  :link url
 			  :description title
+			  :annotation orglink
 			  :initial region)
     (raise-frame)
     (funcall capture-func nil template)))