Il 07/02/2012 21:48, Lorenzo Bettini ha scritto:
On 02/02/2012 06:09 PM, Federico Bruni wrote:
Hi,

I'm trying to find a smarter way to highlight some strings:

All the "\strings" inside \markup{ ... } should have a different colour
of \strings occurences in other parts of the input.
How can I achieve that in a smart way (i.e. without using a list of all
the \strings which can occur inside a \markup{} block)?

I want to preserve all the other highlighting definitions. Maybe
state|environment is not the right tool? Because in Doc 7.9 it says:

"When entering a state/environment, however, the definitions given
outside the state/environment are not matched. "

Let's do an example:

\markup {
\override #'(box-padding . 1.0) \override #'(baseline-skip . 2.7) \box
\center-column {
\small \line { Sheet music from \with-url
#"http://www.MutopiaProject.org";
\line { \teeny www. \hspace #-0.5 MutopiaProject \hspace #-0.5 \teeny
.org \hspace #0.5 }
}
}
}

I want to match only: \override \box \center-column \small \line
\with-url \teeny \hspace

The following environment:

environment markup delim '\\markup\s*\{' "}" multiline nested begin
environment markup delim "{" "}" multiline nested begin
markup_command = '\\[[:alpha:]-]+'
end
end

Hi

what is that - '\\[[:alpha:]-]+' ?

if the strings starting with \ are fixed, you could simply list them

markup_command = "\override","\box" etc.


I want to avoid using a list: that's the main purpose of my question :)
I said it explicitly:
>> How can I achieve that in a smart way (i.e. without using a list of all
>> the \strings which can occur inside a \markup{} block)?



can see the relevant block and highlight the \strings correctly, but at
the same time it breaks something, in particular some elements lose
their highlighting (as documentations says):

1) \markup
2) {}
3) #......

I didn't understand this, could you please elaborate it?


In my lilypond.lang file all these three elements are defined, so that they are supposed to have their own highlighting: \markup and {} are bold black, #... is kind of brown. But if I use the environment pasted above their highlighting is overridden.

I attach the current version of the files.
As you can see, I wrote a list for markup_command, but this is not much efficient because some \commands should be highlighted as markup commands only if they are inside a \markup{} block (for example, \override). I chose to put in the list only the \commands specific of a \markup block, but if I could make this "conditional highlighting" work it would be much better (for a number of reasons).

I'll be off for a week. I hope to finalize it as soon as I'm back.
If you have any advice in the meanwhile, I'll be happy to hear :)

Thanks,
Federico
# LilyPond v2.14.2

string delim "\"" "\"" multiline

environment scheme delim '#\'?\(' ")" multiline nested begin
  environment scheme delim "(" ")" multiline nested begin
    include "scheme.lang"
  end
  environment string delim "\"" "\"" multiline begin
    include "url.lang"
  end
end

scheme_value = '##(t|f)', '#{1,2}\'?[[:alnum:]\.:+-]+'

comment delim "%{" "%}" multiline nested
comment start "%"

# Symbols
cbracket = "{|}|<<|>>"
symbol = "(|)|~|^|_"
dynamic = '\\(<|>|!|f{1,5}|p{1,5}|m(f|p)|fp|(r|s)fz|s(f|p){1,2})(?!\w)'

# Numbers
specialchar = '(?<!#)-[1-5]\b', '\\[0-9]\b' # strings and fingerings
note_duration = '(?<=[a-zR\',!?>\*])(1|2|4|8|16|32|64|128)(\.+|\b)'
value = '[[:digit:]/]+'

# Markup commands
markup_command = '\\((left-|center-|right-|general-)?align|arrow-head',
    'beam|bold|(left-|right-)brace|(filled-|rounded-)?box|(h)?bracket',
    'caps|char|circle|combine|concat|(left-|center-|right-|dir-)?column',
    'dynamic|dot|draw(-circle|-hline|-line)|eyeglasses|epsfile',
    
'fill-with-pattern|finger|(double|semi|sesqui)?flat|fontCaps|(abs-)?fontsize',
    '(auto-)?footnote|fraction|fret-diagram(-terse|-verbose)?|fromproperty',
    'halign|harp-pedal|hcenter-in|hspace|huge|italic|justify(-field|-string)?',
    '(justified-|fill-)?line|large(r)?|lookup',
    'magnify|mark(alphabet|letter)|markup(list|lines)?|medium',
    'musicglyph|natural|normal-size(-super|-sub)|normalsize',
    'normal-text|note(-by-number)?|null|number',
    'override-lines|pad(-around|-markup|-to-box|-x)',
    'page(-link|-ref)|parenthesize|path|pattern',
    'postscript|property-recursive|put-adjacent',
    'raise|replace|roman|rotate|sans|(double|semi|sesqui)?sharp|simple',
    '(back)?slashed-digit|small(er|Caps)?|stencil|strut|sub|super',
    'table-of-contents|teeny|text|tick|tiny',
    'translate(-scaled)?|transparent|triangle|typewriter|underline|upright',
    'vcenter|vspace|verbatim-file',
    'with-(url|color|dimensions|link)|whiteout|woodwind-diagram',
    'wordwrap(-lines|-field|-string)?)\b'


lyric_command = '\\(lyricmode|lyrics(to)?)'

