[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
14/21: gurses: Add predicate to test if a complex char is blank.
From: |
John Darrington |
Subject: |
14/21: gurses: Add predicate to test if a complex char is blank. |
Date: |
Sun, 29 Jan 2017 07:35:02 +0000 (UTC) |
jmd pushed a commit to branch wip-installer
in repository guix.
commit 5944670c47acf5dcde87bad1097fe047075615a9
Author: John Darrington <address@hidden>
Date: Fri Jan 27 08:59:15 2017 +0100
gurses: Add predicate to test if a complex char is blank.
* gurses/stexi.scm (xchar-blank?): New procedure.
---
gurses/stexi.scm | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/gurses/stexi.scm b/gurses/stexi.scm
index 2f04e7e..6174d73 100644
--- a/gurses/stexi.scm
+++ b/gurses/stexi.scm
@@ -102,9 +102,14 @@ described by the stexi STXI"
(parse-fragment (car in) acc normal))))))))
+
(define (xchar->char ch)
(car (xchar-chars ch)))
+(define (xchar-blank? ch)
+ "Return #f if ch is not a blank character"
+ (char-set-contains? char-set:blank (xchar->char ch)))
+
(define (offset-to-end-of-word ccs)
"Return the number of xchars until the end of the current word."
@@ -113,14 +118,14 @@ described by the stexi STXI"
cs
('() dist)
(((? xchar? first) . rest)
- (if (char-set-contains? char-set:blank (xchar->char first))
+ (if (xchar-blank? 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 (xchar->char (car cs)))
+ (if (xchar-blank? (car cs))
(cdr cs)
cs))
@@ -163,11 +168,10 @@ string of length LEN"
(prev-white #t))
(if (null? in)
n
- (let ((white (char-set-contains? char-set:blank
- (xchar->char (car in)))))
- (loop (cdr in) (1+ x) (if (and prev-white (not white))
- (1+ n)
- n) white)))))
+ (let ((white (xchar-blank? (car in))))
+ (loop (cdr in) (1+ x) (if (and prev-white (not white))
+ (1+ n)
+ n) white)))))
(let* ((underflow (- len (length str)))
(word-count (count-words str))
@@ -192,16 +196,15 @@ string of length LEN"
(prev-white #t))
(if (null? in)
(reverse out)
- (let* ((white (char-set-contains? char-set:blank
- (xchar->char (car in))))
+ (let* ((white (xchar-blank? (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
- (truncate (- (*
- (/ underflow
inter-word-space-count)
- words-processed)
- spaces))
- 0)))
+ (truncate (- (*
+ (/ underflow
inter-word-space-count)
+ words-processed)
+ spaces))
+ 0)))
(loop (cdr in)
;; FIXME: Use a more intelligent algorithm.
;; (prefer spaces at sentence endings for example)
- branch wip-installer updated (61c0ffb -> 9ff399e), John Darrington, 2017/01/29
- 02/21: gurses: Use inverse instead of underline for field value area., John Darrington, 2017/01/29
- 07/21: installer: No passphrase is needed for clear networks., John Darrington, 2017/01/29
- 04/21: installer: Change livery., John Darrington, 2017/01/29
- 08/21: installer: Prepare for new wireless network features., John Darrington, 2017/01/29
- 05/21: installer: Tolerate an undefined system role in config generation., John Darrington, 2017/01/29
- 09/21: installer: Clear the mount point field for swap file systems., John Darrington, 2017/01/29
- 03/21: installer: Add new procedure to check file system specifications., John Darrington, 2017/01/29
- 01/21: installer: Delete unused procedure "justify"., John Darrington, 2017/01/29
- 20/21: gurses: Add new procedure "word-endings"., John Darrington, 2017/01/29
- 14/21: gurses: Add predicate to test if a complex char is blank.,
John Darrington <=
- 12/21: gurses: Avoid one usage of car and cdr., John Darrington, 2017/01/29
- 15/21: gurses: Avoid one more use of car and cdr., John Darrington, 2017/01/29
- 13/21: gurses: xchar->char: New procedure., John Darrington, 2017/01/29
- 19/21: installer: Support WEP encrypted wireless., John Darrington, 2017/01/29
- 16/21: gurses: Avoid yet another use of car and cdr., John Darrington, 2017/01/29
- 11/21: installer: Fix the key map option., John Darrington, 2017/01/29
- 18/21: gurses: In paragraph-format avoid use of car and cdr., John Darrington, 2017/01/29
- 06/21: installer: Use a "hard" method of rebooting. Do not rely on shepherd., John Darrington, 2017/01/29
- 10/21: installer: Allow file system specifications to be removed., John Darrington, 2017/01/29
- 17/21: gurses: Use match instead of car/cdr in line-split., John Darrington, 2017/01/29