There is an unintended consequence to removing the \: continuation 
convention: abbreviations would have to be separated by blank lines.  As a 
result, I am going to leave the \: convention unchanged for the definitions 
of abbreviations in @data global-abbreviations nodes and @data 
abbreviations nodes.

However, I do propose to make the following changes:

1. The \: convention is deprecated in @data abbreviations-subst-env nodes. 
The abbreviation code will strip \: from such nodes, but no leading \: will 
appear in the @data abbreviations-subst-env node in leoSettings.leo.  This 
will allow existing @data abbreviations-subst-env nodes to work as always, 
but will encourage people to use the new, simpler form of @data 
abbreviations-subst-env nodes.

2. I have refactored the code in abbrevClass.finishCreate into three parts, 
mostly so each may have its own docstring.

3. I plan to add a bit more to the error reporting code, and I think the 
exec statement should protected by try/except, so that errors in @data 
abbreviations-subst-env do not cause problems during startup.  This is 
really important for newbies.

4. I propose to add a new setting: @bool scripting-abbreviations, default 
False.  Scripting abbreviations will be enabled if *either* of the 
following is True:

    @bool scripting-abbreviations
    @bool scripting-at-script-nodes

This is a safety feature: it allows scripting abbreviations to be enabled 
*without* enabling the (very dangerous in general) 
scripting-at-script-nodes setting.

5. finishCreate will always report either::

    Abbreviations are on
    Abbreviations are off

in the normal operating environment (not unit testing, not null gui, not 
batch mode, etc.)  As a result, there is less need to  issue the following 
message::

    Note: @abbreviations-subst-start found, but no substitutions without 
@scripting-at-script-nodes = True")

In fact, because of the new @bool scripting-abbreviations setting, the 
message would have to be even longer than it was.  I don't think it is 
worth it.

6. I propose one change to the actual contents of Terry's original @data 
abbreviations-subst-env node (apart from stripping \:).  The original code, 
stripped of \: was::

    def user_name():
        """get user's full name if available"""
        if pwd:
            return pwd.getpwnam(os.environ['LOGNAME']).pw_gecos.rstrip(',')
        else:
            os.environ['LOGNAME']

Shouldn't the last line be "return os.environ['LOGNAME']" ?

The two statements to os.environ['LOGNAME'] may throw a NameError.  This is 
really confusing to newbies.

I propose something like::

    def user_name():
        """get user's full name if available"""
        name = os.environ.get('LOGNAME') or ask('log name','my login name')
        if pwd:
            return pwd.getpwnam(name.pw_gecos.rstrip(',')
        else:
            return name

All comments welcome.  I'll be pushing the new code later today, unless 
there are objections.

I'll be documenting scripting abbreviations today.  They deserve a 
prominent place in Leo's users guide.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to