From 1d3beed53413315ec6c0553b003b8c5776f8c38f Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Thu, 5 Jun 2014 20:34:14 +0200 Subject: [PATCH] Issue 3983: Avoid define-public and define*-public with curried definitions Regarding curried definitions, GUILE has problems with define-public before version 2.0.10, and with define*-public even later. define-safe-public is implemented by LilyPond itself rather than the (ice-9 curried-definitions) module and is unproblematic. This is basically a cop-out since juggling with overriding bugfix definitions of define-public is a distraction for getting GUILEv2 migration under way that we can do without. --- scm/chord-name.scm | 3 ++- scm/flag-styles.scm | 3 ++- scm/music-functions.scm | 18 ++++++++++++------ scm/output-lib.scm | 24 ++++++++++++++++-------- scm/tablature.scm | 3 ++- scm/titling.scm | 6 ++++-- scm/translation-functions.scm | 15 ++++++++++----- scripts/musicxml2ly.py | 2 +- 8 files changed, 49 insertions(+), 25 deletions(-) diff --git a/scm/chord-name.scm b/scm/chord-name.scm index 54faaa5ba7..4dd959bb5b 100644 --- a/scm/chord-name.scm +++ b/scm/chord-name.scm @@ -106,7 +106,7 @@ (list-ref '( "ses" "s" "" "is" "isis") (+ 2 (cdr n-a))) (list-ref '("eses" "es" "" "is" "isis") (+ 2 (cdr n-a))))))))) -(define-public ((chord-name->italian-markup re-with-eacute) pitch lowercase?) +(define ((chord-name->italian-markup re-with-eacute) pitch lowercase?) "Return pitch markup for @var{pitch}, using Italian/@/French note names. If @var{re-with-eacute} is set to @code{#t}, french `ré' is returned for pitch@tie{}D instead of `re'." @@ -125,6 +125,7 @@ pitch@tie{}D instead of `re'." lowercase?)) (accidental->markup-italian alt) )))) +(export chord-name->italian-markup) ;; fixme we should standardize on omit-root (or the other one.) ;; perhaps the default should also be reversed --hwn diff --git a/scm/flag-styles.scm b/scm/flag-styles.scm index 98ec0e4d80..502cb7738c 100644 --- a/scm/flag-styles.scm +++ b/scm/flag-styles.scm @@ -214,11 +214,12 @@ a flag always touches a staff line." -(define-public ((glyph-flag flag-style) grob) +(define ((glyph-flag flag-style) grob) "Simulatesthe default way of generating flags: Look up glyphs @code{flags.style[ud][1234]} from the feta font and use it for the flag stencil." (create-glyph-flag flag-style "" grob)) +(export glyph-flag) diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 0665236a08..b8ceadf5bd 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -906,17 +906,19 @@ NUMBER is 0-base, i.e., Voice=1 (upstems) has number 0. (lambda (elt) (grob::has-interface elt symbol))) -(define-public ((outputproperty-compatibility func sym val) grob g-context ao-context) +(define ((outputproperty-compatibility func sym val) grob g-context ao-context) (if (func grob) (set! (ly:grob-property grob sym) val))) +(export outputproperty-compatibility) -(define-public ((set-output-property grob-name symbol val) grob grob-c context) +(define ((set-output-property grob-name symbol val) grob grob-c context) "Usage example: @code{\\applyoutput #(set-output-property 'Clef 'extra-offset '(0 . 1))}" (let ((meta (ly:grob-property grob 'meta))) (if (equal? (assoc-get 'name meta) grob-name) (set! (ly:grob-property grob symbol) val)))) +(export set-output-property) (define-public (skip->rest mus) @@ -1229,7 +1231,7 @@ set to the @code{location} parameter." (and clef (make-cue-clef-unset)))))) quote-music)) -(define-public ((quote-substitute quote-tab) music) +(define ((quote-substitute quote-tab) music) (let* ((quoted-name (ly:music-property music 'quoted-music-name)) (quoted-vector (and (string? quoted-name) (hash-ref quote-tab quoted-name #f)))) @@ -1243,6 +1245,7 @@ set to the @code{location} parameter." ly:quote-iterator::constructor)) (ly:music-warning music (ly:format (_ "cannot find quoted music: `~S'") quoted-name)))) music)) +(export quote-substitute) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1507,7 +1510,7 @@ also get an accidental." (cons need-restore need-accidental))) -(define-public ((make-accidental-rule octaveness laziness) context pitch barnum measurepos) +(define ((make-accidental-rule octaveness laziness) context pitch barnum measurepos) "Create an accidental rule that makes its decision based on the octave of the note and a laziness value. @@ -1525,12 +1528,14 @@ accidental lasts over that many bar lines. @w{@code{-1}} is `forget immediately', that is, only look at key signature. @code{#t} is `forever'." (check-pitch-against-signature context pitch barnum laziness octaveness #f)) +(export make-accidental-rule) -(define-public ((make-accidental-dodecaphonic-rule octaveness laziness) context pitch barnum measurepos) +(define ((make-accidental-dodecaphonic-rule octaveness laziness) context pitch barnum measurepos) "Variation on function make-accidental-rule that creates an dodecaphonic accidental rule." (check-pitch-against-signature context pitch barnum laziness octaveness #t)) +(export make-accidental-dodecaphonic-rule) (define (key-entry-notename entry) "Return the pitch of an @var{entry} in @code{localAlterations}. @@ -2223,7 +2228,7 @@ other stems just because of that." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; The following is used by the alterBroken function. -(define-public ((value-for-spanner-piece arg) grob) +(define ((value-for-spanner-piece arg) grob) "Associate a piece of broken spanner @var{grob} with an element of list @var{arg}." (let* ((orig (ly:grob-original grob)) @@ -2239,6 +2244,7 @@ of list @var{arg}." (if (>= (length siblings) 2) (helper siblings arg) (car arg)))) +(export value-for-spanner-piece) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; measure counter diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 776e618e37..c607fe4122 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -562,34 +562,37 @@ and duration-log @var{log}." ;; a formatter function, which is simply a wrapper around an existing ;; tuplet formatter function. It takes the value returned by the given ;; function and appends a note of given length. -(define-public ((tuplet-number::append-note-wrapper function note) grob) +(define ((tuplet-number::append-note-wrapper function note) grob) (let ((txt (if function (function grob) #f))) (if txt (markup txt #:fontsize -5 #:note note UP) (markup #:fontsize -5 #:note note UP)))) +(export tuplet-number::append-note-wrapper) ;; Print a tuplet denominator with a different number than the one derived from ;; the actual tuplet fraction -(define-public ((tuplet-number::non-default-tuplet-denominator-text denominator) +(define ((tuplet-number::non-default-tuplet-denominator-text denominator) grob) (number->string (if denominator denominator (ly:event-property (event-cause grob) 'denominator)))) +(export tuplet-number::non-default-tuplet-denominator-text) ;; Print a tuplet fraction with different numbers than the ones derived from ;; the actual tuplet fraction -(define-public ((tuplet-number::non-default-tuplet-fraction-text +(define ((tuplet-number::non-default-tuplet-fraction-text denominator numerator) grob) (let* ((ev (event-cause grob)) (den (if denominator denominator (ly:event-property ev 'denominator))) (num (if numerator numerator (ly:event-property ev 'numerator)))) (format #f "~a:~a" den num))) +(export tuplet-number::non-default-tuplet-fraction-text) ;; Print a tuplet fraction with note durations appended to the numerator and the ;; denominator -(define-public ((tuplet-number::fraction-with-notes +(define ((tuplet-number::fraction-with-notes denominatornote numeratornote) grob) (let* ((ev (event-cause grob)) (denominator (ly:event-property ev 'denominator)) @@ -597,10 +600,11 @@ and duration-log @var{log}." ((tuplet-number::non-default-fraction-with-notes denominator denominatornote numerator numeratornote) grob))) +(export tuplet-number::fraction-with-notes) ;; Print a tuplet fraction with note durations appended to the numerator and the ;; denominator -(define-public ((tuplet-number::non-default-fraction-with-notes +(define ((tuplet-number::non-default-fraction-with-notes denominator denominatornote numerator numeratornote) grob) (let* ((ev (event-cause grob)) (den (if denominator denominator (ly:event-property ev 'denominator))) @@ -612,6 +616,7 @@ and duration-log @var{log}." (make-simple-markup " : ") (make-simple-markup (format #f "~a" num)) (markup #:fontsize -5 #:note numeratornote UP))))) +(export tuplet-number::non-default-fraction-with-notes) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1021,7 +1026,7 @@ between the two text elements." '(bound-details left padding) (+ my-padding script-padding))))))) -(define-public ((elbowed-hairpin coords mirrored?) grob) +(define ((elbowed-hairpin coords mirrored?) grob) "Create hairpin based on a list of @var{coords} in @code{(cons x y)} form. @code{x} is the portion of the width consumed for a given line and @code{y} is the portion of the height. For example, @@ -1080,6 +1085,7 @@ and draws the stencil based on its coordinates. (if mirrored? (my-c-p-s downlist thick decresc?) empty-stencil)) (cons xtrans ytrans))) '()))) +(export elbowed-hairpin) (define-public flared-hairpin (elbowed-hairpin '((0.95 . 0.4) (1.0 . 1.0)) #t)) @@ -1099,13 +1105,14 @@ and draws the stencil based on its coordinates. (make-tied-lyric-markup text) text)))) -(define-public ((grob::calc-property-by-copy prop) grob) +(define ((grob::calc-property-by-copy prop) grob) (ly:event-property (event-cause grob) prop)) +(export grob::calc-property-by-copy) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; general inheritance -(define-public ((grob::inherit-parent-property axis property . default) grob) +(define ((grob::inherit-parent-property axis property . default) grob) "@var{grob} callback generator for inheriting a @var{property} from an @var{axis} parent, defaulting to @var{default} if there is no parent or the parent has no setting." @@ -1115,6 +1122,7 @@ parent or the parent has no setting." (apply ly:grob-property parent property default)) ((pair? default) (car default)) (else '())))) +(export grob::inherit-parent-property) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; fret boards diff --git a/scm/tablature.scm b/scm/tablature.scm index 668bf2faa3..36b81106c1 100644 --- a/scm/tablature.scm +++ b/scm/tablature.scm @@ -224,9 +224,10 @@ ;; a callback for custom fret labels -(define-public ((tab-note-head::print-custom-fret-label fret) grob) +(define ((tab-note-head::print-custom-fret-label fret) grob) (ly:grob-set-property! grob 'text fret) (tab-note-head::print grob)) +(export tab-note-head::print-custom-fret-label) (define-public (tab-note-head::print grob) (define (is-harmonic? grob) diff --git a/scm/titling.scm b/scm/titling.scm index 8e6ae7b7bb..41a32dd467 100644 --- a/scm/titling.scm +++ b/scm/titling.scm @@ -23,7 +23,7 @@ ;;;;;;;;;;;;;;;;;; -(define-public ((marked-up-headfoot what-odd what-even) +(define ((marked-up-headfoot what-odd what-even) layout scopes page-number is-last-bookpart is-bookpart-last-page) "Read variables @var{what-odd}, @var{what-even} from @var{layout}, and interpret them as markup. The @var{props} argument will include @@ -71,8 +71,9 @@ variables set in @var{scopes} and @code{page:is-bookpart-last-page}, (markup? (get what-even))) (get what-even) (get what-odd)))) +(export marked-up-headfoot) -(define-public ((marked-up-title what) layout scopes) +(define ((marked-up-title what) layout scopes) "Read variables @var{what} from @var{scopes}, and interpret it as markup. The @var{props} argument will include variables set in @var{scopes} (prefixed with `header:'." @@ -101,3 +102,4 @@ with `header:'." (if (markup? markup) (interpret-markup layout props markup) empty-stencil))) +(export marked-up-title) diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index 4479d3ae1b..3e65016edb 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -42,7 +42,7 @@ way the transposition number is displayed." ;; prepare using other fonts than 'fetaMusic. ;; Currently it ensures that the default-fonts are used by the ;; markup-command 'note-by-number' in 'metronome-markup' (see below). -(define*-public +(define* ((styled-metronome-markup #:optional (glyph-font 'default)) event context) (let ((hide-note (ly:context-property context 'tempoHideNote #f)) @@ -51,6 +51,7 @@ way the transposition number is displayed." (count (ly:event-property event 'metronome-count))) (metronome-markup glyph-font text dur count hide-note))) +(export styled-metronome-markup) (define-public format-metronome-markup (styled-metronome-markup)) @@ -634,16 +635,19 @@ only ~a fret labels provided") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; bar numbers -(define-public ((every-nth-bar-number-visible n) barnum mp) +(define ((every-nth-bar-number-visible n) barnum mp) (= 0 (modulo barnum n))) +(export every-nth-bar-number-visible) -(define-public ((modulo-bar-number-visible n m) barnum mp) +(define ((modulo-bar-number-visible n m) barnum mp) (and (> barnum 1) (= m (modulo barnum n)))) +(export modulo-bar-number-visible) -(define-public ((set-bar-number-visibility n) tr) +(define ((set-bar-number-visibility n) tr) (let ((bn (ly:context-property tr 'currentBarNumber))) (ly:context-set-property! tr 'barNumberVisibility (modulo-bar-number-visible n (modulo bn n))))) +(export set-bar-number-visibility) (define-public (first-bar-number-invisible barnum mp) (> barnum 1)) @@ -688,8 +692,9 @@ only ~a fret labels provided") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; percent repeat counters -(define-public ((every-nth-repeat-count-visible n) count context) +(define ((every-nth-repeat-count-visible n) count context) (= 0 (modulo count n))) +(export every-nth-repeat-count-visible) (define-public (all-repeat-counts-visible count context) #t) diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 2da2dab60e..e270aed95e 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -41,7 +41,7 @@ additional_definitions = { "tuplet-note-wrapper": """ % a formatter function, which is simply a wrapper around an existing % tuplet formatter function. It takes the value returned by the given % function and appends a note of given length. - #(define-public ((tuplet-number::append-note-wrapper function note) grob) + #(define ((tuplet-number::append-note-wrapper function note) grob) (let* ((txt (if function (function grob) #f))) (if txt (markup txt #:fontsize -5 #:note note UP) -- 2.39.2