From: John Kitchin Date: Tue, 17 Mar 2015 20:41:47 +0000 (-0400) Subject: fix issue 23 X-Git-Url: https://git.donarmstrong.com/?p=org-ref.git;a=commitdiff_plain;h=a88e359712d3a7fdfaf71a23f72034bfa9e05ddb;hp=-c fix issue 23 --- a88e359712d3a7fdfaf71a23f72034bfa9e05ddb diff --combined org-ref.el index 4509d2d,fefd831..86d2464 --- a/org-ref.el +++ b/org-ref.el @@@ -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 @@@ -2482,29 -2482,6 +2482,29 @@@ (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) @@@ -2534,12 -2510,6 +2534,12 @@@ (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) @@@ -2564,7 -2534,8 +2564,7 @@@ )) (action . (lambda (x) (switch-to-buffer ,cb) - (funcall x)))) - )))) + (funcall x)))))))) ;; ** Find non-ascii charaters (defun org-ref-find-non-ascii-characters ()