summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README2
-rw-r--r--bog-readme.org6
-rw-r--r--bog-todo.org3
-rw-r--r--bog.el43
4 files changed, 30 insertions, 24 deletions
diff --git a/README b/README
index dae1d21..79e09df 100644
--- a/README
+++ b/README
@@ -172,7 +172,7 @@ and taking notes with Org, not on writing research articles with Org.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a separate BibTeX file is used for each citekey,
- `bog-rename-and-clean-new-bib-files' can be used to rename all new
+ `bog-clean-and-rename-staged-bibs' can be used to rename all new
BibTeX files. `bibtex-clean-entry' is used to clean the entry and
autogenerate the key.
diff --git a/bog-readme.org b/bog-readme.org
index d3743eb..6f47100 100644
--- a/bog-readme.org
+++ b/bog-readme.org
@@ -126,9 +126,9 @@ in [[Opening%20a%20PDF%20file][Opening a PDF file]].)
** Renaming a new BibTeX file
If a separate BibTeX file is used for each citekey,
-=bog-rename-and-clean-new-bib-files= can be used to rename all new
-BibTeX files. =bibtex-clean-entry= is used to clean the entry and
-autogenerate the key.
+=bog-clean-and-rename-staged-bibs= can be used to rename all new BibTeX
+files. =bibtex-clean-entry= is used to clean the entry and autogenerate
+the key.
** Generating a combined BibTeX file
diff --git a/bog-todo.org b/bog-todo.org
index 84612c3..dbc7eb4 100644
--- a/bog-todo.org
+++ b/bog-todo.org
@@ -56,7 +56,8 @@ For documents generated from multiple files
Default could be "*.tex".
-** ENH Use a stage for new BibTeX files
+** DONE Use a stage for new BibTeX files
+ CLOSED: [2014-02-15 Sat 15:06]
Avoid filtering all bib file names.
diff --git a/bog.el b/bog.el
index aed8146..857f747 100644
--- a/bog.el
+++ b/bog.el
@@ -89,10 +89,11 @@ default value of `org-bibtex-key-property'."
:group 'bog
:type 'string)
-(defcustom bog-pdf-directory-stage
- (expand-file-name "pdf-stage" bog-notes-directory)
- "The name of the directory to search for new PDFs in.
-`bog-rename-staged-pdf-to-citekey' will search here for files to
+(defcustom bog-stage-directory
+ (expand-file-name "stage" bog-notes-directory)
+ "The name of the directory to search for new files.
+`bog-rename-staged-pdf-to-citekey' and
+`bog-rename-staged-bib-to-citekey' will search here for files to
rename."
:group 'bog
:type 'string)
@@ -244,7 +245,7 @@ text under point if it matches `bog-citekey-format' or using
;;;###autoload
(defun bog-rename-staged-pdf-to-citekey ()
- "Rename PDF in `bog-pdf-directory-stage' to `bog-pdf-directory'/<citekey>.pdf.
+ "Rename PDF in `bog-stage-directory' to `bog-pdf-directory'/<citekey>.pdf.
The citekey will be taken from the text under point if it matches
`bog-citekey-format' or using `bog-citekey-func'."
(interactive)
@@ -255,7 +256,7 @@ The citekey will be taken from the text under point if it matches
(let* ((pdf-file (bog-citekey-as-pdf citekey))
(choices
(file-expand-wildcards
- (concat (file-name-as-directory bog-pdf-directory-stage) "*.pdf")))
+ (concat (file-name-as-directory bog-stage-directory) "*.pdf")))
(num-choices (length choices))
staged-pdf)
(cond
@@ -309,20 +310,23 @@ text under point if it matches `bog-citekey-format' or using
(bibtex-search-entry citekey))
;;;###autoload
-(defun bog-rename-and-clean-new-bib-files ()
- "Prepare new BibTeX files.
-New files are determined as files in `bog-bib-directory' that do
-not have a basename matching `bog-citekey-format'. This is only
-useful if you use the non-standard setup of one entry per BibTeX
-file."
+(defun bog-clean-and-rename-staged-bibs ()
+ "Clean and rename BibTeX files in `bog-stage-directory'.
+
+New BibTeX files are searched for in `bog-stage-directory', and
+`bog-prepare-bib-file' will be run one each file before it is
+moved to `bog-bib-directory'/<citekey>.bib.
+
+This function is only useful if you use the non-standard setup of
+one entry per BibTeX file."
(interactive)
- (let* ((new (--filter (not (string-match bog-citekey-format it))
- (bog-bib-citekeys)))
- (new (--map (concat (expand-file-name it bog-bib-directory) ".bib")
- new)))
- (--each new (bog-prepare-bib-file it t))))
+ (let ((staged
+ (file-expand-wildcards
+ (concat (file-name-as-directory bog-stage-directory) "*.bib"))))
+ (--each staged
+ (bog-prepare-bib-file it t bog-bib-directory))))
-(defun bog-prepare-bib-file (file &optional new-key)
+(defun bog-prepare-bib-file (file &optional new-key new-directory)
(save-excursion
(let ((was-open (get-file-buffer file))
(buffer (find-file-noselect file)))
@@ -331,7 +335,8 @@ file."
(bibtex-skip-to-valid-entry)
(bibtex-clean-entry new-key)
(let* ((citekey (bibtex-key-in-head))
- (bib-file (concat citekey ".bib")))
+ (bib-file
+ (expand-file-name (concat citekey ".bib") new-directory)))
(when (get-buffer bib-file)
(error "Buffer for %s already exists" bib-file))
(rename-file file bib-file)