all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Trying to font-lock between parenthesis
@ 2008-11-29  0:29 Jules Colding
  2008-11-29  7:55 ` Drew Adams
  0 siblings, 1 reply; 3+ messages in thread
From: Jules Colding @ 2008-11-29  0:29 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

I'm trying to do a major mode for MPC(*) files. Before doing anything  
complicated I want MPC files nicely colorised. An MPC file may say  
something like:

    project(optional name) {
      includes += ${PROJECT_ROOT}/src
    }


I want "optional name" coloured differently than the other elements.  
I've tried this:

    ("\\(\(.*\)\\)" 1 font-lock-constant-face t)


But the regexp is wrong as the enclosing parentheses are including in  
the colouring to. What regexp will let me choose the text between the  
parenthesis but not the parentheses themselves?


Thanks a lot in  advance,
   jules


*) http://downloads.ociweb.com/MPC/MakeProjectCreator.pdf




^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: Trying to font-lock between parenthesis
  2008-11-29  0:29 Trying to font-lock between parenthesis Jules Colding
@ 2008-11-29  7:55 ` Drew Adams
  2008-11-29 10:29   ` Jules Colding
  0 siblings, 1 reply; 3+ messages in thread
From: Drew Adams @ 2008-11-29  7:55 UTC (permalink / raw)
  To: 'Jules Colding', help-gnu-emacs

>     ("\\(\(.*\)\\)" 1 font-lock-constant-face t)
> But the regexp is wrong as the enclosing parentheses are 
> including in the colouring to. What regexp will let me
> choose the text between the parenthesis but not the
> parentheses themselves?

("(\\(.*\\))" 1 font-lock-constant-face t)

But you probably don't want to allow parens between the parens, so maybe
something like this:

("(\\([^()]*\\))" 1 font-lock-constant-face t)

Or if you just want word and symbol constituents between the parens, then
something like this:

("(\\(\\(\\sw\\|\\s_\\)*\\))" 1 font-lock-constant-face t)





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Trying to font-lock between parenthesis
  2008-11-29  7:55 ` Drew Adams
@ 2008-11-29 10:29   ` Jules Colding
  0 siblings, 0 replies; 3+ messages in thread
From: Jules Colding @ 2008-11-29 10:29 UTC (permalink / raw)
  To: Drew Adams; +Cc: help-gnu-emacs


On 29/11/2008, at 08.55, Drew Adams wrote:

>>    ("\\(\(.*\)\\)" 1 font-lock-constant-face t)
>> But the regexp is wrong as the enclosing parentheses are
>> including in the colouring to. What regexp will let me
>> choose the text between the parenthesis but not the
>> parentheses themselves?
>
> ("(\\(.*\\))" 1 font-lock-constant-face t)
>
> But you probably don't want to allow parens between the parens, so  
> maybe
> something like this:
>
> ("(\\([^()]*\\))" 1 font-lock-constant-face t)
>
> Or if you just want word and symbol constituents between the parens,  
> then
> something like this:
>
> ("(\\(\\(\\sw\\|\\s_\\)*\\))" 1 font-lock-constant-face t)

It works perfectly :-)

Thank you so very much!
   jules





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-29 10:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-29  0:29 Trying to font-lock between parenthesis Jules Colding
2008-11-29  7:55 ` Drew Adams
2008-11-29 10:29   ` Jules Colding

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.