diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-02-07 01:23:35 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-02-07 01:25:11 -0500 |
commit | dc7806b748effca4ea57a165df0fff33b1f83ef3 (patch) | |
tree | cc801c5b50652e93941e3c160ac57f2926b86be5 | |
parent | f4b7bea779a3a4ea1e07d5d98c917a6c79f7a1ea (diff) | |
download | bog-dc7806b748effca4ea57a165df0fff33b1f83ef3.tar.gz |
ENH: Make compatible with single BibTeX file
-rw-r--r-- | README.org | 14 | ||||
-rw-r--r-- | bog-todo.org | 3 | ||||
-rw-r--r-- | bog.el | 32 |
3 files changed, 39 insertions, 10 deletions
@@ -98,13 +98,15 @@ heading that is a study. ** Opening a BibTeX file -All BibTeX files are kept in a single directory and are named as -<citekey>.bib. The function =bog-find-citekey-bib= will open the BibTeX -file associated with a citekey. The citekey is obtained in the same way -as the [[Opening a PDF file][PDF citekey]]. +The function =bog-find-citekey-bib= will open the BibTeX entry +associated with a citekey. -Although I prefer the above setup, using a single for all entries is -more common, so I plan to add support for this (see [[./bog-todo.org][bog-todo.org]]). +The citekey is obtained in the same way as the [[Opening%20a%20PDF%20file][PDF citekey]]. + +BibTeX entries can be stored in one of two ways: + +1. As a single file with many entries +2. As single-entry files named <citekey>.bib within a common directory ** Searching citekey on the web diff --git a/bog-todo.org b/bog-todo.org index 067f3a7..fd4a0ae 100644 --- a/bog-todo.org +++ b/bog-todo.org @@ -45,7 +45,8 @@ Redefine org refile targets. * BibTeX files -** ENH [#A] Make `bog-find-citekey-bib' compatible with a single BibTeX file +** DONE [#A] Make `bog-find-citekey-bib' compatible with a single BibTeX file + CLOSED: [2014-02-07 Fri 01:16] ** ENH Create combined bib from a suffix glob @@ -88,9 +88,29 @@ rename." :group 'bog :type 'string) +(defcustom bog-find-citekey-bib-func 'bog-find-citekey-bib-file + "Function used to find BibTeX entry for citekey. + +Default is `bog-find-citekey-bib-file' that locates single entry +BibTeX files in `bog-bib-directory'. + +The other option is `bog-find-citekey-entry' that searches within +a single BibTeX file, `bog-bib-file', for the citekey entry." + :group 'bog + :type 'function) + (defcustom bog-bib-directory (expand-file-name "bibs" bog-notes-directory) - "The name of the directory that BibTeX files are stored in." + "The name of the directory that BibTeX files are stored in. +This is only meaningful if `bog-find-citekey-bib-func' set to +`bog-find-citekey-bib-file'." + :group 'bog + :type 'string) + +(defcustom bog-bib-file nil + "BibTeX file name. +This is only meaningful if `bog-find-citekey-bib-func' set to +`bog-find-citekey-entry'." :group 'bog :type 'string) @@ -273,16 +293,22 @@ available citekeys. Otherwise, the citekey will be taken from the text under point if it matches `bog-citekey-format' or using `bog-citekey-func'." (interactive "P") - (bog-citekey-action 'bog-open-citekey-bib + (bog-citekey-action bog-find-citekey-bib-func '(lambda () (bog-select-citekey (bog-bib-citekeys))) arg)) -(defun bog-open-citekey-bib (citekey) +(defun bog-find-citekey-bib-file (citekey) + "Open BibTeX file of CITEKEY contained in `bog-bib-directory'." (let ((bib-file (bog-citekey-as-bib citekey))) (unless (file-exists-p bib-file) (error "%s does not exist" bib-file)) (find-file-other-window bib-file))) +(defun bog-find-citekey-entry (citekey) + "Search for CITEKEY in `bog-bib-file'." + (find-file-other-window bog-bib-file) + (bibtex-search-entry citekey)) + ;;;###autoload (defun bog-rename-and-clean-new-bib-files () "Prepare new BibTeX files. |