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