diff options
author | Mathieu Lirzin <mthl@gnu.org> | 2015-09-06 03:05:33 +0200 |
---|---|---|
committer | Mathieu Lirzin <mthl@gnu.org> | 2016-05-07 16:17:52 +0200 |
commit | 805c04fb9033f0d052e3be01eeeed007f940e810 (patch) | |
tree | 423f992ef905767920940482513239598f3bf0d9 /scm | |
parent | 831b14d9805875862d35fccbeace426b5f55d73d (diff) | |
download | mcron-805c04fb9033f0d052e3be01eeeed007f940e810.tar.gz mcron-805c04fb9033f0d052e3be01eeeed007f940e810.tar.bz2 mcron-805c04fb9033f0d052e3be01eeeed007f940e810.zip |
main: Improve 'process-user-file' definition.
* scm/mcron/main.scm (process-user-file): Rename parameters 'file-path'
to 'file-name' and 'assume-guile' to 'guile-syntax?'. Capture
'guile-regexp' and 'vixie-regexp' bindings in the procedure scope.
(guile-file-regexp, vixie-file-regexp): Delete variables.
Diffstat (limited to 'scm')
-rw-r--r-- | scm/mcron/main.scm | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/scm/mcron/main.scm b/scm/mcron/main.scm index 58f1efa..727f013 100644 --- a/scm/mcron/main.scm +++ b/scm/mcron/main.scm @@ -188,23 +188,21 @@ received." (mcron-error 0 (apply format (append (list #f fmt) args))) #f))) -(define guile-file-regexp (make-regexp "\\.gui(le)?$")) -(define vixie-file-regexp (make-regexp "\\.vix(ie)?$")) - -(define (process-user-file file-path . assume-guile) - "Process FILE-PATH according its extension. When ASSUME-GUILE is non nil, -usage of guile syntax is forced for FILE-PATH. If a file is not recognized, -it is silently ignored (this deals properly with most editors' backup files, -for instance)." - (cond ((string=? file-path "-") - (if (string=? (option-ref options 'stdin "guile") "vixie") - (read-vixie-port (current-input-port)) - (eval-string (stdin->string)))) - ((or (not (null? assume-guile)) - (regexp-exec guile-file-regexp file-path)) - (load file-path)) - ((regexp-exec vixie-file-regexp file-path) - (read-vixie-file file-path)))) +(define process-user-file + (let ((guile-regexp (make-regexp "\\.gui(le)?$")) + (vixie-regexp (make-regexp "\\.vix(ie)?$"))) + (lambda* (file-name #:optional guile-syntax?) + "Process FILE-NAME according its extension. When GUILE-SYNTAX? is TRUE, +force guile syntax usage. If FILE-NAME format is not recognized, it is +silently ignored." + (cond ((string=? "-" file-name) + (if (string=? (option-ref options 'stdin "guile") "vixie") + (read-vixie-port (current-input-port)) + (eval-string (stdin->string)))) + ((or guile-syntax? (regexp-exec guile-regexp file-name)) + (load file-name)) + ((regexp-exec vixie-regexp file-name) + (read-vixie-file file-name)))))) (define (process-files-in-user-directory) "Process files in $XDG_CONFIG_HOME/cron and/or ~/.cron directories (if |