From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: jan Newsgroups: gmane.emacs.help Subject: Re: How do I get emacs to highlight subroutine calls in c-mode. Date: 17 Oct 2003 10:40:42 -0700 Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1066350803 24139 80.91.224.253 (17 Oct 2003 00:33:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 17 Oct 2003 00:33:23 +0000 (UTC) Cc: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Oct 17 02:33:20 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AAIYS-0004ZW-00 for ; Fri, 17 Oct 2003 02:33:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AAIXJ-0005lU-Ra for geh-help-gnu-emacs@m.gmane.org; Thu, 16 Oct 2003 20:32:09 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AAIWA-0005Sb-1M for help-gnu-emacs@gnu.org; Thu, 16 Oct 2003 20:30:58 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AAIVW-0004ja-1Z for help-gnu-emacs@gnu.org; Thu, 16 Oct 2003 20:30:49 -0400 Original-Received: from [210.50.30.52] (helo=smtp01.syd.iprimus.net.au) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AAIVV-0004hb-8e for help-gnu-emacs@gnu.org; Thu, 16 Oct 2003 20:30:17 -0400 Original-Received: from ABE (210.50.172.182) by smtp01.syd.iprimus.net.au (7.0.020) id 3F8B009E00133700; Fri, 17 Oct 2003 10:30:14 +1000 Original-To: "Javier Oviedo" In-Reply-To: Original-Lines: 37 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 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 Xref: main.gmane.org gmane.emacs.help:13274 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13274 "Javier Oviedo" writes: > This is pretty cool. Could this be adapted to also work for calls > through function pointers? That would be quite nice!! > > Example: > (*someStructure.someCallTable->someFunctionPointer)((void *)&test); ("\\<\\(\\sw+\\)[ \t\n)]*(" 1 font-lock-function-call-face) This version will do the job, however, being more general it also runs the risk of getting false positive matches. I can't think of any cases off the top of my head. You can still get false negatives, for example: (*someStructure.someCallTable->someFunctionPointer) /* comment */ ((void *)&test); or some_function_array[0](); but I think it's best not to handle those cases unless you actually write code like that. The basic problem is that regular expressions aren't powerful enough to describe a language like C (or almost any other language for that matter). They cannot be made to understand operator precedence or remove redundant parenthesis or handle any kind of nesting. In other words they really have no understanding of the structure of the code and the font tables are reduced to making guesses by matching against simple text patterns. -- jan