From 3ca3bd1022b16c26811af86d48a85e9e74f2c00a Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Sun, 4 Jul 2021 19:46:43 +0530 Subject: doc: Remove redundant file open. * doc/skribilo.scm (source-ref): Remove redundant file open. --- doc/skribilo.scm | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'doc') diff --git a/doc/skribilo.scm b/doc/skribilo.scm index 4a1eda0..3438b82 100644 --- a/doc/skribilo.scm +++ b/doc/skribilo.scm @@ -108,22 +108,20 @@ and END are line numbers indexed from 1." (position->line-number str end)))))) (define (source-ref file regexp text) - (call-with-input-file file - (lambda (port) - (ref #:url (match (sexp-file-lines file regexp) - ((start-line . end-line) - (if (= start-line end-line) - (string-append %source-uri-base - file - "#L" - (number->string start-line)) - (string-append %source-uri-base - file - "#L" - (number->string start-line) - "-L" - (number->string end-line))))) - #:text text)))) + (ref #:url (match (sexp-file-lines file regexp) + ((start-line . end-line) + (if (= start-line end-line) + (string-append %source-uri-base + file + "#L" + (number->string start-line)) + (string-append %source-uri-base + file + "#L" + (number->string start-line) + "-L" + (number->string end-line))))) + #:text text)) ;; HTML engine customizations (let ((html-engine (find-engine 'html))) -- cgit v1.2.3