From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nate Bargmann Newsgroups: gmane.emacs.help Subject: Re: Regex to match underscore in function name in Python Mode? Date: Sat, 29 Jul 2017 02:10:50 +0000 (UTC) Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1501331156 30869 195.159.176.226 (29 Jul 2017 12:25:56 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 29 Jul 2017 12:25:56 +0000 (UTC) User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jul 29 14:25:51 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dbQoU-0007Ur-6z for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Jul 2017 14:25:46 +0200 Original-Received: from localhost ([::1]:52229 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbQoZ-0001gu-Sn for geh-help-gnu-emacs@m.gmane.org; Sat, 29 Jul 2017 08:25:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dbQo7-0001gb-UP for help-gnu-emacs@gnu.org; Sat, 29 Jul 2017 08:25:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dbQo4-0005ge-On for help-gnu-emacs@gnu.org; Sat, 29 Jul 2017 08:25:23 -0400 Original-Received: from [195.159.176.226] (port=36233 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dbQo4-0005fa-IK for help-gnu-emacs@gnu.org; Sat, 29 Jul 2017 08:25:20 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dbQnm-0005K1-Vt for help-gnu-emacs@gnu.org; Sat, 29 Jul 2017 14:25:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 44 Original-X-Complaints-To: usenet@blaine.gmane.org X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:113907 Archived-At: 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