all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Clément Pit--Claudel" <clement.pit@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: Feature request/RFC: proper highlighting of code embedded in comments
Date: Sun, 16 Oct 2016 17:05:01 -0400	[thread overview]
Message-ID: <0a7df382-4edf-3a27-a102-bfc61e5b6aae@gmail.com> (raw)
In-Reply-To: <jwvvawsry74.fsf-monnier+gmane.emacs.devel@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 1547 bytes --]

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
> 
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-10-16 21:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-15 15:19 Feature request/RFC: proper highlighting of code embedded in comments Clément Pit--Claudel
2016-10-15 20:22 ` Dmitry Gutov
2016-10-15 21:21   ` Clément Pit--Claudel
2016-10-16 17:42 ` Stefan Monnier
2016-10-16 21:05   ` Clément Pit--Claudel [this message]
2016-10-17 13:02     ` Stefan Monnier
2016-10-17 14:19       ` Clément Pit--Claudel
2016-10-16 21:10 ` Clément Pit--Claudel
2016-10-17 13:12   ` Stefan Monnier
2016-10-17 14:25     ` Clément Pit--Claudel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0a7df382-4edf-3a27-a102-bfc61e5b6aae@gmail.com \
    --to=clement.pit@gmail.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.