[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
143/197: gurses: Add predicate to test if a complex char is blank.
From: |
Danny Milosavljevic |
Subject: |
143/197: gurses: Add predicate to test if a complex char is blank. |
Date: |
Mon, 3 Jul 2017 20:37:15 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit d5af3b384b1bf30e7cb3be9198840cf26cebb63d
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)
- 170/197: installer: Remove unused procedure., (continued)
- 170/197: installer: Remove unused procedure., Danny Milosavljevic, 2017/07/03
- 152/197: installer: New file i18n.scm., Danny Milosavljevic, 2017/07/03
- 110/197: installer: Add an explanatory text to the main page., Danny Milosavljevic, 2017/07/03
- 120/197: gurses: Mini refactor., Danny Milosavljevic, 2017/07/03
- 124/197: gurses: Populate dropdown boxes in forms using a menu., Danny Milosavljevic, 2017/07/03
- 131/197: gurses: Use inverse instead of underline for field value area., Danny Milosavljevic, 2017/07/03
- 133/197: installer: Change livery., Danny Milosavljevic, 2017/07/03
- 146/197: gurses: Use match instead of car/cdr in line-split., Danny Milosavljevic, 2017/07/03
- 147/197: gurses: In paragraph-format avoid use of car and cdr., Danny Milosavljevic, 2017/07/03
- 144/197: gurses: Avoid one more use of car and cdr., Danny Milosavljevic, 2017/07/03
- 143/197: gurses: Add predicate to test if a complex char is blank.,
Danny Milosavljevic <=
- 149/197: gurses: Add new procedure "word-endings"., Danny Milosavljevic, 2017/07/03
- 155/197: installer: Use _ instead of M_ for host-name-refresh., Danny Milosavljevic, 2017/07/03
- 160/197: installer: New convenience procedures., Danny Milosavljevic, 2017/07/03
- 158/197: installer: Correct placement of gettext call., Danny Milosavljevic, 2017/07/03
- 163/197: gurses: Cache the windows of buttons., Danny Milosavljevic, 2017/07/03
- 172/197: gurses: Update the cursor position when posting the form., Danny Milosavljevic, 2017/07/03
- 165/197: installer: New procedure key-value-slurp., Danny Milosavljevic, 2017/07/03
- 175/197: gurses: Don't crash if asked for an item by an invalid index., Danny Milosavljevic, 2017/07/03
- 171/197: installer: New page to edit user accounts., Danny Milosavljevic, 2017/07/03
- 187/197: installer: Add procudure for starting a wireless interface., Danny Milosavljevic, 2017/07/03