From ea66b07bac97367426bba900c9fbeb6b2b9b8c9e Mon Sep 17 00:00:00 2001 From: Joris van der Hoeven Date: Thu, 16 Feb 2012 11:59:22 +0000 Subject: [PATCH] Continued preparations for reorganization of contextual overloading --- devel/interface/interface-commands.en.tm | 61 +++++++++++++--------- devel/plugin/plugin-simple.en.tm | 46 +++++----------- devel/scheme/overview/overview-start.en.tm | 50 +++++++++--------- main/scheme/man-menus.en.tm | 37 ++++++------- 4 files changed, 94 insertions(+), 100 deletions(-) diff --git a/devel/interface/interface-commands.en.tm b/devel/interface/interface-commands.en.tm index 2fd66b5..bf57d47 100644 --- a/devel/interface/interface-commands.en.tm +++ b/devel/interface/interface-commands.en.tm @@ -1,4 +1,4 @@ - + @@ -6,16 +6,16 @@ > The application may use as a very particular output - format in order to send commands to . In other - words, the block + format in order to send commands to . In other words, the + block <\quotation> command:>> will send the command > to . Such commands are - executed immediately after reception of . We also recall that - such command blocks may be incorporated recursively in larger + executed immediately after reception of . We also + recall that such command blocks may be incorporated recursively in larger - blocks. plug-in> @@ -33,7 +33,7 @@ The body of the main loop of simply contains - <\cpp-fragment> + <\cpp-code> char buffer[100]; cin.getline (buffer, 100, '\\n'); @@ -52,36 +52,29 @@ cout \\ DATA_END; fflush (stdout); - + - The macro is defined in - : + The macro is defined in : - <\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) - \ \ \ \ \ \ (=\ "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)))) - + \; - The configuration of proceeds as usual: - - <\scheme-fragment> (plugin-configure menus \ \ (:require (url-exists-in-path? "menus.bin")) @@ -89,7 +82,27 @@ \ \ (:launch "menus.bin") \ \ (:session "Menus")) - + + \; + + (menu-bind plugin-menu + + \ \ (:require (in-menus?)) + + \ \ (=\ "Menus" (link menus-menu))) + + + The configuration of proceeds as usual: + + <\scm-code> + (plugin-configure menus + + \ \ (:require (url-exists-in-path? "menus.bin")) + + \ \ (:launch "menus.bin") + + \ \ (:session "Menus")) + diff --git a/devel/plugin/plugin-simple.en.tm b/devel/plugin/plugin-simple.en.tm index 2332325..7efbf81 100644 --- a/devel/plugin/plugin-simple.en.tm +++ b/devel/plugin/plugin-simple.en.tm @@ -1,9 +1,9 @@ - + <\body> - code> + code> plug-in> @@ -13,8 +13,8 @@ \ \ \ \ $TEXMACS_PATH/examples/plugins - This plug-in shows how to extend with some additional - code in the file + This plug-in shows how to extend with some additional + code in the file <\verbatim> \ \ \ \ @@ -35,14 +35,10 @@ The file essentially contains the following code: - <\scheme-fragment> + <\scm-code> (define (world-initialize) - \ \ (menu-extend texmacs-extra-menu - - \ \ \ \ (=\ "World" - - \ \ \ \ \ \ \ \ ("Hello world" (insert-string "Hello world"))))) + \ \ (display* "Using world plug-in!\\n")) \; @@ -51,19 +47,17 @@ \ \ (:require #t) \ \ (:initialize (world-initialize))) - + - The configuration option specifies a condition which - needs to be satisfied for the plug-in to be detected by (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 specifies a condition which needs + to be satisfied for the plug-in to be detected by (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 specifies an instruction which will be + The option 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 - and a menu item , 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 .scm> files simple will reduce the startup time of . @@ -81,17 +75,5 @@ <\initial> <\collection> - - - - - - - - - - - - \ No newline at end of file diff --git a/devel/scheme/overview/overview-start.en.tm b/devel/scheme/overview/overview-start.en.tm index e6013b5..854f416 100644 --- a/devel/scheme/overview/overview-start.en.tm +++ b/devel/scheme/overview/overview-start.en.tm @@ -1,4 +1,4 @@ - + @@ -29,7 +29,7 @@ in this file, the keyboard shortcuts and for starting a new theorem 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))) - + Similarly, the following command extends the standard 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,")))) - + The customization of the and is described in more detail in the @@ -73,7 +75,7 @@ The file 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))) - + Notice that the check is important: when omitted, the styles of existing documents would also be changed to . @@ -94,11 +96,11 @@ following code will force to automatically launch a session for every newly opened document: - <\scm-fragment> + <\scm-code> (if (no-name?) \ \ \ \ (make-session "maxima" (url-\string (get-name-buffer)))) - + Using string (get-name-buffer))> as the second argument of ensures that a different session will be opened for @@ -125,11 +127,11 @@ Furthermore, the file .scm> should a piece of configuration code of the form - <\scm-fragment> + <\scm-code> (plugin-configure \ \ (:require #t)) - + Any other code present in .scm> will then be executed when the plug-in is booted, that is, shortly after is @@ -160,8 +162,8 @@ In order to rapidly test the effect of commands, it is convenient to execute them directly from within the editor. provides two mechanisms for doing this: directly type the command on the footer using - the shortcut, or start a session using - . + the shortcut, or start a + session using . 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|scheme] > (square 1111111) - <|folded-io> - + <\folded-io|scheme] > (kbd-map ("h i ." (insert "Hi there!"))) - <|folded-io> - + <\folded-io|scheme] > ;; try typing ``hi.'' - <|folded-io> - + commands> @@ -208,9 +206,9 @@ scheme command > when booting has completed. For instance, - <\shell-fragment> + <\shell-code> texmacs -x "(display \\"Hi there\\\\n\\")" - + causes to print ``Hi there!'' when starting up. Notice that the option may be used several times. @@ -219,9 +217,9 @@ to quit. It is usually used after a option. For instance, - <\shell-fragment> + <\shell-code> texmacs text.tm -x "(print)" -q - + will cause to load the file , to print it, and quit. diff --git a/main/scheme/man-menus.en.tm b/main/scheme/man-menus.en.tm index 84e0cf0..dd47a76 100644 --- a/main/scheme/man-menus.en.tm +++ b/main/scheme/man-menus.en.tm @@ -1,37 +1,38 @@ - + <\body> - You may define (or modify) a (part of a) menu with name - using + You may define a menu with name either using - <\scm-fragment> - (menu-bind . ) - + <\scm-code> + (menu-bind . ) + - and append new entries to an existing (part of a) menu with name - using + or - <\scm-fragment> - (menu-extend . ) - + <\scm-code> + (tm-menu () . ) + - Here is a program which represents the entries of the menu. - In particular, you may take a look at the files in the directory + Here is a program which represents the entries of the menu. + In particular, you may take alook at the files in the directory <\verbatim> \ \ \ \ $TEXMACS_PATH/progs/menu - in order to see how the standard menus are defined. + in order to see how the standard menus are defined. In the case + of , 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 > in or - is a list of entries of one of the following forms: + More precisely, the program > in or + is a list of entries of one of the following forms: - <\scm-fragment> + <\scm-code> (=\ "pulldown menu name" ) (-\ "pullright menu name" ) @@ -43,7 +44,7 @@ (if ) (link ) - + \;