Subject: mailing-list for TeXmacs Users
List archive
Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting.
Chronological Thread
From : Michael Lachmann <address@hidden>- To: address@hidden
- Subject: Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting.
- Date: Sun, 13 Sep 2009 14:02:26 +0200
- Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=FQdEqOEvU/r3N0MTdnVfagRlfJa2PVMDl04jaR8MoAEF2fq0sR8ngCaICvQQDQXYtb GfpqZqyAjtqWdp3Yv3mHKVzrxZUAW4rDWEQG0BaU+bLQ/vg4p/yLyTuC1JSE5htl6/qH 9hsVbiAT77nrlhkhmPurPEBPJvEWFuR6pmUm4=
Thank you very much, bytecolor (Edward)!
This works great!
I edited cpp_language.cpp to add some D keywords.
Just a small comment:
The way noweb works is that you can have several <<>>= definitions
with the same name, and they are just concatenated in order. I guess
it is a "feature", though it helps when you break up code into parts.
This seems to work correctly in noweb.ts: when you click on the <<>>
label, it goes to the first reference of the definition. I don't know
if this breaks anything otherwise. I guess one could define a
noweb-fragment, and a noweb-fragment-part, if it matters.
Michael
if anyone is interested, here are the keywords I added to
cpp_color_setup_keywords... there are some more though...
///// D
t("unittest")=c ;
t("import")=c ;
t("assert")=c ;
t("alias")=c ;
t("const")=c ;
t("cast")=c ;
t("foreach")=c ;
t("long")=c ;
t("int")=c ;
t("bool")=c ;
t("real")=c ;
t("char")=c ;
t("ref")=c ;
t("auto")=c ;
2009/9/13 bytecolor <address@hidden>:
> Hello Michael and David,
>
> I had never heard of Literate Programming. Thanks for the tip.
>
> I have a few of your requests implemented. I've attached noweb.ts. It's a
> minimal style sheet for noweb documents. It contains two macros:
>
> 1. \noweb-fragment
> 2. \noweb-ref
>
> The first wraps \cpp-fragment but inserts:
> <<_>>=
>
> @
> into the box. The _ is where the cursor ends up. As you type an identifier
> between <<>> a \label is automatically created. You can go back and change
> the identifier and the label will change too. The <<, >>, =, and @
> characters are read-only.
>
> The second just inserts <<_>>. Again, the _ is where the cursor ends up.
> This automatically creates an \hlink as well. But, as you figured out, you
> can not type markup in the fragment (at least I don't think you can). So, I
> created a key sequence that calls \noweb-ref.
>
> I've played around with it a little. It seems to work ok. The only downside
> is it only works for C++. There are only a few languages that have
> fragment-type markup. R is not one of them AFAIK. The C++ colorizing is
> actually implemented in C++, not Scheme. Which is probably why you could
> not find the relative code. Here is a link to the code in case you don't
> have a local copy.
>
> http://svn.savannah.gnu.org/viewvc/trunk/src/src/System/Language/?root=texmacs
>
> I put noweb.ts in $HOME/.TeXmacs/styles/.
>
> I added the arbitrary key sequence C-A-l to
> $HOME/.TeXmacs/progs/my-init-texmacs.scm
>
> (kbd-map
> ("C-A-l" (make 'noweb-ref)))
>
> --
> bytecolor (S. Edward Dolan)
>
>
> --- On Sat, 9/12/09, Michael Lachmann <address@hidden> wrote:
>
>> From: Michael Lachmann <address@hidden>
>> Subject: [TeXmacs] Re: literate programming, again. Question about syntax
>> highlighting.
>> To: address@hidden
>> Date: Saturday, September 12, 2009, 7:04 AM
>> Some more about syntax highlighting.
>>
>> In the document style tmdoc there are formating styles for
>> different
>> programming languages, like scheme, shell, and c++. These
>> show up as
>> nice light-blue boxes, and have syntax highlighting.
>>
>>
>> By copying and pasting from the documentation and using the
>> tmdoc
>> style, I managed to create the attached literate programing
>> example.
>> This is much nicer than what I had before! (Notice that in
>> the
>> previous example I manually formated strings to have
>> certain colors,
>> whereas here it is all done by teXmacs....)
>> It is actually all I need, maybe apart from:
>> - automatic indentation (it also exists in TeXmacs, when
>> editing scm
>> files... how do I harness the power?)
>> - adding the "@" at the end of a code section
>> automatically,
>> - formating the "<<section>>" in a special
>> style, and adding
>> links/labels to them automatically.
>>
>> But even like this, it is much more than I had hoped!
>>
>> I have the following questions, though:
>>
>> 1. How do I insert these styles without copy/pasting them
>> from the
>> documentation?
>> 2. Where are the programming languages defined? I searched
>> all through
>> the source code, but couldn't find where it is defined that
>> "cout" and
>> "cin" are keywords of c++.
>>
>> On an unrelated subject, it would be really nice if TeXmacs
>> could
>> format R code in the same way it formats C++ or shell code
>> here. What
>> should I do to add this to the R plugin?
>>
>> thanks,
>> Michael
>>
>
>
>
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., bytecolor, 09/13/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., Michael Lachmann, 09/13/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., Michael Lachmann, 09/14/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., Alvaro Tejero Cantero, 09/14/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., bytecolor, 09/14/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., Michael Lachmann, 09/15/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., Joris van der Hoeven, 09/24/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., Michael Lachmann, 09/14/2009
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., Michael Lachmann, 09/13/2009
Archive powered by MHonArc 2.6.19.