[main]Notes on TeXmacs

Customizing the color of code snippets

By default, the preprocessor directives in C++ code snippets are rendered in green:

#include "stdio.h"

It is controlled by the following preference:

Scheme]

(get-preference "syntax:cpp:preprocessor_directive")

"dark green"

Scheme]

And the preferences can be changed:

Scheme]

(set-preference "syntax:cpp:preprocessor_directive" "black")

Scheme]

(get-preference "syntax:cpp:preprocessor_directive")

"black"

Scheme]

Preferences are stored when we set it. For GNU TeXmacs v1.99.15, a re-render trigger (eg. Restart) is required for your changes to take effect.

Decolorize

To decolorize all C++ code snippet, we need to know all the preferences for the C++ language. Some of them can be found in $TEXMACS_PATH/progs/prog/cpp-lang.scm. A complete list can be found at texmacs@v1.99.15:src/System/Language.cpp#L259.

Scheme]

(map

(lambda (key) (set-preference key "black"))

(list

"syntax:cpp:comment"

"syntax:cpp:keyword"

"syntax:cpp:constant_string"

"syntax:cpp:constant_number"

"syntax:cpp:constant_type"

"syntax:cpp:preprocessor_directive"

"syntax:cpp:preprocessor"

"syntax:cpp:error"))

(#<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified>)

Scheme]

Restart TeXmacs or type some C++ code below to trigger recoloring:

#include "stdio.h"
int main() {
  return 0;
}

Reset

To reset the colorizer:

Scheme]

(map

(lambda (key) (reset-preference key))

(list

"syntax:cpp:comment"

"syntax:cpp:keyword"

"syntax:cpp:constant_string"

"syntax:cpp:constant_number"

"syntax:cpp:constant_type"

"syntax:cpp:preprocessor_directive"

"syntax:cpp:preprocessor"

"syntax:cpp:error"))

(#<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified> #<unspecified>)

Scheme]

Restart TeXmacs or type something below to see the effects:

#include "stdio.h"
int main() {
  return 0;
}