[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Texmacs-dev] Re: extern-exec and "further customization"

From: Lionel Elie Mamane
Subject: [Texmacs-dev] Re: extern-exec and "further customization"
Date: Wed, 8 Feb 2006 10:07:48 +0100
User-agent: Mutt/1.5.11+cvs20060126

On Tue, Feb 07, 2006 at 10:33:05PM +0100, Henri Lesourd wrote:

>>- When the user types a command for the plug-in in a session, instead
>>  of sending what he typed, call a scheme procedure with arguments:

>>  * the string the user typed
>>  * the port used to talk to the child process

> You can already do this without changing
> anything in the standard components
> of TeXmacs (but this remains somehow
> a hack) ; write a new plugin (let's
> call it "foo", to define things clearly),
> and in the plugin "foo", do :
> <<
> (define (foo-plugin-eval name session t)
>  (display* "foo-plugin-eval=" name "; session=" session "; t=" t "\n")
>  (if (equal? name "foo")
>      (begin
>         ... the stuff for the foo plugin ...
>      )
>    ; Default case
>      (plugin-eval0 name session t))
> )
> (define plugin-eval0 plugin-eval)
> (set! plugin-eval foo-plugin-eval)))
> >>

> This way, (foo-plugin-eval) behaves as a
> stub for the real (plugin-eval0) that uses
> the socket, and you can preprocess/postprocess
> the input & the output exactly the way you
> want.

TeXmacs seems not to call plugin-eval itself when the user types
something in a field and "enter", so this fails to achieve the desired
result; it preprocesses only commands to the plugin called by scheme
code with plugin-eval, not commands typed by the user.

Here is exactly what I tried:

 Open a document with a pnambic and a scheme session in. Don't launch
 the pnambic plugin yet (don't type anything in its session). In the
 scheme session, do:

  (define (foo-plugin-eval name session t)
          (display* "debug: " name session t)
          (if (equal? name "pnambic")
              (plugin-eval0 name session (string-append "pre: " t))
              (plugin-eval0 name session t)))
  (define plugin-eval0 plugin-eval)
  (set! plugin-eval foo-plugin-eval)

Then go to the pnambic session and type something. foo-plugin-eval
doesn't get called.

But if it worked, it would permit me to do what I want. Thanks for
trying. Unless you can patch it to work, the solutions I have in mind
now are:

 - Make two plugins "foo" and "bar" instead of one. Each launches a
   process tm_foo and tm_bar, respectively. tm_foo and tm_bar
   communicate directly between themselves. tm_foo is the "main"
   plugin and when it needs to query the current state of TeXmacs
   (cursor position, ...), it issues
     DATA_BEGIN command:(plugin-eval "bar" "default" (get-cursor-position)) 
   tm_bar gets the information and passes it on to tm_foo.

   This idea was suggested by Bas Spitters.

 - Suggestion by Joris: There is already a complete preprocessing
   system available. Use it!

   It first sight, it seems like I'll have to use the complete
   (:serializer ,routine) option: the plugin-input-converters rules
   seem not to be able to rewrite plain text. The documentation
   doesn't say much about the :serializer option. In particular, is
   there a way to call the default serializer? So that I can do
   something like:

       "cursor-pos: " (get-cursor-position) "\n"
       "user-command: " (default-serializer input))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]