[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
162/197: gurses: Avoid one use of car/cdr.
From: |
Danny Milosavljevic |
Subject: |
162/197: gurses: Avoid one use of car/cdr. |
Date: |
Mon, 3 Jul 2017 20:37:18 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit c969da3496d54eb56df0402355bc53d4ba31966f
Author: John Darrington <address@hidden>
Date: Wed Feb 1 16:12:25 2017 +0100
gurses: Avoid one use of car/cdr.
* gurses/buttons.scm (buttons-post): Use match instead of car/cdr
---
gurses/buttons.scm | 73 +++++++++++++++++++++++++++---------------------------
1 file changed, 36 insertions(+), 37 deletions(-)
diff --git a/gurses/buttons.scm b/gurses/buttons.scm
index eaa7e31..5afef38 100644
--- a/gurses/buttons.scm
+++ b/gurses/buttons.scm
@@ -31,6 +31,7 @@
#:export (buttons-key-matches-symbol?)
#:use-module (ncurses curses)
+ #:use-module (ice-9 match)
#:use-module (srfi srfi-9))
(define-record-type <buttons>
@@ -114,43 +115,41 @@
(let loop ((bl (buttons-items buttons))
(i 0)
(alist '()))
- (if (null? bl)
- (reverse alist)
- (let* ((but (car bl))
- (key (car but))
- (raw-label (gettext (cadr but)))
- (use-underscore (caddr but))
- ;; Convert the raw-label into a "complex rendered string" which
- ;; has the mnemonic character highlighted
- (label.mark
- (let mk-label ((us #f)
- (mark #f)
- (output '())
- (input (string->list raw-label)))
- (if (null? input)
- (cons (reverse output) mark)
- (let ((c (car input)))
- (mk-label (eq? c #\_)
- (if mark mark (if us c #f))
- (if (and (eq? c #\_) use-underscore)
- output
- (cons
- (if us
- ;; On some terminals bold isn't
visible
- ;; Inverse is much clearer.
- (inverse c)
- (normal c))
- output))
- (cdr input))))))
- (label (car label.mark))
- (mark (cdr label.mark))
- (width (+ (length label) 2))
- (w (derwin win 3 width 0
- (round (- (* (1+ i) (/ (getmaxx win) (1+ n)))
- (/ width 2))) #:panel #f)))
- (box w 0 0)
- (addchstr w label #:y 1 #:x 1)
- (loop (cdr bl) (1+ i) (acons mark (list w key) alist))))))))
+ (match bl
+ (() (reverse alist))
+ (((key raw-label use-underscore) . _)
+ (let* (
+ ;; Convert the raw-label into a "complex rendered string"
which
+ ;; has the mnemonic character highlighted
+ (label.mark
+ (let mk-label ((us #f)
+ (mark #f)
+ (output '())
+ (input (string->list raw-label)))
+ (if (null? input)
+ (cons (reverse output) mark)
+ (let ((c (car input)))
+ (mk-label (eq? c #\_)
+ (if mark mark (if us c #f))
+ (if (and (eq? c #\_) use-underscore)
+ output
+ (cons
+ (if us
+ ;; On some terminals bold
isn't visible
+ ;; Inverse is much clearer.
+ (inverse c)
+ (normal c))
+ output))
+ (cdr input))))))
+ (label (car label.mark))
+ (mark (cdr label.mark))
+ (width (+ (length label) 2))
+ (w (derwin win 3 width 0
+ (round (- (* (1+ i) (/ (getmaxx win) (1+ n)))
+ (/ width 2))) #:panel #f)))
+ (box w 0 0)
+ (addchstr w label #:y 1 #:x 1)
+ (loop (cdr bl) (1+ i) (acons mark (list w key) alist)))))))))
- 137/197: installer: Prepare for new wireless network features., (continued)
- 137/197: installer: Prepare for new wireless network features., Danny Milosavljevic, 2017/07/03
- 140/197: installer: Fix the key map option., Danny Milosavljevic, 2017/07/03
- 132/197: installer: Add new procedure to check file system specifications., Danny Milosavljevic, 2017/07/03
- 145/197: gurses: Avoid yet another use of car and cdr., Danny Milosavljevic, 2017/07/03
- 129/197: installer: Emphasise that writing filesystems destroys existing data., Danny Milosavljevic, 2017/07/03
- 150/197: gurses: Reimplement pad-complex-string., Danny Milosavljevic, 2017/07/03
- 159/197: installer: Fix i18n in dialogs., Danny Milosavljevic, 2017/07/03
- 154/197: installer: Main page: Redisplay translatable strings upon refresh., Danny Milosavljevic, 2017/07/03
- 157/197: installer: Replace 'file-browser' with 'key-map'., Danny Milosavljevic, 2017/07/03
- 161/197: installer: Improve i18n in ping page., Danny Milosavljevic, 2017/07/03
- 162/197: gurses: Avoid one use of car/cdr.,
Danny Milosavljevic <=
- 166/197: installer: Provide verbose description of locale., Danny Milosavljevic, 2017/07/03
- 167/197: installer: Fix bug when changing languages., Danny Milosavljevic, 2017/07/03
- 156/197: installer: New page to select language., Danny Milosavljevic, 2017/07/03
- 168/197: installer: Fix the startup locale., Danny Milosavljevic, 2017/07/03
- 173/197: installer: Remove whitespace., Danny Milosavljevic, 2017/07/03
- 01/197: gnu: Add graphical installer, Danny Milosavljevic, 2017/07/03
- 174/197: installer: Provide the ability to add new users., Danny Milosavljevic, 2017/07/03
- 178/197: installer: Infer likely entries for user accounts from the gecos field., Danny Milosavljevic, 2017/07/03
- 180/197: installer: Use a different mount-point for each install attempt., Danny Milosavljevic, 2017/07/03
- 183/197: installer: Specify a pid file for wpa_supplicant., Danny Milosavljevic, 2017/07/03