denemo-devel
[Top][All Lists]
Advanced

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

Re: [Denemo-devel] Bookpart scripts


From: Andreas Schneider
Subject: Re: [Denemo-devel] Bookpart scripts
Date: Sun, 15 May 2016 17:27:24 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.8.0

Looks complicated. I guess it'll take a long time to make that work, and
I don't have that much time for it now; maybe I look into it on the next
long train ride. For now, I have a working version that I can live with,
i.e. I know that I have look that each Bookpart is closed correctly.

Andreas


Am 15.05.2016 um 10:30 schrieb Richard Shann:
> On Sat, 2016-05-14 at 22:18 +0200, Andreas Schneider wrote:
>> Thank you. The corresponding piece to close the { from StartBookpart is
>> EndBookpart (see code below). Do you think those two should be coupled
>> in some way?
> 
> yes. There are several approaches you could take. The simplest would be
> to use a single tag, "BookPart" say, for both the start and end. (I'm
> assuming that these are always disjoint, that is you can have 
> 
> { .... }{...}...
> but not
> {.. { ...}} ...
> 
> for example.
> 
> In this case you would test if there was a bookpart start on the current
> movement with
> 
> (if (d-DirectiveGet-movementcontrol-prefix "BookPart")
> 
> 
> and you would test if there was a bookpart end with
> 
> 
> (if (d-DirectiveGet-movementcontrol-postfix "BookPart")
> 
> 
> and, of course, there may be both. (This works because of Scheme's
> concept of true and false).
> 
> The other thing you would use is
> 
> (d-GoToPosition movement-number)
> 
> which takes the cursor to the movement 1, 2 ... you give.
> 
> The command "BookPart" would then ask for the end movement number and
> install the start and end movementcontrol directives. thus:
> 
> (d-PushPosition) ;;;saves the current cursor position
> (d-DirectivePut-movementcontrol-prefix tag bookpartstart)
> (d-GoToPosition end-movement-number)
> (d-DirectivePut-movementcontrol-postfix tag bookpartend)
> (d-PopPosition)
> 
> The tricky bit comes with toggling this off again. It would be possible
> to store the end movement number in the scheme data field, but that's
> perhaps not worth doing since we can step forward one movement at a time
> and find it:
> 
> (while (and (d-NextMovement) (not (d-DirectiveGet-movementcontrol-postfix 
> tag))))
> 
> and then either remove the postfix (if there is also a prefix, ie start book 
> part)
> or delete it altogether:
> 
>       (if (d-DirectiveGet-movementcontrol-postfix tag)
>               (if (d-DirectiveGet-movementcontrol-prefix tag) 
>                               (d-DirectivePut-movementcontrol-postfix tag "")
>                               (d-DirectiveDelete-movementcontrol tag))
>               (d-WarningDialog (_ "No book part end")))
> 
> I'm not sure how much Scheme you know, so ask if this is not enough 
> guidance...
> (This is just typed out here off the top of my head, so watch for typos!)
> 
> Richard




reply via email to

[Prev in Thread] Current Thread [Next in Thread]