From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jon Dufresne Newsgroups: gmane.emacs.devel Subject: c-mode syntax strings and regexp word boundaries Date: Thu, 5 Sep 2013 22:14:16 -0700 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7bdc90be26050d04e5b01ca6 X-Trace: ger.gmane.org 1378444462 7917 80.91.229.3 (6 Sep 2013 05:14:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Sep 2013 05:14:22 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 06 07:14:24 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 1VHoNB-00060s-Vq for ged-emacs-devel@m.gmane.org; Fri, 06 Sep 2013 07:14:22 +0200 Original-Received: from localhost ([::1]:35120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHoNB-0003wd-IC for ged-emacs-devel@m.gmane.org; Fri, 06 Sep 2013 01:14:21 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHoN7-0003vZ-Rz for emacs-devel@gnu.org; Fri, 06 Sep 2013 01:14:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHoN6-0003bd-V4 for emacs-devel@gnu.org; Fri, 06 Sep 2013 01:14:17 -0400 Original-Received: from mail-qc0-x22f.google.com ([2607:f8b0:400d:c01::22f]:35268) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHoN6-0003bY-QH for emacs-devel@gnu.org; Fri, 06 Sep 2013 01:14:16 -0400 Original-Received: by mail-qc0-f175.google.com with SMTP id v2so1452812qcr.20 for ; Thu, 05 Sep 2013 22:14:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=eFx3tBM9SuaoRQtoOyYOHgFcyu71G1vmHGwaXqKgQGo=; b=we3bjVUGT4c4ft6QmThsHffFpvP/1LRxP++h8CPz7CKBAonf3EBsl5zPCfTSjVSV0i oxVMC7UnBrvtdeompkjxxHTEKnLD2CyMFxvY6ZpTX3bQxfyU1qHvRDFflvbf4D3Uq9ZA rGwQiu6r0Cs3a6vEpf47P/rNWUZX23q22LknveQ2+o/8NAdztOJoRsDXt6m6Ar2MPsIM O+vM0VKGt1rYO4YLKGDQlLnrQqmqsx+THf17lPNw44Y9jhiBhDh3f3FQrw/t6b0kM1PB Je7/7V34fsHCa+H7y7+sDnppEWq+2HPElRPDCjpniUL1yplxdJtt3b/ugN29+AMPYNMw WuCQ== X-Received: by 10.49.30.66 with SMTP id q2mr845924qeh.38.1378444456099; Thu, 05 Sep 2013 22:14:16 -0700 (PDT) Original-Received: by 10.229.67.68 with HTTP; Thu, 5 Sep 2013 22:14:16 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::22f 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:163209 Archived-At: --047d7bdc90be26050d04e5b01ca6 Content-Type: text/plain; charset=UTF-8 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")) --- Running this give me the output: Search forward first time Search forward second time Search failed: "^END\\b" I do not understand why the second regexp fails. I suppose it has to do with the text property string boundary. What is the correct way to look for the boundary in this case? Thanks for any help. --047d7bdc90be26050d04e5b01ca6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

I am trying to modify a major mo= de derived from c-mode. I am adding support for an alternative string synta= x (PHP heredoc). To do this I am using "syntax-propertize-function&quo= t; 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 n= ot clear as to why. I have isolated the problem with the following test cas= e.

---
(with-temp-buffer
=C2=A0 (c-mode)
=C2=A0 (insert &qu= ot;END;\n")
=C2=A0 (goto-char (point-min))
=C2=A0 (message "Search forward firs= t time")
=C2=A0 (re-search-forward "^END\\b")
=C2=A0 (= put-text-property (1- (point)) (point)
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 'syntax-table (string-to-syntax "|"))
=C2=A0 (goto-char (point-min))
=C2=A0 (message "Search forward seco= nd time")
=C2=A0 (re-search-forward "^END\\b"))
---
Running this give me the output:

Search forward first tim= e
Search forward second time
Search failed: "^END\\b"

I do not understand why the= second regexp fails. I suppose it has to do with the text property string = boundary. What is the correct way to look for the boundary in this case?
Thanks for any help.
--047d7bdc90be26050d04e5b01ca6--