diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-02-15 15:56:42 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-02-15 16:04:55 -0500 |
commit | 93d0f444da93375de0480fe8e5009f2423040d79 (patch) | |
tree | d639d33a4d9c70651df7a410bcf763f410b5f551 | |
parent | 289b1399a8791eed9dd58b5364a958db1ee2054e (diff) | |
download | bog-93d0f444da93375de0480fe8e5009f2423040d79.tar.gz |
BUG: Fix renaming staged PDF when one choice
When 4dfcc52 changed remoed the path from choices, this should have been
kept as the full path.
-rw-r--r-- | bog-tests.el | 32 | ||||
-rw-r--r-- | bog.el | 2 |
2 files changed, 33 insertions, 1 deletions
diff --git a/bog-tests.el b/bog-tests.el index be045f8..506cd27 100644 --- a/bog-tests.el +++ b/bog-tests.el @@ -2,6 +2,15 @@ (require 'org) (require 'bog) +;; Modified from magit-tests.el. +(defmacro bog-tests--with-temp-dir (&rest body) + (declare (indent 0) (debug t)) + (let ((dir (gensym))) + `(let ((,dir (file-name-as-directory (make-temp-file "dir" t)))) + (unwind-protect + (let ((default-directory ,dir)) ,@body) + (delete-directory ,dir t))))) + ;;; Citekey functions @@ -138,6 +147,29 @@ (should-error (bog-citekey-from-notes)))) +;;; PDF functions + +(ert-deftest bog-rename-staged-pdf-to-citekey-one-pdf () + (bog-tests--with-temp-dir + (let ((bog-stage-directory (expand-file-name "stage")) + (bog-pdf-directory (expand-file-name "pdfs")) + (citekey "name2010word")) + (make-directory bog-stage-directory) + (make-directory bog-pdf-directory) + (write-region "" nil (expand-file-name "one.pdf" bog-stage-directory)) + (with-temp-buffer + (insert (format "\n* top level\n\n** %s\n\nsome text\n" + citekey)) + (org-mode) + (show-all) + (re-search-backward bog-citekey-format) + (bog-rename-staged-pdf-to-citekey)) + (should (file-exists-p (expand-file-name + (concat citekey ".pdf") bog-pdf-directory))) + (should-not (file-exists-p (expand-file-name + (concat "one.pdf") bog-pdf-directory)))))) + + ;;; BibTeX functions ;; `bog-prepare-bib-file' @@ -265,7 +265,7 @@ The citekey will be taken from the text under point if it matches (setq staged-pdf (funcall bog-read-file-name "Select PDF file to rename: "))) ((= 1 num-choices) - (setq staged-pdf (car choices))) + (setq staged-pdf (car staged-pdfs))) (t (setq staged-pdf (expand-file-name (funcall bog-completing-read |