1

I was told on Reddit that font-lock-studio will help me debug a matcher I was working on, however, I find myself with one more problem than before as I need to learn edebug and also grasp how to debug my font-lock keywords with font-lock-studio.

Thus, I thought maybe setting up something like behavioral tests on the matcher function to help me with the debugging and testing of the matcher itself as I don't exactly know what am I doing (doing right or wrong, to be honest).

At some point, the matcher use set-match-data for the resulting matches, I was wondering if there was a way to get that data in order to compare it with the results I'm looking (match-data is the way to go? Because I eval it after executing manually the matcher function and the values I see makes no sense to me), and also a way to setup a test for the matcher function that can be run at a command.

1
  • Some parts of your question are not clear, to me. Have you read the doc about font-lock-keywords, to understand the possible formats? Have you read the doc about match-data? (If not, that's probably the place to start.) Have you looked at some examples that use font-lock? And please consider showing what you have tried, stating what the result was, and what you expected to see instead.
    – Drew
    Commented Jun 3, 2017 at 5:32

1 Answer 1

2

You can use font-lock-studio to visualize the match data. If you step the matcher function using, say space, the parts of the source buffer that corresponds to the match data is highlighted. The different matches are highlighted in different colors.

If you would like to call your function directly, you can call match-data to get a list that represents the matches. In your case, it should contains eight elements, as in (BEG0 END0 BEG1 END1 etc.).

Edebug isn't hard. You can enable it by evaluating the function using C-u M-C-x and then call it. Execution will stop at the beginning of the function and you can single step though it using space. I would start with the simpler functions, making sure amzn-font-lock-skip-whitespace-etc work as intended (the regexp in looking-at looks suspicious).

If you want to write regression tests, you can use the built-in ert package.

To write regression tests for font-lock packages you can use the package faceup.

5
  • Nothing is highlighted, that's the issue. Other keywords made of regex are, but not the matcher.
    – shackra
    Commented Jun 3, 2017 at 13:20
  • I accepted the answer because it cover many aspects of my question and stuff that aren't asked on it, which is good.
    – shackra
    Commented Jun 3, 2017 at 13:45
  • @shackra, I can try to figure out the problem, can you post a link to the code and an example sourest file to highlight. Commented Jun 4, 2017 at 10:28
  • First, thank you very much! Second, the link to the reddit post I linked in the question was updated with the things you need, please let me know on Reddit or edit your answer and tell me what you were able to find!
    – shackra
    Commented Jun 4, 2017 at 13:40
  • I just answered the reddit post. Commented Jun 4, 2017 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.