From 0342e7a1425431fe79c630acaca433c9aed8a882 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Tue, 17 Feb 2015 21:57:17 -0500 Subject: 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. --- bog.el | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'bog.el') diff --git a/bog.el b/bog.el index 2f97c1d..a2da652 100644 --- a/bog.el +++ b/bog.el @@ -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 , it will find files with the format .* and *., -where is one of these characters." +where 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 [/]CITEKEY*., where -is a character in `bog-citekey-file-name-separators' and is +These should be named [/]CITEKEY[*]., where + 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. -- cgit v1.2.3