- From: bytecolor <address@hidden>
- To: address@hidden
- Subject: Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting.
- Date: Sun, 13 Sep 2009 02:42:40 -0700 (PDT)
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=Message-ID:X-YMail-OSG:Received:X-Mailer:Date:From:Subject:To:MIME-Version:Content-Type; b=m8tBSAmzwLVspCeXGtg2VuVY6D460BsXw5ViAul1Laa86GPzycFWAlBUcfzsJtMWup2jz8PmY2/9RGkLTBrqIGLtb+RodQBpAmEMbUF+l7sv1AW94UvqqzK49gINDjB9ekFDWrb+Qnxg9S+/uluzCg2xcAhuKM6g709GWxDPjp8=;
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
>
Attachment:
noweb.ts
Description: application/linguist
- Re: [TeXmacs] Re: literate programming, again. Question about syntax highlighting., bytecolor, 09/13/2009
Archive powered by MHonArc 2.6.19.