help-source-highlight
[Top][All Lists]
Advanced

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

Re: [Help-source-highlight] conditional highlight (without losing other


From: Federico Bruni
Subject: Re: [Help-source-highlight] conditional highlight (without losing other definitions)
Date: Wed, 22 Feb 2012 09:27:36 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

Il 11/02/2012 17:52, 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

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) #......

So I guess that state|environment is not the solution here. Or I'm
missing something?

these elements lose highlighting since they are in a new environment as
you said, but you can put in the environment the definitions that you
want to be valid; instead of repeating them you might want to use
variables, for instance the definition for #... can be put in a variable
and have the definition outside the environment and inside...

for instance

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

scheme_value = $SCHEME_VALUE

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

though, from what I understand, what you said, it should be

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


Yes, the second is better.
I don't like the repetition, but it's necessary.

One more question: how can I create a variable of a delimiter?
For example:

string delim "\"" "\"" multiline

Should I rephrase it as a regexp?
Or there's a better way?
I've tried the following regexp but I can't make it working multiline.

#string delim "\"" "\"" multiline
vardef STRING = '".*"'
string = $STRING

Thanks,
Federico



reply via email to

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