Abbreviations can, in the branch http://bazaar.launchpad.net/~terry-n-brown/+junk/leo_test include computed values and place holders which you can step through, filling in a template. Edward, these changes involve some core code, although I think they're quite benign, but pls. see change notes at the bottom of this email.
Here's a quick screencast of the template expansions: http://www.greygreen.org/tmp/leoabbrev.ogv I tried uploading it to Vimeo, but that seems to have failed (http://www.vimeo.com/48019375) Here are the draft docs. for abbreviations: Abbreviations are very versatile. You can type ``def;;``, and Leo will prompt you for a function name, detect whether the function needs a ``self`` parameter, ask for a list of parameters, and expand your input (just ``"some_function"`` and ``"one, two, three=4"`` to something like:: def some_function(one, two, three=4): """some_function - Return <|return|> :Parameters: - `one`: <|describe one|> - `two`: <|describe two|> - `three`: <|describe three|> Created: Wed Aug 22 10:32:54 CDT 2012 """ <|code|> The first placeholder, ``<|return|>`` will be selected, so you can begin typing in the right place. Hitting ``,,`` will select the next place holder, and so on. They can also close XML tags, enter balanced indented markup for various languages, etc. Here's a list of `@settings` which relate to abbreviations. @bool enable-abbreviations = False True: enable abbreviations False disable abbreviations Typically you would enable abbreviations in myLeoSettings.leo or in individual .leo files. @data global-abbreviations & @data abbreviations # Comments lines (lines starting with '#') are ignored. # Non-comment lines should have the form:: # # name=definition # Definitions in @data abbreviation nodes override definitions in @data # global-abbreviation nodes. Typically you would define @data abbreviation nodes # in myLeoSettings.leo @string abbreviations-subst-start = None If this @string is set to something other than None, *and* @bool scripting-at-script-nodes = True, then substitutions will be made when abbreviations are inserted. For example set abbreviations-subst-start to ``{|{`` and abbreviations-subst-end to ``}|}`` and an abbreviation like:: date;;={|{import time;x=time.asctime()}|} will expand to something like "Mon Aug 20 22:00:40 2012" See also abbreviations-subst-env. @string abbreviations-subst-end = }|} See abbreviations-subst-start. This setting, abbreviations-subst-end, has no effect if abbreviations-subst-start is not set. @data abbreviations-subst-env If abbreviations-subst-start is set (see that @setting), the code in this node will be executed, once only, when the outline is loaded, in an environment which will be used for execution of substitutions in abbreviations. For example, if this node contains ``import time``, then an abbreviation like:: date;;={|{import time;x=time.asctime()}|} can be written more simply as:: date;;={|{x=time.asctime()}|} The environment will contain `c` and `g`, a dict called `_values` (see ask() and get() in @data abbreviations-subst-env), and `_abr`, the abbreviation being expanded. Start lines with `\:` to preserve indentation. @@data abbreviations examples See the node for examples of advanced abbreviations with substitutions. @string abbreviations-place-start = <| Start of a placeholder for template expansions. E.g. the `<|` in:: w;;=while <|condition|>: \: <|code|> This would expand with the `<|condition|>` selected, and `,,`, if that's an abbreviation linked to next_place(), see @@data abbreviations examples, would select `<|code|>`. @string abbreviations-place-end = \|> The end of a placeholder for template expansions, e.g. `|>`. See @string abbreviations-place-start. Edward - to look at the changes in theory you could go to http://bazaar.launchpad.net/~terry-n-brown/+junk/leo_test/revision/5430?compare_revid=5424 but in practice I think the lack of context there makes that useless, an you might want to just pull http://bazaar.launchpad.net/~terry-n-brown/+junk/leo_test and look at it with `bzr qlog`. Some of the code is in masterCommand, which is why I wanted you to look at it, but it's guarded by if c.abbrev_subst_start:, so it won't do anything unless enabled. Cheers -Terry -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en.
