emacs-devel
[Top][All Lists]
Advanced

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

Re: Optionally (and correctly) match a group with font-lock


From: Sean Allred
Subject: Re: Optionally (and correctly) match a group with font-lock
Date: Sun, 5 Apr 2015 13:42:32 -0500

Doh! As @Lindydancer pointed on Emacs.SE, I messed up on syntax: (group (+ any 
alnum “_”)) should be (group (+ (any alnum “_”))).

Sorry for the noise!

> On Apr 5, 2015, at 12:53 PM, Sean Allred <address@hidden> wrote:
> 
> Hello everyone,
> 
> Recently I’ve been seeing discussions on Emacs’ C sources and the fundamental 
> aspects of elisp, but I hope asking for help is okay here, too :) I’m writing 
> a mode for expl3, the programming layer that’s going to power LaTeX3. AUCTeX 
> as very little support for it right now and I hope to have expl3-mode 
> included at some point in the future, so this is at least a discussion of 
> that development :)
> 
> When I use the following, I cannot correctly match the test strings below. 
> (For brevity, only the relevant portions have been included in this email.)
> 
>    (define-derived-mode expl3-mode prog-mode
>      "expl3"
>      "Mode for editing expl3 source code."
> 
>      (setq font-lock-set-defaults nil)
>      (font-lock-set-defaults)
>      (font-lock-add-keywords
>       nil
>       `((,(rx (* whitespace)
>               (group (+ (any alnum "-")))
>               (* whitespace)
>               (optional "/" (* whitespace)
>                         (group (+ any alnum "_")))
>               (+ whitespace)
>               (group "." (+ (any alpha)) (optional "_"))
>               (group (optional (any alpha) (+ (any alpha "_"))))
>               (group ":" (* (any "nNpTFwcVvxofD"))))
>          (1 font-lock-variable-name-face t)
>          (2 font-lock-variable-name-face t t)
>          (3 font-lock-type-face t)
>          (4 font-lock-function-name-face t)
>          (5 font-lock-keyword-face t)))))
> 
> ### Test strings
> 
>    test-key .tl_set:N ...
>    with / grouping .code:n …
> 
> `test-key` matches correctly, but `with / grouping` does not. The `grouping` 
> portion matches, but `with` is left out in the cold. Anybody know a good way 
> to fix my regex for font-lock?
> 
> All the best,
> Sean
> 
> (PS: this question has also been asked on Emacs.SE: 
> http://emacs.stackexchange.com/q/10528/2264)




reply via email to

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