mailing-list for TeXmacs Users

Text archives Help


[TeXmacs] alternative shell interface, file editing, and syntax highlighting


Chronological Thread 
  • From: Michael Lachmann <address@hidden>
  • To: texmacs-users <address@hidden>
  • Subject: [TeXmacs] alternative shell interface, file editing, and syntax highlighting
  • Date: Fri, 7 Dec 2012 14:40:27 +0100

Hi!

I just wanted to share some methods/things I learned. The post starts
with describing a technique I use, and then switches to talking about
development. Maybe I should have split it into two posts.. one for dev
and one for users....

The R plugin for TeXmacs can be used as a pretty nice shell interface, also.
What I usually do is the following:
Inside R, issue the following command:
system("bash")
or
system("ssh remote_host")
or some such.
Usually, in bash I then start with the following command:
PS1="; "
just so the prompts are nicer.

The reason that the R plugin works nicely is that it is set up to
interact with a terminal program, so you can issue almost any command
inside it, and things still work.

For example, once in bash, you can do:
sftp remote_host, or ssh remote_host
and things will still work. This currently doesn't work in the regular
shell session.

One nice trick that I use is the following:

If you are running bash in a session, you can issue the following command:
--
cat <<EOF >hello_world.c
#include <stdio.h>
main() {
printf("hello world\n") ;
}
EOF
--
(all in one input field, using shift-enter). This creates the file
hello_world.c, which you can then compile.
This technique allows TeXmacs to be a general editor for small files
you work with.



Below this line starts some development rant..
-----

One thing that doesn't work with this technique is tab completion. The
way tab completion works in the R interface is by issuing R functions
that calculate the completion, and then the right response to TeXmacs.
Much nicer would be if the interface would use the regular TAB
completion that is available in many programs (e.g. bash, and R, too).
Yesterday I discovered how this can be done, but it will take some
time to implement...
You can use the file called ~/.inputrc to specify how tab completion works.
Some of the useful fields for a TeXmacs interface are:
set show-all-if-ambiguous on
set show-all-if-unmodified on #These two are so that there is no need
to press tab twice
set page-completions off #no paging
set print-completions-horizontally on # not presented as a table
set completion-query-items -1 # don't ask if you really want to see
987625 items.

The cool thing is that these setting will work with programs using the
readline interface, so bash, R and many others. Once this is set, it
should be quite trivial to write tab completion that works by sending
a TAB to the program. The environment variable INPUTRC tell a program
to use an alternative file instead of ~/.inputrc, so you can have a
special inputrc for when you are inside TeXmacs.

I'm a bit swamped at the moment, so it will take a bit of time to implement.

Now to the question, and I probably know the answer.
If we use the trick outlined above:
--
cat <<EOF >hello_world.c
#include <stdio.h>
main() {
printf("hello world\n") ;
}
EOF
--
It would be really cool if we could tell TeXmacs that for the code,
one should do C-style syntax highlighting. I'm not totally sure if it
is possible to switch to a different highlighting mode inside a
session, probably yes. I can try to hack it together. But is it worth
it? What is the current state of highlighting?

Thanks for listening,
Michael


  • [TeXmacs] alternative shell interface, file editing, and syntax highlighting, Michael Lachmann, 12/07/2012

Archive powered by MHonArc 2.6.19.

Top of page