Is it possible to make a keyword / variable / predefined name with delimeter?

115 views
Skip to first unread message

Daniel Paz

unread,
Aug 21, 2021, 4:02:30 PM8/21/21
to BBEdit Talk
So I want for example to keyword with the following regex: "keyword-keyword" e.g. "Hello-World", but apparently, the char "-" is not allowed to be used as keyword.

I also tried the follkowing:

<key>BBLMKeywordPatterns</key>
<array>
<dict>
<key>RunKind</key>
<string>com.barebones.bblm.variable</string>
<key>Pattern</key>
<string>[a-zA-Z0-9]+\-[a-zA-Z0-9]+</string>
        </dict>
        </array>

but it does not work

any solution?

Christopher Waterman

unread,
Aug 22, 2021, 1:03:20 AM8/22/21
to bbe...@googlegroups.com
Daniel,
Did you add “-“ to Identifier and Keyword Character Class?

<key>Identifier and Keyword Character Class</key>
<string>A-Za-z-</string>

—Chris

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/998c9228-fde4-44cc-8457-77b8656b275cn%40googlegroups.com.

Daniel Paz

unread,
Aug 24, 2021, 3:06:14 AM8/24/21
to BBEdit Talk
It doesn't work if it includes "-" and numbers, for example "Hello-5" even if I write:

<key>Identifier and Keyword Character Class</key>
<string>A-Za-z0-9-</string>

jj

unread,
Aug 24, 2021, 4:15:54 AM8/24/21
to BBEdit Talk
Hi Daniel,

Here is a minimal Codeless Language Module for an hypothetical "Daniel" language that accepts hyphens in keywords.
Save it as Daniel.plist in ~/Library/Application Support/BBEdit/Language Modules.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>BBEditDocumentType</key>
    <string>CodelessLanguageModule</string>
    <key>BBLMColorsSyntax</key>
    <true/>
    <key>BBLMIsCaseSensitive</key>
    <false/>
    <key>BBLMLanguageCode</key>
    <string>Dani</string>
    <key>BBLMLanguageDisplayName</key>
    <string>Daniel</string>
    <key>BBLMSuffixMap</key>
    <array>
        <dict>
        <key>BBLMLanguageSuffix</key>
        <string>.daniel</string>
        </dict>
    </array>
    <key>BBLMKeywordList</key>
    <array>
        <string>step-by-step</string>
        <string>Juan-les-Pins</string>
        <string>2021-08-24</string>
    </array>
    <key>Language Features</key>
    <dict>
        <key>Identifier and Keyword Character Class</key>
        <string>\p{L}\p{N}\-</string>
    </dict>
</dict>
</plist>

It currently only support 3 keywords:
 •  step-by-step
 • Juan-les-Pins
 • 2021-08-24

HTH

Jean Jourdain

Daniel Paz

unread,
Aug 24, 2021, 5:18:06 AM8/24/21
to BBEdit Talk
thanks it worked! btw how can i create new colors? for example if i go to prefrences -> text colors I can see colors of "CSS", "HTML" and more... how can I create one as well? or define fixed colors in my plist?

Daniel Paz

unread,
Aug 24, 2021, 5:35:33 AM8/24/21
to BBEdit Talk
btw, if I add

<key>String Pattern</key>
<string>(?x:
('[^\s\[\]]*)
)
</string>

it doesn't work anymore.

jj

unread,
Aug 24, 2021, 6:37:46 AM8/24/21
to BBEdit Talk
Try wrapping the regular expression in a CDATA, like so:

        <string><![CDATA[(?x)
            ('[^\s\[\]]*)
        ]]></string>


Daniel Paz

unread,
Aug 24, 2021, 7:02:19 AM8/24/21
to BBEdit Talk
i tried, but the numbers of "-" not working, only chars.

jj

unread,
Aug 24, 2021, 8:07:07 AM8/24/21
to BBEdit Talk
Apparently BBEdit's default numbers highlighter has precedence over keywords'.

Try adding an empty number pattern to disable it.

    <key>Language Features</key>
    <dict>
        ...
        <key>String Pattern</key>
        <string><![CDATA[(?x)
            ('[^\s\[\]]*)
        ]]></string>
        <key>Number Pattern</key>
        <string></string>
    </dict>

Daniel Paz

unread,
Aug 24, 2021, 11:47:19 AM8/24/21
to BBEdit Talk
Thanks it worked!
Reply all
Reply to author
Forward
0 new messages