From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?ISO-8859-1?Q?Andreas_R=F6hler?= Newsgroups: gmane.emacs.devel Subject: Re: c-mode syntax strings and regexp word boundaries Date: Wed, 11 Sep 2013 10:57:05 +0200 Message-ID: <52303061.3030709@online.de> References: <20130906201913.GA3521@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1378889731 32606 80.91.229.3 (11 Sep 2013 08:55:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 11 Sep 2013 08:55:31 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 11 10:55:33 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 1VJgCt-00017H-0R for ged-emacs-devel@m.gmane.org; Wed, 11 Sep 2013 10:55:27 +0200 Original-Received: from localhost ([::1]:34448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJgCq-0006G3-83 for ged-emacs-devel@m.gmane.org; Wed, 11 Sep 2013 04:55:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34525) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJgCh-0006EP-1k for emacs-devel@gnu.org; Wed, 11 Sep 2013 04:55:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJgCZ-00078e-D1 for emacs-devel@gnu.org; Wed, 11 Sep 2013 04:55:14 -0400 Original-Received: from moutng.kundenserver.de ([212.227.17.8]:59262) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJgCZ-000776-4o for emacs-devel@gnu.org; Wed, 11 Sep 2013 04:55:07 -0400 Original-Received: from purzel.sitgens (brln-4dba21f1.pool.mediaWays.net [77.186.33.241]) by mrelayeu.kundenserver.de (node=mreu2) with ESMTP (Nemesis) id 0Lkkvg-1Vu6sm0Mg0-00aiQl; Wed, 11 Sep 2013 10:55:04 +0200 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 In-Reply-To: <20130906201913.GA3521@acm.acm> X-Provags-ID: V02:K0:XSadnqT4GVPjog1hbHfCX7jVCc3Hj38Fg22Jro3fVoM 0uMiNFWLNwZuOqnYQID8LlshUAt6EvjMwO5WJokpJpsBzaimBi 03mEBKyTZ6z5KwG/s/lCNALdL2crqphrVR5FSmAjdwxmPB5/cW x7YXi/A98iXZQabmhLZeEa0XsNv2vEsZFZSWRTd2KZHHZ9Lw90 m95uY0RQJzr20hbLIMcT8glmK6lgufigdJINyFPT1TjAZiohof K39Hx/+SEDvC/I4483tM2LWc4iqCI+as57EMiYNh0nNoLLUoMt iUHile3EGVr7pUx04QET9Waf7lJzMcPXdUq6izrwNwTzjQXaaP YIRtSAiHvCr/BWU08sj0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 212.227.17.8 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:163295 Archived-At: Am 06.09.2013 22:19, schrieb Alan Mackenzie: > 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. > Just for the record: the error in the present case was the wrong position, which would fail also with a single char. Instead of (put-text-property (1- (point)) (point) (put-text-property (point) (1+ point)) should work Cheers