all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nate Bargmann <n0nb@n0nb.us>
To: help-gnu-emacs@gnu.org
Subject: Re: Regex to match underscore in function name in Python Mode?
Date: Sat, 29 Jul 2017 02:10:50 +0000 (UTC)	[thread overview]
Message-ID: <olgqr9$no7$1@blaine.gmane.org> (raw)
In-Reply-To: CAOj2CQRb4NZUEL9WSrJS=2PKX=6DPJ1BDkiVdOtO8QSsjZCTkQ@mail.gmail.com

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




  parent reply	other threads:[~2017-07-29  2:10 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
2017-07-24 23:43         ` Emanuel Berg
2017-07-29  2:10     ` Nate Bargmann [this message]
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='olgqr9$no7$1@blaine.gmane.org' \
    --to=n0nb@n0nb.us \
    --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.