From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: c-mode syntax strings and regexp word boundaries Date: Fri, 6 Sep 2013 20:19:13 +0000 Message-ID: <20130906201913.GA3521@acm.acm> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1378499256 5584 80.91.229.3 (6 Sep 2013 20:27:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Sep 2013 20:27:36 +0000 (UTC) Cc: emacs-devel@gnu.org To: Jon Dufresne Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 06 22:27:38 2013 Return-path: Envelope-to: ged-emacs-devel@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 1VI2d0-0005N9-26 for ged-emacs-devel@m.gmane.org; Fri, 06 Sep 2013 22:27:38 +0200 Original-Received: from localhost ([::1]:39664 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI2cz-00089y-J3 for ged-emacs-devel@m.gmane.org; Fri, 06 Sep 2013 16:27:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI2cp-00089o-24 for emacs-devel@gnu.org; Fri, 06 Sep 2013 16:27:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VI2ch-0002Wh-On for emacs-devel@gnu.org; Fri, 06 Sep 2013 16:27:26 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:23259 helo=mail.muc.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VI2ch-0002WS-Et for emacs-devel@gnu.org; Fri, 06 Sep 2013 16:27:19 -0400 Original-Received: (qmail 1442 invoked by uid 3782); 6 Sep 2013 20:20:36 -0000 Original-Received: from acm.muc.de (pD95191C5.dip0.t-ipconnect.de [217.81.145.197]) by colin.muc.de (tmda-ofmipd) with ESMTP; Fri, 06 Sep 2013 22:20:35 +0200 Original-Received: (qmail 3814 invoked by uid 1000); 6 Sep 2013 20:19:13 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-detected-operating-system: by eggs.gnu.org: FreeBSD 8.x X-Received-From: 193.149.48.1 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:163237 Archived-At: Hi, Jon. On Thu, Sep 05, 2013 at 10:14:16PM -0700, Jon Dufresne wrote: > Hi, > I am trying to modify a major mode derived from c-mode. I am adding support > for an alternative string syntax (PHP heredoc). To do this I am using > "syntax-propertize-function" and > "syntax-propertize-extend-region-functions". (As an aside I am not sure > this is the best approach, but it is best I have come up with so far.) > When trying to extend the propertize region, a regexp fails, but I am not > clear as to why. I have isolated the problem with the following test case. > --- > (with-temp-buffer > (c-mode) > (insert "END;\n") > (goto-char (point-min)) > (message "Search forward first time") > (re-search-forward "^END\\b") > (put-text-property (1- (point)) (point) > 'syntax-table (string-to-syntax "|")) > (goto-char (point-min)) > (message "Search forward second time") > (re-search-forward "^END\\b")) > --- > Thanks for any help. Not what you asked, but as a suggestion, you might want to use the CC Mode macros which deal with text properties on single characters. For example, you could have used `c-put-char-property' instead of `put-text-property'. This has the following pros/cons: (i) these macros are slightly less cumbersome to use, since they take only a single position parameter; (ii) They also work in XEmacs; (iii) there is some effort involved in learning about them and how they work. If you're interested, search cc-defs.el for Macros/functions to handle so-called "char properties", and read the definitions in that page. -- Alan Mackenzie (Nuremberg, Germany).