# Main commands
preproc = '\\(book(part)?|context|consists|header|include|language|layout',
    'midi|once|override(Property)?|paper|remove(WithTag)?',
    'revert|score|(un)?set|version|with)\b'

# Variables of music functions
variable = '(alto|baritone|bass|french|mezzosoprano|percussion',
    'soprano|subbass|tenor|treble|varbaritone',
    'percent|tremolo|unfold|volta',
    
'\\(aeolian|dorian|ionian|lydian|locrian|minor|major|mixolydian|phrygian))\b'

header_variable = 'arranger', 'breakbefore', 'composer', 'copyright', 'date',
    'dedication', 'enteredby', 'filename', 'footer', 'instrument\b', 
'lastupdated',
    'maintainer(Email|Web)?', 'meter', 'moreInfo',
    'mutopia(composer|instrument|opus|poet|title)?',
    'opus', 'poet', 'piece', 'source(url)?', 'style', '(sub){0,2}title',
    'tagline', 'texidoc'

# Contexts
# old regexp: '([A-Z][a-z]+){2,}' <-- too greedy, a list is better
context = '\\?(ChoirStaff|ChordNames|CueVoice|Devnull|Drum(Staff|Voice)',
    'Dynamics|FiguredBass|FretBoards|Global|GrandStaff',
    'GregorianTranscription(Staff|Voice)|Lyrics|Mensural(Staff|Voice)',
    'NoteNames|PianoStaff|RhythmicStaff|Score|Staff(Group)?',
    'Tab(Staff|Voice)|Vaticana(Staff|Voice)|Voice)\b'

# Layout objects
layout_object = 'Accidental(Cautionary|Placement|Suggestion)?',
    'Ambitus(Accidental|Line|NoteHead)?', 'Arpeggio', 'BalloonTextItem',
    'Bar(Line|Number)?', 
'BassFigure(Alignment(Positioning)?|Bracket|Continuation|Line)?',
    'Beam', 'BendAfter', 'Break(AlignGroup|Alignment)?', 'BreathingSign',
    'ChordName', 'Clef', 'Cluster(Spanner(Beacon)?)', 'CombineTextScript',
    'Cue(Clef|EndClef)?', 'Custos', 'Dot(Column|s)?',
    'Double(PercentRepeat(Counter)?|RepeatSlash)?',
    'Dynamic(LineSpanner|Text|TextSpanner)?\b', 'Episema', 'Fingering', 'Flag',
    'Footnote(Item|Spanner)', 'FretBoard', 'Glissando', 'GraceSpacing',
    'Grid(Line|Point)', 'Hairpin', 'HorizontalBracket',
    'Instrument(Name|Switch)', 'Key(Cancellation|Signature)',
    'Laissez(VibrerTie(Column)?)', 'LedgerLineSpanner',
    'LeftEdge', 'LigatureBracket',
    'Lyric(Extender|Hyphen|Space|Text)', 'MeasureGrouping',
    'MelodyItem', 'MensuralLigature', 'MetronomeMark',
    'MultiMeasureRest(Number|Text)?', 'NonMusicalPaperColumn',
    'Note(Collision|Column|Head|Name|Spacing)', 'OctavateEight',
    'OttavaBracket', 'PaperColumn', 'ParenthesesItem',
    'Percent(Repeat(Counter)?)', 'PhrasingSlur', 'PianoPedalBracket',
    'RehearsalMark', 'Repeat(Slash|Tie(Column)?)', 'Rest(Collision)?',
     'Script(Column|Row)?', 'Slur', 'Sostenuto(Pedal(LineSpanner)?)',
     'SpacingSpanner', 'SpanBar', 'Staff(Grouper|Spacing|Symbol)',
     'StanzaNumber', 'Stem(Tremolo)?', 'StringNumber', 'StrokeFinger',
     'SustainPedal(LineSpanner)?',
     'System(StartBar|StartBrace|StartBracket|StartSquare)?',
     'TabNoteHead', 'Text(Script|Spanner)', 'Tie(Column)?', 'TimeSignature',
     'TrillPitch(Accidental|Group|Head)', 'TrillSpanner',
     'Tuplet(Bracket|Number)', 'UnaCordaPedal(LineSpanner)?',
     'VaticanaLigature', 'Vertical(Alignment|AxisGroup)', 'VoiceFollower',
     'VoltaBracket(Spanner)?'

# Context properties
context_property = '\b[a-z]+([A-Z]+[a-z]+)+',
                   'ottavation|output|stanza|timing|tonic'

# Layout properties
layout_property = '\b[a-z]+(-[a-z]+)+', 'indent'

# All the other commands (including variables defined by users)
function = '\\[[:alpha:]-]+'

symbol "#C000C0" b ;
cbracket, preproc black b ;
dynamic "#FF8000" b ;

string "#C20F0F" ;
scheme, scheme_value "#A04900" ;
comment gray i ;

note_duration teal ;
value "#808000" ;
specialchar "#FF8000" ;

function "#0000C0" b ;
markup_command "#008000" ;
lyric_command "#006000" b ;

header_variable, variable blue ;
context "#C000C0" b ;
layout_object "#C000C0" ;
context_property, layout_property blue ;

_______________________________________________
Help-source-highlight mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-source-highlight

Reply via email to