[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

13/21: gurses: xchar->char: New procedure.

From: John Darrington
Subject: 13/21: gurses: xchar->char: New procedure.
Date: Sun, 29 Jan 2017 07:35:02 +0000 (UTC)

jmd pushed a commit to branch wip-installer
in repository guix.

commit e7a07e59fb36d48e9615c8e247f72910a3a340fa
Author: John Darrington <address@hidden>
Date:   Fri Jan 27 08:47:36 2017 +0100

    gurses: xchar->char: New procedure.
    * gurses/stexi.scm (xchar->char): New procedure.
 gurses/stexi.scm |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index b49ff4d..2f04e7e 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -101,6 +101,10 @@ described by the stexi STXI"
                 (loop (cdr in)
                       (parse-fragment (car in) acc normal))))))))
+(define (xchar->char ch)
+  (car (xchar-chars ch)))
 (define (offset-to-end-of-word ccs)
   "Return the number of xchars until the end of the current word."
@@ -109,14 +113,14 @@ described by the stexi STXI"
      ('() dist)
      (((? xchar? first) . rest)
-      (if (char-set-contains? char-set:blank (car (xchar-chars first)))
+      (if (char-set-contains? char-set:blank (xchar->char first))
           (offset-to-end-of-word' rest (1+ dist))))))
   (offset-to-end-of-word' ccs 0))
 (define (remove-leading-whitespace cs)
-  (if (char-set-contains? char-set:blank (car (xchar-chars (car cs))))
+  (if (char-set-contains? char-set:blank (xchar->char (car cs)))
       (cdr cs)
@@ -160,7 +164,7 @@ string of length LEN"
       (if (null? in)
          (let ((white (char-set-contains? char-set:blank
-                                          (car (xchar-chars (car in))))))
+                                          (xchar->char (car in)))))
            (loop (cdr in) (1+ x) (if (and prev-white (not white))
                                      (1+ n)
                                      n) white)))))
@@ -179,7 +183,7 @@ string of length LEN"
                   "You asked to pad to ~a but the string is already ~a 
characters long."
                   len (length str))))
-          (if (eqv? (car (xchar-chars (last str))) #\newline)
+          (if (eqv? (xchar->char (last str)) #\newline)
               str ; Don't justify the last line of a paragraph
               (let loop ((in str)
                          (out '())
@@ -189,7 +193,7 @@ string of length LEN"
                 (if (null? in)
                     (reverse out)
                     (let* ((white (char-set-contains? char-set:blank
-                                                      (car (xchar-chars (car 
+                                                      (xchar->char (car in))))
                            (end-of-word (and white (not prev-white)))
                            (words-processed (if end-of-word (1+ words) words))
                            (spaces-inserted (if end-of-word

reply via email to

[Prev in Thread] Current Thread [Next in Thread]