From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alexis Newsgroups: gmane.emacs.help Subject: Example matcher function for font-lock-keywords? Date: Thu, 26 Feb 2015 10:28:19 +1100 Message-ID: <878uflo9kc.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed X-Trace: ger.gmane.org 1424906934 12756 80.91.229.3 (25 Feb 2015 23:28:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 25 Feb 2015 23:28:54 +0000 (UTC) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Feb 26 00:28:47 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YQlNm-0005vZ-BI for geh-help-gnu-emacs@m.gmane.org; Thu, 26 Feb 2015 00:28:46 +0100 Original-Received: from localhost ([::1]:56745 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQlNl-0005aI-OA for geh-help-gnu-emacs@m.gmane.org; Wed, 25 Feb 2015 18:28:45 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQlNZ-0005a0-2M for help-gnu-emacs@gnu.org; Wed, 25 Feb 2015 18:28:34 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQlNU-000088-3K for help-gnu-emacs@gnu.org; Wed, 25 Feb 2015 18:28:32 -0500 Original-Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:42822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQlNT-00007p-S2 for help-gnu-emacs@gnu.org; Wed, 25 Feb 2015 18:28:28 -0500 Original-Received: by pdbfp1 with SMTP id fp1so8341864pdb.9 for ; Wed, 25 Feb 2015 15:28:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=ycHk6mN/wF1i0+DAqBIJPaByCbYfHidnfEhdbrIwVSQ=; b=KQ2YS66kJH6j6PlMPyoDWF6RMwsU0GvO4VeMDfTkljOIUwPlnigW6/HRlL2wSqk0iZ kwEBvwqWE7oO9+ZLuGETyjt0gX0Z4VApH5GiwMMf+cnr6j6ltjYmYzsM3PragapbuJn+ gr8WaPNS41hAuoogqFqrVqF1o8U8R/km8QqQsYkEGRwOofd81oGesg1JCy2qsfxTo+m2 uHUCDDU8gg+SmCnGy29tPSrFXIQ4b6EwjSHNmsNAn54jiqz0by+RfsNFO6VAu0oflbln AkteC6FzlYWr1sPCGJ3TZz+tCvNASrZ1hwOjkyVBHqIrPm13Fwiw570W7qbhbfZ6NYVV Ning== X-Received: by 10.67.3.73 with SMTP id bu9mr9602090pad.23.1424906906127; Wed, 25 Feb 2015 15:28:26 -0800 (PST) Original-Received: from localhost (CPE-120-147-144-248.gdiv2.lon.bigpond.net.au. [120.147.144.248]) by mx.google.com with ESMTPSA id ie5sm11557442pbb.14.2015.02.25.15.28.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 25 Feb 2015 15:28:25 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::229 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:102899 Archived-At: Hi all, i'm working on a prog-mode for PicoLisp. The design of PicoLisp is such that strings are merely instances of what are called 'transient symbols'; one can do things like: (setq "My string" 10) such that evaluating "My string" will yield the value 10. http://software-lab.de/doc/ref.html#transient provides more details. Consequently, the syntax table for PicoLisp should designate double-quotes as marking a symbol, not a string. This, however, means that syntactic highlighting of comments doesn't work properly - for example, when the comment character '#' appears inside a transient symbol, it /shouldn't/ be treated as a comment character (and the remainder of the line following it shouldn't be treated as a comment). Initially i tried to handle this by using a regex in the mode's font-lock-keywords list, but that quickly became unwieldy. So instead, i'd like to use a matcher function in that list. The documentation for `font-lock-keywords` says: "MATCHER can be either the regexp to search for, or the function name to call to make the search (called with one argument, the limit of the search; it should return non-nil, move point, and set `match-data' appropriately if it succeeds; like `re-search-forward' would)." Having played around with trying to create such a function, using both `re-search-forward` and `string-match`, i can't seem to get any highlighting at all, let alone correct highlighting. Could someone please point me to an example 'in-production' matcher function, e.g. in the Emacs ELisp code base? Thanks in advance, Alexis.