[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \concat markup command
From: |
Han-Wen Nienhuys |
Subject: |
Re: \concat markup command |
Date: |
Fri, 24 Nov 2006 13:03:55 +0100 |
User-agent: |
Thunderbird 1.5.0.8 (X11/20061107) |
Werner LEMBERG escreveu:
>>> Good question. Perhaps `\concat { f i }' should be really
>>> identical to `fi', contrary to \line with word-space set to
>>> zero...
>> It's your call. You could try to inspect the arguments, and if they
>> are strings or simple markups, concatenate the strings.
>
> OK, here it is. Please comment -- especially my Scheme code since I'm
> not really acquainted with it.
> #(define-markup-command (concat layout props args) (markup-list?)
> "Concatenate @var{args} in a horizontal line, without spaces inbetween.
> Strings and simple markups are concatenated on the input level, allowing
> ligatures. For example, @code{\\concat @{ \"f\" \\simple #\"i\" @}} is
> equivalent to @code{\"fi\"}."
>
> (define (concat-string-args arg-list)
> (do ((arg-list arg-list (cdr arg-list))
> (result-list '() result-list)
> (result #f (car result-list)))
> ((null? arg-list) (reverse result-list))
> (let ((arg (car arg-list)))
> (if (and (pair? arg) (eqv? (car arg) simple-markup))
> (set! arg (cadr arg)))
> (if (and (string? result) (string? arg))
> (set! result-list (cons (string-append result arg)
> (cdr result-list)))
> (set! result-list (cons arg result-list))))))
This is unschemey. I think it's better to use a
a functional approach. The signature should probably be something like
(concat-string-args args-todo done)
and have a recursion
(concat-string-args (cdr args-todo)
(if (string? ..)
..string-append onto (car done)..
(cons (car args-todo) done)))
another option is to use fold-left or fold-right (srfi-1 IIRC) to do
the list looping
--
Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen
LilyPond Software Design
-- Code for Music Notation
http://www.lilypond-design.com
- Re: \concat markup command, (continued)
- Re: \concat markup command, Werner LEMBERG, 2006/11/12
- Re: \concat markup command, Han-Wen Nienhuys, 2006/11/12
- Re: \concat markup command, Werner LEMBERG, 2006/11/12
- Re: \concat markup command, Han-Wen Nienhuys, 2006/11/12
- Re: \concat markup command, Werner LEMBERG, 2006/11/18
- Re: \concat markup command, Werner LEMBERG, 2006/11/19
Re: \concat markup command, Erik Sandberg, 2006/11/12
- Re: \concat markup command, Werner LEMBERG, 2006/11/12
- Re: \concat markup command, Han-Wen Nienhuys, 2006/11/13
- Re: \concat markup command, Werner LEMBERG, 2006/11/24
- Re: \concat markup command,
Han-Wen Nienhuys <=
- Re: \concat markup command, Werner LEMBERG, 2006/11/24
- Re: \concat markup command, Werner LEMBERG, 2006/11/24
- Re: \concat markup command, Han-Wen Nienhuys, 2006/11/24
- Re: \concat markup command, Werner LEMBERG, 2006/11/29
- Re: \concat markup command, Han-Wen Nienhuys, 2006/11/29