]> git.donarmstrong.com Git - org-ref.git/blobdiff - org-ref.org
fix bug where clicking on cite: gives an error
[org-ref.git] / org-ref.org
index 5a861776feb9307a605f82221392b29606a23ffc..71dff79ece61eaddbd83571e0ddac3e8d4c8cce2 100644 (file)
@@ -1096,7 +1096,18 @@ keyword we clicked on. We also strip the text properties."
   (interactive)
   (let* ((object (org-element-context))         
         (link-string (org-element-property :path object)))
-
+    (message "%s" object)
+
+    ;; you may click on the part before the citations. here we make
+    ;; sure to move to the beginning so you get the first citation.
+    (let ((cp (point)))
+      (goto-char (org-element-property :begin object))
+      (search-forward link-string (org-element-property :end object))
+      (goto-char (match-beginning 0))
+      ;; check if we clicked before the path and move as needed.
+      (unless (< cp (point))
+       (goto-char cp)))
+       
     (if (not (org-element-property :contents-begin object))
        ;; this means no description in the link
        (progn    
@@ -1723,8 +1734,9 @@ construct the heading by hand."
     ;; put new entry in notes if we don't find it.
     (if (re-search-forward (format ":Custom_ID: %s$" key) nil 'end)
        (progn
-         (show-subtree)
-         (outline-previous-visible-heading 1))
+         (org-show-entry)
+         (outline-previous-visible-heading 1)
+         (recenter-top-bottom 0))
       ;; no entry found, so add one    
       (insert (format "\n** TODO %s - %s" year title))
       (insert (format"