[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regex to match underscore in function name in Python Mode?
From: |
John Mastro |
Subject: |
Re: Regex to match underscore in function name in Python Mode? |
Date: |
Sat, 22 Jul 2017 20:06:32 -0700 |
Nate Bargmann wrote:
> In C mode I have the following in my ~/.emacs that will highlight a
> function name:
>
> ;; Highlight punctuation in C mode
> (add-hook
> 'c-mode-common-hook
> (lambda ()
> (font-lock-add-keywords
> nil
> '(("[<>:&*=+^%!~,.?;/-]"
> 0 font-lock-warning-face nil)))
> ))
I think you may have posted the wrong snippet? This seems to fontify
punctuation characters, not function names.
> In C mode this will highlight all characters in a function name (left
> of the opening parentheses) to the word boundary including
> underscores. I am attempting to use the same for python mode, however,
> the regex matches up to the first underscore, if there is one, but no
> further. I'll admit to not be intimately familiar with Emacs regexes
> and I did try re-builder and was unable to get a match on the
> underscore.
>
> Is it possible that Python Mode is blocking the regex from matching
> underscores?
Is the goal to fontify function names at use sites (e.g. the `foo` in
`foo(0)`) in addition to declaration and definition sites (where they're
already fontified by the major mode)?
John
Re: Regex to match underscore in function name in Python Mode?, Skip Montanaro, 2017/07/22