[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c-mode syntax strings and regexp word boundaries

From: Alan Mackenzie
Subject: Re: c-mode syntax strings and regexp word boundaries
Date: Fri, 6 Sep 2013 20:19:13 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

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

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).

reply via email to

[Prev in Thread] Current Thread [Next in Thread]