guix-commits
[Top][All Lists]
Advanced

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

142/197: gurses: xchar->char: New procedure.


From: Danny Milosavljevic
Subject: 142/197: gurses: xchar->char: New procedure.
Date: Mon, 3 Jul 2017 20:37:15 -0400 (EDT)

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

commit 7bd8cbd515909699803f90e87587ec22061da52a
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"
      cs
      ('() 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))
           dist
           (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)
       cs))
 
@@ -160,7 +164,7 @@ string of length LEN"
       (if (null? in)
          n
          (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 
in)))))
+                                                      (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]