diff options
author | Kyle Meyer <kyle@kyleam.com> | 2014-03-14 00:36:01 -0400 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2014-03-14 01:04:50 -0400 |
commit | b08b66f33ea11c9d6218cd26f7a636d972a7b0f2 (patch) | |
tree | 289501d7451439fc3d217b405fc369194b6ed3cb /bog.el | |
parent | be0c58a1dcdf78b636b1115b0bf4e867d289c222 (diff) | |
download | bog-b08b66f33ea11c9d6218cd26f7a636d972a7b0f2.tar.gz |
ENH: Allow customization of PDF file separator
Diffstat (limited to 'bog.el')
-rw-r--r-- | bog.el | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -144,6 +144,12 @@ alternative is `ido-completing-read'." :group 'bog :type 'string) +(defcustom bog-pdf-file-name-separators '("-" "_") + "Characters allowed to follow the citekey in PDF file names. +When `bog-find-citekey-pdf' is run on <citekey>, it will find +files with the format <citekey><sep>*.pdf, where <sep> is one of +the characters in `bog-pdf-file-name-separators'.") + (defcustom bog-web-search-url "http://scholar.google.com/scholar?q=%s" "URL to use for CITEKEY search. @@ -244,11 +250,7 @@ text under point if it matches `bog-citekey-format' or using (defun bog-open-citekey-pdf (citekey) (let* (citekey-pdf - (citekey-pdfs - (--mapcat (file-expand-wildcards - (concat (file-name-as-directory bog-pdf-directory) - citekey it ".pdf")) - '("" "-*"))) + (citekey-pdfs (bog-citekey-pdfs citekey)) (choices (-map 'file-name-nondirectory citekey-pdfs)) (num-choices (length choices))) (cond @@ -263,6 +265,14 @@ text under point if it matches `bog-citekey-format' or using bog-pdf-directory)))) (start-process "bog-pdf" nil bog-pdf-opener citekey-pdf))) +(defun bog-citekey-pdfs (citekey) + (let* ((patterns (--map (concat it "*") bog-pdf-file-name-separators)) + (patterns (cons "" patterns))) + (--mapcat (file-expand-wildcards + (concat (file-name-as-directory bog-pdf-directory) + citekey it ".pdf")) + patterns))) + ;;;###autoload (defun bog-rename-staged-pdf-to-citekey () "Rename PDF in `bog-stage-directory' to `bog-pdf-directory'/<citekey>.pdf. |