]> git.donarmstrong.com Git - org-ref.git/commitdiff
fix issue 23
authorJohn Kitchin <jkitchin@andrew.cmu.edu>
Tue, 17 Mar 2015 20:41:47 +0000 (16:41 -0400)
committerJohn Kitchin <jkitchin@andrew.cmu.edu>
Tue, 17 Mar 2015 20:41:47 +0000 (16:41 -0400)
1  2 
org-ref.el

diff --combined org-ref.el
index 4509d2d9b263de5c817af0d1e670659c504946ff,fefd8317a0387d5cba569ef98fbff7ba15c82bc0..86d2464e013069f31e568229e8073363a4b0b186
@@@ -326,7 -326,7 +326,7 @@@ You will see a message in the minibuffe
                       (replace-regexp-in-string "\*" "\\\\*" x)
                       )
                     org-ref-cite-types "\\|") "\\)"
-   ":\\([a-zA-Z0-9-_:]*,?\\)*"))
+   ":\\([a-zA-Z0-9-_:\\.]*,?\\)*"))
  
  
  (setq org-ref-label-re
@@@ -2395,7 -2395,7 +2395,7 @@@ Makes a new buffer with clickable links
            (kill-buffer "*Missing citations*"))
        (message "No bad cite links found"))))
  
 -;; ** helm interface to bad citations, labels, refs in orgfile
 +;; ** helm interface to bad citations, labels, refs and files in orgfile
  (defun org-ref-bad-cite-candidates ()
    "Return a list of conses (key . marker) where key does not exist in the known bibliography files, and marker points to the key."
    (let* ((cp (point))                 ; save to return to later
            (goto-char cp)))))
        multiple-labels))
  
 +(defun org-ref-bad-file-link-candidates ()
 +  "Return list of conses (link . marker) wehre the file in the link does not exist."
 +  (let* ((bad-files '()))
 +    (org-element-map (org-element-parse-buffer) 'link
 +      (lambda (link)
 +      (let ((type (org-element-property :type link)))
 +        (when (or  (string= "file" type)
 +                   (string= "attachfile" type))
 +          (unless (file-exists-p (org-element-property :path link))
 +            (add-to-list 'bad-files
 +                         (cons (org-element-property :path link)
 +                               (save-excursion
 +                                 (goto-char
 +                                  (org-element-property :begin link))
 +                                 (point-marker)))))))))
 +    ;; Let us also check \attachfile{fname}
 +    (save-excursion
 +      (goto-char (point-min))
 +      (while (re-search-forward "\\attachfile{\\(.*\\)}" nil t)
 +      (unless (file-exists-p (match-string 1))
 +        (add-to-list 'bad-files (cons (match-string 1) (point-marker))))))
 +    bad-files))
 +
  ;;;###autoload
  (defun org-ref ()
    "Opens a helm interface to actions for org-ref.
@@@ -2513,8 -2490,7 +2513,8 @@@ Shows bad citations, ref links and labe
    (let ((cb (current-buffer))
        (bad-citations (org-ref-bad-cite-candidates))
        (bad-refs (org-ref-bad-ref-candidates))
 -      (bad-labels (org-ref-bad-label-candidates)))
 +      (bad-labels (org-ref-bad-label-candidates))
 +      (bad-files (org-ref-bad-file-link-candidates)))
  
      (helm :sources `(((name . "Bad citations")
                       (candidates . ,bad-citations)
                                          (switch-to-buffer (marker-buffer marker))
                                          (goto-char marker))))
                     ;;
 +                   ((name . "Bad file links")
 +                    (candidates . ,bad-files)
 +                    (lambda (marker)
 +                                 (switch-to-buffer (marker-buffer marker))
 +                                 (goto-char marker)))
 +                   ;;
                     ((name . "Utilities")
                      (candidates . (("Check buffer again" . org-ref)
                                     ("Insert citation" . helm-bibtex)
                                     ))
                      (action . (lambda (x)
                                  (switch-to-buffer ,cb)
 -                                (funcall x))))
 -                    ))))
 +                                (funcall x))))))))
  
  ;; ** Find non-ascii charaters
  (defun org-ref-find-non-ascii-characters ()