GNU TeXmacsUser manualReferenceAboutEnglishยทDeutsch
Sending commands to TeXmacs

The application may use command as a very particular output format in order to send Scheme commands to TeXmacs. In other words, the block

DATA_BEGINcommand:cmdDATA_END

will send the command cmd to TeXmacs. Such commands are executed immediately after reception of DATA_END. We also recall that such command blocks may be incorporated recursively in larger DATA_BEGIN-DATA_END blocks.

The menus plug-in

The menus plug-in shows how an application can modify the TeXmacs menus in an interactive way. The plug-in consists of the files

    menus/Makefile
    menus/progs/init-menus.scm
    menus/src/menus.cpp

The body of the main loop of

menus.cpp

simply contains

char buffer[100];
cin.getline (buffer, 100, '\n');
cout << DATA_BEGIN << "verbatim:";
cout << DATA_BEGIN << "command:(menus-add \""
     << buffer << "\")" << DATA_END;
cout << "Added " << buffer << " to menu";
cout << DATA_END;
cout.flush ();

The Scheme function menus-add is defined in

init-menus.scm

, which contains

(plugin-configure menus
  (:require (url-exists-in-path? "menus.bin"))
  (:launch "menus.bin")
  (:session "Menus"))

(when (supports-menus?)
  (define menu-items '("Hi"))

  (tm-menu (menus-menu)
    (for (entry menu-items)
      ((eval entry) (insert entry))))

  (tm-define (menus-add entry)
    (set! menu-items (cons entry menu-items)))

  (menu-bind plugin-menu
    (:require (in-menus?))
    (=> "Menus" (link menus-menu))))

The configuration of menus proceeds as usual. The additional code is only executed if the plug-in is operational. It defines a dynamic menu menus-menu, whose entries are computed from the list menu-items each time the menu is displayed, and attaches it to the main menu bar through the plugin-menu hook, which is reserved for plug-ins. The predicate in-menus? ensures that the menu is only visible inside menus sessions.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".