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

Re: adding limit/expand to sh highlighting


On Tue, 3 Feb 2026 at 13:01, Bruce Steers <bsteers4@xxxxxxxxx> wrote:

>
>
> On Tue, 3 Feb 2026 at 00:42, Bruce Steers <bsteers4@xxxxxxxxx> wrote:
>
>> I've tried a number of things.
>>
>> placing...
>>   limit
>>   from /^function/
>>
>> in various places in the sh.highlight file, but no success
>>
>> i need to let the sh.highlignt file know a limit (function) beings in 1
>> of 2 ways
>>
>> function MyCommand() {
>> }
>> or just
>> MyCommand() {
>> }
>>
>> to be honest i don't really understand the new highlight system.
>> I'm unsure of where to put the 'limit' definition in the file and what
>> syntax to use to meet the above mentioned function definition.
>>
>> Any advice would be appreciated.
>>
>> Thanks
>> BruceS
>>
>
> From what i understand from the wiki limit is an additional state added to
> another state so i'm going the the state that has the function keyword.
> <snip>
>

Right I have it almost working now by adding the limit to the
expansion(Expansion) part like this...
---------------
  escape:
    match /\\[abeEfnrtv\\'"?]/
    match /\\[0-7]{3}/
    match /\\x[0-9a-fA-F]{2}/
    match /\\u[0-9a-fA-F]{4}/
    match /\\u[0-9a-fA-F]{8}/
    match /\\c[a-zA-Z]/
expansion{Expansion}:
  match /\$[A-Za-z0-9_]+/
  limit
  keyword function
  from /\s*()\s{/
command{Expansion}:
  from ` to ` with sh
keyword:
  keyword function do else test for to in fi if elif then return exit while
until done break continue select case esac

so with that is works on lines that begin with the word "function"
  keyword function

but it's not working on lines that are just a word ending with () and a {
as the next char
   from /\s*()\s{/

any help on how to get true regex from a line that is a bash function not
using the function keyword.
like the following examples...

MyCommand() {
}
or..
MyCommand()
   {
   }

from all the varieties of regex pattern i've tried a can safely say , i
still don't understand regex :(

Respects
BruceS

References:
adding limit/expand to sh highlightingBruce Steers <bsteers4@xxxxxxxxx>
Re: adding limit/expand to sh highlightingBruce Steers <bsteers4@xxxxxxxxx>