[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-mcron] [PATCH 27/33] main: Improve 'process-user-file' definition.
From: |
Mathieu Lirzin |
Subject: |
[Bug-mcron] [PATCH 27/33] main: Improve 'process-user-file' definition. |
Date: |
Sun, 27 Sep 2015 23:00:38 +0200 |
* 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.
---
scm/mcron/main.scm | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/scm/mcron/main.scm b/scm/mcron/main.scm
index 4aea584..58a3509 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
- [Bug-mcron] [PATCH 04/33] main: Add show-version., (continued)
- [Bug-mcron] [PATCH 04/33] main: Add show-version., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 08/33] build: Improve maintainer-clean rule., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 07/33] Augment TODO., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 09/33] build: Generate 'ChangeLog' upon 'make dist'., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 10/33] build: Fix prerequisite of the man page target., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 11/33] main: Import the modules used in one time., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 12/33] main: Use 'when' and 'unless' special forms., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 14/33] main: Make 'catch-mcron-error' macro hygienic., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 16/33] main: Add cron-file-descriptors., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 27/33] main: Improve 'process-user-file' definition.,
Mathieu Lirzin <=
- [Bug-mcron] [PATCH 15/33] main: Add docstrings., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 26/33] mcron: Make functions 'static'., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 29/33] environment: Redefine 'modify-environment'., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 17/33] main: Add main., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 21/33] main: Remove obsolete debug option., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 22/33] redirect: Use module (ice-9 regex)., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 23/33] mcron: Add forward declarations., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 28/33] main: Remove unused 'regular-file?' procedure., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 24/33] mcron: Use symbolic constants., Mathieu Lirzin, 2015/09/27
- [Bug-mcron] [PATCH 25/33] mcron: Rework comments., Mathieu Lirzin, 2015/09/27