]> 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 acb199d379055a80d8c9816196815b145e9fa369..71dff79ece61eaddbd83571e0ddac3e8d4c8cce2 100644 (file)
@@ -568,7 +568,7 @@ We use a link for the bibliography so that we can click on it to open the biblio
                      ((eq format 'html) (org-ref-get-html-bibliography))
                      ((eq format 'latex)
                         ;; write out the latex bibliography command
-                      (format "\\bibliography{%s}" (replace-regexp-in-string  "\\.bib" "" keyword))))))
+                      (format "\\bibliography{%s}" (replace-regexp-in-string  "\\.bib" "" (expand-file-name keyword)))))))
 #+END_SRC
 
 #+BEGIN_SRC emacs-lisp :tangle org-ref.el
@@ -579,9 +579,9 @@ We use a link for the bibliography so that we can click on it to open the biblio
                       ((eq format 'org) (org-ref-get-org-bibliography))
                       ((eq format 'html) (org-ref-get-html-bibliography))
                      ((eq format 'latex)
-                      ;; write out the latex bibliography command
-                      (format "\\printbibliography" keyword))
-)))
+                      ;; write out the biblatex bibliography command
+                      "\\printbibliography"))
+))
 #+END_SRC
 
 We also create a bibliographystyle link. There is nothing to do on clicking here, and we create it for consistency. This sets the style for latex export, so use something appropriate there, e.g. unsrt, plain, plainnat, ...
@@ -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    
@@ -1182,11 +1193,9 @@ Now, we can see if an entry is in a file.
 (defun org-ref-key-in-file-p (key filename)
   "determine if the key is in the file"
   (interactive "skey: \nsFile: ")
-
-  (with-temp-buffer
-    (insert-file-contents filename)
-    (prog1
-        (bibtex-search-entry key nil 0))))
+  (save-current-buffer
+    (let ((bibtex-files (list filename)))
+      (bibtex-search-entry key t))))
 #+END_SRC
 
 Finally, we want to know which file the key is in.
@@ -1723,7 +1732,12 @@ construct the heading by hand."
     
     (goto-char (point-min))
     ;; put new entry in notes if we don't find it.
-    (unless (re-search-forward (format ":Custom_ID: %s$" key) nil 'end)
+    (if (re-search-forward (format ":Custom_ID: %s$" key) nil 'end)
+       (progn
+         (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"
  :PROPERTIES: