help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Regex to match underscore in function name in Python Mode?


From: Nate Bargmann
Subject: Re: Regex to match underscore in function name in Python Mode?
Date: Sat, 29 Jul 2017 02:10:50 +0000 (UTC)
User-agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2)

On Mon, 24 Jul 2017 11:38:49 -0700, John Mastro wrote:

> I tried this:
> 
> (add-hook
>  'python-mode-hook (lambda ()
>    (font-lock-add-keywords
>     nil '(("\\(\\(?:\\sw\\|\\s_\\|\\.\\)+\\)("
>        1 font-lock-function-name-face nil)))))
> 
> I'm not sure it's exactly the same thing you're trying to do, but
> underscores didn't pose any problems for highlighting the full symbol.
> Perhaps your regular expressions just isn't quite right.

Thanks, John!

Yes, I had posted the wrong function originally.  So much for proof 
reading, eh?

This matches everything from the word boundary to the parentheses, which 
is a bit much.  A quick modification of removing the escaped '.' fixed 
things right up:

        nil '(("\\(\\(?:\\sw\\|\\s_\\)+\\)("

Now it appears to match only the characters and underscores to the left 
of the opening parentheses to either the dot or the word boundary.

Much appreciated and the differences in the regex lines will give me
something to study.

My apologies for not replying sooner.  I had originally posted the 
question to the gnu.emacs.help newsgroup and never saw any replies in 
it.  Today I found the gmane.emacs.help groups with my OP and the 
replies, so now I am trying to follow up through Gmane.

- Nate

-- 

"The optimist proclaims that we live in the best of all
possible worlds.  The pessimist fears this is true."

Ham radio, Linux, bikes, and more: http://www.n0nb.us




reply via email to

[Prev in Thread] Current Thread [Next in Thread]