diff options
author | Kyle Meyer <kyle@kyleam.com> | 2015-02-17 21:57:17 -0500 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2015-02-17 21:57:17 -0500 |
commit | 0342e7a1425431fe79c630acaca433c9aed8a882 (patch) | |
tree | 0627f8ed9385193ed51cdd85983376d3a9f14ad9 | |
parent | c558b0ce4b5424411777222b4c9ae67594ebe3a1 (diff) | |
download | bog-0342e7a1425431fe79c630acaca433c9aed8a882.tar.gz |
Use regexp for bog-citekey-file-name-separators
Use regular expression to specify separators. This allows more
flexibility in customizing citekey file names and is easily fed to
directory-files.
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | bog.el | 21 |
2 files changed, 14 insertions, 10 deletions
@@ -8,6 +8,9 @@ Variables =bog-pdf-directory= and =bog-pdf-file-name-separators= have been replaced by new variables =bog-file-directory= and =bog-citekey-file-name-separators=, respectively. + Unlike =bog-pdf-file-name-separators=, the value of + =bog-citekey-file-name-separators= is a regular expression, not a + list. - In addition to =bog-find-citekey-file= and =bog-find-citekey-bib=, most functions will now prompt with set of citekeys when prefix @@ -151,13 +151,13 @@ This is only meaningful if `bog-find-citekey-bib-func' set to :type '(choice (const :tag "Don't use single file" nil) (file :tag "Single file"))) -(defcustom bog-citekey-file-name-separators '("-" "_") - "Values allowed to follow the citekey in file names. +(defcustom bog-citekey-file-name-separators "[-_]" + "Regular expression matching separators in file names. When `bog-find-citekey-file' is run on <citekey>, it will find files with the format <citekey>.* and <citekey><sep>*.<ext>, -where <sep> is one of these characters." +where <sep> is matched by this regular expression.." :group 'bog - :type '(repeat string)) + :type 'regexp) (defcustom bog-file-renaming-func 'bog-file-ask-on-conflict "Function used to rename staged files. @@ -480,16 +480,17 @@ locating a citekey from context fails." (defun bog-citekey-files (citekey) "Return files in `bog-file-directory' associated with CITEKEY. -These should be named [<subdir>/]CITEKEY<sep>*.<ext>, where <sep> -is a character in `bog-citekey-file-name-separators' and is +These should be named [<subdir>/]CITEKEY[<sep>*].<ext>, where +<sep> is a character in `bog-citekey-file-name-separators' and is determined by `bog-subdirectory-group'." (let* ((subdir (bog--get-subdir citekey)) (dir (file-name-as-directory (or (and subdir (expand-file-name subdir bog-file-directory)) - bog-file-directory))) - (patterns (--map (concat it "*") bog-citekey-file-name-separators)) - (patterns (cons ".*" patterns))) - (--mapcat (file-expand-wildcards (concat dir citekey it)) patterns))) + bog-file-directory)))) + (directory-files dir t + (format "^%s\\(%s.*\\)\\{0,1\\}\\..*" + citekey + bog-citekey-file-name-separators)))) (defun bog--get-subdir (citekey) "Return subdirectory for citekey file. |