all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: John Mastro <john.b.mastro@gmail.com>
To: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: Regex to match underscore in function name in Python Mode?
Date: Mon, 24 Jul 2017 14:23:48 -0700	[thread overview]
Message-ID: <CAOj2CQQSOP_dyUY9xth7LG633+O5m3j+v++gtP=2bubq6QfwbA@mail.gmail.com> (raw)
In-Reply-To: <864lu11r09.fsf@zoho.com>

Emanuel Berg <moasen@zoho.com> 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():
          ^^^^^^^^^^^^^^

By default, only this one is fontified with
font-lock-function-name-face.

>         print("This string is for display purposes ONLY.")
>
>     display_string()
      ^^^^^^^^^^^^^^

The snippet I posted causes this one to be fontified too.

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

Since python-mode already fontifies the function name at definition
sites, I presume the OP is asking about having it fontified
"everywhere". However, he hasn't explained in detail.

        John



  reply	other threads:[~2017-07-24 21:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-23  2:12 Regex to match underscore in function name in Python Mode? Nate Bargmann
2017-07-23  3:06 ` John Mastro
2017-07-24 18:38   ` John Mastro
2017-07-24 21:09     ` Emanuel Berg
2017-07-24 21:23       ` John Mastro [this message]
2017-07-24 23:43         ` Emanuel Berg
2017-07-29  2:10     ` Nate Bargmann
2017-07-29 23:21       ` Emanuel Berg
2017-07-23  3:20 ` Skip Montanaro
2017-07-23  3:34   ` Emanuel Berg

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='CAOj2CQQSOP_dyUY9xth7LG633+O5m3j+v++gtP=2bubq6QfwbA@mail.gmail.com' \
    --to=john.b.mastro@gmail.com \
    --cc=help-gnu-emacs@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.