denemo-devel
[Top][All Lists]
Advanced

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

Re: [Denemo-devel] Bookpart scripts


From: Richard Shann
Subject: Re: [Denemo-devel] Bookpart scripts
Date: Sat, 14 May 2016 20:09:13 +0100

Here I take out the scheme-escape and the eval-string and this will be
ok I think (for eval-string to work you would have to have saved the
string with " " around it, so that guile would evaluate it and get a
string. That is, what you pass to eval-string should be what you would
type at a guile prompt to get it to read the data type you want it to
get, in this case what you would want is for it to read the data and
evaluate it to result in a string). I think this will be ok (it is on
Debian, I can check out that Windows is ok with it).

On its own it is a dangerous command since it doesn't place the } after
the last movement in the bookpart, so the LilyPond becomes
un-typesettable. If I understand correctly what you want I think you
will need to ask for the Movement number where the book part should end
and then set the } on that (you would need to go to that movement set
the } in place and then return the cursor to the where you started
d-PushPosition and d-PopPosition for that).

Richard
oh - and I've moved the ))) into the conventional places for a piece of
Scheme code.

;;;StartBookpart
(let ((tag "StartBookpart")(thetitle ""))
  (d-DirectivePut-movementcontrol-override tag (logior
DENEMO_OVERRIDE_GRAPHIC DENEMO_OVERRIDE_TAGEDIT))
  (disp "checking previous bookpart title ...")
  (if (d-Directive-movementcontrol? tag)
    (set! thetitle (d-DirectiveGet-movementcontrol-data tag)))
  (set! thetitle (d-GetUserInputWithSnippets (_ "Start Bookpart")(_
"Give chapter title::") thetitle))
  (if thetitle
          (begin
            (set! thetitle (car thetitle))
            (if (zero? (string-length thetitle)) ;; if empty title string 
=>delete the directive
                    (begin
                      (disp (string-append "Deleting directive " tag "."))
                      (d-DirectiveDelete-movementcontrol tag)
                      (d-SetSaved #f))
                    (begin
                      (disp thetitle)
                      (d-DirectivePut-movementcontrol-data tag  thetitle)
                      (d-DirectivePut-movementcontrol-prefix tag (string-append 
"\\bookpart { %start of bookpart\n  \\header {\n    title = \\markup { "
                                        thetitle " }\n  }\n"))
              (d-SetSaved #f))))
            (d-InfoDialog "Cancelled")))


On Sat, 2016-05-14 at 18:37 +0200, Andreas Schneider wrote:
> Here is my current version:
> 
> ;;;StartBookpart
> (let ((tag "StartBookpart")(thetitle ""))
>   (d-DirectivePut-movementcontrol-override tag (logior
> DENEMO_OVERRIDE_GRAPHIC DENEMO_OVERRIDE_TAGEDIT))
>   (disp "checking previous bookpart title ...")
>   (if (d-Directive-movementcontrol? tag)
>     (set! thetitle (eval-string (d-DirectiveGet-movementcontrol-data tag))))
>   (set! thetitle (d-GetUserInputWithSnippets (_ "Start Bookpart")(_
> "Give chapter title::") thetitle))
>   (if thetitle
>   (begin
>     (set! thetitle (car thetitle))
>     (if (zero? (string-length thetitle)) ;; if empty title string =>
> delete the directive
>     (begin
>       (disp (string-append "Deleting directive " tag "."))
>       (d-DirectiveDelete-movementcontrol tag)
>       (d-SetSaved #f)
>     )
>     (begin
>       (disp thetitle)
>       (d-DirectivePut-movementcontrol-data tag (scheme-escape thetitle))
>       (d-DirectivePut-movementcontrol-prefix tag (string-append "
> \\bookpart { %start of bookpart\n  \\header {\n    title = \\markup { "
> thetitle " }\n  }\n"))
>       (d-SetSaved #f)
>     )
>   ))
>     (d-InfoDialog "Cancelled")
>   )
> )
> 
> I have inserted (eval-string ...) at the readout of the data field, but
> it throws an error. Thank you for your offer to investigate.
> 
> Andreas
> 
> 
> Am 14.05.2016 um 15:49 schrieb Richard Shann:
> > On Fri, 2016-05-13 at 22:16 +0200, Andreas Schneider wrote:
> >> I have discovered a little issue in my script: backslashes have to be
> >> un-escaped when loading a title from the data field (otherwise the
> >> number of backslashes is doubled every time you edit the title). How do
> >> I do that?
> > 
> > it sounds like you didn't need to use scheme-escape. (You would
> > (eval-string thedatafield) to un-escape it, but there would be no
> > point). The problem I was thinking of arises with accented characters on
> > windows (I think).
> > If you send your code I'll experiment.
> > Sorry if I set you on a wild goose chase mentioning scheme-escape.
> > 
> > Richard
> 





reply via email to

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