From: Alan Mackenzie <acm@muc.de>
To: Jon Dufresne <jon.dufresne@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: c-mode syntax strings and regexp word boundaries
Date: Fri, 6 Sep 2013 20:19:13 +0000 [thread overview]
Message-ID: <20130906201913.GA3521@acm.acm> (raw)
In-Reply-To: <CADhq2b5kSexzU4ec-qcjFpEPLcRO96=eKvqYyQH3wmkp1BhgvA@mail.gmail.com>
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).
next prev parent reply other threads:[~2013-09-06 20:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 5:14 c-mode syntax strings and regexp word boundaries Jon Dufresne
2013-09-06 12:21 ` Andreas Röhler
2013-09-06 14:07 ` Stefan Monnier
2013-09-06 14:55 ` Jon Dufresne
2013-09-06 15:44 ` Stefan Monnier
2013-09-06 17:04 ` Jon Dufresne
2013-09-06 20:19 ` Alan Mackenzie [this message]
2013-09-06 22:38 ` Jon Dufresne
2013-09-11 8:57 ` Andreas Röhler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130906201913.GA3521@acm.acm \
--to=acm@muc.de \
--cc=emacs-devel@gnu.org \
--cc=jon.dufresne@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.