- Subject: Re: [Jed-users-l] New mode for n3 / turtle
- From: "John E. Davis" <davis@xxxxxxxxxxxxx>
- Date: Tue, 20 Mar 2012 13:51:41 -0400
Alain Nadeau <nadeau@xxxxxxxxxxx> wrote:
> I'm basically seeking something like the very nice n3 mode offered by emacs
>
> http://larve.net/people/hugo/2003/scratchpad/NotationThreeEmacsMode.html
>
> Notice how this one has the following features:
>
> - chars in one color before a colon, and in another after the colon...
>
> - URLs in one color, from the starting "<" to the closing ">", even and
> including a "#" sign before the closing ">".
>
> - how keyword "@prefix" is all in one color, including the "@"...
>
> All seemingly easy stuff. Until one tries to achieve that.
>
> I have no problems (duh!) with defining keywords through define_keywords_n.
>
> But everything that has to do with dfa_define_highlight_rule in order to
> obtain the features described above has been a failure. I fail to grasp the
> regex vocabulary needed.
See doc/txt/dfa.txt for a description of the dfa RE syntax. Here is
something that I threw together this morning that you might find
helpful. --John
create_syntax_table ("n3");
define_syntax ("A-Za-z", 'w', "n3");
#ifdef HAS_DFA_SYNTAX
%%% DFA_CACHE_BEGIN %%%
private define setup_dfa_callback (name)
{
dfa_define_highlight_rule ("^#.*", "comment", name);
dfa_define_highlight_rule ("@prefix", "keyword", name);
dfa_define_highlight_rule ("<[^>]*>", "url", name);
dfa_define_highlight_rule ("[ \t]+[a-zA-Z]*:", "Qkeyword1", name);
dfa_define_highlight_rule ("\"[^\"]*\"", "string", name);
dfa_build_highlight_table (name);
}
dfa_set_init_callback (&setup_dfa_callback, "n3");
%%% DFA_CACHE_END %%%
#endif
define n3_mode ()
{
variable n3 = "n3";
no_mode (); % reset
set_mode(n3, 1);
use_syntax_table (n3);
use_dfa_syntax (1);
run_mode_hooks ("n3_mode_hook");
}
_______________________________________________
Jed-users-l mailing list
Jed-users-l@xxxxxxxx
http://mailman.jtan.com/mailman/listinfo/jed-users-l
[2012 date index]
[2012 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]