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: Emanuel Berg
Subject: Re: Regex to match underscore in function name in Python Mode?
Date: Mon, 24 Jul 2017 23:09:26 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

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

Interesting :)

Here is another way to do it:

Create a file, e.g. display.py .

Open it in Emacs. Notice that the file
extention is used to automatically put the
editor in Python mode (defined in python.el).

Now, write the following:

    def display_string():
        print("This string is for display purposes ONLY.")

    display_string()

Watch out! "display_string" is in
`font-lock-function-name-face'!

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

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