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 14:23:48 -0700 Message-ID: References: <864lu11r09.fsf@zoho.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1500931651 32183 195.159.176.226 (24 Jul 2017 21:27:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 24 Jul 2017 21:27:31 +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 23:27:24 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 1dZkst-0007xL-Vb for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Jul 2017 23:27:24 +0200 Original-Received: from localhost ([::1]:57133 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZksz-0000FL-J3 for geh-help-gnu-emacs@m.gmane.org; Mon, 24 Jul 2017 17:27:29 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34742) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZkpn-0006gG-CU for help-gnu-emacs@gnu.org; Mon, 24 Jul 2017 17:24:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZkpm-0003mN-3j for help-gnu-emacs@gnu.org; Mon, 24 Jul 2017 17:24:11 -0400 Original-Received: from mail-qt0-x231.google.com ([2607:f8b0:400d:c0d::231]:37484) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZkpl-0003mE-Vk for help-gnu-emacs@gnu.org; Mon, 24 Jul 2017 17:24:10 -0400 Original-Received: by mail-qt0-x231.google.com with SMTP id r14so44104865qte.4 for ; Mon, 24 Jul 2017 14:24:09 -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=be4/BLDDnyyiB9DSZwmkCP6bZojjxOAZCYxC42toYZs=; b=c5ROT9wobnnNwkCu5aFaAj3itwQs0Lx9QZ5v/Lp3pSLsA6RmasNCL0bpPTap/KVRk5 EneVYU7z5EpwCpPJtPDdfMPdJpQNh10Azg6feLHhqgoKs8qRwHD12yfEy8ctiHMxkmZf 65zdCZb8vX8s2l1TBiE6lZjo5jEKwyUA4IJ8F2A38Z7HLEOy1vmzo3DFMpg5nfvsatoL Ct+dEy7zde/odBMDk4tcayCSCs7nltkj+vKW4rOVuTpfaz39qn8dm2MCd4LjwVJD8x81 dnSW6HkTvX0OHlgEN76FYrtbUz6g8r+RqVfocvXNX8V6a42Fcd2y38/FvdPRzrDzJw3J e6eA== 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=be4/BLDDnyyiB9DSZwmkCP6bZojjxOAZCYxC42toYZs=; b=Zf8BXdQX9PrHUO+E1VK0CudKgGBNKslaI45wXdtxg5BKqWpv9wSimF7Y5nS8xdAdzf BDT4z1ggvYk0DOfEzVUR5BHdm+nlj4H2LFs6QAcHqNXflkSVyTBZo+1NrN8MP6dmPFXt qCYn68grLPHHyAcAZSW6A6OZ2DWCBNXOjXQW5EuidVHFkmC9zJXszB4/6Hb+FUb/1LR4 BT+TEjBUE8MplD1LGe40sk+LlZPV/nUBILHTbGcomc3SKp8v6DQ0/efG9OZa8jtk8irB 6xXpH4D+/+Q5YigC0hoYFEjQQvggPHwRq64vS8360qhZ9EnJnKBOVBBb20C1crBl8CNx zUMw== X-Gm-Message-State: AIVw111xui0IhhPBhEEK7o3LcIrOrBMSZLtlNUBz6HjdwXmUdNk4G2dl uWWAvHnerMB7qGyeC2+Z3xsnNro1CHtpzLw= X-Received: by 10.200.37.139 with SMTP id e11mr22284601qte.112.1500931449049; Mon, 24 Jul 2017 14:24:09 -0700 (PDT) Original-Received: by 10.237.48.241 with HTTP; Mon, 24 Jul 2017 14:23:48 -0700 (PDT) In-Reply-To: <864lu11r09.fsf@zoho.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::231 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:113853 Archived-At: Emanuel Berg 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