* Adding a colon as a word boundary for syntax highlighting
@ 2008-02-18 4:27 Tim Johnson
2008-02-18 12:58 ` Johan Bockgård
2008-02-18 16:08 ` Stefan Monnier
0 siblings, 2 replies; 7+ messages in thread
From: Tim Johnson @ 2008-02-18 4:27 UTC (permalink / raw)
To: help-gnu-emacs
Hi:
I'm using the following regex subexpression:
"\\<\\("
As the left-hand word boundary for syntax highlighting in
a lisp-style programming language.
"\\(" adds the opening parenthesis as a word boundary.
I would like to add the colon (':') as an additional word
boundary character.
The subexpressions:
"\\<\\(:" and "\\<\\(\\:" don't seem to work.
In addition I have the following entry:
(?: . "w") to the syntax table.
Could someone advise me on how to make this work correctly.
On a related note, I believe that there is an emacs add-on that
allows the user to test elisp regexes, but for the life of me,
I can't remember where to find it.
TIA
Tim
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Adding a colon as a word boundary for syntax highlighting
2008-02-18 4:27 Adding a colon as a word boundary for syntax highlighting Tim Johnson
@ 2008-02-18 12:58 ` Johan Bockgård
2008-02-18 16:00 ` Tim Johnson
2008-02-18 16:08 ` Stefan Monnier
1 sibling, 1 reply; 7+ messages in thread
From: Johan Bockgård @ 2008-02-18 12:58 UTC (permalink / raw)
To: help-gnu-emacs
Tim Johnson <tim@johnsons-web.com> writes:
> I'm using the following regex subexpression:
> "\\<\\("
> As the left-hand word boundary for syntax highlighting in
> a lisp-style programming language.
>
> "\\(" adds the opening parenthesis as a word boundary.
That doesn't make sense.
> I would like to add the colon (':') as an additional word
> boundary character.
> The subexpressions:
> "\\<\\(:" and "\\<\\(\\:" don't seem to work.
> In addition I have the following entry:
> (?: . "w") to the syntax table.
> Could someone advise me on how to make this work correctly.
Note that font-lock can use a different syntax table than the mode's
ordinary syntax table.
> On a related note, I believe that there is an emacs add-on that
> allows the user to test elisp regexes, but for the life of me,
> I can't remember where to find it.
M-x re-builder or
regex-tool.el
--
Johan Bockgård
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Adding a colon as a word boundary for syntax highlighting
2008-02-18 4:27 Adding a colon as a word boundary for syntax highlighting Tim Johnson
2008-02-18 12:58 ` Johan Bockgård
@ 2008-02-18 16:08 ` Stefan Monnier
2008-02-18 19:23 ` Tim Johnson
1 sibling, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2008-02-18 16:08 UTC (permalink / raw)
To: help-gnu-emacs
> I'm using the following regex subexpression:
> "\\<\\("
> As the left-hand word boundary for syntax highlighting in
> a lisp-style programming language.
> "\\(" adds the opening parenthesis as a word boundary.
No, it doesn't. "\\(" is a regexp element that marks the beginning of
a sub-regexp. It needs a closing "\\)" before the regexp is valid.
It does nothing to parenthesis characters.
Emacs doesn't know "word boundary characters". All it knows is that
some characters are word-constituents and others aren't. And "\\<" is
a regexp that matches an empty string on the condition that the char on
the left is a non-word-constituent and the char on the right is
a word-constituent.
: by default is not considered as a word-constituent. I'm not sure what
you mean by "adding a colon as a word boundary".
> On a related note, I believe that there is an emacs add-on that
> allows the user to test elisp regexes, but for the life of me,
> I can't remember where to find it.
M-x regexp-builder (bundled with Emacs-22)?
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Adding a colon as a word boundary for syntax highlighting
2008-02-18 16:08 ` Stefan Monnier
@ 2008-02-18 19:23 ` Tim Johnson
2008-02-20 19:41 ` Stefan Monnier
0 siblings, 1 reply; 7+ messages in thread
From: Tim Johnson @ 2008-02-18 19:23 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier wrote:
> No, it doesn't. "\\(" is a regexp element that marks the beginning of
> a sub-regexp. It needs a closing "\\)" before the regexp is valid.
> It does nothing to parenthesis characters.
>
> Emacs doesn't know "word boundary characters". All it knows is that
> some characters are word-constituents and others aren't. And "\\<" is
> a regexp that matches an empty string on the condition that the char on
> the left is a non-word-constituent and the char on the right is
> a word-constituent.
Thank you for explaining the logic of this.
> : by default is not considered as a word-constituent. I'm not sure what
> you mean by "adding a colon as a word boundary".
Perhaps my thinking should be revised to mean
"eliminate ':' as a word constituent"
Regards
Tim
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Adding a colon as a word boundary for syntax highlighting
2008-02-18 19:23 ` Tim Johnson
@ 2008-02-20 19:41 ` Stefan Monnier
2008-02-20 20:37 ` Tim Johnson
0 siblings, 1 reply; 7+ messages in thread
From: Stefan Monnier @ 2008-02-20 19:41 UTC (permalink / raw)
To: help-gnu-emacs
> Perhaps my thinking should be revised to mean
> "eliminate ':' as a word constituent"
Better would be to describe concretely with an example what you want
to do.
Stefan
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Adding a colon as a word boundary for syntax highlighting
2008-02-20 19:41 ` Stefan Monnier
@ 2008-02-20 20:37 ` Tim Johnson
0 siblings, 0 replies; 7+ messages in thread
From: Tim Johnson @ 2008-02-20 20:37 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier wrote:
>> Perhaps my thinking should be revised to mean
>> "eliminate ':' as a word constituent"
>
> Better would be to describe concretely with an example what you want
> to do.
>
>
> Stefan
:-) I want to highlight "second" as in (second lst)
or "second" as in (std:second lst)
I created an intermediary solution by adding a group
with ":\\(" as the left regex. Works as I want...
The full solution might be something like this (I think,
but haven't combined them and haven't tested)
":\\(\\|\\<\\(" Where the alternatives are 1)empty string
2)colon
Unfortunately, I don't code elisp or elisp regexes for a living
and I tend to forget most of what I've learned from one session to
another.
I believe that your logical explanation put me on the right track.
thanks
----
Tim
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-02-20 20:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-18 4:27 Adding a colon as a word boundary for syntax highlighting Tim Johnson
2008-02-18 12:58 ` Johan Bockgård
2008-02-18 16:00 ` Tim Johnson
2008-02-18 16:08 ` Stefan Monnier
2008-02-18 19:23 ` Tim Johnson
2008-02-20 19:41 ` Stefan Monnier
2008-02-20 20:37 ` Tim Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).