[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature request/RFC: proper highlighting of code embedded in comment
From: |
Clément Pit--Claudel |
Subject: |
Re: Feature request/RFC: proper highlighting of code embedded in comments |
Date: |
Sun, 16 Oct 2016 17:05:01 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 |
Thanks! How is the package called? I don't see it list-packages :/
This sounds pretty similar to the solution I outlined before, though. The
problem that I ran into with python is that I also need to "reopen" the quotes
or comments. For example. a bit of code might be in the middle of a docstring,
like this:
def example():
"""Blah
>>> blah(xyz)
bluh!
What a great example!
"""
The issue here is that “What a great example” is a string. I tried using a
syntactic face function to mark the last ‘>’ as a strong closer and the newline
as a string opener, but that confused the existing function, which expects the
docstring starter to be ‘"""’, not ‘\n’. Even after fixing this, python-mode
was unusable: it inflooped when trying to find a whole defun, because the
nav-end-of-defun function isn't ready to accept ‘\n’ as a string starter.
Cheers,
Clément.
On 2016-10-16 13:42, Stefan Monnier wrote:
> FWIW, in sm-c-mode.el (in elpa.git), CPP directives are treated as
> comments, and since they do contain code, I have to solve the same kind
> of problem.
>
> I (ab)use for that purpose a syntactic face function. The starting
> point is:
>
> (setq-local font-lock-syntactic-face-function
> #'sm-c-syntactic-face-function)
>
> Take a look at sm-c-syntactic-face-function and especially
> sm-c--cpp-fontify-syntactically to see how I try to re-use the existing
> font-lock functionality.
>
> It's a bit gross, tho.
>
>
> Stefan
>
>
>
signature.asc
Description: OpenPGP digital signature