mirror of https://github.com/texmacs/doc.git
Continued preparations for reorganization of contextual overloading
This commit is contained in:
parent
115bbf012c
commit
ea66b07bac
|
@ -1,4 +1,4 @@
|
|||
<TeXmacs|1.0.4.1>
|
||||
<TeXmacs|1.0.7.14>
|
||||
|
||||
<style|tmdoc>
|
||||
|
||||
|
@ -6,16 +6,16 @@
|
|||
<tmdoc-title|Sending commands to <TeXmacs>>
|
||||
|
||||
The application may use <verbatim|command> as a very particular output
|
||||
format in order to send <value|scheme> commands to <TeXmacs>. In other
|
||||
words, the block
|
||||
format in order to send <scheme> commands to <TeXmacs>. In other words, the
|
||||
block
|
||||
|
||||
<\quotation>
|
||||
<framed-fragment|<verbatim|<render-key|DATA_BEGIN>command:<em|cmd><render-key|DATA_END>>>
|
||||
</quotation>
|
||||
|
||||
will send the command <verbatim|<em|cmd>> to <TeXmacs>. Such commands are
|
||||
executed immediately after reception of <render-key|DATA_END>. We also recall that
|
||||
such command blocks may be incorporated recursively in larger
|
||||
executed immediately after reception of <render-key|DATA_END>. We also
|
||||
recall that such command blocks may be incorporated recursively in larger
|
||||
<render-key|DATA_BEGIN>-<render-key|DATA_END> blocks.
|
||||
|
||||
<paragraph*|The <verbatim|menus> plug-in>
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
The body of the main loop of <verbatim|menus.cpp> simply contains
|
||||
|
||||
<\cpp-fragment>
|
||||
<\cpp-code>
|
||||
char buffer[100];
|
||||
|
||||
cin.getline (buffer, 100, '\\n');
|
||||
|
@ -52,36 +52,29 @@
|
|||
cout \<less\>\<less\> DATA_END;
|
||||
|
||||
fflush (stdout);
|
||||
</cpp-fragment>
|
||||
</cpp-code>
|
||||
|
||||
The <value|scheme> macro <scheme-code|menus-add> is defined in
|
||||
<verbatim|init-menus.scm>:
|
||||
The <scheme> macro <scm|menus-add> is defined in <verbatim|init-menus.scm>:
|
||||
|
||||
<\scheme-fragment>
|
||||
(menu-bind menus-menu
|
||||
|
||||
\ \ ("Hi" (insert "Hello world")))
|
||||
<\scm-code>
|
||||
(define menu-items '("Hi"))
|
||||
|
||||
\;
|
||||
|
||||
(menu-extend texmacs-extra-menu
|
||||
(tm-menu (menus-menu)
|
||||
|
||||
\ \ (if (equal? (get-env "prog language") "menus")
|
||||
\ \ (for (entry menu-items)
|
||||
|
||||
\ \ \ \ \ \ (=\<gtr\> "Menus" (link menus-menu))))
|
||||
\ \ \ \ ((eval entry) (insert entry))))
|
||||
|
||||
\;
|
||||
|
||||
(define-macro (menus-add s)
|
||||
(tm-define (menus-add entry)
|
||||
|
||||
\ \ `(menu-extend menus-menu
|
||||
\ \ (set! menu-items (cons entry menu-items)))
|
||||
|
||||
\ \ \ \ \ (,s (insert ,s))))
|
||||
</scheme-fragment>
|
||||
\;
|
||||
|
||||
The configuration of <verbatim|menus> proceeds as usual:
|
||||
|
||||
<\scheme-fragment>
|
||||
(plugin-configure menus
|
||||
|
||||
\ \ (:require (url-exists-in-path? "menus.bin"))
|
||||
|
@ -89,7 +82,27 @@
|
|||
\ \ (:launch "menus.bin")
|
||||
|
||||
\ \ (:session "Menus"))
|
||||
</scheme-fragment>
|
||||
|
||||
\;
|
||||
|
||||
(menu-bind plugin-menu
|
||||
|
||||
\ \ (:require (in-menus?))
|
||||
|
||||
\ \ (=\<gtr\> "Menus" (link menus-menu)))
|
||||
</scm-code>
|
||||
|
||||
The configuration of <verbatim|menus> proceeds as usual:
|
||||
|
||||
<\scm-code>
|
||||
(plugin-configure menus
|
||||
|
||||
\ \ (:require (url-exists-in-path? "menus.bin"))
|
||||
|
||||
\ \ (:launch "menus.bin")
|
||||
|
||||
\ \ (:session "Menus"))
|
||||
</scm-code>
|
||||
|
||||
<tmdoc-copyright|1998--2002|Joris van der Hoeven>
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<TeXmacs|1.0.3.7>
|
||||
<TeXmacs|1.0.7.14>
|
||||
|
||||
<style|tmdoc>
|
||||
|
||||
<\body>
|
||||
<tmdoc-title|Example of a plug-in with <value|scheme> code>
|
||||
<tmdoc-title|Example of a plug-in with <scheme> code>
|
||||
|
||||
<paragraph*|The <verbatim|world> plug-in>
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
|||
\ \ \ \ $TEXMACS_PATH/examples/plugins
|
||||
</verbatim>
|
||||
|
||||
This plug-in shows how to extend <TeXmacs> with some additional
|
||||
<value|scheme> code in the file
|
||||
This plug-in shows how to extend <TeXmacs> with some additional <scheme>
|
||||
code in the file
|
||||
|
||||
<\verbatim>
|
||||
\ \ \ \ <example-plugin-link|world/progs/init-world.scm>
|
||||
|
@ -35,14 +35,10 @@
|
|||
|
||||
The file <verbatim|init-world.scm> essentially contains the following code:
|
||||
|
||||
<\scheme-fragment>
|
||||
<\scm-code>
|
||||
(define (world-initialize)
|
||||
|
||||
\ \ (menu-extend texmacs-extra-menu
|
||||
|
||||
\ \ \ \ (=\<gtr\> "World"
|
||||
|
||||
\ \ \ \ \ \ \ \ ("Hello world" (insert-string "Hello world")))))
|
||||
\ \ (display* "Using world plug-in!\\n"))
|
||||
|
||||
\;
|
||||
|
||||
|
@ -51,19 +47,17 @@
|
|||
\ \ (:require #t)
|
||||
|
||||
\ \ (:initialize (world-initialize)))
|
||||
</scheme-fragment>
|
||||
</scm-code>
|
||||
|
||||
The configuration option <scheme-code|:require> specifies a condition which
|
||||
needs to be satisfied for the plug-in to be detected by <TeXmacs> (later
|
||||
on, this will for instance allow us to check whether certain programs exist
|
||||
on the system). The configuration is aborted if the requirement is not
|
||||
fulfilled.
|
||||
The configuration option <scm|:require> specifies a condition which needs
|
||||
to be satisfied for the plug-in to be detected by <TeXmacs> (later on, this
|
||||
will for instance allow us to check whether certain programs exist on the
|
||||
system). The configuration is aborted if the requirement is not fulfilled.
|
||||
|
||||
The option <scheme-code|:initialize> specifies an instruction which will be
|
||||
The option <scm|:initialize> specifies an instruction which will be
|
||||
executed during the initialization (modulo the fulfillment of the
|
||||
requirement). In our example, we just create a new top level menu
|
||||
<menu|World> and a menu item <menu|World|Hello world>, which can be used to
|
||||
insert the text ``Hello world''. In general, the initialization routine
|
||||
requirement). In our example, we just send a message to the standard output
|
||||
that we are using our plug-in. In general, the initialization routine
|
||||
should be very short and rather load a module which takes care of the real
|
||||
initialization. Indeed, keeping the <verbatim|init-<em|myplugin>.scm> files
|
||||
simple will reduce the startup time of <TeXmacs>.
|
||||
|
@ -81,17 +75,5 @@
|
|||
<\initial>
|
||||
<\collection>
|
||||
<associate|language|english>
|
||||
<associate|page-bot|30mm>
|
||||
<associate|page-even|30mm>
|
||||
<associate|page-odd|30mm>
|
||||
<associate|page-reduce-bot|15mm>
|
||||
<associate|page-reduce-left|25mm>
|
||||
<associate|page-reduce-right|25mm>
|
||||
<associate|page-reduce-top|15mm>
|
||||
<associate|page-right|30mm>
|
||||
<associate|page-top|30mm>
|
||||
<associate|page-type|a4>
|
||||
<associate|par-width|150mm>
|
||||
<associate|sfactor|4>
|
||||
</collection>
|
||||
</initial>
|
|
@ -1,4 +1,4 @@
|
|||
<TeXmacs|1.0.7.1>
|
||||
<TeXmacs|1.0.7.14>
|
||||
|
||||
<style|tmdoc>
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
|||
in this file, the keyboard shortcuts <key|T h .> and <key|P r o p .> for
|
||||
starting a new theorem <abbr|resp.> proposition:
|
||||
|
||||
<\scm-fragment>
|
||||
<\scm-code>
|
||||
(kbd-map
|
||||
|
||||
\ \ ("D e f ." (make 'definition))
|
||||
|
@ -39,13 +39,15 @@
|
|||
\ \ ("P r o p ." (make 'proposition))
|
||||
|
||||
\ \ ("T h ." (make 'theorem)))
|
||||
</scm-fragment>
|
||||
</scm-code>
|
||||
|
||||
Similarly, the following command extends the standard <menu|Insert> menu
|
||||
with a special section for the insertion of greetings:
|
||||
|
||||
<\scm-fragment>
|
||||
(menu-extend insert-menu
|
||||
<\scm-code>
|
||||
(menu-bind insert-menu
|
||||
|
||||
\ \ (next)
|
||||
|
||||
\ \ ---
|
||||
|
||||
|
@ -60,7 +62,7 @@
|
|||
\ \ \ \ \ \ ("Yours sincerely" (insert "Yours sincerely,"))
|
||||
|
||||
\ \ \ \ \ \ ("Greetings" (insert "Greetings,"))))
|
||||
</scm-fragment>
|
||||
</scm-code>
|
||||
|
||||
The customization of the <hlink|keyboard|../utils/utils-keyboard.en.tm> and
|
||||
<hlink|menus|../utils/utils-menus.en.tm> is described in more detail in the
|
||||
|
@ -73,7 +75,7 @@
|
|||
The file <verbatim|my-init-buffer.scm> can for instance be used in order to
|
||||
automatically select a certain style when starting a new document:
|
||||
|
||||
<\scm-fragment>
|
||||
<\scm-code>
|
||||
(if (no-name?)
|
||||
|
||||
\ \ \ \ (begin
|
||||
|
@ -81,7 +83,7 @@
|
|||
\ \ \ \ \ \ (init-style "article")
|
||||
|
||||
\ \ \ \ \ \ (pretend-save-buffer)))
|
||||
</scm-fragment>
|
||||
</scm-code>
|
||||
|
||||
Notice that the check <verbatim|(no-name?)> is important: when omitted, the
|
||||
styles of existing documents would also be changed to <tmstyle|article>.
|
||||
|
@ -94,11 +96,11 @@
|
|||
following code will force <TeXmacs> to automatically launch a <name|Maxima>
|
||||
session for every newly opened document:
|
||||
|
||||
<\scm-fragment>
|
||||
<\scm-code>
|
||||
(if (no-name?)
|
||||
|
||||
\ \ \ \ (make-session "maxima" (url-\<gtr\>string (get-name-buffer))))
|
||||
</scm-fragment>
|
||||
</scm-code>
|
||||
|
||||
Using <scm|(url-\<gtr\>string (get-name-buffer))> as the second argument of
|
||||
<scm|make-session> ensures that a different session will be opened for
|
||||
|
@ -125,11 +127,11 @@
|
|||
Furthermore, the file <verbatim|init-<em|name>.scm> should a piece of
|
||||
configuration code of the form
|
||||
|
||||
<\scm-fragment>
|
||||
<\scm-code>
|
||||
(plugin-configure <em|name>
|
||||
|
||||
\ \ (:require #t))
|
||||
</scm-fragment>
|
||||
</scm-code>
|
||||
|
||||
Any other <scheme> code present in <verbatim|init-<em|name>.scm> will then
|
||||
be executed when the plug-in is booted, that is, shortly after <TeXmacs> is
|
||||
|
@ -160,8 +162,8 @@
|
|||
In order to rapidly test the effect of <scheme> commands, it is convenient
|
||||
to execute them directly from within the editor. <TeXmacs> provides two
|
||||
mechanisms for doing this: directly type the command on the footer using
|
||||
the <shortcut|(interactive footer-eval)> shortcut, or start a <scheme> session using
|
||||
<menu|Insert|Session|Scheme>.
|
||||
the <shortcut|(interactive footer-eval)> shortcut, or start a <scheme>
|
||||
session using <menu|Insert|Session|Scheme>.
|
||||
|
||||
The first mechanism is useful when you do not want to alter the document or
|
||||
when the current cursor position is important for the command you wish to
|
||||
|
@ -178,23 +180,19 @@
|
|||
<\session|scheme|default>
|
||||
<\folded-io|scheme] >
|
||||
(define (square x) (* x x))
|
||||
<|folded-io>
|
||||
</folded-io>
|
||||
</folded-io|>
|
||||
|
||||
<\folded-io|scheme] >
|
||||
(square 1111111)
|
||||
<|folded-io>
|
||||
</folded-io>
|
||||
</folded-io|>
|
||||
|
||||
<\folded-io|scheme] >
|
||||
(kbd-map ("h i ." (insert "Hi there!")))
|
||||
<|folded-io>
|
||||
</folded-io>
|
||||
</folded-io|>
|
||||
|
||||
<\folded-io|scheme] >
|
||||
;; try typing ``hi.''
|
||||
<|folded-io>
|
||||
</folded-io>
|
||||
</folded-io|>
|
||||
</session>
|
||||
|
||||
<paragraph*|Command-line options for executing <scheme> commands>
|
||||
|
@ -208,9 +206,9 @@
|
|||
scheme command <verbatim|<em|cmd>> when booting has completed. For
|
||||
instance,
|
||||
|
||||
<\shell-fragment>
|
||||
<\shell-code>
|
||||
texmacs -x "(display \\"Hi there\\\\n\\")"
|
||||
</shell-fragment>
|
||||
</shell-code>
|
||||
|
||||
causes <TeXmacs> to print ``Hi there!'' when starting up. Notice that the
|
||||
<verbatim|-x> option may be used several times.
|
||||
|
@ -219,9 +217,9 @@
|
|||
<TeXmacs> to quit. It is usually used after a <verbatim|-x> option. For
|
||||
instance,
|
||||
|
||||
<\shell-fragment>
|
||||
<\shell-code>
|
||||
texmacs text.tm -x "(print)" -q
|
||||
</shell-fragment>
|
||||
</shell-code>
|
||||
|
||||
will cause <TeXmacs> to load the file <verbatim|text.tm>, to print it,
|
||||
and quit.
|
||||
|
|
|
@ -1,37 +1,38 @@
|
|||
<TeXmacs|1.0.7.7>
|
||||
<TeXmacs|1.0.7.14>
|
||||
|
||||
<style|tmdoc>
|
||||
|
||||
<\body>
|
||||
<tmdoc-title|Creating your own dynamic menus>
|
||||
|
||||
You may define (or modify) a (part of a) menu with name <scm-arg|name>
|
||||
using
|
||||
You may define a menu with name <scm-arg|name> either using
|
||||
|
||||
<\scm-fragment>
|
||||
(menu-bind <scm-arg|name> . <scm-arg|prog>)
|
||||
</scm-fragment>
|
||||
<\scm-code>
|
||||
(menu-bind <scm-arg|name> . <scm-arg|def>)
|
||||
</scm-code>
|
||||
|
||||
and append new entries to an existing (part of a) menu with name
|
||||
<scm-arg|name> using
|
||||
or
|
||||
|
||||
<\scm-fragment>
|
||||
(menu-extend <scm-arg|name> . <scm-arg|prog>)
|
||||
</scm-fragment>
|
||||
<\scm-code>
|
||||
(tm-menu (<scm-arg|name>) . <scm-arg|def>)
|
||||
</scm-code>
|
||||
|
||||
Here <scm-arg|prog> is a program which represents the entries of the menu.
|
||||
In particular, you may take a look at the files in the directory
|
||||
Here <scm-arg|def> is a program which represents the entries of the menu.
|
||||
In particular, you may take a<nbsp>look at the files in the directory
|
||||
|
||||
<\verbatim>
|
||||
\ \ \ \ $TEXMACS_PATH/progs/menu
|
||||
</verbatim>
|
||||
|
||||
in order to see how the standard <TeXmacs> menus are defined.
|
||||
in order to see how the standard <TeXmacs> menus are defined. In the case
|
||||
of <scm|tm-menu>, it is possible to specify additional arguments, which
|
||||
makes it possible to dynamically construct more complex menus which depend
|
||||
on parameters.
|
||||
|
||||
More precisely, the program <verbatim|<em|prog>> in <verbatim|menu-set> or
|
||||
<verbatim|menu-append> is a list of entries of one of the following forms:
|
||||
More precisely, the program <verbatim|<em|def>> in <scm|menu-bind> or
|
||||
<scm|tm-menu> is a list of entries of one of the following forms:
|
||||
|
||||
<\scm-fragment>
|
||||
<\scm-code>
|
||||
(=\<gtr\> "pulldown menu name" <scm-arg|menu-definition>)
|
||||
|
||||
(-\<gtr\> "pullright menu name" <scm-arg|menu-definition>)
|
||||
|
@ -43,7 +44,7 @@
|
|||
(if <scm-arg|condition> <scm-arg|menu-definition>)
|
||||
|
||||
(link <scm-arg|variable>)
|
||||
</scm-fragment>
|
||||
</scm-code>
|
||||
|
||||
\;
|
||||
|
||||
|
|
Loading…
Reference in New Issue