From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: Regex to match underscore in function name in Python Mode? Date: Mon, 24 Jul 2017 11:38:49 -0700 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1500922860 7293 195.159.176.226 (24 Jul 2017 19:01:00 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Jul 2017 19:01:00 +0000 (UTC) To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Jul 24 21:00: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 1dZib5-0001P5-PR for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Jul 2017 21:00:51 +0200 Original-Received: from localhost ([::1]:56498 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZibA-0001iR-Rw for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Jul 2017 15:00:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52409) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZiGA-0000q4-1V for help-gnu-emacs@gnu.org; Mon, 24 Jul 2017 14:39:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZiG9-0002kO-8P for help-gnu-emacs@gnu.org; Mon, 24 Jul 2017 14:39:14 -0400 Original-Received: from mail-qt0-x22e.google.com ([2607:f8b0:400d:c0d::22e]:32973) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZiG9-0002hC-4h for help-gnu-emacs@gnu.org; Mon, 24 Jul 2017 14:39:13 -0400 Original-Received: by mail-qt0-x22e.google.com with SMTP id n42so75394002qtn.0 for ; Mon, 24 Jul 2017 11:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=lxHbi4pY9ujVDEVn+G7Mji5YsOfArZ2X/jNsQTVB+os=; b=qq9PToWiUmT1Q85m0aVv/SKRpbi8o9iE8ly1+GtbSeyJrMgP1vp4Iu/fVy4seq07bS 6iVRMAMMCBfRXDlaiimyC5fpIIJr41K6RmH9x2emyJPrTMxf/2d2k/ActYZ+64I1ajEn cbjk933FrwtZqnQv+9eW8Jqf1Q3C+fdhUVNRY1TD8I6rZRUcS67Z8swwiSu/hFhJt36D zsKqnK6MXk82PYxeSgaXu1Cx/RswL9jSGkJpR+nQqzGxkZymzOs1J28RcfM131mjVb08 7I4wKOO6wsCuRQhC0M2osqKD9n+VOMmmYjgjst1QevIZtwA2kFoKF/bmb7Yfzh2MxjcM oc4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=lxHbi4pY9ujVDEVn+G7Mji5YsOfArZ2X/jNsQTVB+os=; b=H5gam72Yrff8OHstf6mCmDbF66g1kMb69ZNkPVrIf2e05bnRyCGSpBwhewV7e7gtEi 0gmVpZMPNrb9pTktcJwqWsntiDYNPyYT0OTPI44c/1lJ8oFgZ4ZUlIazedi4lW5NW17p X4INuKLXczQs+cLB50I+QZxD7PVskfPR5FmLX4VFVktWG9JC56uaeu7XE2he9KbGkfXJ 7inzdPVcwj4CY42VS0RnjppNSGDQGNUieqsqiqOpwsaZMp87AoFBn0+jmlBTk3d9O6fy kBpGMYkjEOYQ+LWNUX7unhqKO3COrGDbfRwbc9sdoZ+nNmwIn9GOwe+cQg97UCDIMGlV +XOA== X-Gm-Message-State: AIVw1131COLaxXTlcQbL47IEsqIHkhs3ld3jhyzhClcOeOcJ1FlL5lgD OcSQ7M3usAAiL7OnT4AUEjAD7XmMMW2EiYY= X-Received: by 10.200.43.163 with SMTP id m32mr22781998qtm.296.1500921550305; Mon, 24 Jul 2017 11:39:10 -0700 (PDT) Original-Received: by 10.237.48.241 with HTTP; Mon, 24 Jul 2017 11:38:49 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::22e 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:113851 Archived-At: John Mastro 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. [snip] > 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)? 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. John