diff options
author | Ludovic Courtès | 2010-03-08 00:27:57 +0100 |
---|---|---|
committer | Ludovic Courtès | 2010-03-08 00:27:57 +0100 |
commit | 86de6d9453a9d747bddadd20fce67e58c4dbe8c7 (patch) | |
tree | 44ad52bc21763d13adf5de74d3c50ab92a75fae4 /src | |
parent | cb2c1a2e6bef653cf9b7aa003d8fcfe09fc4eca0 (diff) | |
download | skribilo-86de6d9453a9d747bddadd20fce67e58c4dbe8c7.tar.gz skribilo-86de6d9453a9d747bddadd20fce67e58c4dbe8c7.tar.lz skribilo-86de6d9453a9d747bddadd20fce67e58c4dbe8c7.zip |
Factorize encoding twiddling in `set-correct-file-encoding!'.
* doc/modules/skribilo/documentation/api.scm (api-search-definition):
Call `set-correct-file-encoding!'.
* doc/user/src/outline.txt (Author): Remove accent from last name, as a
temporary hack.
* doc/user/syntax.skb: Call `set-correct-file-encoding!' in the
`outline' syntax example.
* doc/user/user.skb: Use `(skribilo utils syntax)'.
* src/guile/skribilo.scm (skribilo): Replace encoding twiddling with
`set-correct-file-encoding!' call.
* src/guile/skribilo/evaluator.scm (load-document, include-document):
Likewise.
* src/guile/skribilo/source.scm (source-read-lines): Call
`set-correct-file-encoding!'.
(source-read-definition): Likewise.
* src/guile/skribilo/utils/syntax.scm (set-correct-file-encoding!): New
macro.
Diffstat (limited to 'src')
-rw-r--r-- | src/guile/skribilo.scm | 6 | ||||
-rw-r--r-- | src/guile/skribilo/evaluator.scm | 12 | ||||
-rw-r--r-- | src/guile/skribilo/source.scm | 4 | ||||
-rw-r--r-- | src/guile/skribilo/utils/syntax.scm | 32 |
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 |