summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/guile/skribilo.scm6
-rw-r--r--src/guile/skribilo/evaluator.scm12
-rw-r--r--src/guile/skribilo/source.scm4
-rw-r--r--src/guile/skribilo/utils/syntax.scm32
4 files changed, 27 insertions, 27 deletions
diff --git a/src/guile/skribilo.scm b/src/guile/skribilo.scm
index 7d066da..985e0cd 100644
--- a/src/guile/skribilo.scm
+++ b/src/guile/skribilo.scm
@@ -387,11 +387,7 @@ options."
(if input-file
(with-input-from-file input-file
(lambda ()
- (cond-expand (guile-2
- ;; Use the encoding specified by the `coding:'
- ;; comment.
- (let ((p (current-input-port)))
- (set-port-encoding! p (file-encoding p)))))
+ (set-correct-file-encoding!)
(doskribe user-module)))
(doskribe user-module))
diff --git a/src/guile/skribilo/evaluator.scm b/src/guile/skribilo/evaluator.scm
index be223ca..07a578b 100644
--- a/src/guile/skribilo/evaluator.scm
+++ b/src/guile/skribilo/evaluator.scm
@@ -189,12 +189,7 @@
;; Load it
(with-input-from-file filep
(lambda ()
- (cond-expand (guile-2
- ;; Use the encoding specified by the `coding:'
- ;; comment.
- (let ((p (current-input-port)))
- (set-port-encoding! p
- (file-encoding p)))))
+ (set-correct-file-encoding!)
(evaluate-document-from-port (current-input-port) ei
:module module
:reader reader)))
@@ -222,10 +217,7 @@
(with-input-from-file full-path
(lambda ()
- (cond-expand (guile-2
- ;; Use the encoding specified by the `coding:' comment.
- (let ((p (current-input-port)))
- (set-port-encoding! p (file-encoding p)))))
+ (set-correct-file-encoding!)
(save-module-excursion
(lambda ()
(set-current-module module)
diff --git a/src/guile/skribilo/source.scm b/src/guile/skribilo/source.scm
index b0a2a7f..3d2c858 100644
--- a/src/guile/skribilo/source.scm
+++ b/src/guile/skribilo/source.scm
@@ -1,7 +1,7 @@
;;; source.scm -- Highlighting source files.
;;; -*- coding: iso-8859-1 -*-
;;;
-;;; Copyright 2005, 2008, 2009 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright 2005, 2008, 2009, 2010 Ludovic Courtès <ludo@gnu.org>
;;; Copyright 2003, 2004 Erick Gallesio - I3S-CNRS/ESSI <eg@essi.fr>
;;;
;;;
@@ -110,6 +110,7 @@
(path (*source-path*)))))
(with-input-from-file p
(lambda ()
+ (set-correct-file-encoding!)
(if (> (*verbose*) 0)
(format (current-error-port) " [source file: ~S]\n" p))
(let ((startl (if (string? start) (string-length start) -1))
@@ -194,6 +195,7 @@
(else
(let ((ip (open-input-file p)))
+ (set-correct-file-encoding! ip)
(if (> (*verbose*) 0)
(format (current-error-port) " [source file: ~S]\n" p))
(if (not (input-port? ip))
diff --git a/src/guile/skribilo/utils/syntax.scm b/src/guile/skribilo/utils/syntax.scm
index 4cb856f..5a42b09 100644
--- a/src/guile/skribilo/utils/syntax.scm
+++ b/src/guile/skribilo/utils/syntax.scm
@@ -1,6 +1,6 @@
-;;; syntax.scm -- Syntactic candy for Skribilo modules.
+;;; syntax.scm -- Syntactic candy for Skribilo modules. -*- coding: utf-8 -*-
;;;
-;;; Copyright 2005, 2006, 2007, 2008, 2009 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright 2005, 2006, 2007, 2008, 2009, 2010 Ludovic Courtès <ludo@gnu.org>
;;;
;;;
;;; This program is free software; you can redistribute it and/or modify
@@ -23,10 +23,11 @@
:use-module (system reader compat) ;; make sure `current-reader' exists
:use-module (system reader confinement)
:export (%skribilo-module-reader skribilo-module-syntax
- _ N_)
- :export-syntax (unwind-protect unless when))
+ set-correct-file-encoding!
+ _ N_
+ unwind-protect unless when))
-;;; Author: Ludovic Courtès
+;;; Author: Ludovic Courtès
;;;
;;; Commentary:
;;;
@@ -83,6 +84,21 @@
(car exprs)
`(begin ,@exprs))))
+(cond-expand
+ (guile-2
+ (define-syntax set-correct-file-encoding!
+ (syntax-rules ()
+ ((_)
+ (set-correct-file-encoding! (current-input-port)))
+ ((_ port)
+ ;; Use the encoding specified by the `coding:' comment.
+ (let ((e (false-if-exception (file-encoding port))))
+ (and (string? e)
+ (set-port-encoding! port e)))))))
+ (else
+ (define-macro (set-correct-file-encoding! . p)
+ #f)))
+
;;;
;;; Gettext support.
@@ -98,10 +114,4 @@
(define (N_ msg msgplural n)
(ngettext msg msgplural n %skribilo-text-domain))
-
-;;; Local Variables:
-;;; mode: scheme
-;;; coding: latin-1
-;;; End:
-
;;; syntax.scm ends here