#@+leo-ver=5-thin
#@+node:ekr.20100805165051.7177: * @file release_notes.txt
#@@language plain
#@@tabwidth -4
#@+all
#@+node:edream.110203163054.117: ** Previous versions...
#@+node:ekr.20050210102358: *3* 4.0... New read logic eliminates read errors, eliminated child indices
#@+node:edream.110203163054.66: *4* 4.0.1 through 4.0.4
Leo 4.0.4                         October 29, 2003

- Fixed a problem with the titles in Font and Color panels.
- Worked around a Unicode assert failure in the colorizer.
- Fixed crasher in OnEndEditHeadline.
- Fixed import problems in leoPlugins.leo.
- @first and @last sentinels no longer contain corresponding text.
  This fixes a problem that affected PHP comment delimiters.

Leo 4.0.3                         October 25, 2003

- Fixes several problems with the auto_save and plugin menu plugins.
- Fixes a problem with the Go To Line Number command.

Note: This version does _not_ support Unicode file names or directory names.

Leo 4.0.2                         October 23, 2003

- Fixes a crasher in reportBadChars when a .leo file contains a character that
  can not be represented in the encoding specified in the first line of the
  .leo file.
- Leo now sends full tracebacks to the log window when Leo takes an unexpected
 exception.

Leo 4.0.1                         October 22, 2003

- Fixes several crashers, one of which may prevent Leo from starting.
- Fixes indentation for section references that are preceded by something
  other than whitespace.
- Removes debugging traces when reading and writing unknown attributes.
- Removes some improperly cloned nodes from LeoDocs.leo.
- Adds the checkTopologyOfAllClones script.
- Fixes some problems with plugins.
#@+node:edream.110203163054.67: *4* 4.0 final
Leo 4.0 final                     October 17, 2003

More than a year in the making, Leo 4.0 is finally here.

Highlights of 4.0 final:
-----------------------

** Improved and simplified format of external files.
	- Eliminated child indices, extraneous blank lines and @body sentinels.
	- Eliminated @node sentinels that indicate outline structure.
	- New @nl and @nonl sentinels indicate where newlines are and aren't.
	- These changes will largely eliminate unwanted cvs conflicts.

** Greatly improved error handling.
	- Reading external files _never_ alter outline structure or links.
	- Read errors leave the outline completely unchanged.
	- Broken clone links are gone forever.
	- As a result, 4.0 is much safer than all previous versions.

** Full compatibility will previous versions of Leo.
	- Leo 4.0 reads all external files properly, regardless of version.
	- Leo writes new-format external files by default, and this default may be changed.
	- New commands in the read/write menu allow you to explicitly specify the format of external files.

* New commands:
	- Write 3.x external file and Write 4.x external file.
	- Import External File.
	- Clear Recent Files.

* Dozens of other improvements, including:
	- Better Unicode support.
	- New configuration settings.
	- Several new plugins.

See the notes for the various beta releases for full details.
#@+node:edream.110203163054.68: *5* 4.0 beta 4
Leo 4.0 beta 4                      October 13, 2003

This is the third public release of Leo 4.0. There are no known serious bugs in
this version of Leo.  This will be the last beta release before 4.0 final.

Changes made in 4.0 beta 4
--------------------------

- Changed all instances of string.letters to string.ascii_letters.
  string.letters can cause crashes in some locales (Unicode environments).
- Fixed several bugs that caused clone marks not to be set properly.
#@+node:edream.110203163054.69: *5* 4.0 beta 3
Leo 4.0 beta 3                      October 9, 2003

This is the third public release of Leo 4.0. There are no known serious bugs in
this version of Leo.

Highlights of 4.0 beta 3
------------------------

- Fixed problems with setting Leo's window icons.
- Plugins may now save their own information in <v> and <t> elements in .leo files.
- The usual assortment of bug fixes and minor improvements.

See the children of this node for full details.
#@+node:edream.110203163054.70: *6* Fixed bugs
#@+node:edream.110203163054.71: *7* Fixed bug that caused some clones not to be marked as clones
This was a long-standing bug.  It's effect was cosmetic, and it was important to fix.
#@+node:edream.110203163054.72: *7* Corrected problems with setting icons on Linux
#@+node:edream.110203163054.73: *7* Fixed crasher in sentinelName
This could happen when the external file was corrupted.
#@+node:edream.110203163054.74: *7* Reenabled orphans & ignored test in new write logic
#@+node:edream.110203163054.75: *6* New features
#@+node:edream.110203163054.76: *7* Added support for unknown tnode and vnode attributes
Leo can now read and write "foreign" attributes in <v> and <t> elements in .leo
files:

- When reading a .leo file, Leo will create t.unknownAttributes or
v.unknownAttributes ivars for any tnode and vnode object whose corresponding <v>
or <t> element in the .leo file contains a foreign attribute.

- The unknownAttributes ivars are a dictionary whose keys are the attribute
names and whose values are strings.

- When writing a file, Leo will write "foreign" attributes if a vnode or tnode
contains an unknownAttributes ivar.

- The only "native" attributes that Leo expects to find are the "tx" attribute
in <t> elements and the "a", "t", "vtag" and "tnodeList" attributes of <v>
elements. Everything else is a foreign attribute.

- Leo performs the usual xml escapes on these strings when reading or writing
the unknownAttributes ivars.

Plugins may cause Leo to write such foreign attributes simply by attaching
unknownAttributes ivars to a vnode or tnode. For example:

	v.unknownAttributes = {"vnodeIcon" : pathToIcon}

It would be best not to delete other foreign attributes, so the following would
be preferred:

	if hasattr(v,"unknownAttributes"):
		v.unknownAttributes["vnodeIcon"] = pathToIcon
	else:
		v.unknownAttributes = {"vnodeIcon" : pathToIcon}

Another way:

	try:
		v.unknownAttributes["vnodeIcon"] = pathToIcon
	except AttributeError:
		v.unknownAttributes = {"vnodeIcon" : pathToIcon}
#@+node:edream.110203163054.77: *7* Added build number to signon
#@+node:edream.110203163054.78: *7* Added better error message in setDefaultIcon
Leo now warns if it can't find either the Icons directory or the LeoApp16.ico icon in that directory.
#@+node:edream.110203163054.79: *5* 4.0 beta 2
Leo 4.0 beta 2                      October 3, 2003

This is the second public release of Leo 4.0. There are no known serious bugs
in this version of Leo. Version 4.0 is the culmination of over a year of
collaborative design work and several months of actual implementation.

Highlights of 4.0 beta 2
------------------------
* Fixed several bugs:
  - Fixed several problems with reading and writing 4.0 external files.
  - Fixed several Unicode-related bugs.
  - Fixed a crasher in the Go To Line Number command.
  - Fixed a problem with Importing Python files.
* Important improvements:
  - Added allow_clone_drags setting.  N.B. Allows Leo to be used with Aqua.
  - When running Python 2.3 Leo can now create window icons without third-party packages.
- The usual minor improvements and bug fixes.

See the children of this node for full details.

Highlights of 4.0 beta 1
------------------------
* Improved and simplified format of external files.
* Greatly improved error handling.
* Full compatibility will previous versions of Leo.
#@+node:edream.110203163054.80: *6* To-do for 4.0 final
- Fix undo/redo bug for all commands that change body text in multiple nodes without changing outline structure.
	- This is a long-standing bug that came to light when trying to make Read @file Nodes undoable.

- Make Read @file Nodes command undoable.

- Fix small bugs in the Go To Line Number command.
#@+node:edream.110203163054.81: *6* Fixed Bugs
#@+node:edream.110203163054.82: *7* Added crucial defensive checks in v.headString() and v.bodySting()
The new code prints a warning if Leo's key internal strings are not Unicode.
#@+node:edream.110203163054.83: *7* Ensured newlines before all sentinels in @rawfile
#@+node:edream.110203163054.84: *7* Fixed bugs involving find params
There were bugs involving saving the "Pattern Match" and "Subroutine Only" find settings.
#@+node:edream.110203163054.85: *7* Fixed Python Import bug
@nocolor

Class level-code after the method definitions was dropped.
#@+node:edream.110203163054.86: *7* Fixed several more unicode bugs
The new code ensures that Leo creates and uses only Unicode strings internally.
#@+node:edream.110203163054.87: *7* Fixed crasher in Go To Outline command.
Fixed Go To Outline command so it doesn't crash on 4.0 files.  More work is needed.
#@+node:edream.110203163054.88: *7* Fixed @rawfile write problem
Under certain conditions the no sentinels at all were written when writing @rawfile trees.
#@+node:edream.110203163054.89: *6* Improved commands
#@+node:edream.110203163054.90: *7* Finished Import External File command and made it undoable
#@+node:edream.110203163054.91: *7* Moved Clear Recent Files menu item into Recent Files menu
This is much more natural and less cluttered.
#@+node:edream.110203163054.92: *7* Added better log message for Convert All Tabs/Blanks commands
#@+node:edream.110203163054.93: *7* Marked changed nodes & make the @file node and the outline dirty.
#@+node:edream.110203163054.94: *7* Rewrote icon code so it doesn't use PIL or tkIcon in Python 2.3
Leo will create the Leo icon in Leo windows automatically when using Python 2.3.
The Python Imaging Library and the tkIcon package are only used when using
previous versions of Python.
#@+node:edream.110203163054.95: *7* Created leoGui base class for tkinterGui class
This is the foundation for "foreign" guis.
#@+node:edream.110203163054.96: *6* New and improved settings
#@+node:edream.110203163054.97: *7* Added support for two new settings affecting drags
allow_clone_drags

This is a workaround so that Leo may be used on Aqua. When this setting is zero
Leo always moves nodes when dragging. The default is to enable clone-drags.

enable_drag_messages

Allows the user to suppress the message telling whether dragging nodes will move
them or clone them. The default is to enable those messages.
#@+node:edream.110203163054.98: *7* changed default for config.write_old_format_derived_files
After the 4.0 beta 1 release I changed the default so that _new_ format derived
files are written if leoConfig.txt does not exist.
#@+node:edream.110203163054.99: *5* 4.0 beta 1
leo.py 4.0 beta 1                      September 26, 2003

This is the first public release of Leo 4.0.  Version 4.0 is the culmination of over a year of collaborative design work and several months of actual implementation.

Please use caution when using this beta version of Leo.  It appears very solid and it has been tested by only a few people.

Highlights of 4.0:

** Improved and simplified format of external files.
	- Eliminated child indices, extraneous blank lines and @body sentinels.
	- Eliminated @node sentinels that indicate outline structure.
	- New @nl and @nonl sentinels indicate where newlines are and aren't.
	- These changes will largely eliminate unwanted cvs conflicts.

** Greatly improved error handling.
	- Reading external files _never_ alter outline structure or links.
	- Read errors leave the outline completely unchanged.
	- Broken clone links are gone forever.
	- As a result, using 4.0 is much safer than all previous versions.

** Full compatibility will previous versions of Leo.
	- Leo reads all external files properly, regardless of version.
	- Leo writes new-format external files by default, and this default may be changed.
	- New commands in the read/write menu allow you to explicitly specify the format of external files.

* New commands:
	- Write 3.x external file.
	- Write 4.x external file.
	- Import external file.
	- Clear Recent Files.

- Several new plugins.
- Several minor bug fixes.

See the children of this node for full details.
#@+node:edream.110203163054.100: *6* 4.0 Theory of operation
The Synchronization Principle simplifies everything and at long last puts Leo on
a firm theoretical foundation. This principle states that the "smallest unit of
meaning" of any Leo outline is the entire outline itself. In particular,
individual external files have meaning only in the context of a particular
outline.

The Synchronization Principle has the following happy consequences:

1. We may assume that all external files are in synch with the outline that wrote
them. This assumption allows Leo to use "hidden machinery" in the outline to
associate nodes in the external file with nodes in the outline. This "hidden"
machinery consists of a list of tnodes associated with @file vnodes in the
outline. When writing a external file Leo creates a list of tnodes in the order
they were written to the external file. When reading the external file, Leo uses
this list to associate nodes in the external file with nodes in the outline.

2. external files must get their structure from the .leo file that wrote them. As
we have seen, this is done using the hidden machinery in the .leo file.
Consequently, there is no further need to represent outline structure in derived
files. There is no need any longer either for child indices or for sentinels to
represent outline structure. As a result, we can eliminate @+body and @-body
nodes entirely because all @+node sentinels are followed by body text.

3. All .leo files must contain full outline structure. Even "thin" outline will
contain the full representation of the outline as vnodes.

4. Reading _never_ alters outline structure in the outline. No vnodes are ever
created or destroyed and reading never alters clone links. This is true whether
or not read errors occur. The read code sets a temporary attribute of tnodes
while reading. These attributes are copied to the permanent t.bodyString
attribute only if no read errors were encountered.

4. Error recovery is now trivial: Read errors indicate that the .leo files and
one or more external files are out-of-synch. No error recovery is attempted: the
@file tree in which the error occurred reverts back to its original state.

5. The new Import External File command is the _only_ way to recover data from
mismatched external file.
#@+node:edream.110203163054.101: *6* New commands & options
#@+node:edream.110203163054.102: *7* New write_old_format_derived_files option
The write_old_format_derived_files option in leoConfig.leo and leoConfig.txt
determines which format of external file Leo's Write and Save commands write by
default. If this option is 0 (recommended) Leo writes 4.x format external files.
Otherwise Leo writes 3.x external files.

Note that you can use the Write 3.x/4.x external files commands in the
File:Read/Write menu to write external files in an explicitly specified format.
#@+node:edream.110203163054.103: *7* New Clear Recent Files command
This command deletes all entries in the Recent Files submenu except the most
recent file. The files themselves are not affected, just the menu entries.
#@+node:edream.110203163054.104: *7* New Import External File command
The Import External File command imports all the nodes in a external file into the
outline. Unlike the read commands, no outline structure is preserved. This
command can import either 3.x or 4.x external files.

This command is necessary in version 4.0 because there is no other way to read
external files that are out-of-synch with a .leo file.
#@+node:edream.110203163054.105: *7* New Write 3.x/4.x External Files & autosave
The Write 4.x External Files command and Write 3.x External Files command work
just like the Write @file Nodes command, except that they write the indicated
format off external file. In contrast, the Write @file Nodes command writes 3.x
format external files if and only if the write_old_format_derived_files = 1 in
leoConfig.txt.

All three of these commands automatically save the outline (the .leo file) if
any external file was actually written. This is necessary so that information in
the .leo file always remains in synch with all external files.
#@+node:edream.110203163054.106: *6* New plugins
Paul Paterson contributed the following new plugins:

mod_autosave.py

Autosaves the Leo document every so often.

mod_timestamp.py

Timestamps all save operations to show when they occur.

word_export.py

Exports an outline to a word document. Clicking "plugins ... word export ...
export" exports the selected outline to Word. Word should be running with an
open (empty) document before executing this command.
#@+node:edream.110203163054.107: *6* New read logic and greatly inproved error recovery
#@+node:edream.110203163054.108: *7* Added test for unvisited nodes in read logic
Leo's read code now warns if any non-empty node is unvisited. This check, and
the check that headlines match pretty much guarantees that out-of-synch outlines
will generate errors. Thus, there is no need a gnx timestamp in @+leo sentinels!
#@+node:edream.110203163054.109: *7* Error recovery is _much_ better than before
Version 4.0 is a major advance in Leo's error handling. Using 4.0 is much safer
than all previous versions. This new error handling applies to all derived
files, both 3.x and 4.x format.

Leo's read code never alters the structure of an outline, regardless of whether
read errors are encountered. This means that clone links, marks, and all other
information in the outline except body text remains completely unchanged during
reads. Broken clone links (the dreaded read errors) are gone forever. Also, the
new read code makes no changes to any body text until it is known that no read
errors have occurred. This ensures that absolutely no changes at all are made to
the outline if there are read errors.

Leo's read code now writes a message to the log pane whenever it sees that the
body text in the external file does not match the body text in the outline. These
messages do not indicate errors, only that the body text has been changed
outside of Leo, say in an external editor or by cvs.
#@+node:edream.110203163054.110: *6* Improvements & bug fixes
#@+node:edream.110203163054.111: *7* Added horizontal scrollbar in body pane when @nowrap in effect
#@+node:edream.110203163054.112: *7* Added support for Python 2.3
Added encoding comments to leoGlobals.py and French plugins

This removes a warning new in Python 2.3.
#@+node:edream.110203163054.113: *7* Leo recycles window objects only if more than one window open
There is no need to recycle Python objects when the last outline window is being closed.
#@+node:edream.110203163054.114: *7* Removed "not undoable" message from Read @file Nodes command
This is too annoying during testing.  The Read @file Nodes command will in fact be made undoable for the 4.0 final release.
#@+node:edream.110203163054.115: *7* Removed Open Python Window command
This has been changed in Python 2.3 and it probably wasn't ever a good idea...
#@+node:edream.110203163054.116: *7* Simplified read and write code
The read code has much simplified using look-behind rather than look-ahead.  Both the read and write code write the file line-by-line without recursion.
#@+node:ekr.20050210102150.1: *3* 4.1... gnx's
#@+node:ekr.20040216151748: *4* 4.1 final
Leo 4.1 Final              February 20, 2004

Leo 4.1 Final is the culmination of four months of work. No significant bugs
have been reported since 4.1 rc4. Several people have contributed nifty plugins
recently. See leoPlugins.leo for full details.

The highlights of Leo 4.1:

- Leo runs in batch mode when invoked with --script aScriptFile.py
- Leo supports Unicode characters (e.g. Chinese) in path and file names.
- @directives and section references are now valid when executing scripts.
- @ignored and orphan nodes now valid in @file-nosent trees.
- Script-based find/change commands.
- Check Outline command.
- Hoist & DeHoist commands.
- A new gui-agnostic architecture: useful for batch mode and unit tests.
- Several new configuration settings.
- Many new unit tests.
- Excellent new plugins.
- A host of bug fixes.
#@+node:ekr.20040217085036: *5* Added several new plugins
See leoPlugins.leo for full details.
#@+node:ekr.20040216152948: *5* Added Toggle Angle Brackets command
#@+node:ekr.20040216153725: *5* Changed Undo/Redo messages
Changed Undo/Redo messages:

- Insert Outline to Insert Node.
- Delete Outline to Delete Node.
- Clone to Clone Node.

This is a real code change: it affects the undo/redo logic.
#@+node:ekr.20040217075627: *5* Fixed clone bug when pasting nodes
Clone bits could be improperly set in some cases.  This bug would not have caused serious long-term problems.

Steps to reproduce:

1. Create a parent node (named 'cloned').
2. Create two children nodes (one named 'dummy' and another named 'bottom') under the parent node 'cloned'.
3. Move the 'bottom' node below the 'dummy' node.
4. Clone node 'cloned'.
5. Copy node 'dummy'.
6. Paste node 'dummy' in between 'dummy' and 'bottom'.
7. After pasting you'll see that 'bottom' is now marked as a cloned node.
#@+node:ekr.20040217085036.1: *5* Investigated encoding problem: it's a Python 2.3 bug
Here is the bug report I submitted to Python:

The documentation for encoding lines at

C:\Python23\Doc\Python-Docs-2.3.1\whatsnew\section-encodings.html

states:

"Encodings are declared by including a specially formatted comment in the
first or second line of the source file."

In fact, contrary to the implication, the Python 2.3 parser does not look
for lines of the form:

# -*- coding: <encoding> -*-

For example, Python improperly scans the following line for an encoding

#@verbatim
#@+leo-ver=4-encoding=iso-8859-1.

and reports that iso-8859-1. (note trailing dot) is an invalid encoding!

The workaround for my app is to precede this line with the following line:

# -*- coding: iso-8859-1 -*-

This makes Python 2.3 happy.

To make myself perfectly clear: Python has absolutely no right to complain
about comment lines that do not have the form:

# -*- coding: <encoding> -*-
#@+node:ekr.20040131040356: *4* 4.1 rc4
Leo 4.1 Release Candidate 4              February 3, 2004

This release fixes numerous bugs reported since 4.1 rc3 and makes several other
minor improvements, including several nifty new plugins.

The highlights of Leo 4.1:

- Leo runs in batch mode when invoked with --script aScriptFile.py
- Leo supports Unicode characters (e.g. Chinese) in path and file names.
- @directives and section references are now valid when executing scripts.
- @ignored and orphan nodes now valid in @file-nosent trees.
- Script-based find/change commands.
- Check Outline command.
- Hoist & DeHoist commands.
- A new gui-agnostic architecture: useful for batch mode and unit tests.
- Several new configuration settings.
- Many new unit tests.
- Excellent new plugins.
- A host of bug fixes.
#@+node:ekr.20040201114855: *5* New plugins in 4.1 rc4
#@+node:ekr.20040201114855.42: *6* mod_http.py plugin: Bernhard Mulder
A minimal http plugin for Leo, based on AsyncHttpServer.py.

Use this plugin is as follows:

1. Start Leo with the plugin enabled. You will see a purple message that says
something like: "http serving enabled on port 8080, version 0.9"

2. Start a web browser, and enter the following url: http://localhost:8080/
You will see a a "top" level page containing one link for every open .leo file.
Start clicking :-)

You can use the browser's refresh button to update the top-level view in the
browser after you have opened or closed files.
#@+node:ekr.20040201114855.91: *6* newButtons.py plugin: Paul Paterson
Automatically add nodes for common tasks. This can be used to generate boiler
plate code to quickly build an outline.
#@+node:ekr.20040201114855.29: *6* nodenavigator.py plugin: Paul Paterson
Adds a node navigator to the toolbar. The navigator allows quick access to
marked nodes. You can either go to the marked node or hoist the marked node.
#@+node:ekr.20040201114855.36: *6* rowcol.py: EKR
Adds row/column indicators to the toolbar at the top of Leo Windows.
#@+node:ekr.20040201114855.3: *6* rst2.py plugin: Steve Zatz
This plugin uses Leo and docutils to mix program code and reST documentation.

The Python docutils package must be installed.http://docutils.sourceforge.net

The basic approach is that any Leo node that contains program code that needs
documentation (in an ideal world it would be every node) has an associated child
node whose headline is simply '@rst', that contains reST-style documentation.
While this means that a typical program may have dozens (if not hundreds) of
these @rst nodes, it produces documentation that I think is as close as I have
ever seen to useful, easy-to-read documentation that is easy to create at the
same time as an application is being coded.

There are several interrelated aspects to this work:

- The reST plugin (renamed rst2) was hacked to manage Leo outlines that were a
combination of normal code nodes and reSt nodes.

- The plugin now recognizes a @rst directive (that has no associated file name)
in the headline of a node.

- When it encounters such a @rst Headline node, it writes the contents of the
body of the @rst node's *parent* (which generally contains program code) to the
reST output file (HTML) and then adds the reST content that is contained in the
body of the @rst documentation node to the output HTML file,

- These @rst nodes are used in @file-nosent trees and the @rst nodes have an 
@ignore directive (plus @nocolor directive and @wrap directives) so that 
when the @file is updated the application code does not contain the reST-style
documentation contained in the body of the @rst nodes. (This was the reason I
had asked you in the Leo Forum to allow @file-nosent trees to work appropriately
with @ignore nodes - Thank you for doing this right away.) There is no reason
that the reST content couldn't be written to the 
@file as documentation other than I personally believe in a volume of 
documentation (including musings, failed ideas, questions, etc.) that is 
probably best kept separate from the actual *.py files.

- When you double-click on a plain rst node (no associated filename) Leo opens
both the @rst documentation node and the parent node containing code in an
external editor *simultaneously*. I happen to use Textpad and so the code is
opened with python syntax coloring in one Textpad window and right next to it is
the reST documentation. This makes it much much easier to code and do
documentation at the same time. (Note that the plugin assumes that the python
extension is '.tp' since that is what I use with TextPad.)

So why is this a big deal?

For the first time in my experience the documentation process:

1) is completely in sync with the process of code development.

2) allows the programmer to write as much documentation as he/she wants without
the programming code becoming unreadable because of what would be considered
excessive or intrusive documentation. (This applies whether documentation is
intended for external consumption or just so a solo programmer can remember what
he/she was thinking...)

My conclusion is that Leo + reST/docutils provides the perfect platform for
optimal documentation.

Frankly, I think this is all a minor miracle but maybe I've lost perspective.

Steve Zatz
#@+node:ekr.20040201114855.13: *6* searchbox.py plugin: Paul Paterson
Adds a quick search to the toolbar in Leo.

A search box which behaves like a web site search is added, along with a "GO"
button to do quick searches right from the main Leo window. All the current
search options are retained except that "search body text" is explicitly set -
mainly because this is by far the most common use case.

Pressing <CR> while editing the text automatically does a search. Repeated
searches can be done by clicking the "GO" button.

The combo box also stores a list of previous searches, which can be selected to
quickly repeat a search. When activating a previous search the original search
mode is used.

Still to do:

- incremental search
- reverse search
- persist recent searches across Leo sessions
- use INI file to set options for list size, etc.
#@+node:ekr.20040201120903: *6* status_line.py plugin: EKR
Adds a status line to the bottom of Leo windows.
#@+node:ekr.20040131041015: *5* New features in 4.1 rc4
#@+node:ekr.20040131040544.10: *6* Leo no longer automatically draws the status area
This allows plugins to draw the status area in the icon area.
#@+node:ekr.20040131040544.21: *6* Esc and enter key now work in the find panel
- ESC closes the Find panel.

- Hitting the Return key is now equivalent to hitting the Find button.
#@+node:ekr.20040131040544.55: *6* Improved message for orphan nodes
Leo now reports the parent of the orphan node.
#@+node:ekr.20040131040544.178: *6* Eliminated marking nodes dirty unnecessarily
Leo sets only ancestor @file nodes dirty (not nodes themselves) when altering
outline structure, i.e., when moving, inserting, deleting, cloning and sorting
nodes.
#@+node:ekr.20040131040544.222: *6* Execute Script command now ends all nodes with a newline
That is, when preprocessing the script (expanding section references, etc.) Leo
now ensures that child nodes effectively end in a newline. This prevents
unintended concatenation of lines.
#@+node:ekr.20040131040544.2: *6* Added message when plugins are disabled
#@+node:ekr.20040201061329: *6* Created status_line.py plugin
This creates a status area at the bottom of the Leo Window. Plugins may write to
this area using the status area convenience routines in leoTkinterFrame.py.
#@+node:ekr.20040201114855.105: *6* Simplified operation of script-find/change & improved documentation
#@+node:edream.110603190322.6: *7*  Script Find and Script Change
@nocolor

New in 4.1: Leo now supports scripts in Leo's Find/Change dialog.

Leo's find panel now contains the Script Search radio button and the Script
Change checkbox. When the Script Search radio button is selected Leo treats the
contents of the Search Text as a script to execute whenever any kind of Find
command is executed. Similarly, when the Script Change checkbox is selected Leo
treats the context of the Change Text as a script to execute whenever any kind
of Change command is executed. See below for just how this works.

Script-based find-change is extremely powerful. In effect, Leo's Find/Change
panel becomes a new platform for running scripts interactively. Leo now has all
the find/change capability of pattern matching languages like Snobol and Icon,
just by using the capabilities of the plain Python language. Moreover, Leo can
deliver these capabilities interactively or not depending which buttons you push
in Leo's Find/Change panel.

Script-based find/change frees the user from having to control script-based
searches interactively. Rather than forcing find/change scripts to implement
their own interactive controls, it is much easier to use what Leo already has.
#@+node:edream.111803060152.1: *8* How it works
Leo dedicates a Python dictionary called app.searchDict for communication
between Leo and the search and change scripts. The search and change scripts may
also use app.searchDict for communication between themselves. Leo sets
app.searchDict["type"] to "find", "change", "findAll" or "changeAll" to indicate
the kind of command being executed. Scripts may use all other entries in
app.searchDict as they please.

Leo executes the find script once when you press the Find button (or the Change
then Find button) in Leo's Find/Change dialog. Typically, the find script would
traversing the tree and highlight the found text or otherwise indicate to the
user that the find operation has succeeded. However, the script can do anything
it pleases.

Leo executes the the find script repeatedly when you press the Find All button.
Leo keeps executing the find script until app.searchDict["continue"] evaluates
to false. Initially there is no entry for app.searchDict["continue"], so the
find script must set app.searchDict["continue"] = true if it wants Leo to keep
executing it.

Leo executes the change script once when you press the Change button. Typically,
the change script would change the selected text. Usually the change script will
compute the new value of body text and call c.setBodyString(p,newText) to
make that change permanent. 

The change script also may handle undo, typically by calling
c.frame.onBodyChanged(v,"Change",oldText=oldText). Leo does not handle undo
automatically. Indeed, Leo makes no assumptions whatever about what the change
script really does.

Leo executes the the change script repeatedly when you press the Replace All
button. Just as with the Find All command, Leo keeps executing the change script
until app.searchDict["continue"] evaluates to false.

Most find and change scripts will ignore settings in the Find Panel like "whole
word", "pattern match", and "reverse". However, these settings are available to
the scripts via ivars such as c.whole_word_flag, etc. if desired.
#@+node:ekr.20040201113232: *8* Using the initScriptFind script
@nocolor

The Scripts node in LeoPy.leo contains a script called initScriptFind.  This script makes it easy to set up script based searches as follows:

1. Put the following code in the root of a tree that will contain your script search:

@color
# Initialize Leo's find panel using the named children of this node.
from leoGlobals import *
initScriptFind("Find script","Change script") # Second argument is optional.
# Start searching at the top.
top().selectVnode(c.rootVnode())
@nocolor

2. Put the search script in a child node called "Find script" (no quotes).

3. (Optional) Put the change script in a child node called "Change script"

4.  Execute the code above.  Leo does the following:

- Puts the body of the "Find script" into the find text of Leo's Find/Change dialog.
- Puts the body of the "Change script" into the change text of Leo's Find/Change dialog.
- Selects the Script Find radio button.
- Selects the Script Change checkbox if the change script exists.
- Selects the root of the entire outline.

Presto!  Leo is ready for a script search.
#@+node:edream.111803060152.2: *8* Ideas for using scripts
@nocolor

Some ideas for using scripts:

Either the find and change scripts may use Python's re module.  For
example, the find script could set app.searchDict["m"] to the match object
returned by re's match method.  The change script would then compute the
result, change the text and set the undo info as usual.

There is no reason to confine find/change scripts to operate on data only
within a Leo outline. These scripts could as easily traverse your file system
as the Leo outline. But notice: scripts could pull data from the file system
into the outline so that you can see the effects of changes as the scripts
operate. Again, this can all happen interactively if you like.
#@+node:ekr.20040201114855.106: *6* Added done message to Mark Changed commands
#@+node:ekr.20040131040356.1: *5* Bugs fixed in 4.1 rc4
#@+node:ekr.20040131044727: *6* Fixed several bugs when writing external files
1. Fixed a bug that caused improper indentation of sections.

The bug happened in some cases when a section reference occurred following non-whitespace.

2. Leo ensures that leading whitespace is not added when writing empty lines.

This might fix the "Zope Sprint" bug: "blank" lines in the expansion of @others got leading whitespace.
#@+node:ekr.20040131040754: *6* Fixed several crashers
Fixed crashers in:

- Insert Headline Time/Date commands.
- Change headline command.
- Write Dirty/Missing @file Nodes commands.
- Batch mode.
#@+node:ekr.20040131040544.5: *6* Fixed "bad leo file" when reading some 3.x .leo files
#@+node:ekr.20040131040544.18: *6* Fixed huge performance bug in cut/copy node commands
The old code was concatenating strings; the new code uses list.append.
#@+node:ekr.20040131040544.32: *6* Leo now properly re-enables drawing after exceptions
#@+node:ekr.20040201114855.107: *6* Fixed major bug in tkFind.init
This bug happened when executing the initScriptFind script.  This bug could cause Leo not to be able to save files.
#@+node:ekr.20040131040544.73: *6* Fixed bug in Move Up command
This bug happened when a move up command would cause a node to become the
sibling of (a clone of) itself. In such cases, Leo simply selects the other
cloned copy of the moved node.
#@+node:ekr.20040131040544.81: *6* Fixed bug in Import External File
The bug was causing Leo not to remember the comment delimiters in the @+leo
sentinel. As a result, Leo was recognizing no sentinels and the command
complained about missing @-leo sentinels.
#@+node:ekr.20040131040544.146: *6* Fixed bugs related to saving read-only files
- Leo now does a better job of checking and reporting read-only violations.

- Leo now clears the file-dirty mark only if the file was successfully saved.

#@+node:ekr.20040131040544.169: *6* Fixed bug in Import Python Window command when using Python 2.2
#@+node:ekr.20040131040544.228: *6* Fixed bugs in Convert All BlanksTabs commands
- These commands did not properly count the number of changed nodes.
- These commands now mark only changed nodes as dirty.
#@+node:ekr.20040131040544.258: *6* Fixed crashes in open_shell.py plugin
#@+node:ekr.20040131044136: *6* Fixed several bugs involving cut & paste
- Fixed a bug that caused cut and paste operations in headlines to revert when those commands were chosen from the Edit menu.

- Extended control-v bug fix to "darwin","freebsd4","freebsd5"

- Cut and paste are now always enabled when not editing the body pane.  This isn't perfect, and is an improvement.
#@+node:ekr.20040131040544.227: *6* Fixed whitespace problem in leoTkinterGui.py
A contained a space before a tab in the leading whitespace of the line.
#@+node:ekr.20040131100557: *6* Fixed glitches when inserting node in hoisted outline
Previously, if you hoist a node with no children and then insert a node (CTRL-I)
then the child is created as a sibling of the hoisted node and consequently is
not displayed.

Leo now creates the new node as the first child of the hoisted node. 

Also, Leo disables the Clone command when the presently selected node is the root of a hoist.
#@+node:ekr.20040203084228: *6* Fixed bugs in search command
The Change All command was looping when the find pattern was '\n'.
#@+node:ekr.20040131040356.2: *5* Bug fixed in previous 4.1 releases
See previous release notes for more details:

4.1 rc3:

- Corrected counts when replacing tabs/blanks.
- Don't write tnodeList when executing scripts.
- Fixed long-standing clone-drag bug.
- Fixed inconsistency between how 4.x and 3.x handle @others.
  The code now works as it did in all 3.x versions, namely
  @others does not terminate doc parts.
- Leo now properly sets clone marks when when cutting and pasting nodes.
- Only double-quotes delimit strings in html files.
  This bug prevented Leo from untangling some valid html/xml files.
- Leo now puts class docstrings in class nodes when importing .py files.
- Fixed several reorg bugs.

4.1 rc2, rc1, betas, alphas:

- Fixed several minor problems with the Extract Section and Import commands.
- Fixed problem that prevent the Find panel from working on the Mac.
- Improved @url handling so that @url file:\\path\x.leo works properly.
- Improved support for @lineending platform.
- Leo honors outline/body pane ratio when opening .leo files.
- Leo now ensures that newly-opened windows fit entirely on the screen.
- Fixed a crasher when Undoing a Change All command when searching headlines.
- Fixed other bugs resulting from the 4.1 reorg:
- Fixed problem loading plugins on Linux.
- Fixed crashers in the Extract Section and Extract commands.
- Fixed a crasher when writing a file containing an undefined section.
- Removed duplicate bindings in popup menus.
- Made sure to show Leo's windows in wx gui plugin.
- More than one section reference may now appear on the same line.
- Use "utf-8" encoding for filenames under MacOS (Darwin)
- Allow command or cmnd prefix for menu shortcuts under Darwin.
- Fixed a LaTeX coloring bug
#@+node:ekr.20040131040356.3: *5* New code-level features
- The 4.1 code base has been reorganized to support gui plugins.
- Created a flexible framework for creating & running regression tests.
- app.forceShutdown now works when called from plugins.
- Created app.unitTestDict for communication between tests and between tests and code.

- An example wx_gui plugin is partly functional.

	Warning: Use the __wx_gui.py plugin with extreme caution until further notice:
	bugs in this plugin could cause body text to be cleared improperly when changing nodes.
#@+node:ekr.20040131040356.4: *5* New configuration settings
- use_gnx specifies whether .leo files use integers as indices:

	use_gnx = 0 makes .leo files compatible with previous versions of Leo.
	use_gnx = 1 makes .leo files cvs-friendly

- config_encoding specifies the encoding of leoConfig.txt.
#@+node:ekr.20040131040356.5: *5* New features
- Import External File command now uses a file dialog.

	This is much more natural than using @file nodes.
#@+node:edream.121403160546: *4* 4.1 rc3
Leo 4.1 Release Candidate 3              December 19, 2003

This release fixes a serious bug in the logic that reads old-style external files.

There are no known bugs in this version of Leo.

The highlights of this release:

- Leo runs in batch mode when invoked with --script aScriptFile.py
- Leo supports Unicode characters (e.g. Chinese) in path and file names.
- @directives and section references are now valid when executing scripts.
- @ignored and orphan nodes now valid in @file-nosent trees.
- Script-based find/change commands.
- Check Outline command.
- Hoist & DeHoist commands.
- A new gui-agnostic architecture: useful for batch mode and unit tests.
- Several new configuration settings.
- Many new unit tests.
- A host of bug fixes.
#@+node:edream.121403165221: *5* Bugs fixed in this release
- Corrected counts when replacing tabs/blanks.
- Don't write tnodeList when executing scripts.
- Fixed long-standing clone-drag bug.
- Fixed inconsistency between how 4.x and 3.x handle @others.
  The code now works as it did in all 3.x versions, namely
  @others does not terminate doc parts.
- Leo now properly sets clone marks when when cutting and pasting nodes.
- Only double-quotes delimit strings in html files.
  This bug prevented Leo from untangling some valid html/xml files.
- Leo now puts class docstrings in class nodes when importing .py files.
- Fixed several reorg bugs.
#@+node:edream.121403161017: *5* Bug fixed in previous 4.1 releases
See previous release notes for more details:

- Fixed several minor problems with the Extract Section and Import commands.
- Fixed problem that prevent the Find panel from working on the Mac.
- Improved @url handling so that @url file:\\path\x.leo works properly.
- Improved support for @lineending platform.
- Leo honors outline/body pane ratio when opening .leo files.
- Leo now ensures that newly-opened windows fit entirely on the screen.
- Fixed a crasher when Undoing a Change All command when searching headlines.
- Fixed other bugs resulting from the 4.1 reorg:
- Fixed problem loading plugins on Linux.
- Fixed crashers in the Extract Section and Extract commands.
- Fixed a crasher when writing a file containing an undefined section.
- Removed duplicate bindings in popup menus.
- Made sure to show Leo's windows in wx gui plugin.
- More than one section reference may now appear on the same line.
- Use "utf-8" encoding for filenames under MacOS (Darwin)
- Allow command or cmnd prefix for menu shortcuts under Darwin.
- Fixed a LaTeX coloring bug
#@+node:edream.121403161017.1: *5* New code-level features
- The 4.1 code base has been reorganized to support gui plugins.
- Created a flexible framework for creating & running regression tests.
- app.forceShutdown now works when called from plugins.
- Created app.unitTestDict for communication between tests and between tests and code.

- An example wx_gui plugin is partly functional.

	Warning: Use the __wx_gui.py plugin with extreme caution until further notice:
	bugs in this plugin could cause body text to be cleared improperly when changing nodes.
#@+node:edream.121403161017.2: *5* New configuration settings
- use_gnx specifies whether .leo files use integers as indices:

	use_gnx = 0 makes .leo files compatible with previous versions of Leo.
	use_gnx = 1 makes .leo files cvs-friendly

- config_encoding specifies the encoding of leoConfig.txt.
#@+node:edream.121403161340: *5* New features
- Import External File command now uses a file dialog.

	This is much more natural than using @file nodes.
#@+node:edream.110603185805: *4* 4.1 beta 5
Leo 4.1 beta 5                   December 5, 2003

This is the fifth release of the reorganized 4.1 code base.

For the first time in months there are no serious bugs outstanding.

Warning: By default Leo 4.1 creates .leo files that can not be read by older versions of Leo.

Warning: Use the __wx_gui.py plugin with extreme caution until further notice:
bugs in this plugin could cause body text to be cleared improperly when changing nodes.

Beta 5:
  * Leo runs in batch mode when invoked with --script aScriptFile.py
    - Created "null gui" classes that do not use any gui code.
  * Leo supports Unicode characters (e.g. Chinese) in path and file names.
  * Fixed several long-standing bugs:
    - Fixed several minor problems with the Extract Section and Import commands.
    - Fixed problem that prevent the Find panel from working on the Mac.
    - Improved @url handling so that @url file:\\path\x.leo works properly.
    - Improved support for @lineending platform.
    - Leo honors outline/body pane ratio when opening .leo files.
    - Leo now ensures that newly-opened windows fit entirely on the screen.
    - Fixed a crasher when Undoing a Change All command when searching headlines.
  - Fixed other bugs resulting from the 4.1 reorg:
    - Fixed problem loading plugins on Linux.
    - Fixed crashers in the Extract Section and Extract commands.
    - Fixed a crasher when writing a file containing an undefined section.
    - Removed duplicate bindings in popup menus.
    - Made sure to show Leo's windows in wx gui plugin.

Beta 4:
  - Fixed several "reorg" bugs, some of which affected plugins.
  - Allow @directives and section references when executing scripts!
  - More than one section reference may now appear on the same line.
  - Use "utf-8" encoding for filenames under MacOS (Darwin)
  - Allow command or cmnd prefix for menu shortcuts under Darwin.

Beta 3:
  - Completed the reorg, making many changes to the code base.
  - Fixed a LaTeX coloring bug

Beta 2:
  - Fixed a startup problem on Linux: the "mbcs" text encoding is not valid on Linux.

Beta 1:
  * Script-based find/change commands.
  - Hoist & DeHoist commands for viewing parts of an outline.
  - Check Outline command finds user clone mistakes.
  * New configuration settings:
    - use_gnx specifies whether .leo files use integers as indices:
      use_gnx = 0 makes .leo files compatible with previous versions of Leo.
      use_gnx = 1 makes .leo files cvs-friendly
    - config_encoding specifies the encoding of leoConfig.txt.
  * Several significant code-level changes:
    - The 4.1 code base has been reorganized to support gui plugins.
    - An example wx_gui plugin is partly functional.
    - Created a flexible framework for creating & running regression tests.
    - app.forceShutdown now works when called from plugins.
#@+node:edream.120403174147: *5* Changes made in 4.1 beta 5
#@+node:edream.120403180443: *6* New and improved features
#@+node:edream.120403174147.105: *7* Honor outline/body pane ratio when opening files
This bug has been around for a long time.
#@+node:edream.120403174147.112: *7* Leo now adjusts newly opened windows so they fit on the screen
Leo makes sure that opened files or newly-created outlines fit entirely on the screen.  The Cascade commands leaves the sizes of windows unchanged: it merely ensures that the top left corner of a window is visible on the screen.
#@+node:edream.120403174147.119: *7* Tested support for Unicode file & directory names
#@+node:edream.120403174147.128: *7* Added code so @url nodes may open .leo files
@

A problem: the new window gets put behind the old.  This is probably because Tk
thinks that the mouse-down event should select then new window... 
#@+node:edream.120403174147.56: *7* Fixed problems with @lineending platform
#@+node:edream.120403174241: *6* Bugs fixed
#@+node:edream.120403174147.30: *7* Fixed crasher in Apply Settings command
Another 4.1 reorg bug.
#@+node:edream.120403174147.102: *7* Fixed crasher in Toggle Angle Brackets command
Another 4.1 reorg bug.
#@+node:edream.120403174147.109: *7* Fixed crasher when setting Icon in Linux)
The new code attempts to use bitmap files only on Windows.
#@+node:edream.120403174147.33: *7* Fixed Find panel bug on the Mac
This was due to a missing activate event.
#@+node:edream.120403174147.36: *7* Fixed Import backslash-newline bug
Continuation lines caused the import command to terminate functions, methods and classes prematurely.
#@+node:edream.120403174147.61: *7* Fixed Linux import problem
This was causing Leo not to load plugins properly on Linux.  The problem was that the imp module does not handle Unicode file names properly.
#@+node:edream.120403174147.63: *7* Fixed Recent files crasher
This was a reorg bug.
#@+node:edream.120403174147.65: *7* Fixed Replace Blanks command
Another bug caused by the 4.1 reorg.
#@+node:edream.110603190322.8: *7* Fixed Serious Undo Change All bugs
Undoing Change All cleared the body pane or the headline pane.

The fix was simple: call setUndoParams instead of setUndoTypingParams in batchChange.
#@+node:edream.120403174147.94: *7* Fixed several long-standing bugs related to Extract commands
- Leo now properly enables and disables the Extract Section menu item.
- Leo no longer removes leading forward slashes in section names in headlines.
- Corrected the documentation for the Extract Section command.
#@+node:edream.120403180443.1: *5* Changes made in earlier 4.1 betas
#@+node:edream.110603190234.1: *6* Code-level features
#@+node:edream.110603190125.3: *7* Regression tests started
The file test.leo in the test directory contains real regression tests for
syntax coloring.  Regression testing scripts create regression tests dynamically
from data in Leo's outline.  Very cool, very easy, very general.  In particular,
regression tests may use temporary nodes in test.leo rather than creating
separate Tk windows for testing. 
#@+node:edream.110603190125.4: *7* Code reorganized to support other guis
The 4.1 code base has been reorganized to support gui's other than tkinter.
Leo's src directory contains several new source files.

This reorg affects almost all plugins. Considerably more work and testing will
be done before 4.1 final.

The __wx_gui.py plugin is uses the newly reorganized code.  It is functional
except for gui-dependent commands like Toggle-Split Direction.  WARNING: treat
the this plugin with extreme caution until further notice.  The possibility
exists that bugs in the code could cause body text to be cleared improperly when
changing nodes. 
#@+node:edream.110303182253.39: *7* Made app.forceShutdown work in "idle" hook
#@+node:edream.110603190404: *6* Fixed bugs
#@+node:edream.110603190322.13: *7* Fixed bug involving 0x1a characters in body text.
The fix was to open files with 'rb' instead of 'r'.  This probably should be done in more places.
#@+node:edream.110603190322.11: *7* Fixed first node-only find bug
The node-only option wasn't working due to a bug in createFrame.

There still may be a problem with the interaction between Node-only,Change All and Undo.
#@+node:edream.110603190322.3: *7* Fixed bug in idle_body_key
This involved fixing a bug in idle_body_key so that the oldText param is honored if present.
#@+node:edream.111803060643: *7* Fixed LaTeX syntax coloring bug
#@+node:edream.110603192009: *6* Improved format of .leo files
#@+node:edream.110603190322.9: *7* Leo now ignores unknown prefs and find prefs
#@+node:edream.110603190322.10: *7* Leo now writes node_only find prefs
#@+node:edream.110603190125.1: *7* .leo files are now cvs-friendly
Leo 4.1 uses immutable gnx's (id:timestamp:n) by default to associate tnodes with vnodes in .leo files.  This makes Leo as cvs friendly as possible.  From now on .leo files will be checked in to cvs with the -ko (text/keywords off) option.
#@+node:edream.110603192009.1: *6* New & improved commands
#@+node:edream.112303173638: *7* Running Leo in batch mode
@color
@  New in version 4.1: On startup, Leo looks for two arguments of the form --script scriptFile.  If found, Leo enters batch mode.

In batch mode Leo does not show any windows.  Leo assumes the scriptFile contains a Python script and executes the contents of that file using Leo's Execute Script command.  By default, Leo sends all output to Leo's log pane to the console window.  Scripts in the scriptFile may disable or enable this output by calling app.log.disable() or app.log.enable()

Scripts in the scriptFile may execute any of Leo's commands except the Edit Body and Edit Headline commands.  Those commands require interaction with the user.

For example, the following batch script reads a Leo file and prints all the headlines in that file.
@c

import leoGlobals as g

path = r"c:\prog\leoCVS\leo\test\test.leo"

g.app.log.disable() # disable reading messages while opening the file
flag,newFrame = g.openWithFileName(path,None)
g.app.log.enable() # re-enable the log.

for p in newFrame.c.all_positions():
	g.es(g.toEncodedString(p.headString(),"utf-8"))
#@+node:edream.110203163054.833: *7* Executing Python scripts in body text
The Execute Script command executes body text as a Python script. Leo execute
the selected text, or the entire body text if no text is selected.

Scripts are executed in a "pristine" environment, that is, with __builtins__ as
both the local and global environments.

New in version 4.1: Body text may now contain @directives and section
references. This is a major step forward: you can now use all of Leo's features
to organize scripts that you execute interactively.

Section definitions must appear in the node containing the script or in
descendant nodes. Leo "preprocesses" all scripts by simulating the writing of a
external file to a string.

The Execute Script command sets app.scriptDict["script1"] to the value of the
script before preprocessing, and sets app.scriptDict["script2"] to the value of
the script after preprocessing. Scripts may examine and change app.scriptDict as
they please.
#@+node:edream.110603190322.14: *7* Added Check Outline command
This command checks for unused tnodeLists and checks the topology of all clones.
#@+node:edream.110603190322.15: *7* Added Hoist/De-Hoist commands
The Hoist command redraws the screen so presently selected tree becomes the only visible part of the outline.  Leo prevents the you from moving nodes outside the hoisted outline.  The De-hoist command restores the outline.  Hoist commands may be nested.
#@+node:edream.111803060152: *7* Added script-based find/change commands
#@+node:edream.110603190322.6: *8*  Script Find and Script Change
@nocolor

New in 4.1: Leo now supports scripts in Leo's Find/Change dialog.

Leo's find panel now contains the Script Search radio button and the Script
Change checkbox. When the Script Search radio button is selected Leo treats the
contents of the Search Text as a script to execute whenever any kind of Find
command is executed. Similarly, when the Script Change checkbox is selected Leo
treats the context of the Change Text as a script to execute whenever any kind
of Change command is executed. See below for just how this works.

Script-based find-change is extremely powerful. In effect, Leo's Find/Change
panel becomes a new platform for running scripts interactively. Leo now has all
the find/change capability of pattern matching languages like Snobol and Icon,
just by using the capabilities of the plain Python language. Moreover, Leo can
deliver these capabilities interactively or not depending which buttons you push
in Leo's Find/Change panel.

Script-based find/change frees the user from having to control script-based
searches interactively. Rather than forcing find/change scripts to implement
their own interactive controls, it is much easier to use what Leo already has.
#@+node:edream.111803060152.1: *9* How it works
Leo dedicates a Python dictionary called app.searchDict for communication
between Leo and the search and change scripts. The search and change scripts may
also use app.searchDict for communication between themselves. Leo sets
app.searchDict["type"] to "find", "change", "findAll" or "changeAll" to indicate
the kind of command being executed. Scripts may use all other entries in
app.searchDict as they please.

Leo executes the find script once when you press the Find button (or the Change
then Find button) in Leo's Find/Change dialog. Typically, the find script would
traversing the tree and highlight the found text or otherwise indicate to the
user that the find operation has succeeded. However, the script can do anything
it pleases.

Leo executes the the find script repeatedly when you press the Find All button.
Leo keeps executing the find script until app.searchDict["continue"] evaluates
to false. Initially there is no entry for app.searchDict["continue"], so the
find script must set app.searchDict["continue"] = true if it wants Leo to keep
executing it.

Leo executes the change script once when you press the Change button. Typically,
the change script would change the selected text. Usually the change script will
compute the new value of body text and call c.setBodyString(p,newText) to
make that change permanent. 

The change script also may handle undo, typically by calling
c.frame.onBodyChanged(v,"Change",oldText=oldText). Leo does not handle undo
automatically. Indeed, Leo makes no assumptions whatever about what the change
script really does.

Leo executes the the change script repeatedly when you press the Replace All
button. Just as with the Find All command, Leo keeps executing the change script
until app.searchDict["continue"] evaluates to false.

Most find and change scripts will ignore settings in the Find Panel like "whole
word", "pattern match", and "reverse". However, these settings are available to
the scripts via ivars such as c.whole_word_flag, etc. if desired.
#@+node:ekr.20040201113232: *9* Using the initScriptFind script
@nocolor

The Scripts node in LeoPy.leo contains a script called initScriptFind.  This script makes it easy to set up script based searches as follows:

1. Put the following code in the root of a tree that will contain your script search:

@color
# Initialize Leo's find panel using the named children of this node.
from leoGlobals import *
initScriptFind("Find script","Change script") # Second argument is optional.
# Start searching at the top.
top().selectVnode(c.rootVnode())
@nocolor

2. Put the search script in a child node called "Find script" (no quotes).

3. (Optional) Put the change script in a child node called "Change script"

4.  Execute the code above.  Leo does the following:

- Puts the body of the "Find script" into the find text of Leo's Find/Change dialog.
- Puts the body of the "Change script" into the change text of Leo's Find/Change dialog.
- Selects the Script Find radio button.
- Selects the Script Change checkbox if the change script exists.
- Selects the root of the entire outline.

Presto!  Leo is ready for a script search.
#@+node:edream.111803060152.2: *9* Ideas for using scripts
@nocolor

Some ideas for using scripts:

Either the find and change scripts may use Python's re module.  For
example, the find script could set app.searchDict["m"] to the match object
returned by re's match method.  The change script would then compute the
result, change the text and set the undo info as usual.

There is no reason to confine find/change scripts to operate on data only
within a Leo outline. These scripts could as easily traverse your file system
as the Leo outline. But notice: scripts could pull data from the file system
into the outline so that you can see the effects of changes as the scripts
operate. Again, this can all happen interactively if you like.
#@+node:edream.110303182253.3: *7* Leo now does an auto-save only if files have actually been changed.
Leo does an auto-save only if something has actually been changed.
#@+node:edream.111803062437: *7* Shift commands now shift single line if no selection
#@+node:edream.110303182719: *6* New config settings
The config_encoding setting controls the encoding of non-ascii characters in leoConfig.txt.

The use_gnx setting in leoConfig.txt determines whether uses gnx's (cvs friendly) or ints.  No version of Leo before 4.1 can read .leo files containing gnx.   Only gnx's are immutable.  Leo recomputes all non-gnx indices from scratch whenever writing a .leo file. It is possible to convert between 3.x and 4.1 file formats by changing the use_gnx setting.
#@+node:edream.110203163054.64: *4* 4.1 alpha 1
Leo 4.1 alpha 1                   November 3, 2003

*** Alpha quality code:  Please make full backups before playing with this code!

This release marks another significant milestone in Leo's history:

- Leo's 4.x file code is complete. At present I have no plans to change the
format of .leo files or external files. I am eating my own dog food: I do all my
editing with the 4.1 code base.

- Leo uses immutable gnx's (id:timestamp:n) by default to associate tnodes with
vnodes in .leo files. This makes Leo as cvs friendly as possible. From now on
.leo files will be checked in to cvs with the -ko (text/keywords off) option.

- The use_gnx setting in leoConfig.txt determines whether uses gnx's (cvs
friendly) or ints. No version of Leo before 4.1 can read .leo files containing
gnx. Only gnx's are immutable. Leo recomputes all non-gnx indices from scratch
whenever writing a .leo file. It is possible to convert between 3.x and 4.1 file
formats by changing the use_gnx setting.

- The 4.1 code base has been reorganized to support gui's other than tkinter.
Leo's src directory contains several new source files.

- The file test.leo in the test directory contains real regression tests for
syntax coloring. Regression testing scripts create regression tests dynamically
from data in Leo's outline. Very cool, very easy, very general. In particular,
regression tests may use temporary nodes in test.leo rather than creating
separate Tk windows for testing.

Known bugs:

- The Extract commands eat one character too much.

- The __wx_gui.py plugin is only partly functional.
#@+node:ekr.20050210102150: *3* 4.2... @file-thin, shared tnodes
#@+node:ekr.20040922074200: *4* 4.2 final
Leo 4.2 Final       September 20, 2004

The highlights of Leo 4.2:

- @thin trees make Leo much more friendly to cvs. Files derived from @thin can
be committed to cvs and updated from cvs without having to commit or update the
corresponding .leo file. There is no longer any need to keep .leo files and
external files in synch.

- Leo's data structures have been reorganized. As a result, all outline
operations are much faster. To support this organization, scripts that traverse
Leo's data structures must now use a positions rather than vnodes. Old scripts
that appear to use vnodes will still work because methods like c.currentVnode
that appear to return vnodes actually return positions.

- A new mod_scripting plugin is a big advance in scripting and testing.
test.leo now uses @test and @script nodes to define unit tests without
explicitly creating subclasses of unittest.TestCase. Converting scripts to unit
tests now takes a few seconds!

- A much faster and more robust spell checker plugin. (requires Python 2.3)

- Leo is now much more friendly to using spaces instead of tabs.

- The Execute Script command reports erroneous lines more clearly.
#@+node:ekr.20040914103359: *4* 4.2 rc1
Leo 4.2 release candidate 1        September 14, 2004

This version fixes a number of minor bugs reported since the last release. See
the children of this node for details.

The highlights of Leo 4.2:

- @thin trees make Leo much more friendly to cvs. Files derived from @thin can
be committed to cvs and updated from cvs without having to commit or update the
corresponding .leo file. There is no longer any need to keep .leo files and
external files in synch.

- Leo's data structures have been reorganized. As a result, all outline
operations are much faster. To support this organization, scripts that traverse
Leo's data structures must now use a positions rather than vnodes. Old scripts
that appear to use vnodes will still work because methods like c.currentVnode
that appear to return vnodes actually return positions.

- A new mod_scripting plugin is a big advance in scripting and testing.
test.leo now uses @test and @script nodes to define unit tests without
explicitly creating subclasses of unittest.TestCase. Converting scripts to unit
tests now takes a few seconds!

- A much faster and more robust spell checker plugin. (requires Python 2.3)

- Leo is now much more friendly to using spaces instead of tabs.

- The Execute Script command reports erroneous lines more clearly.

- The Perfect Import feature guarantee that Leo imports file exactly.
#@+node:ekr.20040914103743.1: *5* Added new features
#@+node:ekr.20040914103359.137: *6* Added c.frame.openDirectory to sys.path when executing scripts
#@+node:ekr.20040914103359.37: *6* Added expanded_click_area option to disable left click logic in outline pane
#@+node:ekr.20040914103359.2: *6* Restored the "iconclick1/2" hooks
#@+node:ekr.20040914103359.19: *6* (Allow longer headlines for to support long url's)
#@+node:ekr.20040914103359.20: *7* Report
@killcolor

From Dan Winkler:

On a couple of occasions, I tried to paste in a long @url node and got 
this message:

	Truncating headline to 250 characters

I wonder if the 250 character limit on headline length should be 
rethought in light of the @url directive and long web addresses.
#@+node:ekr.20040914103743: *5* Fixed bugs
#@+node:ekr.20040914103359.47: *6* Disabled perfect import
There were too many problems with this feature. In the future Leo will have a
Check Import command.
#@+node:ekr.20040914103359.12: *6* Fixed Import External Files command
If only one file was specified Leo gave an error for every character of the file name!
#@+node:ekr.20040914103359.15: *6* Fixed parsing of minimal <preferences> tag
#@+node:ekr.20040914103359.7: *6* Fixed problem with tabs on MacOs
With TclTkAqua on the Mac (but *not* with tcltk installed via Fink), the tab
problem doesn't exist there), the tab, return, and backspace keys did not generate
ASCII codes, i.e. event.char is an empty string. So when I press the tab key,
Tk inserts a tab character and Leo isn't even aware of it.
#@+node:ekr.20040914103359.28: *6* Fixed read errors with @language html
#@+node:ekr.20040914103359.4: *6* Made sure a proper message is given with invalid versions of Python
#@+node:ekr.20040914103359.110: *6* Removed failed assert from colorizer
#@+node:ekr.20040914103359.31: *6* Removed spurious "Warning: updating changed text" messages
#@+node:ekr.20040914103359.129: *6* Shifted all Alt-shortcuts to Ctrl shortcuts on the Mac
http://sourceforge.net/forum/message.php?msg_id=2742238
By: hinsen

The shortcut definitions in Leo are quite inconvenient on the Mac, as those
using the Alt key don't work. Alt is used for entry of additional characters.
On the other hand, ctrl is available for shortcuts but not used in Leo, since
the ctrl-based shortcuts are shifted to the command key (following standard
Mac practice).

The patch at the end of this message simply shifts all Alt-shortcuts to Ctrl
on the Mac.

That leaves one minor clash: Command-` is used for CloneNode in Leo, although
it canonical MacOS function (switching between the windows of an application)
would be very useful in Leo as well. Removing the CloneNode binding is easy
enough, but it seems that I must implement a window switching function myself.
Not today :-)

Konrad.
#@+node:ekr.20040713110718: *4* 4.2 beta 3
Leo 4.2 beta 3           August 10, 2004

This version of Leo is feature complete.  Leo's core code has been stable for several months.

To do: most plugins work with the new code base, but other plugins need some more work.

The highlights of Leo 4.2:

- @thin trees make Leo much more friendly to cvs. Files derived from @thin can
be committed to cvs and updated from cvs without having to commit or update the
corresponding .leo file. There is no longer any need to keep .leo files and
external files in synch.

- Leo's data structures have been reorganized. As a result, all outline
operations are much faster. To support this organization, scripts that traverse
Leo's data structures must now use a positions rather than vnodes. Old scripts
that appear to use vnodes will still work because methods like c.currentVnode
that appear to return vnodes actually return positions.

- A new mod_scripting plugin is a big advance in scripting and testing.
test.leo now uses @test and @script nodes to define unit tests without
explicitly creating subclasses of unittest.TestCase. Converting scripts to unit
tests now takes a few seconds!

- A much faster and more robust spell checker plugin. (requires Python 2.3)

- Leo is now much more friendly to using spaces instead of tabs.

- The Execute Script command reports erroneous lines more clearly.

- The Perfect Import feature guarantee that Leo imports file exactly.
#@+node:ekr.20040804165258.1: *5* Bug fixes
#@+node:ekr.20040804164600.16: *6* Leo gives the user a chance to save read-only files
Leo now vetoes the shutdown logic if saving a dirty file fails.

Leo prints in red the warning about not being able save the read-only file. The
user can use the Save To command to save the file. The Save To command does not
clear the file's dirty bit, so Leo will prompt again to save the file. The user
will have to ignore this prompt in order to exit. This is correct: the
_original_ file has not been saved.
#@+node:ekr.20040804164600.36: *6* Fixed some unit-test bugs
- g.getScript implicitly assumed that p == c.currentPosition.
  I removed that assumption.

- The scriptButton callback in the scripting.py plugin no longer calls c.executeScript.
  It's simpler and easier to call exec directly.

- Improved c.checkOutline:
    - Added full keyword arg.
    - Print more if verbose is on.
#@+node:ekr.20040804164600.56: *6* Added 3 .cascading style sheets to the distribution list
#@+node:ekr.20040804164600.98: *6* Fixed some bugs in g.importFromPath
#@+node:ekr.20040804164600.102: *6* Fixed major bug in write logic
Spurious entries in a tnodeList for @thin trees wiped out all the headlines in
the @thin tree.
#@+node:ekr.20040804164600.265: *6* Fixed bug in p.isAncestorOf
#@+node:ekr.20040804164600.275: *6* Leo now writes only the currently selected tree when pasting to the clipboard
# The new code only writes tnodes for the current tree when pasting to the clipboard.
#@+node:ekr.20040804164600.377: *6* Fixed performance bug when reading .leo files
There was a big performance bug in the nodenavigator plugin.
#@+node:ekr.20040804170846: *6* Leo now reports problems with bad directories more clearly
@thin bad-directory caused excessive and confusing tracebacks.
#@+node:ekr.20040804164600.394: *6* Leo reads collapsed xml tags properly in .leo files
@nocolor

As a result, the minimal .leo file is:

@color
@language html

<?xml version="1.0" encoding="UTF-8"?>
<leo_file>
<leo_header/>
<globals/>
<preferences/>
<find_panel_settings/>
<vnodes/>
<tnodes/>
</leo_file>

@nocolor

The empty_leo_file plugin now uses this code. The minimal .leo file that Leo
might actually write is more like this:

@color

<?xml version="1.0" encoding="UTF-8"?>
<leo_file>
<leo_header/>
<globals/>
<preferences/>
<find_panel_settings>
    <find_string/>
    <change_string/>
</find_panel_settings>
<vnodes/>
<tnodes/>
</leo_file>
#@+node:ekr.20040804164600.406: *6* Leo makes brings the confirm save box to the front
#@+node:ekr.20040804164600.419: *6* Improved how es_exception gets line number of errors
#@+node:ekr.20040804164600.421: *6* Fixed major bug: changing headline now marks subnodes dirty
This is required to make @thin work properly.
#@+node:ekr.20040804164600.470: *6* Leo now gives update warning only once per external file
#@+node:ekr.20040804164600.471: *6* Leo updates tnodeLists properly in all situations
A major change: putVnode doesn't put tnodeLists for @thin nodes.

Instead it issues an informational message and deletes the tnodeList.
#@+node:ekr.20040804164600.515: *6* Fixed several leaks of positions
Leo used to allocate more positions than necessary.  This unnecessarily stressed the garbage collector.
#@+node:ekr.20040804171818: *6* Fixed all unit tests so they work with both Python 2.2 and Python 2.3
#@+node:ekr.20040804165258.2: *5* Features
#@+node:ekr.20040804172113: *6* @test and @suite greatly aid unit testing
#@+node:ekr.20040804172113.1: *6* New scripts in test.leo make it very easy to use the gc, profile and timeit modules
#@+node:ekr.20040804165258.3: *6* Import dialogs allow multiple selections
Leo now allows you to select multiple files in the dialogs for all Import
commands. This fixes a major annoyance. However, you must be running Python 2.3
or above to get this feature.
#@+node:ekr.20040804165258.4: *6* New Check menu and commands
Added the Check submenu of the Outline menu. This contains the Check Outline and
Dump Outline commands, as well as four new commands:

The Check All Python Code and Check Python Code commands report any syntax
errors or tabnanny errors. These commands mark erroneous nodes. These commands
work on the selected Node and its descendants. These commands ignore any nodes
for which a) @ignore is in effect or b) @language python is in not effect.

The Check Python Code and Pretty Print Python Code commands replace nodes with
their pretty-printed alternative. No doubt everyone will have their own favorite
style. You could implement alternate pretty printers in a plugin merely by
overriding the following methods of class prettyPrinter in leoCommands.py:

---- putOperator:      puts whitespace around operators.
---- putNormalToken:   puts whitespace around everything else.
#@+node:ekr.20040804170531: *6* Perfect Import feature automatically corrects imported files
#@+node:ekr.20040804170657: *6* Improved performance of outline pane
Leo now reuses all widgets used to draw the outline pane. This improves
performance and ends leaks of bindings and widgets.
#@+node:ekr.20040804164600.424: *6* The Go To Line Number command ignores all @all nodes
This makes the command more useful.
#@+node:EKR.20040628095213: *4* 4.2 beta 1 & beta 2
Leo 4.2 beta 2           July 5, 2004
Leo 4.2 beta 1           June 30, 2004

The highlights of 4.2 beta 2:

- Leo now writes the entire contents of @ignore'd @thin trees to the .leo file.
This change ensures that users can create and remove @ignore directives without
any chance of losing data inadvertently.

- Leo now saves and restores marks and the expansion state of nodes in @thin trees.

- Leo marks @thin nodes as dirty whenever they become "newly unignored", i.e.,
when an @thin node no longer falls in the range of an @ignore directive.

Beta 1 completes all fundamental work in the 4.2 code base. All essential code
is complete. Dozens of bugs have been fixed since the Alpha 3 release about a
month ago.

Known bugs in 4.2 beta 2:

- Not all plugins work correctly.
- Some plugins leak memory very slightly.

The highlights of Leo 4.2:

- @thin trees make Leo much more friendly to cvs. Files derived from @thin can
be committed to cvs and updated from cvs without having to commit or update the
corresponding .leo file. There is no longer any need to keep .leo files and
external files in synch.

- Leo's data structures have been reorganized. As a result, all outline
operations are much faster. To support this organization, scripts that traverse
Leo's data structures must now use a positions rather than vnodes. Old scripts
that appear to use vnodes will still work because methods like c.currentVnode
that appear to return vnodes actually return positions.

Other features of 4.2:

- Leo is now much more friendly to using spaces instead of tabs.
- The Execute Script command reports erroneous lines more clearly.
- The usual assortment of bug features and minor features.

Coming soon in 4.2:

- Perfect Import will guarantee that Leo imports file perfectly.
- @import will allow you to study files using Leo without changing those files.
#@+node:EKR.20040628095213.311: *5* New coding conventions
@nocolor

- Leo now uses True and False everywhere instead of true and false.

- All of Leo's code uses spaces instead of tabs for indentation.
#@+node:EKR.20040524104904.242: *5* Extending the format of .leo files
Leo reads and writes "foreign" attributes in <v> and <t> elements in .leo files as follows:

- When reading a .leo file, Leo will create t.unknownAttributes or v.unknownAttributes ivars for
  any tnode or vnode whose corresponding <v> or <t> element in the .leo file contains a foreign attribute.

- The unknownAttributes ivars are dictionaries whose keys are the attribute names and whose values are strings.

- When writing a file, Leo will write "foreign" attributes if a vnode or tnode contains an unknownAttributes ivar.

- The only native attribute of <t> elements is tx.

- The native attributes of <v> elements are a, t, vtag and tnodeList.

- The native attributes of <v> elements are marks, expanded and descendentTnodeUnknownAttributes.

- Non-native attributes are called **foreign** attributes.

- Leo performs the usual xml escapes on these strings when reading or writing the unknownAttributes ivars.

Plugins may cause Leo to write such foreign attributes simply by attaching unknownAttributes ivars to a vnode or tnode.
Like this::

	if hasattr(v,"unknownAttributes"):
		v.unknownAttributes ["vnodeIcon"] = pathToIcon
	else:
		v.unknownAttributes = {"vnodeIcon" : pathToIcon}

See the section called "Recommended conventions for plugins" for advice about
how to avoid potential conflicts in naming new attributes.

All members of these dictionaries should be "pickleable". That is, Leo uses
Python's Pickle module to encode all values in these dictionaries. Leo will
discard any attributes that can not be pickled. This should not be a major
problem to plugins. For example, instead of putting a tnode into these
dictionaries, a plugin could put the tnode's gnx (a string) in the dictionary.

Leo writes only t.unknownAttributes when writing @thin trees to the .leo
file. Leo puts (the encoding of) these elements into an attribute called
descendentTnodeUnknownAttributes. This attribute is part of the <v>
element representing the @thin node. Leo does _not_ write
v.unknownAttributes in @thin trees because *only tnodes have gnx's in
thin external files*. In effect, vnodes are anonymous. We could attempt to get
around this by identifying vnodes by their corresponding tnodes, but that's not
a general solution and it is, in effect, equivalent to writing only
t.unknownAttributes. So it seems pointless to "pretend" to be writing
v.unknownAttributes.

The effect of this is to make all vnodes identical, as far as using
unknownAttributes is concerned. This won't work in all cases. For example, a
plugin that creates an arbitrary directed graph between vnodes must distinguish
between joined vnodes. In that case, the plugin should confine itself to @file
trees, or just vnodes in .leo files, for that matter.
#@+node:ekr.20040705111716: *5* in 4.2 b2
#@+node:ekr.20040705111716.1: *6* Savedmarks and expantion state in <v> elements for @thin nodes
Leo will write only t.unknownAttributes to the .leo file when writing the <v>
element corresponding to the root of an @thin tree. Leo will do this by writing
a new xml attribute, say descendentTnodeUnknownAttributes, in <v> element.

The reason that Leo will only write t.unknownAttributes and not
v.unknownAttributes is that only tnodes have gnx's in thin external files. In
effect, vnodes are anonymous. We could attempt to get around this by identifying
vnodes by their corresponding tnodes, but that's not a general solution and it
is, in effect, equivalent to writing only t.unknownAttributes. This being so, it
seems pointless to "pretend" to be writing v.unknownAttributes.

The effect of this is to make all vnodes identical, as far as using
unknownAttributes is concerned. As I've stated in the past, this won't do if,
for example, a plugin is trying create an arbitrary directed graph between
vnodes. In that case, the plugin should confine itself to @file trees, or just
vnodes in .leo files, for that matter.

7/1/04:

- Leo now writes "marks" and "expanded" attributes in the root <v> element for @thin trees.

- VERY IMPORTANT.  Leo now writes entire tree of @ignored @thin nodes.  This fixes a major bug.
#@+node:ekr.20040705111716.45: *6* Marked all related @thin nodes dirty when a node changesd
Leo marks as dirty all @file nodes when they become "newly unignored".
#@+node:ekr.20040705111716.126: *6* Fixed bug when reading  4.1 files with topology errors
#@+node:ekr.20040705150130: *6* Leo passes all important pychecker tests
Leo now generates no warnings with all significant tests enabled.  Some tests have been disabled in bases classes, and in a few cases pychecker gives erroneous warnings that have been suppressed directly in the source code using the __pychecker__ = arg syntax.
#@+node:ekr.20040705112148: *5* in 4.2 b1
#@+node:EKR.20040628095213.513: *6* Changed *nix install script
#@+node:EKR.20040628100535: *6* Fixed bugs
@killcolor
#@+node:EKR.20040628095213.3: *7* Made "end1" and "ilde"events work again
- Leo calls g.enableIdleTimeHook at end of startup code.
	- This means that g.idleTimeHookHandler gets called periodically, even if no hooks have been defined.
	- g.enableIdleTime hook now calls g.app.gui.setIdleTimeHook at most once.

- app.forceShutdown now calls "end1" hook before calling app.finishQuit.
	- This ensures that the "end1" hook always gets called once.
	- app.finishQuit calls doHook("end1",...) only if it hasn't been called before.
		- This isn't necessary, but it makes traces in doHook less confusing.

- idleTimeHookHandler now calls the idle-time hook for all open windows.
	- So having multiple windows open should not affect idle-time hooks.

** Warning: new convention required to workaround apparent Tk problems.
	- "idle" hooks should return if g.app.killed is True.
#@+node:EKR.20040628095213.23: *7* Put drawing hooks back in
@color

Added the following hooks:

tag argument                                               keys in keywords
(hook name)           overrides    when called           dictionary argument
---------             ---------    -----------           -------------------

"draw-outline-box"       yes   start of drawBox          tree,p,v,x,y (note 6)
"draw-outline-icon"      yes   start of tree.drawIcon    tree,p,v,x,y (note 6)
"draw-outline-node"      yes   start of tree.drawNode    tree,p,v,x,y (note 6)
"draw-outline-text-box"  yes   start of tree.drawText    tree,p,v,x,y (note 6)
"draw-sub-outline"       yes   start of tree.drawTree    tree,p,v,x,y,h,level,hoistFlag (note 6)
#@+node:EKR.20040628095213.56: *7* Fixed syntax colouring Bug in html mode
#@+node:EKR.20040628095213.60: *7* Colorizing fixes
Added support for RapidQ, css, shell scripts and PHP.
#@+node:EKR.20040628095213.113: *7* Fixed Select All bug
When in headline, the Select All command selected the body text.
#@+node:EKR.20040628095213.121: *7* Fixed bugs in @tab_width: support backspace with negative tab width
- idle_body_key must call g.scanDirectives in order to support @tab_width.
	- This must be done for tabs and newlines.

- Fixed bug in g.scanDirectives that was rejecting negative tabwidth values.
	- This bug did not exist in the other versions of scanDirectives.

- With a negative tabwidth, a backspace now computes what spaces are equivalent
to a tab and delete all of those. This is easy to do!
#@+node:EKR.20040628095213.143: *7* Fixed bugs in Remove Sentinel command
#@+node:EKR.20040628095213.160: *7* Eliminated spurious error messages in Import External File command
#@+node:EKR.20040628095213.192: *7* Removed gnx in headlines when importing thin external files
#@+node:EKR.20040628095213.202: *7* Fixed bugs reading 4.1 files
atFile.scanHeader was not handling -encoding fields properly.
#@+node:EKR.20040628095213.213: *7* Fixed Open With bug
#@+node:EKR.20040628095213.225: *7* Fixed Go To Line Number command
#@+node:EKR.20040628095213.246: *7* Fixed crash when importing Borland wstring.cpp
Namespace not handled very well.
#@+node:EKR.20040628095213.279: *7* Fixed bug in insertBodyTime
I inserted "import time", and while I was at it I improved the error checking.
#@+node:EKR.20040628095213.297: *7* Fixed bug when pasting large text into headlines
The code now limits what can be pasted to a maximum of one line or a about 250 characters.
#@+node:EKR.20040628095213.308: *7* Fixed bug in delete command
#@+node:EKR.20040628095213.312: *7* Fixed oops: nullGui setIdleTimeHook
#@+node:EKR.20040628095213.324: *7* Fixed problems with trailing newlines and spurious changed bit
- Set removeTrailing to True unless ch is a newline.

This allows Alt-f to work properly.

- Return "break" after the "final" text has been computed if nothing has changed.

This suppresses spurious newlines.

A new idea:  Make sure the text _does_ have a newline at all times.  I'm not sure this will work...

- ALWAYS set the text in select.  This prevents some weird problems with trailing newlines.
#@+node:EKR.20040628095213.346: *7* Fixed headline key handling
Hitting return in middle of a headline didn't work.
#@+node:EKR.20040628095213.348: *7* Fixed Problems executing script
#@+node:EKR.20040628095213.354: *7* Fixed problem with PHP and @last
#@+node:EKR.20040628095213.366: *7* Fixed bug when writing unknownAttributes
#@+node:EKR.20040628095213.368: *7* Fixed bugs opening a second file
#@+node:EKR.20040628095213.404: *7* Fixed bug: @last silently failed when extra lines exist
#@+node:EKR.20040628095213.407: *7* Fixed hang when dragging from one clone copy to another
#@+node:EKR.20040628095213.412: *7* Fixed crash in Write Missing
#@+node:EKR.20040628095213.442: *7* Fixed bug in getScript
This only happened after previous write error.

The fix was to init self.errors in openWriteFile.

The whole atFile logic is pretty gruesome.  It's got to be cleaned up.
#@+node:EKR.20040628095213.444: *7* Fixed problems with @all
- Allow indented @all.
    - Changed to g.is_special
    - Changed leoColor.doAtKeyword

- Fixed bug in is_special that broke p.isAtAllNode.
#@+node:EKR.20040628095213.499: *7* Fixed double print in Execute Script command
#@+node:EKR.20040628095213.512: *7* Fixed bug reading leo.nsi
The problem was setting endSentinelComment to None instead of "" in readDirective.

The code is pretty fragile; it should handle either None or "", but in fact it requires "".
#@+node:EKR.20040628100535.1: *6* Added new features
#@+node:EKR.20040628095213.52: *7* Allowed </leo_header> tag
#@+node:EKR.20040628095213.109: *7* Replaced the word "Leo" with Leo icon in Find/Compare/Prefs windows
http://sourceforge.net/forum/message.php?msg_id=2429098

The Leo icon can eliminate the need for the word Leo.

What I did:

- Eliminate Leo in name of Find panel.
- Derived leoTkinterPrefs from leoTkinterDialog: creates icon.
- Derived leoComparePanel from leoTkinterDialog: creates icon.
- Eliminated the -t option when opening Idle: the idle window is now called "Python Shell"
#@+node:EKR.20040628095213.110: *7* Improved Import command slightly
- Added @language html when importing ".htm" and ".html" files.
- Added @nocolor when importing ".txt" and ".text" files
#@+node:EKR.20040628095213.197: *7* Added 3 files to distribution lists
doc\leoUsersGuide.txt
doc\leoFAQ.txt
doc\leoLeaps.txt
#@+node:EKR.20040628095213.198: *7* Supported @tabwidth in indent/dedent
The old code used at c.tab_width.  It should also look for @tabwidth directives.

This was not good when @tabwidth -4 was in effect.
#@+node:EKR.20040628095213.264: *7* Import now creates absolute path
#@+node:EKR.20040628095213.269: *7* Created @killcolor directive
#@+node:EKR.20040628095213.282: *7* Added Paste Retaining Clones command
- By default, finishPaste command reassigns all indices in copied nodes.
- Created pasteOutlineRetainingClones.
- Added reassignIndices arg to pasteOutline, getLeoOutline and finishPaste.
- Added << recreate tnodesDict >> in getLeoOutline.
- Simplified getTnode slightly: the "if t" code is the same for both kinds of reads.
#@+node:EKR.20040628095213.314: *7* Added readLineGenerator & readLineClass to leoGlobals
#@+node:EKR.20040628095213.334: *7* Much better error handling in executeScript
- The string passed to exec now includes sentinels.

goToLineNumber needs sentinels to work properly.

- es_exception now gets the error line number from the traceback.

- Added new keyword arguments to goToLineNumber.

- Created goToScriptLineNumber, which just calls goToLineNumber.
#@+node:EKR.20040628095213.377: *7* Recovered nodes when reading .leo files containing topology errors
Changed getVnode so it checks for v = None after calling getExistingVnode.  Creating the node seems to work in this case: I wouldn't bet my life that it works in all cases.
#@+node:EKR.20040628095213.391: *7* Generalized write-to-string logic
- Added toString to most write methods.
- Retained scriptFile option for compatibility with plugins.
#@+node:EKR.20040628095213.408: *7* Added case_sensitiveLanguage to colorizer
#@+node:EKR.20040628095213.425: *7* Write entire @thin tree on write errors
#@+node:EKR.20040628095213.485: *7* Handled inner @language and @comment properly
There was a small hole in the format of external files. Leo assumed that comment
delimiters do not change within any particular external file. This assumption is
not necessarily true in files like leoProjects.txt.

What I did:

- putDirective and readDirective now check for @langauge and @comment, and
change comment delims appropriately.

This is slightly dubious: after all, an @langauge directive in the middle of
most external files will cause havoc. However, one could say that this is the
users problem :-)

BTW, this doesn't really solve all problems in @all trees: Leo can still get
mightily confused about comment delims if the user doesn't put proper @language
directives in @all trees.
#@+node:EKR.20040628095213.490: *7* Better reporting of body text conflicts
readEndNode uses the existing tempBodyString attribute to determine if the body text has changed.  If so, we mark the tnode dirty.  The code in 

top_df.read.<< copy all tempBodyStrings to tnodes >>

propagates the dirty marks to all ancestor @file nodes.  This can't be done in readEndNode because no positions are available at that time.
#@+node:EKR.20040628095213.493: *7* Improved error handling for unknownAttributes
#@+node:EKR.20040628095213.501: *7* Read and write all t.unknownAttributes in top vnode of an @thin tree
Leo now writes t.unknownAttributes to the .leo file when writing the <v> element
corresponding to the root of an @thin tree. Leo will do this by writing a new
xml attribute, descendentTnodeUnknownAttributes, in <v> element.

Leo will only write t.unknownAttributes, not v.unknownAttributes. This is
because only tnodes have gnx's in thin external files. In effect, vnodes are
anonymous. We could attempt to get around this by identifying vnodes by their
corresponding tnodes, but that's not a general solution and it is, in effect,
equivalent to writing only t.unknownAttributes. This being so, it seems
pointless to "pretend" to be writing v.unknownAttributes.

The effect of this is to make all vnodes identical, as far as using
unknownAttributes is concerned. As I've stated in the past, this won't do if,
for example, a plugin is trying create an arbitrary directed graph between
vnodes. In that case, the plugin should confine itself to @file trees, or just
vnodes in .leo files, for that matter.
#@+node:EKR.20040601084317: *4* 4.2 a3
Leo 4.2 alpha 3           June 1, 2004

This version fixes completes the essential features of version 4.2. All known
incompletions and bugs involving shared nodes and Leo's new file format have
been fixed. BTW, this version of Leo completes Leaps 201 and 202.

It should be safe to use this version for collaboration between Leo's
developers. I hereby encourage people to start using cvs for collaboration. Only
by doing so will we discover any possible problems.

The only item that must be completed before releasing 4.2 beta is fixing the Go
To Line Number command so it supports thin external files.

There are many known bugs in this version: most are minor bugs that have been
around for a long time. All known bugs will be fixed by the first release
candidate. See the to-do list in LeoPy.leo for the complete list.

The highlights of this version:

- All features of @file-thin are now complete and appear to be stable. - All
	.leo files in the distribution use @thin files where possible. - Leo ignores
	all directives within the range of the @all directive. - The @+middle and
	@-middle sentinels allow sections to be defined in any descendant node. -
	The @clone sentinel marks duplicate cloned siblings. - The beginnings of a
	new undo scheme are in place. - @thin, @nosent, @noref and @asis are
	abbreviations for @file-thin, @file-nosent, @file-noref and @file-asis. -
	Created new iterators that return lists of vnodes and tnodes, including
	iterators that remove all duplicates from those lists.
#@+node:EKR.20040601084317.2: *5* Bug fixes
#@+node:EKR.20040601101118: *6* Fixed copy/paste operations involving @thin trees
If the copied node was an @thin or @file-thin node node only the root node was copied.
#@+node:EKR.20040601101430: *6* Fixed Change Headline command
This bug exists in 4.1 final. Leo did not properly show the found text in
headlines. The fix was in the code that redraws the screen, not in the
find/change code itself.
#@+node:EKR.20040601084317.99: *6* Eliminated spurious "Not written x.tmp" message after write errors
This happened after write errors such as orphan nodes.
#@+node:EKR.20040601084317.142: *6* Fixed problems saving unknownAttribute field
When writing .leo files Leo now pickle's and hexlify's all data in the
v.unknownAttribute and t.unknownAttribute dictionaries. When reading .leo files
Leo does the reverse.

Leo ignores all elements in these dictionaries if some element can not be pickled.
#@+node:EKR.20040601102115: *6* Fixed unicode problem in the Dump Outline command
#@+node:EKR.20040601101227: *5* New Features
#@+node:EKR.20040601101227.1: *6* Leo ignores all directives in @all trees
#@+node:EKR.20040601101430.1: *6* @+-middle sentinels allow sections to be defined in grandchildren
#@+node:EKR.20040601101510: *6* @clone sentinel allows siblings to be cloned
#@+node:EKR.20040601101547: *6* Created @thin, @nosent, @noref and @asis abbreviations
#@+node:EKR.20040601084317.102: *6* Made undo extensible
Added u.registerUndoHandlers.

This will become largely unnecessary in the new undo scheme.  It's good to have though.
#@+node:EKR.20040601102703: *6* Started work on simple new undo scheme
The new scheme simply saves all information in one or more vnodes and their
associated tnodes. This is a general scheme that can be used by almost any
command.

At present only the u.saveTree method exists. Coming soon, u.saveNode,
u.saveNodeAndChildren and u.saveListOfNodes.
#@+node:EKR.20040601084317.161: *6* Created new c, p, v iterators
I have fallen madly in love with generators.
The following new iterators are defined with generators.

c.all_positions_iter
c.all_tnodes_iter
c.all_vnodes_iter
c.all_unique_tnodes_iter
c.all_unique_vnodes_iter

p.tnodes_iter
p.vnodes_iter
p.unique_tnodes_iter
p.unique_vnodes_iter

v.self_and__subtree_iter
v.self_and_unique_subtree_iter
#@+node:EKR.20040601102808: *5* Known bugs
See the to-do list in LeoPy.leo for a list of known bugs in this version.

None of these bugs is serious:  I consider this version to be suitable for day-to-day work.
#@+node:EKR.20040518070558: *4* 4.2 a2
Leo 4.2 alpha 2           May 18, 2004

This is an important milestone in Leo's history; the two defining features of
the 4.2 code base are complete:

1. This is the first stable version using the "shared nodes" code base.

Shared nodes dramatically improve the time needed to insert, delete, and move
nodes. Moreover, the new code base is code compatible with the old. Indeed, much
of Leo still uses the old code base. See the Scripting Leo for full details of how to
script Leo with the 4.2 code base.

2. This is the first version to use @file-thin for most external files.

@file-thin makes it possible to use Leo effectively in a cvs environment.  Indeed, cvs now contains only a "dummy" version of LeoPy.leo.  The idea is that:

- LeoPyRef.leo hardly ever changes. Developers will download LeoPyRef.leo once
from cvs, then rename LeoPyRef.leo to be LeoPy.leo. LeoPy.leo is private to each
developer.

- Developers will commit and update to cvs only thin external files. There is no
longer any need to keep .leo files and the files derived from them "in synch".

- Similar remarks apply to LeoPlugins.leo. Cvs contains only LeoPluginsRef.leo,
and contributors will need only to submit thin external files.

I have been using the new code base without incident for weeks now, and I am
fairly confident that it is safe to use. Nevertheless, I would suggest routine
caution when dealing with this version until more people have tested it.

Known bugs

- Cutting and pasting an @file-thin node does not work properly. This will be
easy to fix, I think.

- The present algorithm for reading thin external files probably does not handle
properly the situation in which a named node is some kind of grand child of the
referencing node rather than being an immediate child of the referencing node.
This is a rare situation, easily avoided, and it doesn't happen at all in
LeoPy.leo. Nevertheless, something must be done.

Other improvements:

- Fixed a number of problems with using Leo on MacOS X. In particular, Leo now
uses the clover key as is usual on the Mac. More Mac and *nix specific
improvements are coming.

Still to do:

- Perfect import and @import. - Make the Go To Line Number command work with
@file-thin files. - Fix minor bugs and add new features See the "To Do: 4.2"
node in the leoToDo.txt node in LeoPy.leo.
#@+node:EKR.20040518070940.5: *5* Implemented @file-thin
What I did:

File format

Added -thin field to @+leo sentinel

Recognizers

- Added vnode recognizers for @file-thin option.
- Added position proxies for vnode recognizers.

Directives & sentinels
- Added support for @all.

Writing

- Added top-level atFile code to write @file-thin tree.
- DO write @file-thin vnodes if there was an error writing the external file.
	- No autosave for @file-thin.
 	- Leo writes @file nodes first, so this is not a problem.
	- putVnode checks orphan bit, which gets set if there was an error.
- Don't write vnodes (or related tnodes) for @file-thin trees. (fileCommands).
- Do write empty nodes in @thin trees.
- Don't generate close node sentinels until all children have been generated.

Reading

- Set at.thinFile when reading thin files.
- Suppressed changed message and related items for thin files.
- Modified scanText4 and allies to read thin external files.
	- Don't look for tnodeList for thin files.
	- Initially, at.lastThinNode is at.root.v
	- readStartNode calls createThinChild
	- createThinChild makes a child of at.lastThinNode if needed and sets at.lastThinNode.
- Updated fc.tnodesDict in at.createThinChild.
	Otherwise clones existing only in two thin files won't be linked properly.
#@+node:EKR.20040518070824: *5* Fixed bugs
#@+node:EKR.20040518071415: *6* Fixed clone bug that caused parts of outlines to disappear
Leo did not handle moving a node to the root position of the outline correctly.
#@+node:EKR.20040518070940.156: *6* Fixed long-standing problem with the outline-only command
After a match, the find-next command searched only in the suboutline where the first match occurred.
To fix this, we call g.app.findFrame.handleUserClick in various Tk event handlers.
#@+node:EKR.20040518070824.1: *6* Made sure file indices are always assigned when writing files.
- Moved call to assignFileIndices into write_Leo_file.
- Called assignFileIndices in writeAtFileNodes, writeDirtyAtFileNodes, writeMissingAtFileNodes
#@+node:EKR.20040518070940: *6* Fixed problems with missing tnodeList with @file-noref
#@+node:EKR.20040518070940.164: *6* Added t.writeBit
@nocolor


p.v.t.visitedBit was used for two purposes:

- To mark the nodes to be written.
- To mark nodes that are not orphan.

What I did:

- Added t.is/set/clearWriteBit.
- Call t.setWriteBit in putVnode unless we are in a thin node.
- putTnodes tests for t.writeBit rather than t.visitedBit.
#@+node:EKR.20040518075457: *5* Dangers of @file-thin
Using @ignore with @file-thin is asking for trouble.
If you remove the @ignore and then save, you will lose data.

How to recover the data:
	- Read Outline.
	- Remove @ignore
	- Import External File... 
#@+node:ekr.20060206111600: *3* 4.3...@settings
#@+node:ekr.20050917092557: *4* 4.3.3 final
Leo 4.3.3 final                 September 17, 2005

Leo 4.3.3 fixes several bugs reported in Leo 4.3.2 final in the last several days.

To learn about Leo, see: http://leoeditor.com/tutorial.html

The highlights of 4.3.3 (and 4.3.2)
-----------------------------------

- Improved Leo's documentation:
    - A tutorial introduction to Leo.
    - A 5-minute guide to programming with Leo.

- The new rst3 plugin creates .html and .tex files from reStructuredText
  embedded in Leo files. Any node of the source outline may contain options for
  the rst3 plugin, which makes this plugin much more useful and flexible than
  the previous rst plugins. All of Leo's documentation was created using this
  plugin from sources in LeoDocs.leo. For full documentation for rst3 see:
  http://leoeditor.com/rstplugin3.html.

- The spellpyx (spell checking) plugin is now much easier to use.

- The vim plugin now uses Python's subprocess module if it is present.

- Improved the Pretty Printing command.

- The usual assortment of bug fixes.
#@+node:ekr.20050917105646: *5* Fixes made in 4.3.3
- Fixed bug that caused the Open With command to crash if the subprocess module was not installed.

- Fixed problems in the niceNocent and fastGotoNode plugins.
#@+node:ekr.20050917092557.1: *5* Rewrote documentation
Here is a summary of the changes:

- General: All chapters created with rst3 plugin. This ensures a uniform look.
The source is in LeoDocs.leo. Removed all references to older versions of Leo,
except when discussing old file formats in the Appendices. Corrected all text so
it discusses present version.

- rst3 plugin itself: Correct bug that caused chapters to be formatted
differently when processing multiple @rst trees.

- rst3 button in LeoDocs.leo: The script first looks *up* the tree, looking for
an @rst node. If found, it processes just that tree. If not found, it processes
all @rst nodes *below* the originally selected node. The button is now much more
convenient to use.

- Preface: Shorter, no history. No longer a dead end.

- What People are Saying About Leo: No longer a dead end.

- FAQ: Reorganized, simplified, revised. Added entries for running Leo in a
console window and debugging docutils. Improved entry for using cvs.

- Installation: Now the first chapter. Revised.

- Tutorial: Completely rewritten. Like Python's tutorial, this
chapter contains everything a beginner needs to understand and use Leo. The
`Quickstart for programmers` section is the heart of this chapter. All terms
used have links either to their definition in the tutorial or in the Glossary.
Newbies should be able to digest this chapter easily. This chapter should make
Leo comprehensible to many more people.

- Using Outlines: Revised per general remarks above.

- Writing Programs in Leo. Completely rewritten. The old chapter was
an embarrassment. The new chapter is a reference guide, properly organized as
such. The introduction warns newbies away.

- Using Leo's Commands. 'Minor' revisions and corrections create a
substantially better result.

- Scripting Leo with Python: Rewritten, simplified, updated and
corrected. The sources in LeoDocs.leo are directly executable. rST sources use
literal blocks instead of code-blocks so that the sources are simplified.
(Important when executing examples). Properly discusses positions, including
'supremely important' section on copying positions.

- Customizing Leo. Heavily revised. Discusses leoSettings.leo, not
leoConfig.txt. Security warnings are more reasonable. Section on script buttons.
Rewrote section on uA's (Adding extensible attributes to nodes and .leo files).

- History of Leo. Rewritten. Much shorter and more useful. Discusses
the major milestones, concentrating on explaining the major differences between
versions. Gone are details of how discoveries came to be. They are in
LeoPostings.leo, which will be included in the distribution.

- Theory of Operation. Largely rewritten. Discusses positions
properly. Omits discussion of how clones were implemented before 4.2.

- White Papers. A new chapter. This is a slightly-edited version of
writing that had been buried in the appendices.

- Appendices. Heavily revised and reformatted. Rewrote sections on file formats.

- Glossary: A separate chapter. All terms have links to their definition. All
definitions are rST targets so other chapters may refer to them. Added several
new entries.
#@+node:ekr.20050917092557.2: *5* Bug fixes...
#@+node:ekr.20050917092557.3: *6* Fixed various unicode bugs
- Fixed bug with non-unicode characters in file name

    http://sourceforge.net/forum/message.php?msg_id=3224635

    Leo crashed try to read .leo files whose name contained non-ascii characters.

- Fixed bug with non-unicode characters in settings value

    http://sourceforge.net/forum/message.php?msg_id=3222750

    Leo crashed try to write settings whose values contained non-ascii characters.

- Fixed bug tangling sections with non-unicode characters.

    http://sourceforge.net/forum/message.php?msg_id=3307318
#@+node:ekr.20050917092557.4: *6* Fixed bugs relating to recent files
http://sourceforge.net/forum/message.php?msg_id=3218558
#@+node:ekr.20050917092557.5: *6* Fixed minor crasher in colorizer
The fix was to add an entry of 'unknown' state to state_dict. This fixes the
crash by brute force, but may not be strictly correct. However, this is pretty
much moot: we shall soon be moving to the new colorizer.
#@+node:ekr.20050917092557.6: *6* Protected several methods used by plugin manager
The code gets c = keywords.get('c') in several places.
The protection is to return if c is None.
This affects the following files: plugins_menu.py, pluginsTest.py, plugin_manager.py
#@+node:ekr.20050917092557.7: *6* Added test files to distribution list and cvs
http://sourceforge.net/forum/message.php?msg_id=3231597

test.leo had some non-@ignore'd @thin nodes for files not in the distribution.

- Only files used by unit tests should be on cvs and the distribution.
    - test\unittest\batchTest.py and test\unittest\errorTest.py were already on cvs.
    - Added these files to the distribution.

- Other test files should be distributed in @ignore nodes.

- Leo's distribution checklist now has an item to check that the distributed test.leo can be opened without errors.
#@+node:ekr.20050917092557.8: *5* New and improved  plugins
#@+node:ekr.20050917092557.9: *6* New rst3 plugin
See http://leoeditor.com/rstplugin3.html for full documentation
of this plugin.

The rst3 plugin creates output files from Leo outlines containing
reStructuredText (rST) ReStructuredText is a simple and powerful text formatting
markup language. Outlines are a natural way to organize rST (or any text).

This plugin adds the Write Restructured Text command to Leo's Edit menu. The
Write Restructured Text command searches the selected outline looking for rst
root nodes whose headline have the form @rst <filename>. The plugin then creates
the named file in various ways depending which rst3 options are in effect.

By default, the rst3 plugin creates rST headings automatically from outlines, so
the higher-level nodes in the outline correspond to higher-level sections in the
output. Creating rST headings automatically relieves you from one of the most
tedious chores in creating rST markup.

To use this plugin effectively, Python's docutils module must be installed.

This plugin sends .htm, .html or .tex files to the docutils module for further
processing. Docutils generates HTML files or LaTeX files depending on the file's
extension. HTML files generated by docutils refer to three .css (cascading style
sheet) files that should exist in the same directory as the generated HTML file.
You can control the formatting of the HTML file by altering these .css files.
#@+node:ekr.20050917092557.11: *6* Improved vim plugin
The vim plugin now uses Python's subprocess module if it is present. The
subprocess module comes standard with Python 2.4. For Linux systems, Leo will
use subprocess.py in Leo's extensions folder if necessary.

For Windows systems you can install Python's subprocess module in Python 2.2 or
2.3 as follows:

    - Go to http://www.effbot.org/downloads/#subprocess

    - Download and execute one of the following installers, depending on your version of Python:
        subprocess-0.1-20041012.win32-py2.3.exe 
        subprocess-0.1-20041012.win32-py2.2.exe

This installer installs the subprocess sources and also _subprocess.pyd in Python's site-packages folder.
#@+node:ekr.20050917092557.12: *5* New & improved features...
#@+node:ekr.20050917092557.13: *6* Added g.es_print, g.es_trace function
Calling print directly is dangerous: it will fail for unicode characters.
#@+node:ekr.20050917092557.14: *6* Improved PrettyPrinting
The new Pretty Print code has the following improvements:

- Strip trailing blanks in get.
- Many improvement to doOp.
- Improved DoMultiline:
    - Added special case logic to ensure '#' is preceded by space except at start of line.
    - Added blank after multi-line string if needed.
- Added lastName token for special-case handling depending on previous token.
- No change to put, putArray or doName.
#@+node:ekr.20050913131848: *4* 4.3.2 final
Leo 4.3.2 final                 September 16, 2005

To learn about Leo, see: http://leoeditor.com/tutorial.html

The highlights of 4.3.2:
-----------------------

- Improved Leo's documentation:
    - A tutorial introduction to Leo.
    - A 5-minute guide to programming with Leo.

- The new rst3 plugin creates .html and .tex files from reStructuredText
  embedded in Leo files. Any node of the source outline may contain options for
  the rst3 plugin, which makes this plugin much more useful and flexible than
  the previous rst plugins. All of Leo's documentation was created using this
  plugin from sources in LeoDocs.leo. For full documentation for rst3 see:
  http://leoeditor.com/rstplugin3.html.

- The spellpyx (spell checking) plugin is now much easier to use.

- The vim plugin now uses Python's subprocess module if it is present.

- Improved the Pretty Printing command.

- The usual assortment of bug fixes.
#@+node:ekr.20050906104918.1: *5* Rewrote documentation
Here is a summary of the changes:

- General: All chapters created with rst3 plugin. This ensures a uniform look.
The source is in LeoDocs.leo. Removed all references to older versions of Leo,
except when discussing old file formats in the Appendices. Corrected all text so
it discusses present version.

- rst3 plugin itself: Correct bug that caused chapters to be formatted
differently when processing multiple @rst trees.

- rst3 button in LeoDocs.leo: The script first looks *up* the tree, looking for
an @rst node. If found, it processes just that tree. If not found, it processes
all @rst nodes *below* the originally selected node. The button is now much more
convenient to use.

- Preface: Shorter, no history. No longer a dead end.

- What People are Saying About Leo: No longer a dead end.

- FAQ: Reorganized, simplified, revised. Added entries for running Leo in a
console window and debugging docutils. Improved entry for using cvs.

- Chapter 1: Installation: Now the first chapter. Revised.

- Chapter 2: Tutorial: Completely rewritten. Like Python's tutorial, this
chapter contains everything a beginner needs to understand and use Leo. The
`Quickstart for programmers` section is the heart of this chapter. All terms
used have links either to their definition in the tutorial or in the Glossary.
Newbies should be able to digest this chapter easily. This chapter should make
Leo comprehensible to many more people.

- Chapter 3: Using Outlines: Revised per general remarks above.

- Chapter 4: Writing Programs in Leo. Completely rewritten. The old chapter was
an embarrassment. The new chapter is a reference guide, properly organized as
such. The introduction warns newbies away.

- Chapter 5: Using Leo's Commands. 'Minor' revisions and corrections create a
substantially better result.

- Chapter 7: Scripting Leo with Python: Rewritten, simplified, updated and
corrected. The sources in LeoDocs.leo are directly executable. rST sources use
literal blocks instead of code-blocks so that the sources are simplified.
(Important when executing examples). Properly discusses positions, including
'supremely important' section on copying positions.

- Chapter 8: Customizing Leo. Heavily revised. Discusses leoSettings.leo, not
leoConfig.txt. Security warnings are more reasonable. Section on script buttons.
Rewrote section on uA's (Adding extensible attributes to nodes and .leo files).

- Chapter 9: History of Leo. Rewritten. Much shorter and more useful. Discusses
the major milestones, concentrating on explaining the major differences between
versions. Gone are details of how discoveries came to be. They are in
LeoPostings.leo, which will be included in the distribution.

- Chapter 10: Theory of Operation. Largely rewritten. Discusses positions
properly. Omits discussion of how clones were implemented before 4.2.

- Chapter 11: White Papers. A new chapter. This is a slightly-edited version of
writing that had been buried in the appendices.

- Appendices. Heavily revised and reformatted. Rewrote sections on file formats.

- Glossary: A separate chapter. All terms have links to their definition. All
definitions are rST targets so other chapters may refer to them. Added several
new entries.
#@+node:ekr.20050906104931.1: *5* Bug fixes...
#@+node:ekr.20050909082711: *6* Fixed various unicode bugs
- Fixed bug with non-unicode characters in file name

    http://sourceforge.net/forum/message.php?msg_id=3224635

    Leo crashed try to read .leo files whose name contained non-ascii characters.

- Fixed bug with non-unicode characters in settings value

    http://sourceforge.net/forum/message.php?msg_id=3222750

    Leo crashed try to write settings whose values contained non-ascii characters.

- Fixed bug tangling sections with non-unicode characters.

    http://sourceforge.net/forum/message.php?msg_id=3307318
#@+node:ekr.20050906104931.15: *6* Fixed bugs relating to recent files
http://sourceforge.net/forum/message.php?msg_id=3218558
#@+node:ekr.20050906104931.38: *6* Fixed minor crasher in colorizer
The fix was to add an entry of 'unknown' state to state_dict. This fixes the
crash by brute force, but may not be strictly correct. However, this is pretty
much moot: we shall soon be moving to the new colorizer.
#@+node:ekr.20050906104931.42: *6* Protected several methods used by plugin manager
The code gets c = keywords.get('c') in several places.
The protection is to return if c is None.
This affects the following files: plugins_menu.py, pluginsTest.py, plugin_manager.py
#@+node:ekr.20050906104931.43: *6* Added test files to distribution list and cvs
http://sourceforge.net/forum/message.php?msg_id=3231597

test.leo had some non-@ignore'd @thin nodes for files not in the distribution.

- Only files used by unit tests should be on cvs and the distribution.
    - test\unittest\batchTest.py and test\unittest\errorTest.py were already on cvs.
    - Added these files to the distribution.

- Other test files should be distributed in @ignore nodes.

- Leo's distribution checklist now has an item to check that the distributed test.leo can be opened without errors.
#@+node:ekr.20050908164150: *5* New and improved  plugins
#@+node:ekr.20050908164150.1: *6* New rst3 plugin
See http://leoeditor.com/rstplugin3.html for full documentation
of this plugin.

The rst3 plugin creates output files from Leo outlines containing
reStructuredText (rST) ReStructuredText is a simple and powerful text formatting
markup language. Outlines are a natural way to organize rST (or any text).

This plugin adds the Write Restructured Text command to Leo's Edit menu. The
Write Restructured Text command searches the selected outline looking for rst
root nodes whose headline have the form @rst <filename>. The plugin then creates
the named file in various ways depending which rst3 options are in effect.

By default, the rst3 plugin creates rST headings automatically from outlines, so
the higher-level nodes in the outline correspond to higher-level sections in the
output. Creating rST headings automatically relieves you from one of the most
tedious chores in creating rST markup.

To use this plugin effectively, Python's docutils module must be installed.

This plugin sends .htm, .html or .tex files to the docutils module for further
processing. Docutils generates HTML files or LaTeX files depending on the file's
extension. HTML files generated by docutils refer to three .css (cascading style
sheet) files that should exist in the same directory as the generated HTML file.
You can control the formatting of the HTML file by altering these .css files.
#@+node:ekr.20050910143326: *6* Improved vim plugin
These plugins now use Python's subprocess module if it is present. The
subprocess module comes standard with Python 2.4. For Linux systems, Leo will
use subprocess.py in Leo's extensions folder if necessary.

For Windows systems you can install Python's subprocess module in Python 2.2 or
2.3 as follows:

    - Go to http://www.effbot.org/downloads/#subprocess

    - Download and execute one of the following installers, depending on your version of Python:
        subprocess-0.1-20041012.win32-py2.3.exe 
        subprocess-0.1-20041012.win32-py2.2.exe

This installer installs the subprocess sources and also _subprocess.pyd in Python's site-packages folder.
#@+node:ekr.20050906104931.48: *5* New & improved features...
#@+node:ekr.20050906104931.49: *6* Added g.es_print, g.es_trace function
Calling print directly is dangerous: it will fail for unicode characters.
#@+node:ekr.20050906104931.56: *6* Improved PrettyPrinting
The new Pretty Print code has the following improvements:

- Strip trailing blanks in get.
- Many improvement to doOp.
- Improved DoMultiline:
    - Added special case logic to ensure '#' is preceded by space except at start of line.
    - Added blank after multi-line string if needed.
- Added lastName token for special-case handling depending on previous token.
- No change to put, putArray or doName.
#@+node:ekr.20050906104918: *4* 4.3.2 beta 1
Leo 4.3.2 beta 1                  September 10, 2005

To learn about Leo, see: http://leoeditor.com/tutorial.html

The highlights of 4.3.2:
-----------------------

- Improved Leo's documentation:
    - A tutorial introduction to Leo.
    - A 5-minute guide to programming with Leo.

- The new rst3 plugin creates .html and .tex files from reStructuredText
  embedded in Leo files. Any node of the source outline may contain options for
  the rst3 plugin, which makes this plugin much more useful and flexible than
  the previous rst plugins. All of Leo's documentation was created using this
  plugin from sources in LeoDocs.leo. For full documentation for rst3 see:
  http://leoeditor.com/rstplugin3.html.

- The spellpyx (spell checking) plugin is now much easier to use.

- The vim plugin now uses Python's subprocess module if it is present.

- Improved the Pretty Printing command.

- The usual assortment of bug fixes.
#@+node:ekr.20050620144052: *4* 4.3.1
Leo 4.3.1                    June 20, 2005

- Added support for Tk resource files.
- Added support for coloring the PL/SQL language.
- All Mark commands are now undoable.
- Improved Resize To Screen command.
- The usual assortment of minor bug fixes.
#@+node:ekr.20050620144052.2: *5* Bug fixes...
#@+node:ekr.20050620144052.3: *6* Fixed bug in @ratio setting
http://sourceforge.net/forum/message.php?msg_id=3166883
By: rogererens

I swear I didn't wait for the release to be the first to report a bug! I just
didn't try this in the alpha/beta versions:

Leo 4.3 final, build  1.262 , May 23, 2005
Python 2.4.1, Tk 8.4.7, win32

Changing
Global settings: C:\Leo\config\leoSettings.leo-->Window options-->@page Options
for new windows-->@ratio initial_horizontal_ratio = 0.3
or any of the other ratios, does not save them to leoSettings.leo. So after
restarting I still have the old settings in use.
#@+node:ekr.20050620144052.6: *6* Fixed crasher footprint plugin
http://sourceforge.net/forum/message.php?msg_id=3167166

The fix was to add the following line to the init function:

    global click_registry, coloured_nodes
#@+node:ekr.20050620144052.8: *6* Fixed invalid position bug)
Modifying outlines can invalidate existing positions! This rarely happens. At
present it affects the atFile.read logic when reading an outline whose initial
current position is a clone outside an @thin tree with another clone inside the
@thin tree. So the read logic computes the expected current position before
reading all external files, and this expected current position becomes invalid.

What I did:

1. Moved << set current and top positions >> from getVnodes to end of
getLeoFile. This ensures that the outline won't change after computing the
position.

2. Unit tests will have to be revised to make sure that only valid positions get
used.
#@+node:ekr.20050620144052.48: *6* Fixed undo problems in unit tests
- Fixed bugs in convertAllBlanks and convertAllTabs.

These must always call afterChangeGroup to match beforeChangeGroup, even if
nothing has changed.

- Added u.getMark and u.rollbackToMark.

These allow unit tests to cut the undo stack back to an initial position in the
tearDown method. This should be done for all tests that use u.undo and u.redo
methods. The bug was probably the result of changing the outline in the tearDown
method.

Both the Reformat Paragraph and Edit Body unit tests now roll back the undo stack.

- Added traces for unexpected conditions in u.undo, u.redo and tree.select.

- Call u.setUndoTypes() in u.setUndoTypingParams when returning early.

- Corrected Edit Body unit tests.

These tests should not call undo/redo when nothing is expected to change. Doing
so may trigger the new 'cant undo' traces in u.undo.

- doTest in leoTest.py now makes copies of both p and p1.

It's not clear that this is needed, it can't hurt, and it may have been important.
#@+node:ekr.20050620144052.112: *6* Made sure same case is used in all recent files entries
The problem was that leo.__file__ returns a randomly upper or lower cased drive letter.
#@+node:ekr.20050620144052.114: *6* Made sure all dialogs gets focus when they are run
# The About Leo dialog was not getting focus.
#@+node:ekr.20050620144052.116: *6* Improved Resize To Screen command
#@+node:ekr.20050620144052.119: *6* Made sure comments are always visible in setting dialog even for non-@ nodes
http://sourceforge.net/forum/message.php?msg_id=3176499

5) am I missing text in the Settings panels?  the outline shows that certain
nodes have text (e.g., "About keyboard shortcuts" has the blue rectangle), yet
the body pane is empty; heck, even the title suggests that something should
be there...
#@+node:ekr.20050620144052.154: *6* Fixed problem with leading @ in body text
http://sourceforge.net/forum/message.php?msg_id=3190593

As luck would have it, I need to put an @ character at the beginning of a line
in source code (windows registry file format) and can't figure out how to do
it. 
#@+node:ekr.20050620144052.166: *6* Fixed several  crashers while undoing a move involving clones
#@+node:ekr.20050620144052.182: *6* Fixed Unicode encoding problem
http://sourceforge.net/forum/message.php?msg_id=3186385

I just tried 4.3-final, and it seems it does not work with Chinese LC_CTYPE:
#@+node:ekr.20050620144052.185: *6* Fixed problem with coloring @language plain
http://sourceforge.net/forum/message.php?msg_id=3175553

When I set default_target_language to plain in 4.2., no words in any body text
is colored. This behavior seems to have changed in 4.3. Is it right, that I
now have to write @nocolor on top of *every* body text to get rid of randomly
colored words?

What I did:

- Added entries for target_language to ivarsDic and defaultsDict in leoConfig.py.
- Added @language target_language = Python to leoSettings.leo.
- Convert c.target_language to lowercase in several places.
#@+node:ekr.20050620144602: *6* Fixed bug: Mark Clones command did not work
#@+node:ekr.20050620144052.207: *5* New features...
#@+node:ekr.20050620144052.208: *6* Created separate helpers for idle_body_key
idle_body_key now calls doAutoIndent and convertBlanksToTabs. The idea is that
plugins could override these methods if desired.
#@+node:ekr.20050620144052.210: *6* Made all Mark commands undoable
# I also fixed a bug: the Mark Clones command did not work!
#@+node:ekr.20050620144052.222: *6* Removed dependence on profile and pstats modules from leoTest.py
Some non-standard distributions don't include the profile and pstats modules.
#@+node:ekr.20050620144052.231: *6* Added support for tk resource files
Leo will now look for a file called .leo_xresources in the users home directory.
If found, Leo will pass that file to Tk's option_readfile method for the top
widget. This allows users to set Tk options.
#@+node:ekr.20050620144425: *6* Added support for coloring the PL/SQL language
#@+node:ekr.20050523092026: *4* 4.3-final
Leo 4.3 final                 May 23, 2005

Leo 4.3 is here after almost five months of work.

The defining features of Leo 4.3:
---------------------------------
1. Leo now stores options in @settings trees, that is, outlines whose headline
is '@settings'. When opening a .leo file, Leo looks for @settings trees not only
in the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.  Readers of Python's configParser shootout take note!

2. The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

3. Leo now stores recent files information in .leoRecentFiles.txt files.

4. Leo's read/write code in leoAtFile.py has been rewritten to support user-
defined tangling and untangling.  This is a major cleanup of Leo's core.

5. Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables
and disables plugins automatically. This plugin also tells you everything you need to know
about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

6. You can install third-party extensions in Leo's extensions directory. Leo
will attempt to import such extensions from the extensions directory if normal
imports fail. Leo is distributed with Pmw (Python Mega Widgets), path.py and
sets.py in this directory.
#@+node:ekr.20050523092056.1: *5* Fixed crasher when pie-menu plugin enabled
http://sourceforge.net/forum/message.php?msg_id=3155657

Enabling the Pie Menu plug-in caused Leo to quit when opening .leo files.
#@+node:ekr.20050523092056.4: *5* Fixed crasher in Extract Section Command
This fixed a recent bug.
The crash happened if not section text was specified.
Added new checks and new error messages.
#@+node:ekr.20050513141852: *4* 4.3-beta 2
Leo 4.3 beta 2                 May 15, 2005

Leo 4.3 beta 2 completes all major features of Leo 4.3 and fixes all bugs
reported since the beta 1 release.

The defining features of Leo 4.3:
---------------------------------
1. Leo now stores options in @settings trees, that is, outlines whose headline
is '@settings'. When opening a .leo file, Leo looks for @settings trees not only
in the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.  Readers of Python's configParser shootout take note!

2. The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

3. Leo now stores recent files information in .leoRecentFiles.txt files.

4. Leo's read/write code in leoAtFile.py has been rewritten to support user-
defined tangling and untangling.  This is a major cleanup of Leo's core.

5. Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables
and disables plugins automatically. This plugin also tells you everything you need to know
about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

6. You can install third-party extensions in Leo's extensions directory. Leo
will attempt to import such extensions from the extensions directory if normal
imports fail. Leo is distributed with Pmw (Python Mega Widgets), path.py and
sets.py in this directory.
#@+node:ekr.20050513141913.1: *5* Fixed bugs...
#@+node:ekr.20050513141913.16: *6* Fixed nodenavagator bug
http://sourceforge.net/forum/message.php?msg_id=3133917

'Recent' and 'Marked' button now appear in new windows.
#@+node:ekr.20050513141913.17: *6* Fixed LaTex Coloring bug
http://sourceforge.net/forum/message.php?msg_id=3133915

The colorizer now correctly handles the following:

\@, \(, \), \{, \}

And also constructs like \documentclass{report}.
#@+node:ekr.20050513141913.22: *6* Error messages in scripts are now redirected properly.
http://sourceforge.net/forum/message.php?msg_id=3051870
#@+node:ekr.20050513141913.30: *6* Fixed 2 crashers in nav_buttons plugin
The nav_buttons plugin was using self.c rather than keywords.get('c') in a hook
handler. The general rule is that hook handlers should do nothing if self.c !-
keywords.get('c').  This was an old bug, arising from the rewrite of the plugin.

I added a warning to that effect in the plugin template.

It would perhaps be better to specify an optional commander in registerHandler
and only call the handler if the commander matches. However, this isn't so easy
or clean to do.I

The plugin was failing to set the positionList ivar (in the base
tkinterListBoxDialog class). This was a fairly recent blunder: I saw that
positionList wasn't used in the plugin directly, so I 'improved' the code by
using a local var instead of self.positionList. This illustrates a hazard of
using subclassing.
#@+node:ekr.20050513141913.57: *6* Fixed crasher in yoffsetTree
This happened when creating a new chapter with chapters.py enabled.
#@+node:ekr.20050513141913.60: *6* Fixed crasher in undo
The fix was to recompute newSel in << handle backspace with negative tab_width >> in idle_body_key.
#@+node:ekr.20050513141913.82: *6* Fixed  several problems with Extract and Extract Section
- The section name lost its indentation.
- The created section had extra indentation.
- Undoing did not remove the inserted section node.

The unit tests now properly test indentation.
#@+node:ekr.20050513141913.91: *6* Fixed bug with Delete in headlines
http://sourceforge.net/forum/message.php?msg_id=3143895

The Edit->Delete command did nothing when the selected text was in a headline.
#@+node:ekr.20050513141913.127: *6* Fixed bugs re initial_splitter_orientation & @strings & @ints generally
doStrings now accepts either:

@strings[values]name=value
@strings name[values]=value

Similarly, doInts accepts:

@ints[values]name=value
@ints name[values]=value
#@+node:ekr.20050513141913.140: *6* Fixed bug with hoist + insert
http://sourceforge.net/forum/message.php?msg_id=3149604

Changed c.hoistStack[-1].current to c.hoistStack[-1].p in c.insertHeadline.
#@+node:ekr.20050513141913.145: *6* Fixed problem with settings dialog position when panes split horizontally
The code now calls frame.resizePanesToRatio in createFrame in Leo.

Not only does this fix this bug, it honors the following settings:

- initial_horizontal_ratio
- initial_horizontal_secondary_ratio
- initial_vertical_ratio
- initial_vertical_secondary_ratio
#@+node:ekr.20050513141913.149: *6* Fixed problem changing shortcut & redid shortcuts widget
http://sourceforge.net/forum/message.php?msg_id=3138608

Replaced individual shortcuts widget with a single text widget. This allows the
user to add or delete shortcuts.
#@+node:ekr.20050513141913.187: *5* New Features...
#@+node:ekr.20050513141913.97: *6* Marking any node sets the outline changed
The following methods changed:

- markAllAtFileNodesDirty
- markAtFileNodesDirty
- markClones
- markHeadline
- markSubheads

I also rewrote the code using explicit positions.
#@+node:ekr.20050513141913.188: *6* Allow quoted urls in  @urls nodes
http://sourceforge.net/forum/message.php?msg_id=3135170
#@+node:ekr.20050513141913.194: *6* Moved executeFile into core
For a test of this, see the script in test.leo at:

Scripts-->Script to execute @test, @suite or file

Read the documentation in that node before running the script.
#@+node:ekr.20050513141913.197: *6* Rewrote g.getScript using at.writeFromString
g.getScript now fully processes all scripts, regardless of where they came from.

- Changed g.getScript:
    - p arg is now required.
    - Removed unused script arg.
    - Added forcePythonSentinels arg (default is True).
    - g.getScript no longer temporarily alters any body text.
        - atFile.writeFromString gets the initial text using the fromString arg.
    - g.getScript now always calls atFile.writeFromString to handle all Leo directives.

- Added forcePythonSentinels to atFile.initWriteIvars and atFile.scanAllDirectives.
    - Default is None, in which case the code sets forcePythonSentinels to the scriptWrite arg.

- Added forcePythonSentinels to atFile.scanAllDirectives.
    - Default is False.

- Created atFile.putAtFirstLines and atFile.putAtLastLines.
    - These replace the corresponding sections in writeOpenFile.
    - It was not actually necessary to define these, but it cleans up the code.

- Created atFile.writeFromString.
    - This handles all the details of simulating a write _from_ a string _to_ a string.

- atFile.initWriteIvars and atFile.openFileForWriting now allow root to be None.
    - This is not used at present: root is always defined.

- Added fromString arg to atFile.writeOpenFile and atFile.putBody.
#@+node:ekr.20050513141913.233: *6* Added define_name arg to c.executeScript
http://sourceforge.net/forum/forum.php?thread_id=1281640&forum_id=10228

The default is ''.  It define_name exists c.executeScript executes the script in an environment containing
__name__ = define_name.
#@+node:ekr.20050429094215: *4* 4.3-beta 1
Leo 4.3 beta 1                 April 30, 2005

Leo 4.3 beta 1 completes all major features of Leo 4.3. There are no known
significant bugs remaining.

The defining features of Leo 4.3:
---------------------------------
1. Leo now stores options in @settings trees, that is, outlines whose headline
is '@settings'. When opening a .leo file, Leo looks for @settings trees not only
in the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.  Readers of Python's configParser shootout take note!

2. The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

3. Leo now stores recent files information in .leoRecentFiles.txt files.

4. Leo's read/write code in leoAtFile.py has been rewritten to support user-
defined tangling and untangling.  This is a major cleanup of Leo's core.

5. Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables
and disables plugins automatically. 
This plugin also tells you everything you need to know
about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

6. You can install third-party extensions in Leo's extensions directory. Leo
will attempt to import such extensions from the extensions directory if normal
imports fail. Leo is distributed with Pmw (Python Mega Widgets), path.py and
sets.py in this directory.
#@+node:ekr.20050429094215.2: *5* Fixed bugs...
#@+node:ekr.20050429094215.3: *6* Made sure NameErrors are reported with tracebacks in scripts
The initial bug report:

http://sourceforge.net/forum/message.php?msg_id=3048149

The problem arose from a misguided attempt to eliminate non-useful information
from traces. Alas, the baby got thrown out with the bath water.

Here are the changes I made:

 - c.executeScript now calls g.es_exception(full=True) to ensure that a full
 stack trace always gets produced. This is especially important when the
 exception happens in a module (file) called by the script.

- c.executeScript now always executes the section < < dump the lines near the
error > >, regardless of context. The lines are printed (in black) in the log.
This is useful information in almost all cases.

- After much experimentation, g.es_exception is basically unchanged. Note: If
the error occurs in your script itself (as contrasted with an exception thrown
from a file called by your script) Leo always has properly put the cursor on the
offending line. I made no changes in this logic.

BTW, calling pdb.set_trace() in your scripts may cause more problems than it is
worth. Indeed.pdb.set_trace() uses only the information on the stack, and that
may not be enough information to be useful. I usually use g.trace to find out
what is happening. This works well.
#@+node:ekr.20050429094215.22: *6* Finally! fixed .leoID problem!
Initial bug report:

http://sourceforge.net/forum/message.php?msg_id=3053699

There were three similar bugs, all arising from the fact that g.os_path_abs and
g.os_path_join return the _working_ directory if the initial path is None!

I removed my HOME directory for testing. This was essential.

- Compute home directory must return None, rather than the working directory if
the HOME variable is None.

- app.setLeoId must be careful (in two sections) to do nothing if any of
(homeDir,globalConfigDir,loadDir) is None.
#@+node:ekr.20050429094215.31: *6* Investigated problem with LeoPluginsRef.leo
The problem is that newButtons must use @nosent, so any changes to newButtons
must be accompanied by a change to LeoPluginsRef.py. There is nothing more that
needs to be done.
#@+node:ekr.20050429094215.41: *6* Fixed conflicts in menu shortcuts
The De-hoist command conflicted with the Expand/Contract submenu.

The Paste Node As Clone conflicted with the Mark submenu.
#@+node:ekr.20050429094215.113: *6* Fixed bug in p.initStatus caught by pychecker
The status bits weren't being passed to v.initStatus!
#@+node:ekr.20050429094215.116: *6* Fixed crasher in import logic (leoAtFile)
Traceback (most recent call last):
  File "c:\prog\leoCVS\leo\src\leoCommands.py", line 174, in doCommand
    command()
  File "c:\prog\leoCVS\leo\src\leoCommands.py", line 863, in importDerivedFile
    c.importCommands.importDerivedFiles(v,names)
  File "C:\prog\leoCVS\leo\src\leoImport.py", line 137, in importDerivedFiles
    isThin = at.scanHeaderForThin(theFile,fileName)
  File "C:\prog\leoCVS\leo\src\leoAtFile.py", line 570, in scanHeaderForThin
    junk,junk,isThin = at.scanHeader(theFile,fileName)
  File "C:\prog\leoCVS\leo\src\leoAtFile.py", line 2616, in scanHeader
    at.error("Bad @+leo sentinel in: %s" % fileName)
  File "C:\prog\leoCVS\leo\src\leoAtFile.py", line 4500, in error
    self.printError(message)
  File "C:\prog\leoCVS\leo\src\leoAtFile.py", line 4509, in printError
    if self.errors == 0:
AttributeError: atFile instance has no attribute 'errors'
#@+node:ekr.20050429094215.120: *6* Put in protections against unbounded recursion in idle_scrollTo
Traceback (most recent call last):
  File "C:\prog\leoCVS\leo\src\leoTkinterTree.py", line 1409, in idle_scrollTo
    h1 = self.yoffset(p)
  File "C:\prog\leoCVS\leo\src\leoTkinterTree.py", line 1488, in yoffset
    h, flag = self.yoffsetTree(root,v1)
  File "C:\prog\leoCVS\leo\src\leoTkinterTree.py", line 1506, in yoffsetTree
    h2, flag = self.yoffsetTree(child,p1)

# Maximum recursion depth exceeded.

It is still not completely clear why this happened.
#@+node:ekr.20050429094215.130: *5* New features...
#@+node:ekr.20050429094215.131: *6* Created stand-alone leoGlobals.py module
- Moved computeGlobalConfigDir, computeHomeDir, computeLoadDir and
startupEncoding from leo.py to leoGlobals.py.

- Created g.computeStandardDirectories and used it in leo.py.

- Created g.createStandAloneApp using the above functions. This function was
based on the 'Standalone Operation' classed in the plugin_manager plugin.
g.createStandAloneApp doesn't actually use any of these classes because the
nullGui class is basically a clumsier version of the BlackHole class.

- Added a do-nothing attachLeoIcon method to nullGui class to suppress a
warning. As I said, the nullGui class is not as elegant as Paul's BlackHole
class.

- Added <<importLeoGlobals>> button to newButtons plugin. This creates a node
  named << define importLeoGlobals >> whose body text defines an
  importLeoGlobals function.

The idea is that importing leoGlobals from a stand-alone plugin is a bit tricky.
The importLeoGlobals handles these details. Note that we don't want to define
importLeoGlobals in a node included by @others, because this function must be
available to the code in the << imports >> section. So we use a named section
and reference it in before referencing the << imports >> section. See the
plugin_manager plugin for an example.

- Changed the plugin_manager plugin as follows: - Used the newButtons plugin to
    add an << define importLeoGlobals >> section. - Simplified the import logic
    using importLeoGlobals function. - Commented out the Standalone Operation
    classes. - Called g.createStandAloneApp in the '__name__ == "__main__"'
    code.
#@+node:ekr.20050429094215.139: *6* Leo now ignores problems opening settings file for chapters plugin
- config.openSettingsFile returns None if there is a read error.

- leoFileCommand.open gives no BadLeoFile message if silent is True.
#@+node:ekr.20050429094215.145: *6* Improved write logic
- Simplified write_Leo_file using new leoFileCommand.deleteFileWithMessage and g.utils_rename.

- Eliminated outputList var.
    - The code that writes to a clipboard sets self.outputFile to g.fileLikeObject.

- Sped up put routine: it always writes to self.outputFile.

- self.outputFile is now a cStringIo object.  However, the heart of the put routine is:

    s = g.toEncodedString(s,self.leo_file_encoding,reportErrors=True)
    self.outputFile.write(s)

and it appears that the call to g.toEncodedString is the limiting factor.
#@+node:ekr.20050429094215.173: *6* Rewrote the undo code
- Use g.Bunch to simplify code.
- Added 'before' & 'after' methods
- Added entries to optionalIvars dynamically in bead methods.
- Eliminated 'case-itis' by making it unnecessary ever to add more cases.
- Removed 'v' key in undoer:  replaced it with 'p'.
- Replaced u.v by u.p and v by p in find code (It's too confusing).
- p.setDirty and p.setAllAncestorAtFileNodesDirty  return list of nodes that were marked dirty.
- Create new top-level before/after methods & helpers:
- Changed setUndoTypingParams to use new dispatch method.
- Removed makeBeadDict.
- Removed updateSetChangedFlag.
- Added new methods to nullUndoer class.
- Moved undo methods from leoNodes.py to leoUndo.py
- Added dirtyVnodeList param to afterChangeNodeContents.
#@+node:ekr.20050429094215.286: *6* Implemented undo/redo for Paste Retaining clones
#@+node:ekr.20050429094215.316: *6* Added support for 'str_' uA's
The only changes concern how Leo encodes and decodes items in
t.unknownAttributes and v.unknownAttributes.

Without changing the file format, the only way to tell Leo how to write
attributes is to use naming conventions. When writing attributes, Leo now does
the following:

- Do nothing except apply xml escapes if the attribute name (in
t.unknownAttributes or v.unknownAttributes) starts with str_ and the attribute
is, in fact, a string. If the string is a Unicode string Leo converts the
Unicode string to an encoded string.

- Use the present pickling/hexlifying scheming otherwise. In particular, issue a
warning and ignore the attribute if the attribute can not be pickled. BTW, there
is no need for separate base64 support: hexlifying guarantees that the result is
valid in any xml environment.

Leo now does the reverse when reading.

BTW, plugins could add their own naming conventions in an emergency. Indeed, the
conventions will be confined to code in atFile.putUa and atFile.getUa, so a
plugin would only need to override these two methods.
#@+node:ekr.20050429094215.347: *6* Removed unused params from leoAtFile.py
Removed inAtOthers  param from putOpen/CloseNodeSentinel.
Removed inAtAll param from putCloseNodeSentinel.
Removed putCloseSentinel param from putAtAllBody
Removed putCloseSentinel param from putBody

Removed toString param from openFileForWritingHelper
Removed toString param from v.putUnknownAttributes

Note: most(all?) top-level atFile.write methods pass toString to initWriteIvars.
#@+node:ekr.20050429094215.353: *6* Leo  saves recent files info in .leoRecentFiles.txt files
Leo stores recent files information as follows.

1. Leo stores recent files info in files called .leoRecentFiles.txt. These will
be a plain text files with one line per recent files entry. An Easter egg: if
the file starts with read-only, read_only, readonly, etc. Leo will never update
the file and will not remember changes to the Recent Files menu.

2. On startup, Leo searches for the .leoRecentFiles.txt files in the user's home
directory, if it exists. Leo looks in Leo's config directory next, but only if
the home directory does not exist, or does not contain a .leoRecentFiles.txt
file. In other words, Leo will use at most one .leoRecentFiles.txt file on
startup.

3. When opening a .leo file, Leo looks for .leoRecentFiles.txt in the directory
containing the file.

4. At no time after installation does Leo create any .leoRecentFiles.txt file.
This will allow users (or their managers) to set policy regarding where to store
this information (if anywhere).

5. Leo writes at most one .leoRecentFiles.txt file when saving a .leo file,
namely the file read in item 3 if it exists, or the file read in item 2
otherwise.

This is a flexible scheme that should meet most needs without having to resolve
thorny questions about exactly where recent files info belongs.
#@+node:ekr.20050429094215.354: *7* What I did
@killcolor

- Properly implemented undo/redo Clear Recent Files.

- readSettingsFiles now reads @recentfiles nodes from all settings files.

- Created @settings nodes and @recent-files nodes if they do not exist.
#@+node:ekr.20050429094215.355: *7* New plan
You all have convinced me that storing recent files data in .leo files is a
dubious idea. My new plan is as follows:

1. Leo will store recent files info in files called .leoRecentFiles.txt. These
will be a plain text files with one line per recent files entry. These will be
local files, so problems concerning directory structure and path specifications
should go away.

2. On startup, Leo will search for the .leoRecentFiles.txt files in the user's
home directory, if it exists. Leo will look in Leo's config directory next, but
only if the home directory does not exist, or does not contain a
.leoRecentFiles.txt file. In other words, Leo will use at most one
.leoRecentFiles.txt file on startup.

3. When opening a .leo file, Leo will look for .leoRecentFiles.txt in the
directory containing the file.

4. At no time after installation will Leo create any .leoRecentFiles.txt file.
This will allow users (or their managers) to set policy regarding where to store
this information (if anywhere).

5. Leo will write at most one .leoRecentFiles.txt file when saving a .leo file,
namely the file read in item 3 if it exists, or the file read in item 2
otherwise.

6. Leo will have settings to tell which .leoRecentFiles.txt files may be
written.

7. Leo will never create @settings nodes or @recent-files nodes automatically.
Moreover, I shall remove the @recent-files panel from the settings dialog and
the corresponding @recent-files code from the config classes.

I believe this will address everyone's concerns without the need for resolving
thorny questions about exactly where recent files info belongs.
#@+node:ekr.20050429095849: *6* Finished all @settings coding
- Saved expansion state of @settings trees when the user hits the OK button.

- Added support for UNL's in the status line when the settings dialog is active.

- Debugged @if-platform, @if-gui, @ints & @strings.

- Reloaded settings files when opening the settings dialog.

- Removed support for @recent-files nodes.  This is now handled by .leoRecentFiles.txt files.
#@+node:ekr.20050313101229: *4* 4.3-a4
Leo 4.3 alpha 4                 March 15, 2005

Leo 4.3 is the culmination of more than five months of work. This alpha 4
focuses on plugins: all known plugins are now in leoPlugins.leo. Most plugins
now work with the 4.3 code base. Warning: not all plugins have been tested
thoroughly.

This alpha 4 release also adds the frequently-requested Add Comments and Delete
Comments commands to Leo's Edit Body menu.

The defining features of Leo 4.3:

1. Leo now stores options in @settings trees, that is, outlines whose headline
is '@settings'. When opening a .leo file, Leo looks for @settings trees not only
in the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.  Readers of Python's configParser shootout take note!

2. The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

3. Leo's read/write code in leoAtFile.py has been rewritten to support user-
defined tangling and untangling.  This is a major cleanup of Leo's core.

4. Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables
and disables plugins automatically. 
This plugin also tells you everything you need to know
about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

5. You can install third-party extensions in Leo's extensions directory. Leo
will attempt to import such extensions from the extensions directory if normal
imports fail. Leo is distributed with Pmw (Python Mega Widgets), path.py and
sets.py in this directory.
#@+node:ekr.20050313101229.2: *5* Fixed bugs...
#@+node:ekr.20050313101229.74: *6* Fixed @wrap bug
http://sourceforge.net/forum/message.php?msg_id=3035471

Leo was not inserting a visible horizontal scrollbar when @nowrap was in effect.
#@+node:ekr.20050313101229.77: *6* Fixed change-all bug
http://sourceforge.net/forum/message.php?msg_id=3042593

Leo now properly redraws the screen after a Change All command.
#@+node:ekr.20050313103448: *5* New features...
#@+node:ekr.20050313101229.95: *6* Created Add Comments and Delete Comments commands
The Add Comments command puts comments around a block of code. This command uses
single-line comments if the language in effect for the node supports single-line
comments.

The Delete Comments command deletes the comments specified by the Add Comments command.
#@+node:ekr.20050313101229.94: *6* Deprecated new_c key in hooks, added c key
Several hooks use the 'new_c' key in the keywords dictionary. Plugin writers had
to remember whether to get the commander using keywords.get('c') or
keywords.get('new_c') or both. This was needlessly confusing.

All hooks that use the 'new_c' key now use also include the 'c' key. The 'new_c'
key is deprecated; plugins should use the 'c' key instead. 

None of the plugins presently in leoPlugins.leo use the 'new_c' key, but the
'new_c' key still exists for compatibility.

The following plugins were affected by this change:

ConceptualSort.py
URLloader.py
UASearch.py
arrows.py
autocompleter.py
base64Packager.py
cleo.py
dyna_menu.py
macros.py
mod_read_dir_outline.py
mod_scripting.py
multifile.py
nodebar.py
nodenavigator.py
open_with.py
scheduler.py
read_only_nodes.py
templates.py
#@+node:ekr.20050313103448.1: *6* Added the 'before-create-leo-frame' hook
Leo calls the 'before-create-leo-frame' hook just before calling frame.onCreate.
Similarly, Leo calls the 'after-create-leo-frame' just after calling
frame.onCreate.
#@+node:ekr.20050313101229.101: *6* Added support for mod_labels plugin
atFile.copyAllTempBodyStringsToTnodes calls:

    c.mod_label_controller.add_label(p,"before change:",old_body)
#@+node:ekr.20050313101229.100: *5* Revised plugins for the 4.3 code base
Fixed problems in the following plugins. See the << version history >> section
in each plugin for details.

autocompleter.py
cleo.py
mod_scripting.py
mod_tempfname.py
templates.py
vim.py
xemacs.py

Replaced the 'new_c' key by the 'c' key in the following plugins:

ConceptualSort.py
URLloader.py
UASearch.py
arrows.py
autocompleter.py
base64Packager.py
cleo.py
dyna_menu.py
macros.py
mod_read_dir_outline.py
mod_scripting.py
multifile.py
nodebar.py
nodenavigator.py
open_with.py
scheduler.py
read_only_nodes.py
templates.py

Replaced the 'start2' hook by the 'new' hook in the following plugins: (This was
made possible now that 'new' is called when opening a new window if the
'open1/2' hooks are not called.

URLloader.py
UASearch.py
at_produce.py
autocompleter.py
color_markup.py
fastGotoNode.py
groupOperations.py
import_cisco_config.py
multifile.py
nodebar.py
open_with.py
read_only_nodes.py
scheduler.py
table.py
usetemacs.py
xsltWithNodes.py
#@+node:ekr.20050221104844: *4* 4.3-a3
Leo 4.3 alpha 3                 February 24, 2005

Leo 4.3 is the culmination of more than five months of work. This alpha 3
release corrects various bugs in Leo's core and in plugins. This is the first
release that include an installer for MacOSX.

The defining features of Leo 4.3:

1. Leo now stores options in @settings trees, that is, outlines whose headline
is '@settings'. When opening a .leo file, Leo looks for @settings trees not only
in the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.  Readers of Python's configParser shootout take note!

2. The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

3. Leo's read/write code in leoAtFile.py has been rewritten to support user-
defined tangling and untangling.  This is a major cleanup of Leo's core.

4. Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables
and disables plugins automatically.
This plugin also tells you everything you need to know
about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

5. You can install third-party extensions in Leo's extensions directory. Leo
will attempt to import such extensions from the extensions directory if normal
imports fail. Leo is distributed with Pmw (Python Mega Widgets), path.py and
sets.py in this directory.
#@+node:ekr.20050221104844.2: *5* Bugs
#@+node:ekr.20050221104844.12: *6* Applied patch to rst2 plugin
http://sourceforge.net/forum/message.php?msg_id=2999651

I was pleasantly surprised to discover the reST2 plug-in working under 4.3a2
(this is one the first thing I try as I'd like to use Leo as an editor
for that).

As mentioned in early threads, it still needs @rst for each node to be included
in the reST rendering process. So I put @rst test.html and then a child with
@rst and some reST code and it worked !!

Then I tried to to get a simple rst file using @rst test but the plugin complained:

[snip]

  File "C:\dn_apps\Leo\plugins\rst2.py", line 164, in onIconDoubleClick
    writeTreeAsRst(rstFile,fname,p,c)
TypeError: writeTreeAsRst() takes exactly 5 arguments (4 given)

So I looked at the rst2.py and found a way to get it working but I would need
someone to verify it :

line 164, replaced   writeTreeAsRst(rstFile,fname,p,c)  by

syntax = False
writeTreeAsRst(rstFile,fname,p,c,syntax)

And it worked!
#@+node:ekr.20050221104844.14: *6* Revised searchbox plugin so it works with Leo 4.3
#@+node:ekr.20050221104844.27: *6* Fixed bugs in nav_buttons and nodenavigator plugins
http://sourceforge.net/forum/message.php?msg_id=3005140
By: ktenney

- perform a search which marks a number of nodes
- select "Outline -> Mark/Unmark -> Unmark All"
- Several marks are still listed in in the nodenavigator "Marks" list.
  (They are not marked in the outline.)

What I did:

- The p.set/clearMark methods now call the hook _after_ changing the marked status.
  This fixes the apparent bug in nodenavigator.py.
- Rewrote nav_buttons.py.  The old code was a mess; the new code is clean.
- Changed the vnodeList ivar in leoTkinterDialog to positionList.
- Rewrote c.unmarkAll to make clear that it is using positions.
    - Added test_c_unmark_all test routine.
#@+node:ekr.20050221104844.45: *6* Made sure Leo asks for leoID at most once
http://sourceforge.net/forum/message.php?msg_id=2958470
From: Rich

Leo 4.3 alpha 1, build  1.208 , January 24, 2005
Python 2.3.4, Tk 8.4.3, win32

Opened a new .leo file. It asked for an ID, and said it saved it. Closed the
new leo file & tried opening "Leo\config\leoSettings.leo". _It_ is asking for
a leoID!

What I did

All changes were to g.app.leoID():
    - Fixed bug:  set g.app.leoID in << put up a dialog requiring a valid id >>.
    - Improved signon message.
    - Better error handling and reporting. 
#@+node:ekr.20050221104844.54: *6* Fixed botch in g.pdb
g.pdb wasn't working because pdb wasn't imported inside the function.
#@+node:ekr.20050222100936: *6* Fixed crasher when executing a script if the script was selected text in a new window
http://sourceforge.net/forum/message.php?msg_id=3008045

Leo crashed when executing a script if the script was selected text in a new window.

What I did:

- g.getScript now calls g.getOutputNewline(c=c) rather than look at atFile.output_newline.

atFile.output_newline may not exist if a) the file is new and b) g.getScript
doesn't call atfile.write.

- Set scripting=scriptWrite in call to atFile.scanAllDirectives in atFile.write.

This suppresses the following irrelevant message when executing scripts:

    "No absolute directory specified anywhere."
#@+node:ekr.20050221104844.57: *5* New features
#@+node:ekr.20050221104844.58: *6* Added sets.py to distribution
This allows plugins such as plugin_manager.py to work on Python 2.2.x.
#@+node:ekr.20050221104844.59: *6* Added color='suppress' hack to g.es
g.es does nothing if color=='suppress'.  This can be useful in unit tests.
#@+node:ekr.20050126100405: *4* 4.3-a2
Leo 4.3 alpha 2                 February 14, 2005

Leo 4.3 is the culmination of more than four months of work. This alpha 2
release corrects various bugs and distribution problems.

a2 also adds several new features:

- Adds 'word', 'line' and 'node' undo granularities.
- Predefines 'c','g', and 'p' in scripts and unit tests.
- Added support for top-level init functions in plugins.
- Buttons can remove themselves when their scripts fail.

The defining features of Leo 4.3:

1. Leo now stores options in @settings trees, that is, outlines whose headline
is '@settings'. When opening a .leo file, Leo looks for @settings trees not only
in the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.  Readers of Python's configParser shootout take note!

2. The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

3. Leo's read/write code in leoAtFile.py has been rewritten to support user-
defined tangling and untangling.  This is a major cleanup of Leo's core.

4. Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables
and disables plugins automatically. 
This plugin also tells you everything you need to know
about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

5. You can install third-party extensions in Leo's extensions directory. Leo
will attempt to import such extensions from the extensions directory if normal
imports fail.  Leo is distributed with Pmw (Python Mega Widgets) in this directory.
#@+node:ekr.20050130112336.1: *5* To do: Improve how Leo handles recent files
Warning: The following features of @recentfiles nodes are confusing and probably
will be changed:

- Leo does not save recent file information unless the open .leo file has an
@settings tree and an @recentfiles node within the @settings tree. That is, Leo
does not save recent files information in leoSettings.leo files.

- Changing the @rencentfiles node doesn't mark the Leo file as dirty, so if you
don't save the .leo file the recent files information will not be updated.
#@+node:ekr.20050209141626.3: *5* Bugs fixed...
#@+node:ekr.20050209141626.4: *6* Fixed very old bug in Undo Insert Node
http://sourceforge.net/forum/message.php?msg_id=2795653

1. Select a node in the tree
2. Hit CTRL-I to insert a node
3. Hit CTRL-Z to undo the insert
4. There is no longer a node selected in the tree so keyboard tree navigation etc 
commands don't work until you click on something with the mouse

-----

http://sourceforge.net/forum/message.php?msg_id=2795656

1. Select a node in the tree
2. Hit CTRL-I to insert a node
3. Hit CTRL-Z to undo the insert
4. Hit Hoist before clicking on anything

Now you are hoisted on the recently removed node! The node is dead but his memory lives on ...
#@+node:ekr.20050209141626.8: *6* Made sure to remove duplicates from recent files
#@+node:ekr.20050209141626.12: *6* Fixed indentation problems in leoTkinterFind.py
#@+node:ekr.20050209141626.13: *6* Changed leoConfig.txt to leoSettings.leo in Help menu, etc.
#@+node:ekr.20050209141626.16: *6* Investigated recent files problems
http://sourceforge.net/forum/message.php?msg_id=2966541

---- Report:

"Recent Files"  is not remembering files after one closes all open leo sessions.

But it does update the "Recent Files" list while leo is open in the same session.
If one opens more files it adds them to the list. But close all files and Leo
forgets them all.

---- Added to @recentfile documentation: 

Warning: The following features of @recentfiles nodes are confusing and probably
will be changed:

- Leo does not save recent file information unless the open .leo file has an
@settings tree and an @recentfiles node within the @settings tree. That is, Leo
does not save recent files information in leoSettings.leo files.

- Changing the @rencentfiles node doesn't mark the Leo file as dirty, so if you
don't save the .leo file the recent files information will not be updated.
#@+node:ekr.20050209141626.23: *6* Improved queuing of log messages
http://sourceforge.net/forum/message.php?msg_id=2960328

Symptom

Can not import messages were not being sent to the console, even though there is a call to es in g.cantImport.

What I did

- The code in g.es now checks for nullLog as well as log == None when deciding when to queue messages.

- g.openWithFileName now calls g.app.writeWaitingLog immediately after enabling the new log.

This writes the queued log messages in the proper order: a major advance in clarity.

- Added silent param to two methods.

This allows the 'reading settings from' message to be sent to the log instead of the default 'reading' message.
#@+node:ekr.20050209141626.42: *6* Fixed crasher in Change All command
#@+node:ekr.20050209141626.43: *6* Fixed crasher in script button
The new code no longer requires that the present node have a tnodeList.

File "/Users/edream/leoCVS/leo/src/leoAtFile.py", line 3830, in putOpenNodeSentinel
    at.root.v.t.tnodeList.append(p.v.t)

AttributeError: 'tnode' object has no attribute 'tnodeList'
#@+node:ekr.20050209141626.46: *6* Fixed print problems on the Mac
The message 'command for widget 5' was a message from Tk saying in effect that no command was bound to the button.

Indeed, this was so: a recent botch in a change in mod_scripting.py prevented the binding.

Moreover, there were some extra print statements in the g.es logic for the Mac.
#@+node:ekr.20050209141626.53: *6* leoTest.runTests now makes copies of all positions
This makes the test more robust in case of failure.
#@+node:ekr.20050209141626.54: *6* Fixed problems with unit test file paths
Changed the setup code for the import/export test cases so that it uses os.path.sep when it sees \\ in the test nodes.

With this change all unit tests pass on the Mac as well as on XP.
#@+node:ekr.20050209141626.55: *6* Made local config settings work again
*None* of the local settings were working(!!)

The old init code in the configSettings class had no chance of working. We must
use the full g.app.config.get logic.

Added some very simple unit tests to make sure the basics will never break
again so easily.
#@+node:ekr.20050209141626.91: *6* Fix problems searching for nothing but whitespace
There were problems searching for whitespace.

Note: it just ran slowly & silently.
#@+node:ekr.20050210101318: *6* Fixed problems with typing return in the Find panel
Typing return now correctly invokes the Find button, without adding a newline in the find string.
#@+node:ekr.20050209141626.101: *6* Buttons no longer work in toolbars when settings dialog is open
#@+node:ekr.20050209141626.102: *6* Fixed bug in delayed focus logic
http://sourceforge.net/forum/message.php?msg_id=2958470

I opened a new .leo file, and the cursor was flashing in the text box. I started
typing "@language", and found that the first character is in the text box, and
the rest is in the headline!

What I did:

This was the result of a race condition in the new scheme for setting focus. I
rewrote set_focus so the delayed callback always sets the last requested focus.
The new code also takes care to clear the last request after fulfilling it.
#@+node:ekr.20050209141626.105: *6* Made sure Leo asks for leoID at most once
http://sourceforge.net/forum/message.php?msg_id=2958470

All changes were to g.app.leoID():

- Fixed bug:  set g.app.leoID in << put up a dialog requiring a valid id >>.
- Improved signon message.
- Better error handling and reporting. 
#@+node:ekr.20050209141626.113: *6* Leo now prints unicode characters properly in the log pane
This now works: g.es('ﺻﺱ',color='red')

g.es must send the original unicode string to the log pane widget, NOT an encoded string.
#@+node:ekr.20050209141626.114: *6* Fixed various problems with opening files with Unicode filenames
http://sourceforge.net/forum/message.php?msg_id=2983923

- Replaced string.+ with string.% in numerous places.
- Simplified g.openWithFileName and corrected problems in error-reporting logic.
#@+node:ekr.20050211095754: *6* Fixed bug reading encoding field in external files
@nocolor
http://sourceforge.net/forum/message.php?msg_id=2990951
Milan Melena

I think, I found two bugs:

1) leoAtFile.py:
<< read optional encoding param >>
changed first instance of i = j + 1 to i = j + 2

2) leoGlobals.py
g.getScript now returns with

if at.output_newline == 'crlf':
    return script.replace("\r\n","\n")
else:
    return script
#@+node:ekr.20050212054743: *6* Allow indented code blocks to be run using Execute Script command
At present, such indented blocks may not contain Leo directives or section references.  This will be fixed in 4.3a3.
#@+node:ekr.20050212144116: *6* Fixed problems found by pychecker
1. (fixed) C:\prog\leoCVS\leo\src\leoCommands.py:4539: No global (loadDir) found
    # Would cause leoSettings.leo in Window menu to crash.

2. (fixed) C:\prog\leoCVS\leo\src\leoGlobals.py:3426: No global (local) found

    # Local --> locale
    # Might cause getpreferredencoding to fail on *nix.

3. (fixed) C:\prog\leoCVS\leo\src\leoGlobals.py:4152: No global (testing) found
    # Should be self.testing.

4. (fixed) mu problems:
    - Changed x to self.x:
        - C:\prog\leoCVS\leo\src\leoGlobals.py:3795: No global (removeSentinelsFromLines) found
        - C:\prog\leoCVS\leo\src\leoGlobals.py:3838: No global (getSentinelsFromLines) found
    - Changed self.x to g.x:
        C:\prog\leoCVS\leo\src\leoGlobals.py:3854: No class attribute (comment_delims_from_extension) found
    - pull_source has been renamed, I don not know to what.
        C:\prog\leoCVS\leo\src\leoGlobals.py:4170: Object (mu) has no attribute (pull_source)
        (commented out the code that contains this)

5. (removed code) from << create a node p for  kind & root2 >>
    - last_p is None at first, so last_p.insertAfter does not make sense.
#@+node:ekr.20050209141626.150: *5* New features...
#@+node:ekr.20050126100405.1: *6* Added undo granularity
#@+node:EKR.20040524104904.48: *7* Undoing operations
Leo supports unlimited undo for all typing and all commands. The
'undo_granularity' setting controls the granularity of undo. There are four
possible values:

node
    Starts a new undo unit when typing moves to a new node.

line (default)
    Starts a new undo unit when typing moves to new line.

word
    Starts a new undo unit when typing starts a new word.

char (not recommended)
    Starts a new undo unit for each character typed.
    This wastes lots of computer memory.

Internally, setUndoTypingParams() calls recognizeStartOfTypingWord() to recognize the
start of words. Plugins can modify recognizeStartOfTypingWord(). It should
return True if the typing indicated by the params starts a new 'word' for the
purposes of undo with 'word' granularity. setUndoTypingParams() calls this
method only when the typing could possibly continue a previous word. In other
words, undo will work safely regardless of the value returned. See the actual
code for recognizeStartOfTypingWord() for more details.
#@+node:ekr.20050209141626.185: *6* Added support for top-level init function in plugins
When loading plugins, the Leo checks to see if the plugin has an init function
at the top level (the module level). If so, Leo calls the init function. This
function should return True (or equivalent) if the module loaded correctly.

If the top-level init function does not exist, Leo assumes the module loaded
correctly.
#@+node:ekr.20050209141626.190: *6* Changed name of Paste Retaining Clones to Paste Node As Clone
#@+node:ekr.20050209141626.193: *6* Added leoPlugins.leo to Help menu
#@+node:ekr.20050209141626.194: *6* Script buttons can request to be removed
A script in an @button node or script node can now request to be removed by
setting g.app.scriptDict['removeMe'] = True. Leo checks this value after
executing the script in the button.
#@+node:ekr.20050209141626.195: *6* Improved documentation in several nodes in leoSettings.leo
#@+node:ekr.20050209141626.196: *6* Predefined c,g & p in scripts, unit tests & test routines
@nocolor

Added define_p keyword arg in executeScript. When True (the default), the script
or unit test is run in an environment in which c, p and g are all defined.
c is the commander for the outline in which the script appears.
p is the same as c.currentPosition and g is the leoGlobals module.

Therefore, the following lines need never appear in scripts or unit tests!

@color

import leoGlobals as g
p = c.currentPosition()
#@+node:ekr.20050209141626.198: *6* Changed name of Preferences command to Settings
#@+node:ekr.20050122090311: *4* 4.3-a1
Leo 4.3 alpha 1                 January 24, 2005

Leo 4.3 is the culmination of more than four months of work. 

The defining features of Leo 4.3:

1. Leo now stores options in @settings trees, that is, outlines whose headline
is '@settings'. When opening a .leo file, Leo looks for @settings trees not only
in the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.  Readers of Python's configParser shootout take note!

2. The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

3. Leo's read/write code in leoAtFile.py has been rewritten to support user-
defined tangling and untangling.  This is a major cleanup of Leo's core.

4. Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables
and disables plugins automatically. This plugin also tells you everything you need to know
about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

5. You can install third-party extensions in Leo's extensions directory. Leo
will attempt to import such extensions from the extensions directory if normal
imports fail.
#@+node:ekr.20050123112834: *5* Defining features of 4.3
#@+node:ekr.20050123110009: *6* Using @settings trees and leoSettings.leo
Leo now stores options in @settings trees, that is, outlines whose headline is
'@settings'. When opening a .leo file, Leo looks for @settings trees not only in
the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.

The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

For full details, see the children of this node.
#@+node:ekr.20050122084954: *7* Using leoSettings.leo and @settings trees
Leo stores options in @settings trees, that is, parts of Leo outlines whose root node has the headline @settings.  When opening a .leo file, Leo looks for @settings trees in the following places:

- The file called leoSettings.leo in the leo/config directory.
- The file called leoSettings.leo in the users home directory.
- The file being loaded.

Settings that later in the above list override settings found earlier. For
example, any setting specified in an @settings tree in the file being loaded
overrides any setting seen in any leoSettings.leo file.

The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings dialog" pane. This settings dialog pane allows
you to change the settings selected in the outline pane using standard gui
widgets.

The format of nodes in @settings trees are as follows:

1. "Simple settings nodes" have headlines of the form:

@<type> name = val

set the value of name to val, with the indicated type.

<type> may be one of the following, with valid values shown:

<type>          Valid values
-----           ------------
\@bool           True, False, 0, 1
\@color          A Tk color name or value, such as 'red' or 'xf2fddff' (without the quotes)

For a list of Tk color specifiers see:

- http://www.tcl.tk/man/tcl8.4/TkCmd/colors.htm
- http://www.tcl.tk/man/tcl8.4/TkLib/GetColor.htm

\@directory      A path to a directory
\@float          A floating point number of the form nn.ff.
\@int            An integer
\@ints[list]     An integer (must be one of the ints in the list).
                 Example: @ints meaningOfLife[0,42,666]=42
\@path           A path to a directory or file
\@ratio          A floating point number between 0.0 and 1.0, inclusive.
\@string         A string
\@strings[list]  A string (must be one of the strings in the list).
                 Example: @strings tk_relief['flat','groove','raised']='groove'

2. "Complex settings nodes" have headlines of the form:

\@<type> description

The actual settings are specified in the body text.  At present, there are two such kinds of complex settings nodes:

- @font

The body text contains a list of settings for a font.  For example:

body_text_font_family = Courier New
body_text_font_size = None
body_text_font_slant = None
body_text_font_weight = None

- @recentFiles

The body text contains a list of paths of recently opened files, one path per line.

Warning: The following features of @recentfiles nodes are confusing and probably
will be changed:

- Leo does not save recent file information unless the open .leo file has an
@settings tree and an @recentfiles node within the @settings tree. That is, Leo
does not save recent files information in leoSettings.leo files.

- Changing the @rencentfiles node doesn't mark the Leo file as dirty, so if you
don't save the .leo file the recent files information will not be updated.

3.  All other nodes are "Organizer" nodes.  Such nodes have no effect on the settings shown in the dialog.  You may use them as you please to organize settings.

Notes:

A.  At present, you can not change @settings trees while executing the Settings command.  You can, however, change any @settings tree normally when not executing the Settings command.

B. Other kinds of settings nodes are planned for future releases.
#@+node:ekr.20050122091036: *7* Unfinished configuration features
The essential features of @settings trees and the settings dialog appear to be stable.  However, many improvements can be imagined, including the following:

- Allow searching for nodes while in the settings dialog.

- Allow adding, deleting, rearranging nodes while in the settings dialog.

- Allow adding, deleting, rearranging recent files while in the settings dialog.

These will be added as time permits and people request.
#@+node:ekr.20050123092834.520: *6* Rewrote Leo's read/write logic
The new code greatly simplifies the class structure. The intention is to allow plugins to override methods of this file more easily.

The highlights:

- Plugins may now override methods in this file much more easily.
    - All code is now in a single class.
    - Resolved the few name conflicts by renaming x to x3 or x4.
    - The new code generally uses methods instead of sections.
    - Initialization is now simple and sane, and is done in dedicated methods.
    - All constants are class constants: no more module-level constants.

- All top-level methods support toString or fromString arguments.
#@+node:ekr.20050123115804: *6* Added Plugins Manager plugin
Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables and
disables plugins automatically.This plugin also tells you everything you need to
know about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

Note. The Plugins Manager plugin requires Pmw. You can install Pmw in Leo's
extensions directory if you like.
#@+node:ekr.20050123115804.1: *6* You can install third-party extensions in Leo's extensions directory
You can can import any extension to Leo by putting the extension in the 'extensions' directory and using g.importExtension to import it.

- created the 'extensions' directory and g.app.extensionsDir

- created g.importModule and g.importExtension
#@+node:ekr.20050123092834.1: *5* Fixed bugs...
#@+node:ekr.20050123101208: *6*  Major bugs: these bugs corrupted external files!
#@+node:ekr.20050123092834.432: *7* Fixed double doc part bug
Leo did not correctly write adjacent @doc parts in @file trees.  Leo could not read the resulting external files!

The bug happened if any node in an @file tree contains adjacent @doc parts, like this:

@  first doc part
...
@ second doc part
...

Leo failed to write the closing #@-at sentinel that would finish the first @doc part.
#@+node:ekr.20050123092834.497: *7* Fixed bug in how Leo writes thin external files
Leo did not properly write external files that contained section references to grand-children.

For example:

<< current level>>
  reference to << 3. level>>
    << 1.level>>
        << 2.level >>
            << 3.level>>

The fix was simply to reverse the order in which putRefAt puts +middle and -middle sentinels.
#@+node:ekr.20050123092834.2: *6* Commands
#@+node:ekr.20050123092834.6: *7* Fixed problems with spawnv option of openWith
The Open With logic in createOpenWithMenuFromTable for the 'spawnv' case now
actually calls os.spawnv (rather than spawnl) and it allows a variable length
list of parameters.
#@+node:ekr.20050123092834.19: *7* Fixed bug in  Remove Sentinels command
The old code wasn't handling single file selections properly. The new code works
around an apparent bug in Tk.askopenfilename.
#@+node:ekr.20050123092834.27: *7* Fixed bug re Paste Node As Clone
The new code forbids Paste Node As Clone if the paste would result in a node being a clone of itself.
#@+node:ekr.20050123092834.42: *7* Fixed Pretty Print commands for Python 2.4
The '@' sign is an operator in Python 2.4, not an error token.
#@+node:ekr.20050123092834.71: *7* Fixed crasher in Import external files command
What I did:

- Created a new top-level method: scanHeaderForThin.

This sets self.encoding temporarily. The actual value of self.encoding does not
really matter: no errors will be given by readLine and its helpers even if there
are unicode encoding errors.

- We must _not_ set self.encoding in scanHeader: that would interfere with
normal initialization.
#@+node:ekr.20050123092834.510: *7* Search commands are now restricted to hoisted area
#@+node:ekr.20050123100706.1: *6* Distribution
#@+node:ekr.20050123092834.491: *7* Fixed file association in leoDist.leo
Changed the open command associated with .leo files on Windows from:

pythonw.exe "<leodir>\src\leo.py" %1

to:

"pythonw.exe" "<leodir>\src\leo.py" "%1"

The difference is in quotes.  Especially quotes around "%1" seem to matter.
#@+node:ekr.20050123092834.165: *6* Files
#@+node:ekr.20050123092834.492: *7* g.import wrappers return module if it is in sys.modules
This is an important difference. imp.load_module is equivalent to a reload, so
we must not call this if the module already exists!
#@+node:ekr.20050123092834.166: *7* Disabled changes to comment delims in @@language and @@comment sentinels
he readDirective method was changing the comment delimiters as the result of
seeing the sentinels corresponding to @language or @comment directives. But in
general this makes no sense! Comment delimiters should be set once and for all
in the @+leo sentinel: there is no compiler in the world that tolerates mixed
comment delimiters.

BTW, the way to set javascript "inner" comments is to use @delims, not @comment.
N.B. The @language and @comment delimiters _will_ have an effect, and that
effect is in the _write_ logic, not the read logic. The effect is to set the
comment delims in the @+leo sentinel.

The quick fix is to comment out code in readDirective.
#@+node:ekr.20050123092834.176: *7* Made sure files that differ only in line ending get written if @lineending is in effect
The old code did not honor the @lineending directive if the two files would otherwise be identical.

What I did:

- Added self.explicitLineEnding to remember whether an explicit @lineending directive is in effect.

- Make sure the user knows why an otherwise identical file was written.

- Changed name of compareFilesIgnoringNewlines to compareFiles.

- Added ignoreLineEndings arg to compareFiles.
#@+node:ekr.20050123092834.196: *7* Fixed bug:  @nosent wrote sentinels!
The fix was to add nosentinels=nosentinels in the call to initWriteIvars in atFile.write.
#@+node:ekr.20050123092834.422: *7* Fixed bug in replaceTargetFileIfDifferent
This method now does nothing if at.toString is True.
#@+node:ekr.20050123092834.424: *7* Made sure that @ignore forces writing of inner @thin trees
#@+node:ekr.20050123092834.431: *7* Fixed crasher when attempting to write a external file to an invalid path
#@+node:ekr.20050123092834.434: *7* Fixed Python 2.4 deprecation warning when saving .leo files
The new code uses protocol=1 instead of the deprecated bin argument to Pickler.
#@+node:ekr.20050123092834.499: *7* Fixed crasher in getOutputNewline
In some cases g.app.config.output_newline was None.  The new code sets the default to '', and then assigns a valid default to ''.
#@+node:ekr.20050123092834.544: *7* Always use os.rename in utils_rename
Apparently distutils.file_util is not present in all Python distributions!

New approaches:
    - Fall back on code in distutils.file_util if import fails.
    - Make sure the src and dst volumes are the same (so Linux os.rename will always work)
    - Simplify replaceTargetFileIfDifferent by creating new routines.

What I did:
    - Rewrote replaceTargetFileIfDifferent in terms of atFile.rename, atFile.remove, etc.
    - Rewrote update_file_if_changed in terms of g.utils_rename, g.utils_remove, etc.
#@+node:ekr.20050123151338: *7* Fixed bugs handling @language & @comment in atFile.scanAllDirectives & g.scanDirectives)
Changed scanDirectives and atFile.scanDirectives so they work like
tangle.scanAllDirectives. Also added a few clarifying words in LeoDocs.leo.

This should have worked, but didn't:

+ Code 
  @language python 
  + @file sql_create.sql 
    @comment -- 

So I rearranged the outline (probably more logical anyway) to  
+Code 
  + Python 
  ... 
+ SQL 
  ... 
#@+node:ekr.20050123103303: *6* Gui
#@+node:ekr.20050123092834.502: *7* Put the scrollWheel workaround in createTkTreeCanvas
This binds scroll-wheel events to Button-4 and Button-5
#@+node:ekr.20050123100706.2: *6* Menus
#@+node:ekr.20050123092834.81: *7* Fixed problems with Control-E
- Restored non Pmw code in resizePanesToRatio. This code got deleted by mistake.
The Equal Sized Panes works again.

- Added many do-nothing methods to nullMenu class.

This should prevent the startup logic from messing with shortcuts in any way.
It's also the right thing to do.

- Added an entry for EqualSizedPanes to leoSettings.leo. This overrides the
default (Ctrl-E) and thereby prevents the default from overriding the entry for
ExecuteScript!

- Re-enabled code in createMenuEntries that warns when shortcuts have been
redefined. Not sure if this is a wise idea, or indeed if it actually does
anything :-)

I am tempted to remove all the default entries entirely. This would simplify
error reporting, but then Leo would hardly work at all if leoSettings.leo were
not present.
#@+node:ekr.20050123092834.490: *7* Better handling of duplicate menu shortcuts
The code now clears previous shortcut, and tells what the previous entry was.
#@+node:ekr.20050123092834.159: *6* Nodes
#@+node:ekr.20050123092834.160: *7* Fixed crash after cutting an imported node
p.moveToParent now just returns if p is a null position.
#@+node:ekr.20050123092834.163: *7* Removed invalid assert in lastVisible
# Leo looped after this assert failed.
#@+node:ekr.20050123093854.1: *7* Fixed bugs in tnodes_iter and unique_tnodes_iter
tnodes_iter and unique_tnodes_iter were returning vnodes, not tnodes!
#@+node:ekr.20050123111723: *6* Plugins
#@+node:ekr.20050123092834.1047: *7* Fixed two bugs in Plugins Manager plugin
- This plugin now handles both kinds of triple-quotes correctly so that both
kinds of docstrings are recognized.
#@+node:ekr.20050123092834.1052: *7* Fixed bug re referencing destroyed ivars
Created callTagHandler. This checks 'idle' hooks to make sure that any commander
referenced by the 'c','new_c' or 'old_c' keywords still exists.
#@+node:ekr.20050123092834.1057: *7* Fixed bug in registerOneHandler
leoPlugins.registerOneHandler wasn't working properly at all. In effect, only
the last registered hook was ever being remembered!
#@+node:ekr.20050123092834.506: *7* Fixed conflict between settings panel and chapters plugin
chapters.py requires that the canvas have a name ivar.

Added treeCanvas.name = '1' in:

<< replace tree pane with settings tree >>
#@+node:ekr.20050123092834.526: *6* Pychecker
Fixed shadow warnings.  The following are all Python global functions:

cmp -> compare
dict -> theDict
dir -> theDir
file -> theFile
id -> theId
type -> theType
input  (suppressed the warning)
iter -> theIter
#@+node:ekr.20050123092834.438: *6* Scripting
#@+node:ekr.20050123092834.439: *7* Fixed unbounded recursion with --script and redirected output
The problem was that nullLog.write calls print, and if print is redirected the
code ends up calling nullLog.write again.

What I did:

- g.redirectClass.redirect does nothing if g.app.batchMode is True.
- added g.rawPrint.
- Changed self.old.write(s) to self.old.write(s+'\n') throughout.
#@+node:ekr.20050123092834.474: *7* Script buttons now execute the entire script
It makes no sense to use only the selected text.
#@+node:ekr.20050123092834.480: *7* Fixed error reporting in executeScript when the error happens outside the script
The old code assumed that the error is always in the script itself. Not true!
The error could happen in methods called by the script.

This code works with Python 2.3.4 and Python 2.4.  It may be version dependent.
#@+node:ekr.20050123092834.486: *6* Startup
#@+node:ekr.20050123092834.487: *7* Non-existent command-line file becomes name of new Leo wiindow
Leo now sets the name of the frame to the requested file name on the command line even if the file name does not exist.
#@+node:ekr.20050123092834.1011: *7* computeHomeDir now handles references to other vars
computeHomeDir() now test the first retrieval of the %HOME% var and grab it's
results if it is in fact another environment variable.
#@+node:ekr.20050123092834.896: *5* New or improved features...
#@+node:ekr.20050123110009: *6* Using @settings trees and leoSettings.leo
Leo now stores options in @settings trees, that is, outlines whose headline is
'@settings'. When opening a .leo file, Leo looks for @settings trees not only in
the outline being opened but also in various leoSettings.leo files.

The key design goal of @settings trees was that Leo's user options must be
infinitely flexible. That goal has been accomplished. Indeed, users can create
arbitrarily complex user options with @settings trees. Leo settings outlines
are, in fact, infinitely more flexible and powerful than any scheme based on
flat text.

The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings pane". This settings pane allows you to change
the settings selected in the outline pane using standard gui widgets. The
settings pane is dynamically created from nodes in the settings tree; it is as
extensible as the @settings tree itself.

For full details, see the children of this node.
#@+node:ekr.20050122084954: *7* Using leoSettings.leo and @settings trees
Leo stores options in @settings trees, that is, parts of Leo outlines whose root node has the headline @settings.  When opening a .leo file, Leo looks for @settings trees in the following places:

- The file called leoSettings.leo in the leo/config directory.
- The file called leoSettings.leo in the users home directory.
- The file being loaded.

Settings that later in the above list override settings found earlier. For
example, any setting specified in an @settings tree in the file being loaded
overrides any setting seen in any leoSettings.leo file.

The Settings command temporarily replaces the outline pane with an outline
showing all the @settings trees in effect. The Settings command also replaces
the body pane with a "settings dialog" pane. This settings dialog pane allows
you to change the settings selected in the outline pane using standard gui
widgets.

The format of nodes in @settings trees are as follows:

1. "Simple settings nodes" have headlines of the form:

@<type> name = val

set the value of name to val, with the indicated type.

<type> may be one of the following, with valid values shown:

<type>          Valid values
-----           ------------
\@bool           True, False, 0, 1
\@color          A Tk color name or value, such as 'red' or 'xf2fddff' (without the quotes)

For a list of Tk color specifiers see:

- http://www.tcl.tk/man/tcl8.4/TkCmd/colors.htm
- http://www.tcl.tk/man/tcl8.4/TkLib/GetColor.htm

\@directory      A path to a directory
\@float          A floating point number of the form nn.ff.
\@int            An integer
\@ints[list]     An integer (must be one of the ints in the list).
                 Example: @ints meaningOfLife[0,42,666]=42
\@path           A path to a directory or file
\@ratio          A floating point number between 0.0 and 1.0, inclusive.
\@string         A string
\@strings[list]  A string (must be one of the strings in the list).
                 Example: @strings tk_relief['flat','groove','raised']='groove'

2. "Complex settings nodes" have headlines of the form:

\@<type> description

The actual settings are specified in the body text.  At present, there are two such kinds of complex settings nodes:

- @font

The body text contains a list of settings for a font.  For example:

body_text_font_family = Courier New
body_text_font_size = None
body_text_font_slant = None
body_text_font_weight = None

- @recentFiles

The body text contains a list of paths of recently opened files, one path per line.

Warning: The following features of @recentfiles nodes are confusing and probably
will be changed:

- Leo does not save recent file information unless the open .leo file has an
@settings tree and an @recentfiles node within the @settings tree. That is, Leo
does not save recent files information in leoSettings.leo files.

- Changing the @rencentfiles node doesn't mark the Leo file as dirty, so if you
don't save the .leo file the recent files information will not be updated.

3.  All other nodes are "Organizer" nodes.  Such nodes have no effect on the settings shown in the dialog.  You may use them as you please to organize settings.

Notes:

A.  At present, you can not change @settings trees while executing the Settings command.  You can, however, change any @settings tree normally when not executing the Settings command.

B. Other kinds of settings nodes are planned for future releases.
#@+node:ekr.20050122091036: *7* Unfinished configuration features
The essential features of @settings trees and the settings dialog appear to be stable.  However, many improvements can be imagined, including the following:

- Allow searching for nodes while in the settings dialog.

- Allow adding, deleting, rearranging nodes while in the settings dialog.

- Allow adding, deleting, rearranging recent files while in the settings dialog.

These will be added as time permits and people request.
#@+node:ekr.20050123103303.1: *6* Code
#@+node:ekr.20050123092834.520: *7* Rewrote Leo's read/write logic
The new code greatly simplifies the class structure. The intention is to allow plugins to override methods of this file more easily.

The highlights:

- Plugins may now override methods in this file much more easily.
    - All code is now in a single class.
    - Resolved the few name conflicts by renaming x to x3 or x4.
    - The new code generally uses methods instead of sections.
    - Initialization is now simple and sane, and is done in dedicated methods.
    - All constants are class constants: no more module-level constants.

- All top-level methods support toString or fromString arguments.
#@+node:ekr.20050123092834.173: *7* Added g.cantImport
#@+node:ekr.20050123092834.901: *7* Added g.fileLikeObject.readline
This supports the fromString option in read commands.
#@+node:ekr.20050123092834.928: *7* Added support for g.app.debugSwitch in es_exception
It's not clear that this support is so useful for debugging scripts.

If g.app.debugSwitch is True es_exception gives a full traceback.
#@+node:ekr.20050123092834.984: *7* Restored drawing/event hooks
Restored the following hooks:

"boxclick1"     before click in +- box            c,p,v,event
"boxclick2"     after  click in +- box            c,p,v,event
"drag1"         before start of drag              c,p,v,event
"drag2"         after  start of drag              c,p,v,event
"dragging1"     before continuing to drag         c,p,v,event
"dragging2"     after  continuing to drag         c,p,v,event
"enddrag1"      before end of drag                c,p,v,event
"enddrag2"      after  end of drag                c,p,v,event

The following already existed.  I added v=p keyword params:

"iconclick1"    before single click in icon box   c,p,v,event
"iconclick2"    after  single click in icon box   c,p,v,event
"iconrclick1"   before right click in icon box    c,p,v,event
"iconrclick2"   after  right click in icon box    c,p,v,event
"icondclick1"   before double click in icon box   c,p,v,event
"icondclick2"   after  double click in icon box   c,p,v,event
#@+node:ekr.20050123092834.1004: *7* Added p=p param to all hooks containing v=v
Changed these hooks:

"bodyclick1", "bodyclick2",
"bodydclick1", "bodydclick2",
"bodyrclick1", "bodyrclick2",
"bodykey1", "bodykey2",
"command1", "command2",
"headclick1", "headclick2",
"headrclick1", "headrclick2",
"headkey1", "headkey2", 
"hyperclick1", "hyperclick2",
"hyperenter1", "hyperenter2",
"hyperleave1", "hyperleave2", 
"openwith1", "openwith2",
"menu1", "menu2", 
"recentfiles1", "recentfiles2",
"save1", "save2",
"select1", "select2", "select3",
"start2",
"unselect1", "unselect2",
"url1", "url2", 

"clear-mark", "set-mark", 
"color-optional-markup",
"create-popup-menu", 
"draw-outline-icon",
"draw-outline-node",
"draw-outline-text-box",
"draw-sub-outline", 
"init-color-markup",
"scan-directives", 
"draw-outline-box",
"enable-popup-menu-items",
"show-popup-menu",
#@+node:ekr.20050123092834.565: *7* Implemented delayed focus scheme
Leo's code now contains an important simplification to Leo's gui code. This
arose because of a problem in the UNL plugin. The window that opened when double
clicking an @url UNL node wasn't staying on top.

It turns out that this was essentially impossible to fix with the old code. The
proximate cause of the original problem button-1 was bound to OnActivateTree,
which called g.app.gui.set_focus after the new window was visible, thereby
bringing the old tree to the front.

Further investigation revealed other problems. For example, the idle-time code
in the status line logic was also messing with the focus. It turns out that
repeatedly calling g.app.gui.set_focus is a very bad idea, for lots of reasons
which I won't go into in detail here.

The old code called g.app.gui.set_focus explicitly whenever it wanted focus to
change. But there is a much better way, namely to have routines that _indicate_
where they want the focus to be "after the dust settles", that is, when all gui
calls have been completed. I call this a "delayed focus" scheme.

So I rewrote all the code that sets the focus. The new code replaces direct
calls to g.app.gui.set_focus with calls to the following methods in
leoTkinterFrame class: bodyWantsFocus, statusLineWantsFocus, treeWantsFocus and
logWantsFocus. Actually, these xWantsFocus methods all do the same thing, but
using different methods improves traces.

This is an excellent pattern. Again, rather than setting the focus directly,
these xWantsFocus methods merely signal their intension to set the focus. This
allows very complex logic to be hidden in leoTkinterFrame.set_focus.

leoTkinterFrame.set_focus is indeed complex. It took me several hours this
morning to get it just right. It queues up a 'one-shot' callback. That is, at
most one copy of the callback is ever waiting to be executed. Furthermore, the
callback is only queued for execution at the result of a call to xWantsFocus; it
is never run automatically at idle time. Finally, even when executed, the
callback does nothing if the last requested commander (in the new ivar,
g.app.wantedFocus) does not match the commander to which the callback was bound.

These checks allow the UNL plugin to open a window properly and keep it topmost.

This is a big step forward for Leo, for the following reasons:

- Delayed focus ensures that the body pane always has focus unless the code has
a specific, positive reason for the focus to be elsewhere. This was difficult
(or rather impossible) to do with the old code: there are _many_ Tk calls that
can affect the focus.

- Delayed focus minimizes calls to g.app.gui.set_focus. Unlike the old code,
many seconds may elapse between calls. The stress on Tk is much less, and I
believe this may cure some flakiness in how focus changes, especially in
headlines.

- There are some cases where focus must change immediately. The xWantsFocus
methods all support a 'later' keyword argument. By default it is True, but when
it is False leoTkinterFrame.set_focus calls g.app.gui.set_focus immediately.

- The xWantsFocus methods all support a 'tag' keyword argument that tells what
routine the method is called from. It is a big help in making sense of traces.
BTW, extensive traces are the _only_ possible way of tracking down
focus/selection problems.
#@+node:ekr.20050123103521: *6* Commands
#@+node:ekr.20050123092834.897: *7* Added 'Expand Or Go Right' and 'Contract or Go Left' commands
These commands work as do the similar commands in Windows Explorer. How did we
ever live without them?
#@+node:ekr.20050123092834.908: *7* Added keyboard shortcuts to find panel
- Tab toggles between the Search to the Replace areas.

- Control-Tab inserts a tab.

- Added hot keys for all settings.  Use Alt-x to activate hot key x.
  The Enter key activates the Find button.

- As usual, Alt-F4 dismisses the Find panel.
#@+node:ekr.20050123092834.1005: *7* Find panels are now associated with individual Leo windows
Leo no loner has any global windows!

- Each commander has its own find window.
    - It's title tells to what commander it applies.
#@+node:ekr.20050123105026: *7* Find panels are now inited from @settings nodes
- Leo now ignores all find settings in .leo files.  Instead, Leo inits find settings from @settings entries.

- Removed all c ivars corresponding to leoFind ivars.
    - This eliminates the ugliest code in Leo.
    - Inits all leoFind ivars from @settings in init, a helper of the ctor.
    - Updates all the leoFind ivars in update_ivars, called just before doing any find.

- Removed the _flag suffix from leoFind ivars.
    - Another major mess cleaned up.

- Renamed find/change_text to find/change_ctrl to avoid name conflict.
#@+node:ekr.20050123092834.961: *7* Improved Go To Line Number and Execute Script commands
- Go To Line Number command now assumes the presently selected node is a script if there is no ancestor @file node.

- Execute Script command uses this new logic to select the proper node and line in a script if there is an error.

How did we ever live without these features?
#@+node:ekr.20050123092834.1018: *7* Improved support for relative path names
Actually, support already existed for them in getBaseDirectly!

What I did.

- Added a c keyword to getBaseDirectory.
- Added similar logic to os_path_join.

- Changed some stupid code in g.openWithFileName (called by @url logic):
    changed: fileName = g.os_path_join(os.getcwd(),fileName)
    to:      fileName = g.os_path_abspath(fileName)

MAYBE g.os_path_abspath should force '.' to mean c.openDir, but I kinda doubt
it. This could be asking for trouble.

OTOH, the various flavors of scanAllDirectives already do this.  Hmmmmmm.
#@+node:ekr.20050123092834.1043: *7* Implemented 'Undo Clear Recent Files'
#@+node:ekr.20050123092834.517: *7* Removed old-style write commands
Leo can still read such files, but old-style file formats are now deprecated
#@+node:ekr.20050123092834.1044: *6* Plugins & extensions
#@+node:ekr.20050123115804: *7* Added Plugins Manager plugin
Leo now boasts a wonderful new Plugins Manager plugin. This plugin enables and
disables plugins automatically.This plugin also tells you everything you need to
know about each plugin. Finally, this plugin also lets you download plugins from
Leo's cvs site! Many thanks to Paul Patterson for this excellent work.

Note. The Plugins Manager plugin requires Pmw. You can install Pmw in Leo's
extensions directory if you like.
#@+node:ekr.20050123115804.1: *7* You can install third-party extensions in Leo's extensions directory
You can can import any extension to Leo by putting the extension in the 'extensions' directory and using g.importExtension to import it.

- created the 'extensions' directory and g.app.extensionsDir

- created g.importModule and g.importExtension
#@+node:ekr.20050123112151: *7* Improved doHandlersForTag
- leoPlugins.doHandlersForTag now executes the list of hook handlers for a
particular tag (hook name) until one of the handlers returns a non-None result.
doHandersForTag no longer tries to "sort" handlers, so the order that the
handlers are executed is the order in which they were registered.

I finally understand the concerns people have raised several times about hooks
interfering with each other. If two handlers try to return a non-None result
only one of them will ever execute. doHandlersForTag can't do much about this: a
better solution would require more conceptual framework. Not now...
#@+node:ekr.20050123092834.1013: *7* Leo now associates modules with hook handlers
#@+node:ekr.20050123103753: *6* Syntax Coloring & languages
#@+node:ekr.20050123092834.903: *7* Added support for Ada
Thanks to Bernhard Mulder for the new code.
#@+node:ekr.20050123092834.929: *7* Added support for Forth
Thanks to David McNab <david@freenet.org.nz> for this work.
#@+node:ekr.20060206111717.1: *3* 4.4 minibuffer, keys, autocompletion, multiple log panes
#@+node:ekr.20051219150602: *4* 4.4 alpha 5
Leo 4.4 alpha 5                                             January 6, 2006

This release completes the last major features of Leo 4.4:

- User-specified key-binding modes.
- Support for multiple key-bindings for individual minibuffer commands.

This will be the last alpha version of Leo 4.4. Beta 1 is coming in about a
week. You should be able to use this version safely; there are no known serious
bugs.

To learn about Leo, see: http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
----------------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name. Support for tab completion.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Support for most commands in the Emacs Cmds menu, including cursor and screen
movement, basic character, word and paragraph manipulation, and commands to
manipulate buffers, the kill ring, regions and rectangles.

- Per-pane key bindings. You can bind shortcuts to multiple commands depending
on which of Leo's panes presently has focus. For example, you can use arrow keys
to move nodes in the outline pane, while retaining their defaults in Leo's body
pane.

- User-specified key-binding modes. This feature makes it possible to emulate all
aspects of Emacs and Vim as far as key bindings are concerned.

- @command nodes create minibuffer commands. You can bind key shortcuts to
@button and @command nodes.

- Leo recovers from crashes much more reliably than in any previous version.

- Leo handles keystrokes and updates the screen immediately rather than waiting
for idle time.
#@+node:ekr.20051219150602.2: *5* Fixed bugs
#@+node:ekr.20051219150602.3: *6* Made sure focus doesn't go to log during tab completion or after writes to log
#@+node:ekr.20051219150602.7: *6* Fixed problem with getScript in batch mode
#@+node:ekr.20051219150602.10: *6* Text box is now selected in goto-line-number command
http://sourceforge.net/forum/message.php?msg_id=3464874
#@+node:ekr.20051219150602.13: *6* Restored headkey  & bodykey hooks
http://sourceforge.net/forum/message.php?msg_id=3466412

New in Leo 4.4: Leo calls the 'headkey1' and 'headkey2' hooks only when the user
completes the editing of a headline, and ch is always '\r', regardless of
platform.

http://sourceforge.net/forum/message.php?msg_id=3462294
#@+node:ekr.20051219150602.28: *6* Fixed ancient bug in read error logic that hung Leo
http://sourceforge.net/forum/message.php?msg_id=3467558

What I did:

- atFile.readError deletes root's entire subtree.
- atFile.read only warns about unvisited node if there is no error.
#@+node:ekr.20051219150602.75: *6* Fixed many headline problems
http://sourceforge.net/forum/message.php?msg_id=3461068

And a recent bug: clicking in the expand/contract box didn't save the headline.
#@+node:ekr.20051219150602.81: *6* Fixed problem in reformatParagraph
The problem was caused by the recent change to g.app.gui.setTextSelection.

The default for the new 'insert' keyword must be sel.end for compatibility with old code.
#@+node:ekr.20051219150602.85: *6* Installed LeoUsers patch
Read @file Nodes and Import external file commands no longer create copies of the root node.
#@+node:ekr.20060105182648.376: *6* Improved Import external files command.
Leo no longer creates a duplicate root node when importing external files.

The code is due to LeoUser.
#@+node:ekr.20060105182648.377: *6* Fixed crasher in backwardDeleteCharacter
#@+node:ekr.20060105182648.378: *6* Fixed recent bug: dialogs now get focus properly when first opened.
#@+node:ekr.20060105182648.379: *6* Made sure shortcuts are printed clearly by k.registerCommand
#@+node:ekr.20060105182648.382: *6* Suppressed crash undoing a clone followed by a drag
The reason for this assert is unclear.
#@+node:ekr.20051219150602.100: *5* New features
#@+node:ekr.20051219150602.101: *6* created ut.leo, ut.py and ut.bat
The provide batch-mode unit testing.
#@+node:ekr.20051219150602.102: *6* Added modes/*.xml to distribution
#@+node:ekr.20051219150602.105: *6* Revised cursor movement commands and added selection-extension commands
Leo now supports the following commands, shown below with their present bindings:

back-char ! text = LtArrow
back-char-extend-selection ! text = Shift-LtArrow
back-paragraph ! text = Alt-braceleft 
back-paragraph-extend-selection ! text = Alt-Shift-braceleft
back-sentence ! text = Alt-a 
back-sentence-extend-selection  = None
back-word ! text = Alt-b  # No conflict   
back-word-extend-selection  ! text = Alt-Shift-b
beginning-of-buffer ! text = Alt-less # Note: same as Alt-Shift-less
beginning-of-buffer-extend-selection  = None
beginning-of-line ! text = Ctrl-a
beginning-of-line-extend-selection = None
exchange-point-mark = None
forward-char ! text = RtArrow
forward-char-extend-selection ! text = Shift-RtArrow
forward-paragraph ! text = Alt-braceright
forward-paragraph-extend-selection ! text = Alt-Shift-braceright
forward-sentence ! text = Alt-e
forward-sentence-extend-selection ! text = Alt-Shift-e
forward-word ! text = Alt-f
forward-word-extend-selection ! text = Alt-Shift-f
next-line ! text = DnArrow
next-line-extend-selection  ! text = Shift-DnArrow
previous-line ! text = Uparrow
previous-line-extend-selection ! text = Shift-UpArrow

The -extend-selection variants move the cursor and also extend the selection
from the insert point in the indicated direction. As usual exchange-point-mark
switches the insert point from one side of the selection to the other: which
side of the selection the insert point is on does make a difference.

I also added three commands that implement so-called 'extend mode':

clear-extend-mode = None
set-extend-mode = None
toggle-extend-mode = None

When extend mode is on (it is off at first), all cursor movement commands listed
above extend the selection. Very handy. Thanks to Brian for this suggestion.

This is the start of mouseless Leo. For the first time all the common Emacs
cursor-movement commands exist. These commands should work in any text widget.
#@+node:ekr.20051219151926: *6* Added classic key bindings in leoSettings.leo
leoSettings.leo now contains a node called:

@@shortcuts traditional Leo bindings

This node contains the 'classic' Leo key bindings that appeared in Leo 4.3. I
have proofed these settings carefully, but some errors may remain. Please report
any errors or any other suggestions for these settings.
#@+node:ekr.20060105182648.432: *6* Allow multiple key bindings to the same command
#@+node:ekr.20060105182648.469: *6* Settings command now opens leoSettings.leo
This is the end of the ill-fated settings dialog.

Important: you can use the show-colors and show-fonts commands to help set
colors and fonts in leoSettings.leo.
#@+node:ekr.20051028051444: *4* 4.4 alpha 4
Leo 4.4 alpha 4                                         December 5, 2005

Leo 4.4 a4 introduces the 'Newer World Order' for redrawing the screen,
corrects numerous bugs in the 4.4 code base, and introduces several new features.

You should be able to use this version safely. There are no known serious bugs,
but several minibuffer commands are not ready for prime time. All the major
features of 4.4 are in place.

To learn about Leo, see: http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
----------------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name. Support for tab completion.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Support for almost all commands in the Emacs Cmds menu, including cursor
and screen movement, basic character, word and paragraph manipulation, and
commands to manipulate buffers, the kill ring, regions and rectangles.

- Per-pane key bindings. You can bind shortcuts to multiple commands depending
on which of Leo's panes presently has focus. For example, you can use arrow keys
to move nodes in the outline pane, while retaining their defaults in Leo's body
pane. Per-pane key bindings are essential for mouseless Leo.

- @command nodes create minibuffer commands. You can bind key shortcuts to
@button and @command nodes.

- A rewrite of Leo's keystroke handling. In particular, Leo handles key events
immediately rather than queuing them for idle time.

- Leo recovers from crashes much more reliably than in any previous version.

- Leo updates the screen immediately rather than waiting for idle time.
This 'Newer World Order' simplifies the code and improves performance.

Known bugs in Leo 4.4a4
-----------------------
- Several minibuffer commands do not work.  See the release notes for details.

Coming in later releases of Leo 4.4:
------------------------------------
- An auto-complete command that shows class members in the Completion tab.

- More support for mouseless Leo. There will be commands to manipulate all
aspects of Leo using commands, so your fingers will never have to leave the
keyboard.

- Support for Vim and other 'plain-key' input modes.
#@+node:ekr.20051028051444.1: *5* Quick Start
Here are the default bindings relating to the minibuffer. Any of
these may be changed by changing @shortcuts nodes in leoSettings.leo.

Alt-x: Just like Emacs: starts minibuffer. The prompt is 'full-command' Type a
full command name, then hit <Return> to execute the command. Tab completion
works, but not for file names.

Alt-c: Like Emacs Control-C: (Ctrl-C conflicts with XP cut). starts minibuffer.
The prompt is 'quick-command'. This mode is not completed, but stuff like
`Ctrl-C r` and `Ctrl r r` do work.

Alt-u: Like Emacs Ctrl-u: (Ctrl-u conflicts with move-outline-up). Add a repeat
count for later command. Ctrl-u 999 a adds 999 a's, but many features remain
unfinished.

Ctrl-g: Just like Emacs Ctrl-g: Closes the mini-buffer.

The @bool useMinibuffer setting in leoSettings.leo just controls whether the
minibuffer is visible. The minibuffer exists (and you can type into it) even if
it isn't visible! You can use the show-mini-buffer, hide-mini-buffer and
toggle-mini-buffer commands to show or hide the minibuffer.
#@+node:ekr.20051028051444.2: *5* The 'key' features of 4.4
The most important new features of Leo 4.4 have to do with key bindings.

See the children of this node for details.


#@+node:ekr.20051101161405: *6* Leo's minibuffer works like the Emacs mini-buffer
At the bottom of Leo's window you will now see an area labeled the mini-buffer.
You can't type in it directly, you activate the buffer by typing Alt-x or Alt-c.
Typing Alt-x takes you to 'full-command' mode. Type the full name of a command,
followed by a 'return'. 

- To get help, type Alt-x help.
- For a list of commands, type Alt-x print-commands.
- For a list of present key bindings, type Alt-x print-bindings.
- To leave the mini-buffer at any time type Ctrl-g.

Note: you can redefine any of these keys as you wish.

Important: you can execute any of Leo's 'legacy' commands from the mini-buffer.
For example, Alt-x about-leo or Alt-x open-find-dialog. Note: Leo's Find
*dialog* is deprecated. You will find it much more convenient to use Leo's new
Find *tab*. Use the open-find-tab command.

You can use tab-completion in the minibuffer to cycle through the list of
commands that start with what is in the buffer. Typing backspace takes you back
to the what you previously typed (less on character.) The 'Completion' tab shows
all possible completions. This tab appears automatically when you type a tab in
the minibuffer.

The mini-buffer reduces the need for shortcuts dramatically. For example, none
of Leo's import commands need a shortcut because it is easy enough to execute
them from the minibuffer. In particular, executing commands from the minibuffer
is much easier than executing commands by hand from a menu. 
#@+node:ekr.20051101161405.1: *6* @shortcuts nodes in leoSettings.leo allow per-pane bindings
leoSettings.leo contains one functional @shortcuts node and one disabled
@@shortcuts node. These node contain entries for every command.

You can assign key shortcuts to any command, as discussed in the comments in
that file. You can leave the nodes as they are, use them as base for
modifications, or roll your own. You should define a binding for every function,
even if that binding is 'None'. If you don't, Leo will issue a warning.

Leo now supports per-pane bindings.  Bindings of the form:

command-name ! pane = shortcut

bind the shortcut to the command only withing a single pane. The possible values
for 'pane' are:

pane    affected panes
----    --------------
all     body,log,tree
body    body
log     log
mini    minibuffer
text    body,log
tree    tree
#@+node:ekr.20051101161405.2: *6* The scripting plugin allows key bindings
The scripting plugin has been improved in two ways:

1. You can specify key bindings in @button nodes as follows:

@button name @key=shortcut

This binds the shortcut to the script in the script button. The button's name is
'name', but you can see the full headline in the status line when you move the
mouse over the button.

2. You can create new minibuffer commands with @command nodes:

@command name @key=shortcut

This creates a new minibuffer command and binds shortcut to it.
#@+node:ekr.20051101161405.3: *6* EKR shortcuts
Abbreviations may not work at present. A new kind of abbreviation is presently
hard coded in add_ekr_altx_commands in leoKeys.py. For example, one ekr-shortcut
is: 'f', which is bound to leo-find-panel. Typing Alt-x f Return executes
leo-find-panel. These may be quicker than Emacs abbreviations, or not.
#@+node:ekr.20051101162123: *6* Leo now ignores key bindings in menu tables
These 'hard-coded' bindings are no longer needed and interfere with per-pane bindings.
#@+node:ekr.20051205091625: *5* Status of minibuffer commands
- The abbreviation and buffer commands are not ready yet.

- repeat-complex-command does not work.

- Moving the cursor when the 'mark' has been defined does not expand the visibly
selected text.

- Yanking and killing have not been well tested.

- C-u 5 <return> works but is not undone properly. Also, the kill-line command
does not work as in Emacs.

- Many new commands must be generalized to handle the more complex environment
Leo offers. For example, search commands must be told whether to limit the
search a single node, or a node or and its descendants, or the entire outline.
We need a set-variable command that sets a (Python) variable using an
emacs-style variable name.

- The notion of the 'point' must be expanded so it indicates a node as well as
text location.

- New commands are needed to support 'mouseless-Leo'. The user must be able to
drive all dialogs from the keyboard, or to get the same effect without using a
dialog at all. Examples: dismiss-top-dialog, scroll-outline-up/down. We also
need commands to change focus and to manage menus. Examples: focus-in-body,
focus-in-tree, etc, activate-edit-menu, etc.
#@+node:ekr.20051028051616: *5* New in alpha 1...
#@+node:ekr.20051028051444.4: *6* New options
#@+node:ekr.20051028051444.5: *7* The @bool useMinibuffer option
1. The minibuffer exists regardless of this setting, but will not be shown
   initially if it is False.

2. Hiding the minibuffer does not change any bindings or the operation of Leo in
   any other way. Therefore, if you do hide the minibuffer initially, and never
   want to use it, you should not bind shortcuts to any commands that use the
   minibuffer.

3. You can execute the show-mini-buffer, hide-mini-buffer and toggle-mini-buffer
   commands (or any other minibuffer command!) if the minibuffer is hidden.
   Indeed, the following will work even if the minibuffer is hidden.

       <alt-x>show-mini-buffer<return>
#@+node:ekr.20051028051444.6: *7* The @bool useCmdMenu option
This option controls whether Leo creates a Cmds menu.

This menu is not ready yet, though nothing bad happens if this option is True.
#@+node:ekr.20051028051444.7: *7* Options for selected body text
http://sourceforge.net/forum/message.php?msg_id=3355954

'body_text_selection_background_color'  Default is 'Gray80'
'body_text_selection_foreground_color'  Default is 'white'
#@+node:ekr.20051028051444.8: *6* New mini-buffer commands
- The contract-and-go-right command moves to the parent node and collapses the
parent node.

- The goto-first-sibling and goto-last-sibling commands allow rapid movement
through an ouline without collapsing nodes.

- The print-bindings and print-commands show what commands exist and what keys
are bound to them.

- The help command gives a brief quick start introduction to Leo's Emacs-like
features.
#@+node:ekr.20051028051444.9: *6* New code-level features
#@+node:ekr.20051028051444.10: *7* Dictionaries of keys and commands
Leo maintains the following dictionaries.  As usual, k refers to c.keyHandler:

- c.keyHandler.registerCommand can be called from scripts to register new alt-x
  commands. It probably won't work from plugins yet.

New dictionaries and methods make it easier to customize and extend Leo:

- c.commandsDict describes all commands. Keys are full Emacs command names;
values are functions f.

- k.inverseCommandsDict: keys are f.__name__, values are emacs command names.

- k.leoCallbackDict: keys are leoCallback functions, values are called
functions.

- k.bindingsDict: keys are shortcuts, values are g.bunches with the following
    members: func, name, warningGiven, fromMenu.
#@+node:ekr.20051028051444.11: *7* Functions that return the present key bindings
The following helper functions make it easy to discover the binding presently in
effect for a command:

- k.getShortcutForCommandName(self,commandName) returns the shortcut given
  f.__name__.

- k.getShortcutForCommand(self,f) returns the shortcut for f.
#@+node:ekr.20051028051444.12: *7* Added registerCommand helper
c.k.registerCommand (self,commandName,shortcut,func)

This function make the func available as a minibuffer command, and optionally
binds a shortcut to func. You can wrap any method in a function, so the
restriction to functions is not significant.

Here is an example take from an @button node::

k = c.keyHandler

def f (event):
    g.es_print('Hello',color='purple')

k.registerCommand('print-hello','Alt-Ctrl-Shift-p',f)
k.registerCommand('print-hello2',None,f)
#@+node:ekr.20051028051444.13: *6* Bugs fixed (in 4.3 code base)
The following bugs exist in 4.3 final.
#@+node:ekr.20051028051444.14: *7* Leo protects c.endUpdate with a 'finally' clause
This makes it much harder to hang Leo after taking an exception. Leo 4.4a1 is
*much* more robust than Leo 4.3 final in this regard.
#@+node:ekr.20051028051444.15: *7* Added kludge to solve infamous control-v problems
Added big kludge to menu.createMenuEntries so that f.OnCut/Copy/PasteFromMenu get called
**only** when explicitly selected from the menu (rather than from a shortcut).
This allows the code in cut/copy/paste-text to be different as needed.

Users can override the shortcut by assigning shortcuts to cut/copy/paste-text commands.
The shortcut will appear in the menu, but does **not** get bound to c.frame.menu.

This is an essential step in solving the infamous Control-V problem.
The code appears to work properly on XP.  Not tested other places.

This is the last best hope to solve this problem: the code interacts as little as possible with Tk.
#@+node:ekr.20051028051444.16: *7* Fixed bug in Leo's read logic
http://sourceforge.net/forum/message.php?msg_id=3351985

Leo did not read empty tnodes like <t/> properly.
#@+node:ekr.20051028051444.17: *7* Fixed bug in goto-last-node.
#@+node:ekr.20051028051444.18: *7* Leo now reads @settings trees when opening a .leo file from another outline.
http://sourceforge.net/forum/message.php?msg_id=3376527
#@+node:ekr.20051028051444.19: *7* Improved g.removeExtraLws
It now computes the minimum leading whitespace of all non-blank lines. The old
code computed the leading whitespace of the *first* non-blank line. This would
give the wrong results if the first line were indented.
#@+node:ekr.20051028051616.1: *5* New in alpha 2
#@+node:ekr.20051101162123.1: *6* The tabbed log
- The open-find-tab command opens the Find tab.

- The open-spell-tab command opens the Spell-checking tab.

The Find and Spell *tabs* replace the corresponding legacy *dialogs*. Using tabs
eliminates previous problems with dialogs obscuring Leo's main window.

Two essential components of the settings dialog now are implemented in the tabbed log:

- The show-colors command creates the 'Colors' tab in the log pane.

- The show-fonts command creates the 'Fonts' tab in the log pane.

These two tabs allow you to pick color or font names without using the @settings dialog.

Important: scripts and plugins can easily create new tabs in the Log pane. See
Chapter 7 of the Users Guide for details.
#@+node:ekr.20051028051616.172: *7* Programming the tabbed log
@color

# Plugins and scripts can easily create new tabs in the log panel.
# Important: you can run any of these examples using the 'Run Script' button.

# To create a tab named "Test" or make it visible if it already exists:

c.frame.log.selectTab('Test')

# When first created, a tab contains a text widget.
# To write to this widget, add the tabName argument to g.es:

g.es('Test',color='blue',tabName='Test')

# Plugins and scripts can easily replace the default Text widget with other Tk widgets.
# c.frame.log.tabFrame contains the Tk.Frame that contains all the other widgets of the frame.
# c.frame.log.logCtrl contains the Tk.Text widget that is initially the only widget in this frame.
# So to remove this text widget just do:

c.frame.log.logCtrl.pack_forget()

# Now you can pack any other widgets into c.frame.log.tabFrame.

import Tkinter as Tk ; log = c.frame.log
log.selectTab('Test')
log.logCtrl.pack_forget()
f = Tk.Frame(log.tabFrame,bg='red',height='1inch',width='2inch')
f.pack(side='left',expand=0,fill='none')
#@+node:ekr.20051028061322: *6* New minibuffer commands
**Important**: The print-bindings and print-commands commands (new in a1) show
what commands exist and what keys are bound to them.

- The help command tells how to use the minibuffer.

- The show-minibuffer, hide-minibuffer and toggle-mini-buffer commands show and hide the minibuffer.

It *is* possible to execute these command even if the minibuffer isn't presently
visible. For example, typing 

<alt-x>toggle-mini-buffer<return>

should always work.

- The open-find-tab command opens the Find tab. The Find tab replaces the old
Find panel. The Find panel is deprecated.

- The open-spell-tab command opens the Spell-checking tab.

- The show-colors command creates the 'Colors' tab in the log pane. This tab allows you to
experiment with picking fonts.

- The show-fonts command creates the 'Fonts' tab in the log pane. This tab allows you to
experiment with picking colors.
#@+node:ekr.20051028051616.299: *6* Optional generation of closing brackets
Leo can optionally generate matching brackets depending on the setting:

@bool autocomplete-brackets = TrueOrFalse

If True, Leo will immediately type the corresponding closing bracket whenever
you type a '(', '[' or '{' character. You can use the forward-char command to
move past the closing bracket, and Leo will move past any closing bracket if you
type the closing bracket with the cursor just to the left of a closing bracket.
#@+node:ekr.20051101182739: *6* New settings in leoSettings.leo
- The node::

    @shortcuts traditional Leo shortcuts with important emacs bindings

contains Leo key bindings.

- The spelling settings in leoSettings.leo replace the settings in spellpyx.ini.

- You can specify the background of tabs using the following pattern::

    @color log_pane_XXX_tab_background_color = aColor

For example::

    @color log_pane_Find_tab_background_color = #d6c7d3

- The @bool autocomplete-brackets setting controls whether Leo types a matching
closing bracket immediately when you type '(', '[' or '{'.
#@+node:ekr.20051101161949: *6* Improved and retired plugins
#@+node:ekr.20051028051616.160: *7* Improved the scripting plugin
@nocolor

The scripting plugin has been improved as follows:

1. You can bind shortcuts in @button nodes.  Like this:

@button name @key=shortcut

This binds the shortcut to the script in the script button. The button's name is
'name', but you can see the full headline in the status line when you move the
mouse over the button. This is a clean and simple way of discovering the
shortcut.

2. You can create your own minibuffer commands with @command nodes.

A node whose headline has the form:

@command command-name

a new minibuffer command whose name is 'command-name'.

A node whose headline has the form:

@command command-name @key=shortcut

creates new minibuffer command and binds shortcut to it.

3. The scripting plugin no longer contains the 'bindLate' code-level option. The
scripts for all @button or @command nodes are computed 'dynamically', that is,
when the button is pushed or the command is executed from the minibuffer. This
is the most useful way, and the most intuitive.

Previously, scripts for @button nodes were never dynamic, while scripts in
@button nodes created by the 'Script button' button were dynamic only if
bindLate was True. You could call this a bug: it was unhelpful, annoying and
confusing.

4. The scripting plugin no longer prints an 'end of script' message. This allows
scripts to select tabs in the log pane
#@+node:ekr.20051101162947: *7* Retired the TabbedLog plugin
Leo's core now supports tabs in the log pane.
#@+node:ekr.20051101163145: *6* Many code-level improvements
Leo 4.4a2 contains a large number of code-level improvements--some very
significant. For full details, see the (Projects) section of LeoPy.leo.
#@+node:ekr.20051101163404: *6* Fixed minor bugs
The following bugs existed in the 4.4a1 code base and have now been fixed:

- Removed warnings from compare dialog.
#@+node:ekr.20051109112610: *5* New in alpha 3
#@+node:ekr.20051109112826: *6* The New and Newer World Orders
@nocolor

The New World Order means that drawing happens immediately, not at idle time.

The Newer World Order means that c.endUpdate is equivalent to c.redraw_now.
#@+node:ekr.20051109141223: *6* Bugs fixed...
#@+node:ekr.20051109112826.217: *7* Fix crasher in Open logic
http://sourceforge.net/forum/message.php?msg_id=3411030

The fix was to add guards so the code does not assume w._name exists for all widgets w.
#@+node:ekr.20051109112826.227: *7* (Undo ends editing
#@+node:ekr.20051109112826.257: *7* Disabled minibuffer when not in use
For now, I just set c.useTextMinibuffer = False,
so Leo uses a Tk.Label rather than a Tk.Text widget.

This will cause less confusion than always having the minibuffer enabled.
#@+node:ekr.20051109112826.315: *7* Fixed bug in Find Backward
http://sourceforge.net/forum/message.php?msg_id=3418304

Fixed an edge effect when backward searching for a match that occurs at the very
end of body text. In the process I removed an ancient hack.
#@+node:ekr.20051109112826.265: *7* Improved Spell tab
http://sourceforge.net/forum/message.php?msg_id=3415021

The code now uses the settings in leoSettings.leo.
#@+node:ekr.20051109141524: *6* New features
#@+node:ekr.20051109112826.222: *7* Created scripts.leo and unitTest.leo
Scripts.leo contains general-purpose scripts.

unitTest.leo contains all of Leo's unit tests.

test.leo is now for recent tests.  Its small size speeds up my workflow.
#@+node:ekr.20051109112826.254: *7* c.executeMinibufferCommand executes a minibuffer command by name
http://sourceforge.net/forum/message.php?msg_id=3412644

You can invoke minibuffer commands by name.  For example:

c.executeMinibufferCommand('open-outline')

Note: c.keyHandler.funcReturn contains the value returned from the command. In
many cases, as above, this value is simply 'break'.
#@+node:ekr.20051109112826.310: *7* Improved perl entries in language dicts
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3414639

The entries for Perl and Perlpod are now as follows:

@color

self.language_extension_dict = {
    "perl" : "pl",
    "perlpod" : "pod",
}

self.extension_dict = {
    "pl"    : "perl",
    "pod"   : "perlpod",
}
#@+node:ekr.20051109141524.1: *6* Code-level changes
#@+node:ekr.20051109112826.223: *7* Changed  edit_text to edit_widget everywhere
Changed the following plugins:

cleo.py, footprints.py,__wx_gui.py, zodb.py
#@+node:ekr.20051109112826.224: *7* Removed tree ivars
Removed tree.redrawScheduled, tree.updateCount and tree.disableRedraw

Three major complications are gone.
#@+node:ekr.20051109142920: *7* Removed frame.begin/endUpdate
This code should never have existed.  It was used only in the macro plugin.
#@+node:ekr.20051128181229: *5* New in alpha 4
#@+node:ekr.20051128181351: *6* Bugs fixed
#@+node:ekr.20051128181302.148: *7* Changed scripting plugin so files opened with buttons stay in front
The plugin can not call bodyWantsFocus.
#@+node:ekr.20051128181302.183: *7* Fixed undo/redo bugs
http://sourceforge.net/forum/message.php?msg_id=3434727

- Added calls to c.frame.body.onBodyChanged in cut/paste handlers.

- Added call to c.selectPosition(c.currentPosition()) in undo/redo.
    This is essential because previous calls to c.selectPosition may have had redraw_flag = False.
#@+node:ekr.20051128181302.192: *7* Fixed focus problem with tab completion
#@+node:ekr.20051128181302.193: *7* Fixed minor Save bug
http://sourceforge.net/forum/message.php?msg_id=3425967

When creating a new Leo outline (no leo file created yet), the Save As command
created the file Test4.leo instead of the expected Test4.3.leo
#@+node:ekr.20051128181302.231: *7* Fixed long-standing problem with Plugins Manager plugin
http://sourceforge.net/forum/message.php?msg_id=3442064

This was not, in fact, a problem with the plugins manager plugin.

The bug was in << put up a dialog requiring a valid id >> in app.setLeoID.
The code set g.app.gui to None after calling g.app.gui.runAskLeoIDDialog the code set!

While I was at it, Leo's core now always inits Pmw when creating Tk.Tk. This
removes the necessity for Plugins to do this.
#@+node:ekr.20051128181302.244: *7* Fixed 2 outline editing bugs
1: Outline not marked dirty during editing

https://sourceforge.net/forum/message.php?msg_id=3447570

2: Inserting a headline didn't save previous edits of headlines
#@+node:ekr.20051205090923.13: *7* Fixed crasher in deleteNextChar
#@+node:ekr.20051205090923.16: *7* Fixed new headline bug
http://sourceforge.net/forum/message.php?msg_id=3450435
#@+node:ekr.20051205090923.22: *7* Fix problems applying settings
http://sourceforge.net/forum/message.php?msg_id=3389810
#@+node:ekr.20051128181302.204: *7* Fixed several bugs in rst3 plugin
http://sourceforge.net/forum/message.php?msg_id=3427809

Allowed relative path to stylesheets.

http://sourceforge.net/forum/message.php?msg_id=3433717

The rst3 plugin now traverses the tree as was done previously in the @button rst3 nodes.

http://sourceforge.net/forum/message.php?msg_id=3456419

The rst3 plugin now looks up and down the tree for settings doc parts.

The rst3 plugin now supports the default_path option.
#@+node:ekr.20051128181651: *6* Code changes
Leo 4.4a4 completes the transition to the 'Newer World Order'.
#@+node:ekr.20051128181302.149: *7* Removed later arg from c.frame.xWantsFocus
Later may never come in the Newer World Order, so everything must happen immediately.
#@+node:ekr.20051128181302.196: *7* Created enableTclTraces
#@+node:ekr.20051128181302.208: *7* Eliminated w.update in g.app.gui.set_focus
@nocolor

- The focusIn/Out trace is a great tool.

- doTabCompletion now calls w.update before calling bodyWantsFocus.

- Eliminated w.update from g.app.gui.set_focus.  It is now called only in
those places where it is truly essential, such as in k.doTabCompletion and
wherever else it might be required.

- Pmw.Notebook does a *lot* when it switches panes (e.g., the _layout method)
and potentially any of the things it does could result in focus shifting to
widget. Rather than trying to make sense of it all, Leo will simply call
w.update as necessary to force completion of the Pmw.Notebook work before trying
to set focus.
#@+node:ekr.20051128181651.1: *6* New & improved features and files
#@+node:ekr.20051128181302.147: *7* Moved all scripts into scripts.leo
#@+node:ekr.20051128181302.150: *7* Improved how the New Tab and Rename Tab commands work in the log pane
This ensures that the widget is always visible.
#@+node:ekr.20051128181302.151: *7* Improved the appearance of the Spell tab
#@+node:ekr.20051128181302.156: *7* Added Clone-find checkbox to the Find tab
http://sourceforge.net/forum/message.php?msg_id=3425070

This code was contributed by Roger Erens.

When the Clone Find All checkbox is checked, the Find All command creates a new
root node called Found: <your search pattern>

This node contains clones of the nodes found by the Find All command. It is your
own responsibility to navigate to this new node and to clean it up when it's no
longer needed.
#@+node:ekr.20051128181302.171: *7* Improved find tab
The tab now scrolls properly.
#@+node:ekr.20051128181302.211: *7* Improved formatting of shortcuts in print-commands and print-bindings
#@+node:ekr.20051128181302.213: *7* Added settings for vim plugin
http://sourceforge.net/forum/message.php?msg_id=3440420

Added @string vim_cmd and @string vim_exe settings. The defaults now correspond
to default installations of vim.
#@+node:ekr.20051128181302.214: *7* Put up a dialog if can't import Pmw
http://sourceforge.net/forum/message.php?msg_id=3436726

The dialog warns about the extensions folder not containing Pmw. This can happen
when getting files from cvs.
#@+node:ekr.20051128181302.229: *7* Bound <Return> to end-edit-headline
http://sourceforge.net/forum/message.php?msg_id=3437089

The new default binding causes focus to move to the body pane when the user hits
<Return> to end editing in a headline.
#@+node:ekr.20060116174906: *4* 4.4 beta 1
Leo 4.4 beta 1                                             January 17, 2006

The code is stable; there are no known serious bugs. Some features are
incomplete.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060116174906.2: *5* Bugs fixed
#@+node:ekr.20060116174906.3: *6* Fixed minor headline problems
A 'backward' delete at the start of a headline deletes the first character.
delete-char did not work in headlines.
#@+node:ekr.20060116174906.63: *6* Fixed undo problems
http://sourceforge.net/forum/message.php?msg_id=3465251
#@+node:ekr.20060116174906.86: *6* Improved word-export plugin
http://sourceforge.net/forum/message.php?msg_id=3495741

The plugin now uses sys.getdefaultencoding() to set the encoding.
#@+node:ekr.20060116174906.87: *6* Removed a bad use of g.app.log in the find panel
This could have been the source of weird find behavior.
#@+node:ekr.20060116174906.88: *6* Fix crash: tab in minibuffer
The fix was to have x.getSelectedText return '' instead of None.
#@+node:ekr.20060116174906.90: *6* Installed patch for headline width
http://sourceforge.net/forum/message.php?msg_id=3510983
#@+node:ekr.20060116174906.97: *6* Redraw screen properly after Move To Next Dirty
#@+node:ekr.20060116174906.100: *6* Fixed focus bug
https://sourceforge.net/forum/message.php?msg_id=3514627

c.endUpdate now restores the previous focus by default.
#@+node:ekr.20060116174906.103: *6* Made sure to bring proper window on top in settings.leo button
#@+node:ekr.20060116174906.104: *6* Arrow keys now clear the text selection
http://sourceforge.net/forum/message.php?msg_id=3514755
#@+node:ekr.20060116174906.113: *6* Fixed several minor bugs
http://sourceforge.net/forum/message.php?msg_id=3515341
#@+node:ekr.20060116174906.118: *6* Fixed problems with plugins
http://sourceforge.net/forum/message.php?msg_id=3509141

Problems with cleo.  Installed patch: http://sourceforge.net/forum/message.php?msg_id=3517080

https://sourceforge.net/forum/message.php?msg_id=3515025

Problems with fastgotonode and and groupOperations.
#@+node:ekr.20060116174906.122: *6* Fixed old file handling bug
http://sourceforge.net/forum/message.php?msg_id=3518722

To generate HTML file I entered the outline header "@file bbb.xml" under which
I put the following body text:

//////////////// beginning of excerpt
@first <?xml version="1.0" encoding="windows-1250" ?>
@language html
@
comment line
@c
@others
//////////////// end of excerpt

This works OK.
But, if I put a space after the sole @ above "comment line",  save and close
the .leo file and then open it, Leo protests in log pane on the right:

//////////////// beginning of excerpt
----- error reading @file: bbb.xml
Missing open block comment
//////////////// end of excerpt
#@+node:ekr.20060116174906.125: *6* Use shutil.move in g.utils_rename
This corrects a problem that shows up as 'Invalid cross-device link' messages on Linux.

http://sourceforge.net/forum/message.php?msg_id=3519803
#@+node:ekr.20060116174906.130: *6* Simplified k.copyBindingsToWidget and eliminated k.onTextWidgetKey
These should be considered bug fixes.

- copyBindingsToWidget now binds keys in priority order. This also simplifies
and clarifies the code.

- Removed k.onTextWidgetKey.  Added a callback that invokes k.masterCommand.
#@+node:ekr.20060116174906.160: *6* Made sure that focus stays in body during tab completion
Hitting Backspace immediately put the focus in the log. Another backspace put
the focus in the body pane.

The problem was in log.clearTab.  It must do call t.update().
#@+node:ekr.20060116174906.163: *6* Leo now puts focus in body pane after deleting a window
#@+node:ekr.20060116174906.164: *6* Fixed many binding problems
#@+node:ekr.20060116174906.185: *6* Fixed extend-selection problems
extensionHelper resets movePoint any time there is no selection.
#@+node:ekr.20060116174906.187: *6* Fixed per-pane bindings!
#@+node:ekr.20060116174906.194: *6* Always redraw the screen after editing a label
The fix was to call endUpdate() rather than endUpdate(changed) in onHeadChanged.
#@+node:ekr.20060116174906.195: *5* Code level changes
#@+node:ekr.20060116174906.198: *6* Removed g.top from Leo's core and all plugins
g.top and the associated g.app.log logic is inherently unreliable.
#@+node:ekr.20060116174906.199: *6* Created c.exists ivar and related logic
This allows code to determine in a standard way whether a window is in the process of being destroyed.
#@+node:ekr.20060116174906.213: *6* Call c.setLog in all entries into code
This includes k.masterCommand and all event handlers.
#@+node:ekr.20060116174906.255: *6* Generalized doCommand
Leo now calls doCommand on all commands, so the 'command' hooks and error
processing always get done.
#@+node:ekr.20060116174906.258: *5* New features
#@+node:ekr.20060116174906.259: *6* Installed many standard bindings to leoSettings.leo
@nocolor
#@+node:ekr.20060116174906.262: *6* Added Check Bindings script in leoSettings.leo
#@+node:ekr.20060116174906.263: *6* Scripts now maintain original focus
http://sourceforge.net/forum/message.php?msg_id=3518792

EKR: The change in focus happened in c.endEditing in at.writeFromString.

I added a new restoreFocus keyword arg to c.endEditing.
#@+node:ekr.20060116174906.267: *6* Added scroll-up/down-extend-selection commands
#@+node:ekr.20060116174906.272: *6* Improved cursor move/extend commands
http://sourceforge.net/forum/message.php?msg_id=3515616

Could we have a visible-line-up and visible-line-down command? (I.e. to move
the cursor up or down by a visible rather than a logical line).  With these
commands, the arrows plugin could be permanently retired!

What I did:

- next-line and prev-line now work as requested.  This obsoletes the arrow plugin.
    - Removed the redundant tree.OnUpKey and tree.OnDownKey
    - Retired the arrows plugin.

- Created the extendHelper method.
    This creates and maintains the moveSpot, moveCol an moveSpotNode ivars,
    and is responsible for extending the selection range.
#@+node:ekr.20060116174906.296: *6* Added support for @mode nodes
Still to do:

Specify what mode to enter after each command:

- command-name -> mode-name = binding

will specify what mode to enter after each command.
At present, all commands exit to the top-level mode.

- Add @string active-keyset setting?
#@+node:ekr.20060116174906.306: *6* keyboard-quit restores default input mode
#@+node:ekr.20060116174906.257: *5* Added discusion to FAQ about when deleting a node is 'dangerous'
#@+node:ekr.20060111192108: *6* When is deleting a node dangerous?
A **dangerous** delete is a deletion of a node so that all the data in the node
is deleted *everywhere* in an outline. The data is gone, to be retrieved only
via undo or via backups. It may not be obvious which deletes are dangerous in an
outline containing clones. Happily, there is a very simple rule of thumb::

    Deleting a non-cloned node is *always* dangerous.
    Deleting a cloned node is *never* dangerous.

We could also consider a delete to be dangerous **if it results in a node being
omitted from an external file.** This can happen as follows. Suppose we have the
following outline (As usual, A' indicates that A is marked with a clone mark)::

    - @file spam.py
        - A'
            - B
    - Projects
        - A'
            - B

Now suppose we clone B, and move the clone so the tree looks like this::

    - @file spam.py
        - A'
            - B'
    - Projects
        - A'
            - B'
        - B'

If (maybe much later), we eliminate B' as a child of A will get::

    - @file spam.py
        - A'
    - Projects
        - A'
        - B

B has not been destroyed, but B is gone from @file spam.py! So in this sense deleting a clone node can also be called dangerous.
#@+node:ekr.20060206111508: *4* 4.4 beta 2
Leo 4.4 beta 2                                              February 14, 2006

This version fixes dozens of bugs, improves performance and polishes the user
interface. The code is stable; there are no known serious bugs.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4b2:
----------------------------
- Much better 'fit and finishes'.
- New commands that support mouseless Leo.
- Minibuffer search commands provide all features of Leo's legacy search commands.
- User modes are fully functional and you can create special bindings for the minibuffer.
- New master key and click handlers and improved allocation of screen widgets.

Coming in Leo 4.4b3:
--------------------
- A revived chapters plugin.
- Autocompleter Tab.
- Improved incremental searches.

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060206111508.2: *5* Bugs fixed
#@+node:ekr.20060206111508.3: *6* Fixed crasher in Save button
@nocolor

Must check for c.exists in c.executeScript after executing the script.
#@+node:ekr.20060206111508.4: *6* Fixed minor bugs & made minor improvements
@nocolor

- keyboard-quit now ends editing.

- print-bindings shows plain keys only in 'ignore' mode.

- Removed k.add_ekr_altx_commands and k.makeHardBindings.

- Added binding to vim plain shortcuts: mode-help = h

- Print the initial mode when first creating a window.
  The change had to be made in g.openWithFileName because of the UNL plugin.

- Improved print-bindings & mode help.

- endMode retains the widget on entry, so e.g., inserting a new node retaining the headline editing state.

@color
#@+node:ekr.20060206111508.5: *7* Fixed two annoying headline glitches
@nocolor

- Added initialClickExpandsOrContractsNode settings.  Clicking an node expands or contracts the node if this setting is True.  EKR much prefers False. 

- Selecting a headline should not select text in it.

@color
#@+node:ekr.20060206111508.14: *7* Insert headline didn't redraw headline properly in vim mode
@nocolor

What I did:

- endMode must not change focus.

- modeHelp calls c.endEditing(retainFocus=True)

@color
#@+node:ekr.20060206111508.40: *7* Improved printBindings, printCommands & modeHelp
#@+node:ekr.20060206111508.48: *6* Fixed crasher re BackSpace in log window

#@+node:ekr.20060206111508.49: *6* Fixed crashers in cut/copy/paste commands
Traceback (most recent call last):

  File "c:\prog\leoCVS\leo\src\leoCommands.py", line 250, in doCommand
    val = command() # Call legacy command

  File "C:\prog\leoCVS\leo\src\leoTkinterFrame.py", line 1777, in cutText
    oldText = w.get('1.0','end')

AttributeError: Canvas instance has no attribute 'get'
#@+node:ekr.20060206111508.54: *6* Fixed crasher when clicking the close box during a long command
#@+node:ekr.20060206111508.58: *6* cloneFindAll now honor present find settings
#@+node:ekr.20060206111508.63: *6* Double-click didn't work in the body pane.
#@+node:ekr.20060206111508.74: *6* Improved body.makeInsertPointVisible
Call w.see('insert'), not w.see('insert-5L')
#@+node:ekr.20060206111508.75: *6* Fixed cut/copy/paste from menu
#@+node:ekr.20060206111508.553: *6* Fixed major blunder: tree.onHeadChanged sets focus only if there was a real change
#@+node:ekr.20060206111508.97: *6* Disabled plain-key bindings in insert/overwrite modes
#@+node:ekr.20060206111508.103: *6* Disabled auto-scrolling in outline pane on clicks
The outline jumps around too much when expanding/contracting nodes
#@+node:ekr.20060206111508.136: *6* move-outline and find commands force a screen scroll
# This is required now that scrolling is disabled by default.
#@+node:ekr.20060211104746.2: *6* Fixed undo problem in headlines
In the new drawing scheme, tree.redraw_now always calls c.endEditing, which
calls tree.onHeadChanged. The effect of this was to reverse the action of
undo/redoNodeContents.

The solution was to change the edit widget directly before calling
tree.redraw_now. To do this, I created the new tree.setHeadline method.
#@+node:ekr.20060214085054: *6* Found the cause of 'sticking focus' problem
The problem with focus 'sticking' in the Pmw.Notebook was due to a call to
bringToFront. Apparently, the side effect was to assign a focus to the widget
that had it previously. This makes sense, and can not be considered a Tk bug.

Remove almost all calls to w.update in Leo.

No more calls to w.after that were used to draw the status line. The master key
and click handlers now call the label update method directly. This may ease a
major stress on Tk.
#@+node:ekr.20060211104746.162: *6* Fixed tree icon bug
Backspace in empty body text sometimes moved focus to canvas, and sometimes
improperly drew icon.

Made several fixes to onBodyChanged. There was no test for unchanged text! This
could have created all sorts of problems for undo.
#@+node:ekr.20060211104746.177: *6* Set remembered column properly in prev-line and next-line
http://sourceforge.net/forum/message.php?msg_id=3549737

for extend selection,
with binding to arrow keys,
if you switch from up to down arrow,
the selection restarts again.
this should just change extend direction
while still using the same selection.
#@+node:ekr.20060211104746.208: *6* Fixed focus problems in spell tab
#@+node:ekr.20060214074035.9: *6* Fixed problem with body_gmt_time setting
http://sourceforge.net/forum/message.php?msg_id=3549737

The fix was to call getBool rather than getString.
#@+node:ekr.20060214074035.20: *6* Made sure save updates the open directory
http://sourceforge.net/forum/message.php?msg_id=3534349
By: edcdave

Saving the Leo file is not sufficient - I have to exit the document and open
it again before the rst destination directory is set correctly.

The fix was to set c.frame.openDirectory in save.
#@+node:ekr.20060214074035.41: *6* Fixed sort-lines problems
The problem: event.widget is the minibuffer.  It must be the body text.

- k.fullCommand saves the initial event and passes it on to callAltXFunction.

- There was a bug in c.masterFocusHandler.  The correct test for 'no change' is:

    if c.hasFocusWidget and c.requestedFocusWidget == c.hasFocusWidget:

** Important: the 'extra' calls to set_focus are correct. The minibuffer messes
with the tab pane, and so we *must* be careful to yank the focus back to the
body.
#@+node:ekr.20060214074035.101: *6* Fixed bug: paste outline lost headline editing
#@+node:ekr.20060206111508.547: *5* Code improvements
- Replaced frame.xWantsFocus with c.xWantsFocus.
- Added event arg to all legacy commands.
- Replaced k.tkBindingFromSetting by k.shortcutFromSetting.
- Replaced k.canonicalizeShortcut by k.shortcutFromSetting.
- Replaced k.bindShortcut with bindKey.
- k.makeBindingsFromCommandsDict does not call k.bindKey for mode bindings.
- Call update_idletasks when writing to the log.
- Updated selection point immediately in masterKeyHandler.
  Otherwise, updateStatusLine would be one click behind.
#@+node:ekr.20060206111508.550: *6* Removed code in c.begin/EndUpdate and c.endEditLabel that tried to save/restore focus
@nocolor

This is logically and practically dubious.
True, a screen redraw shouldn't mess with the focus,
but there are the following problems:

1. c.endUpdate can happen anytime, and it could interfere with other efforts to set focus.
2. g.app.get_focus might get the 'wrong' or a 'bad' focus.
#@+node:ekr.20060206111508.596: *6* Improved tree allocation
A *major* improvement to the tree allocation code:

1.  Use p.key() to as keys to tree.visibleText.
 This greatly speeds up tree.findEditWidget

2. Eliminated the brain-dead requirement that previously-allocated widgets must match the position.
   - The allocation code just gets *any* previously allocated widget.
     This eliminates an n**2 search!
   - The ancient problem was that theId refers to the *window* not its Text widget:
     the *window* must be moved to the right spot.

3. recycleWidgets is simpler and a bit faster.

4. destroyWidgets now works: (the bug was not clearing tree.ids).
#@+node:ekr.20060211104746.12: *6* Created c.masterFocusHandler
* Found the reason why focus was *still* sticking in the outline pane:
    - The click handlers must return 'break', not continue.
    - However, OnActivateHeadline must return 'continue' when the headline is active
      so that Tk will handle the click properly.

- UNL does not seem to be causing problems.

- No need to save/restore focus in status line.

- Added several new traces to tkTree class.

* tree.redraw_now now ends editing properly. This fixes lots of bugs. In
particular, it avoid any chance that p.edit_widget won't correspond to the
present position.

- k.masterClickHandler calls tree.OnDeactivate() if there is no callback function.
  This solves most headline focus problems, provided that all panes bind clicks to k.masterClickHandler.

- toggle-active-pane now ends editing properly.

- insert-headline now calls c.editPosition after calling c.endUpdate().
#@+node:ekr.20060211104746.168: *6* Added unit tests for key dicts
@ This revealed several problems:

- Most find dialog commands do not actually exist. All find commands except
open-find-dialog actual refer to the find tab.

- Several other minor shortcut problems.
#@+node:ekr.20060211104746.346: *6* Special-cased commands for minibuffer
select-all-text, move back/forward line/char, start/end-of-line.
#@+node:ekr.20060214074035.6: *6* Made sure yield works with Python 2.2
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3549737

\src\leoEditCommands.py:340: 
Warning: 'yield' will become a reserved keyword 

for python2.2 leoEditCommands.py needs
from __future__ import generators

Also changed the following plugins:

at_produce.py
fastGotoNode.py
rst3.py
zodb.py
#@+node:ekr.20060214074035.12: *6* Use os.getenv('User") if it exists to get initial cvs name
http://sourceforge.net/forum/message.php?msg_id=3237845

On startup, it asked me for a unique id, "possibly your CVS username".
As a non-windows-user, that made no sense at all to me - at very least, it should
fill in os.getenv("USER") as a default, because it's right on non-windows systems,
isn't it?  (If it isn't, there's no explanation at that point that would tell
me otherwise, that's the value I used anyway...)  Just an out-of-box-experience
issue.
#@+node:ekr.20060206112001: *5* Improved commands
- Improved format of print-commands and print-bindings commands.

- Eliminated clone-find-all, selection-only, show-context checkboxes
  when show_only_find_tab_options setting is True.

- All minibuffer find commands copy the find string from the Find tab into the minibuffer.

- The replace-string command sets up arguments for Tab find. This is different
  from the normal Emacs replace-string command, but it works well in Leo.

- Leo doesn't abort the minibuffer if the command does not exist.
  This is much more convenient.
#@+node:ekr.20060212102459.4: *6* Minibuffer-oriented find commands
All minibuffer search commands, with the exception of the isearch (incremental) commands, simply provide a minibuffer interface to Leo's legacy find commands.  This means that all the powerful features of Leo's legacy commands are available to the minibuffer search commands.

Note: all bindings shown are the default bindings for these commands.  You may change any of these bindings using @shortcuts nodes in leoSettings.leo.

Settings

leoSettings.leo now contains several settings related to the Find tab:

- @bool show_only_find_tab_options = True

When True (recommended), the Find tab does not show the 'Find', 'Change', 'Change, Then Find', 'Find All' and 'Change All' buttons.

- @bool minibufferSearchesShowFindTab = True

When True, Leo shows the Find tab when executing most of the commands discussed below.  It's not necessary for it to be visible, but I think it provides good feedback about what search-with-present-options does.  YMMY.  When True, the sequence Control-F, Control-G is one way to show the Find Tab.

Basic find commands

- The open-find-tab command makes the Find tab visible.  The Find tab does **not** need to be visible to execute any search command discussed below.

- The hide-find-tab commands hides the Find tab, but retains all the present settings.

- The search-with-present-options command (Control-F) prompts for a search string.  Typing the <Return> key puts the search string in the Find tab and executes a search based on all the settings in the Find tab.   This command is my 'workhorse' search command.

- The show-search-options command shows the present search options in the status line.  At present, this command also shows the Find tab.

Search again commands

- The find-tab-find command (F3) is the same as the search-with-present-options command, except that it uses the search string in the find-tab.  This is what I use as my default 'search again' command.

- Similarly, the find-tab-find-previous command (F2) repeats the command specified by the Find tab, but in reverse.

- The find-again command a combination of the search-with-present-options and find-tab-find command.  It is the same as the find-tab-find command if a search pattern other than '<find pattern here>' exists in the Find tab.  Otherwise, the find-again is the same as the search-with-present-options command.

Setting find options

- Several minibuffer commands toggle the checkboxes and radio buttons in the Find tab, and thus affect the operation of the search-with-present-options command. Some may want to bind these commands to keys. Others, will prefer to toggle options in a mode.


Here are the commands that toggle checkboxes: toggle-find-ignore-case-option, toggle-find-in-body-option, toggle-find-in-headline-option, toggle-find-mark-changes-option, toggle-find-mark-finds-option, toggle-find-regex-option, toggle-find-reverse-option, toggle-find-word-option, and toggle-find-wrap-around-option.

Here are the commands that set radio buttons: set-find-everywhere, set-find-node-only, and set-find-suboutline-only.

- The enter-find-options-mode (Ctrl-Shift-F) enters a mode in which you may change all checkboxes and radio buttons in the Find tab with plain keys.  As always, you can use the mode-help (Tab) command to see a list of key bindings in effect for the mode.

Search commands that set options as a side effect

The following commands set an option in the Find tab, then work exactly like the search-with-present-options command.

- The search-backward and search-forward commands set the 'Whole Word' checkbox to False.

- The word-search-backward and word-search-forward set the 'Whole Word' checkbox to True.

- The re-search-forward and re-search-backward set the 'Regexp' checkbox to True.

Find all commands

- The find-all command prints all matches in the log pane.

- The clone-find-all command replaces the previous 'Clone Find' checkbox.  It prints all matches in the log pane, and creates a node at the beginning of the outline containing clones of all nodes containing the 'find' string.  Only one clone is made of each node, regardless of how many clones the node has, or of how many matches are found in each node.

Note: the radio buttons in the Find tab (Entire Outline, Suboutline Only and Node only) control how much of the outline is affected by the find-all and clone-find-all commands.

Search and replace commands

The replace-string prompts for a search string.  Type <Return> to end the search string.  The command will then prompt for the replacement string.  Typing a second <Return> key will place both strings in the Find tab and executes a **find** command, that is, the search-with-present-options command.

So the only difference between the replace-string and search-with-present-options commands is that the replace-string command has the side effect of setting 'change' string in the Find tab.  However, this is an extremely useful side effect, because of the following commands...

- The find-tab-change command (Ctrl-=) replaces the selected text with the 'change' text in the Find tab.

- The find-tab-change-then-find (Ctrl--) replaces the selected text with the 'change' text in the Find tab, then executes the find command again.

The find-tab-find, find-tab-change and find-tab-change-then-find commands can simulate any kind of query-replace command.  **Important**: Leo presently has separate query-replace and query-replace-regex commands, but they are buggy and 'under-powered'.  Fixing these commands has low priority.

- The find-tab-change-all command changes all occurrences of the 'find' text with the 'change' text.  Important: the radio buttons in the Find tab (Entire Outline, Suboutline Only and Node only) control how much of the outline is affected by this command.

Incremental search commands

Leo's incremental search commands are completely separate from Leo's legacy search commands.  At present, incremental search commands do not cross node boundaries: they work only in the body text of single node.

Coming in Leo 4.4b3: the incremental commands will maintain a list of previous matches.  This allows for

a) support for backspace and
b) an incremental-search-again command.

Furthermore, this list makes it easy to detect the end of a wrapped incremental search.

Here is the list of incremental find commands: isearch-backward, isearch-backward-regexp, isearch-forward and
isearch-forward-regexp.'''
#@+node:ekr.20060214074035.67: *6* Leo remembers the previous open directory
http://sourceforge.net/forum/message.php?msg_id=3571431
By: ktenney

To reiterate a request:

When doing File->Open the default directory should the directory which
was navigated to for previous 'Open'

What I did:

- Defined g.app.globalOpenDir # The directory last used to open a file.
#@+node:ekr.20060214090742: *5* Improved plugins
#@+node:ekr.20060214074035.65: *6* Fixed problem with view plugin
http://sourceforge.net/forum/message.php?msg_id=3538274

It's not clear that there were serious problems with the plugin, but I improved the code and error messages.  All features work for me.

Several plugins use the icon-double-click hook.  The reported problems could have been due to plugin conflicts.
#@+node:ekr.20060214074035.66: *6* Installed cleo patch
http://sourceforge.net/forum/message.php?msg_id=3517080
#@+node:ekr.20060214083808: *5* New commands
Debugging commands:

- dump-all-objects, ump-new-objects, verbose-dump-objects.
- free-text-widgets.

Find commands:

See the child of this node for details.

- find-again.
- find-all and clone-find-all.
- find-tab-find command, find-tab-find-previous.
- find-tab-change, find-tab-change-all, find-tab-change-then-find.
- hide-find-tab, open-find-tab.
- re-search-forward and re-search-backward.
- replace-string.
- search-with-present-options.
- search-backward and search-forward.
- show-search-options.
- word-search-backward and word-search-forward.

Search options:

- set-find-everywhere, set-find-node-only, and set-find-suboutline-only.
- toggle-find-ignore-case-option, toggle-find-in-body-option,
  toggle-find-in-headline-option, toggle-find-mark-changes-option,
  toggle-find-mark-finds-option, toggle-find-regex-option,
  toggle-find-reverse-option, toggle-find-word-option, 
  toggle-find-wrap-around-option.

Mouseless Leo:

- activate-cmds-menu, activate-edit-menu, activate-file-menu activate-help-menu,
  activate-outline-menu, activate-plugins-menu, activate-window-menu.
- contract-body-pane, contract-log-pane, contract-outline-pane, contract-pane.
- expand-body-pane, expand-log-pane, expand-outline-pane, expand-pane.
- fully-expand-body-pane, fully-expand-log-pane, fully-expand-outline-pane, fully-expand-pane.
- hide-body-pane, hide-log-pane, hide-outline-pane, hide-pane.
- click-click-box, click-headline, click-icon-box, double-click-headline,
  double-click-icon-box, simulate-begin-drag, simulate-end-drag.
  (These commands trigger event hooks. In particular, double-click-icon-box will
  invoke the vim or xemacs plugins if they are enabled.)
#@+node:ekr.20060212102459.4: *6* Minibuffer-oriented find commands
All minibuffer search commands, with the exception of the isearch (incremental) commands, simply provide a minibuffer interface to Leo's legacy find commands.  This means that all the powerful features of Leo's legacy commands are available to the minibuffer search commands.

Note: all bindings shown are the default bindings for these commands.  You may change any of these bindings using @shortcuts nodes in leoSettings.leo.

Settings

leoSettings.leo now contains several settings related to the Find tab:

- @bool show_only_find_tab_options = True

When True (recommended), the Find tab does not show the 'Find', 'Change', 'Change, Then Find', 'Find All' and 'Change All' buttons.

- @bool minibufferSearchesShowFindTab = True

When True, Leo shows the Find tab when executing most of the commands discussed below.  It's not necessary for it to be visible, but I think it provides good feedback about what search-with-present-options does.  YMMY.  When True, the sequence Control-F, Control-G is one way to show the Find Tab.

Basic find commands

- The open-find-tab command makes the Find tab visible.  The Find tab does **not** need to be visible to execute any search command discussed below.

- The hide-find-tab commands hides the Find tab, but retains all the present settings.

- The search-with-present-options command (Control-F) prompts for a search string.  Typing the <Return> key puts the search string in the Find tab and executes a search based on all the settings in the Find tab.   This command is my 'workhorse' search command.

- The show-search-options command shows the present search options in the status line.  At present, this command also shows the Find tab.

Search again commands

- The find-tab-find command (F3) is the same as the search-with-present-options command, except that it uses the search string in the find-tab.  This is what I use as my default 'search again' command.

- Similarly, the find-tab-find-previous command (F2) repeats the command specified by the Find tab, but in reverse.

- The find-again command a combination of the search-with-present-options and find-tab-find command.  It is the same as the find-tab-find command if a search pattern other than '<find pattern here>' exists in the Find tab.  Otherwise, the find-again is the same as the search-with-present-options command.

Setting find options

- Several minibuffer commands toggle the checkboxes and radio buttons in the Find tab, and thus affect the operation of the search-with-present-options command. Some may want to bind these commands to keys. Others, will prefer to toggle options in a mode.


Here are the commands that toggle checkboxes: toggle-find-ignore-case-option, toggle-find-in-body-option, toggle-find-in-headline-option, toggle-find-mark-changes-option, toggle-find-mark-finds-option, toggle-find-regex-option, toggle-find-reverse-option, toggle-find-word-option, and toggle-find-wrap-around-option.

Here are the commands that set radio buttons: set-find-everywhere, set-find-node-only, and set-find-suboutline-only.

- The enter-find-options-mode (Ctrl-Shift-F) enters a mode in which you may change all checkboxes and radio buttons in the Find tab with plain keys.  As always, you can use the mode-help (Tab) command to see a list of key bindings in effect for the mode.

Search commands that set options as a side effect

The following commands set an option in the Find tab, then work exactly like the search-with-present-options command.

- The search-backward and search-forward commands set the 'Whole Word' checkbox to False.

- The word-search-backward and word-search-forward set the 'Whole Word' checkbox to True.

- The re-search-forward and re-search-backward set the 'Regexp' checkbox to True.

Find all commands

- The find-all command prints all matches in the log pane.

- The clone-find-all command replaces the previous 'Clone Find' checkbox.  It prints all matches in the log pane, and creates a node at the beginning of the outline containing clones of all nodes containing the 'find' string.  Only one clone is made of each node, regardless of how many clones the node has, or of how many matches are found in each node.

Note: the radio buttons in the Find tab (Entire Outline, Suboutline Only and Node only) control how much of the outline is affected by the find-all and clone-find-all commands.

Search and replace commands

The replace-string prompts for a search string.  Type <Return> to end the search string.  The command will then prompt for the replacement string.  Typing a second <Return> key will place both strings in the Find tab and executes a **find** command, that is, the search-with-present-options command.

So the only difference between the replace-string and search-with-present-options commands is that the replace-string command has the side effect of setting 'change' string in the Find tab.  However, this is an extremely useful side effect, because of the following commands...

- The find-tab-change command (Ctrl-=) replaces the selected text with the 'change' text in the Find tab.

- The find-tab-change-then-find (Ctrl--) replaces the selected text with the 'change' text in the Find tab, then executes the find command again.

The find-tab-find, find-tab-change and find-tab-change-then-find commands can simulate any kind of query-replace command.  **Important**: Leo presently has separate query-replace and query-replace-regex commands, but they are buggy and 'under-powered'.  Fixing these commands has low priority.

- The find-tab-change-all command changes all occurrences of the 'find' text with the 'change' text.  Important: the radio buttons in the Find tab (Entire Outline, Suboutline Only and Node only) control how much of the outline is affected by this command.

Incremental search commands

Leo's incremental search commands are completely separate from Leo's legacy search commands.  At present, incremental search commands do not cross node boundaries: they work only in the body text of single node.

Coming in Leo 4.4b3: the incremental commands will maintain a list of previous matches.  This allows for

a) support for backspace and
b) an incremental-search-again command.

Furthermore, this list makes it easy to detect the end of a wrapped incremental search.

Here is the list of incremental find commands: isearch-backward, isearch-backward-regexp, isearch-forward and
isearch-forward-regexp.'''
#@+node:ekr.20060214083647: *5* New settings
New settings:

- @int max_undo_stack_size
- @bool minibufferSearchesShowFindTab
- @bool show_only_find_tab_options

New debugging settings:

@bool allow_idle_time_hook
@bool gc_before_redraw
@bool show_tree_stats
@bool trace_bindings
@bool trace_doCommand
@bool trace_f.set_focus
@bool trace_focus = False
@bool trace_g.app.gui.set_focus
@bool trace_gc
@bool trace_gc_calls
@bool trace_gc_verbose
@bool trace_masterClickHandler
@bool trace_masterCommand
@bool trace_masterFocusHandler
@bool trace_masterKeyHandler
@bool trace_modes
@bool trace_redraw_now
@bool trace_select
@bool trace_tree
@bool trace_tree_alloc
@bool trace_tree_edit
@bool use_syntax_coloring
@string trace_bindings_filter
@string trace_bindings_pane_filter
#@+node:ekr.20060214092741: *5* User input modes
- @mode nodes in leoSettings.leo allow you to specify input modes with separate key bindings.

See the child of this node for full details.

- All key bindings specified with !mini pane specifier apply to all modes.

#@+node:ekr.20060215112429: *4* 4.4 experimental 1
Leo 4.4 experimental 1                                      February 15, 2006

This version is an emergency measure.  It's goals:

1.  To fix some of the key-handling issues in Leo 4.4 b2.
2.  To allow further experimentation with key handling.
3.  To allow easy reporting of any other key handling problems.

Please do not use this version (or Leo 4.4b2) unless you are ready to report bugs.

My apologies for the key handling problems in Leo 4.4 b2.  I hope this version will
be all that is necessary to fix those problems.

Here are the details of the key-handling changes:

- Added support for trace_key_event setting.
- Added support for ignore_caps_lock setting.
- Added Caps_Lock and Num_Lock to k.tkNamesList and in the list of
  special keys in k.masterCommand and k.masterKeyHandlerHelper.
- Added support for k.ignore_unbound_non_ascii_keys logic in masterKeyHandlerHelper.
- Disabled unknown keysym trace in k.strokeFromEvent.
- Enabled the international keyboard on XP as an aid to testing.
- Added support for swap_mac_keys setting in k.shortcutFromSetting.
#@+node:ekr.20060215112429.9: *5* Fixed (maybe) problems with unicode characters & caps lock
http://sourceforge.net/forum/message.php?msg_id=3573470

What I did:

- Added support for trace_key_event setting.
- Added support for ignore_caps_lock setting.
- Added Caps_Lock and Num_Lock to k.tkNamesList and in the list of
  special keys in k.masterCommand and k.masterKeyHandlerHelper.
- Added support for k.ignore_unbound_non_ascii_keys logic in masterKeyHandlerHelper.
- Disabled unknown keysym trace in k.strokeFromEvent.
- Enabled the international keyboard on XP as an aid to testing.
- Added support for swap_mac_keys setting in k.shortcutFromSetting.
#@+node:ekr.20060215112429.2: *5* Restored some legacy bindings
extract                             = Shift-Ctrl-D
extract-names                       = Shift-Ctrl-N
extract-section                     = Shift-Ctrl-S  # Shift-Ctrl-E: end-of-line-extend-selection

write-at-file-nodes                 = Shift-Ctrl-W # Was enter-file-mode.
write-dirty-at-file-nodes           = Shift+Ctrl+Q

# Removed definitions of find and file modes.  I never used them.
#@+node:ekr.20060215112429.3: *5* Fixed crasher in Go To Line command
http://sourceforge.net/forum/message.php?msg_id=3545403
#@+node:ekr.20060215112429.6: *5* Fixed menu problem on Linux
The patch was reported at:

http://sourceforge.net/forum/message.php?msg_id=3577681
#@+node:ekr.20060217071505: *4* 4.4 a6
Leo 4.4 alpha 6                                         February 17, 2006

Leo 4.4 b2 was broken on some platforms.  Leo 4.4 a6 should fix those problems
forever.  However, only wider distribution will verify that for certain.

Besides fixing the fatal problems with Leo 4.4b2, this version fixes two minor bugs
and adds some new settings in leoSettings.leo.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4 b2 and a6:
----------------------------
- Smoother user interface.
- New commands that support mouseless Leo.
- Minibuffer search commands provide all features of Leo's legacy search commands.
- User modes are fully functional; you can create special bindings for the minibuffer.
- New master key and click handlers and improved allocation of screen widgets.

Coming in Leo 4.4b3:
--------------------
- A revived chapters plugin.
- Autocompleter Tab.
- Improved incremental searches.

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060217071505.1: *5* Fixed urgent compatibility problems
The new scheme binds to keystrokes, not commands.  This should be as portable
and robust as all previous versions (except b2, which was broken).

- Created k.completeAllBindings, called last in k.makeAllBindings. This binds
all keystrokes in k.bindingsDict to k.masterKeyHandler with an optional stroke
argument. This allows k.masterKeyhandler to dispense with the problematic call
to k.strokeFromEvent. This is all that is really required. 

- Added code to menu.createMenuEntries that clears the accelerator on MacOS for
any key that isn't a control, alt or command key. This solves the recurring
problems with the Return key. The only effect is that the menu won't mention a
binding that is actually in effect, but apparently that cannot be helped.

- Added g.safeCompareStrings, which may, or may not, fix the crasher when
comparing k.abortAllModesKey to the incoming keystroke in k.masterKeyHandler.
It's a bit tricky to test.

- The ignore_caps_lock is no longer functional. Sigh. This depends on knowing
the Caps_Lock bit in key events. I may put this back later, but I can't delay a6
even a minute for this.
#@+node:ekr.20060217072324: *5* Minor bugs fixed
- Fixed crasher in k.masterCommand.

- Arrow keys no longer destroy UNL line
#@+node:ekr.20060217072647: *5* New debugging options in leoSettings.leo
- @bool trace_autocompleter # The autocompleter itself is not ready yet.
- @bool trace_key_event
- @bool trace_minibuffer
- @bool trace_status_line
#@+node:ekr.20060227102028: *4* 4.4 a7
Leo 4.4 alpha 7                                             February 28, 2006

This version fixes some minor problems with Leo 4.4a6 and adds autocompletion
and calltips.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Autocompletion and calltips.  Autocompletion works much like tab completion.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060227102028.2: *5* Bugs Fixed
#@+node:ekr.20060227102028.3: *6* Fixed binding bug
# http://sourceforge.net/forum/message.php?msg_id=3583335
#@+node:ekr.20060227102028.14: *6* Fixed bug in open-find-dialog
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3586962
By: bwmulder

the open-find-dialog is broken. 

Error: 4 
TypeError Exception in Tk callback 
Function: <function findButtonCallback at 0x04E219F0> (type: <type 'function'>) 
Args: () 
Traceback (innermost last): 
File "C:\Python24\lib\site-packages\Pmw\Pmw_1_2\lib\PmwBase.py", line 1747, in __call__ 
return apply(self.func, args) 
TypeError: findButtonCallback() takes at least 1 argument (0 given) 
#@+node:ekr.20060227102028.15: *6* Ensure dialogs properly get focus
#@+node:ekr.20060227102028.16: *6* Disabled autocompleter in headlines
# This was causing problems.  It may be an easy fix, but I kinda doubt it.
#@+node:ekr.20060227102028.17: *6* Removed horrible g.app.dialogs hack

#@+node:ekr.20060227102028.18: *6* Fix crasher in plugin
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3597694
By: tfer

Template Plug-in (maybe others too) co,plain when activated:
exception executing command
Traceback (most recent call last):
  File "leoCommands.py", line 265, in doCommand
    val = command(event)
  File "c:\Leo_Cvs\Leo\plugins\plugins_menu.py", line 350, in about
    PluginAbout(self.name, self.version, self.doc)
  File "c:\Leo_Cvs\Leo\plugins\plugins_menu.py", line 576, in __init__
    g.app.dialogs += 1
AttributeError: LeoApp instance has no attribute 'dialogs'
#@+node:ekr.20060328171518: *4* 4.4 b3
Leo 4.4 beta 3                                             April 14, 2006

This version fixes some minor problems and adds various features.  This code
has been in use for several weeks without any major problems reported.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Autocompletion and calltips.  Autocompletion works much like tab completion.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060328171518.1: *5* New features
#@+node:ekr.20060328171518.10: *6* Added scroll outline pane commands
http://sourceforge.net/forum/message.php?msg_id=3608246

Added the following commands:

scroll-outline-down-line       
scroll-outline-down-page       
scroll-outline-up-line       
scroll-outline-up-page
#@+node:ekr.20060328171518.11: *6* Improved registerCommand
It now properly creates bindings.
#@+node:ekr.20060328171518.15: *6* Suppressed autocompletion after numbers
#@+node:ekr.20060328171518.16: *6* Added colorizing support for Lua language
http://sourceforge.net/forum/message.php?msg_id=3572598
#@+node:ekr.20060328171518.45: *6* Added run-unit-test command
This is equivalent to the Unit Test script button in unitTest.leo
#@+node:ekr.20060328171518.47: *5* Bugs
#@+node:ekr.20060328171518.48: *6* Fixed problem with left & right arrows in outline mode
http://sourceforge.net/forum/message.php?msg_id=3619340

Just tried out CVS today, and on Linux left/right and L/R in outline mode
(Ctrl-Shift-O) seem to do nothing, whereas they should expand/contract parent
nodes.
#@+node:ekr.20060328171518.57: *6* Fixed undo problem with clones
http://sourceforge.net/forum/message.php?msg_id=3639193

The dirty bits were not updated properly in several undo/redo operations.
#@+node:ekr.20060328171518.83: *6* Investigated setting descendant @file nodes dirty when changing body text
http://sourceforge.net/forum/message.php?msg_id=3642892

The present code is probably the best compromise between strict accuracy and marking too many nodes dirty.
#@+node:ekr.20060328171518.85: *6* Work around newline problems on the Mac
http://sourceforge.net/forum/message.php?msg_id=3606515

Added insert-newline command and fixed some related commands.
#@+node:ekr.20060328171518.101: *6* Got rid of settings messages
Apparently g.app.unitTesting isn't set properly for the new-window test.
#@+node:ekr.20060328171518.108: *6* Clicks outside minibuffer no longer rip focus
The bug: Hit control-f, then select the text that doesn't have focus.
#@+node:ekr.20060328171518.111: *6* Handled missing leoSettings.leo files more gracefully
http://sourceforge.net/forum/message.php?msg_id=3641107

ConfigSettings.initEncoding now uses the g.app.config settings if no other settings are available.

In particular, this causes at.encoding to be inited to a reasonable value.
#@+node:ekr.20060328171518.119: *6* Converted all shortcuts to unicode
- onBodyChanged now converts everything to unicode, either directly or by calling g.app.gui.getAllText.

- Replaced all calls to g.safeStringCompare by g.app.gui.getAllText which calls g.toUnicode.

- Converted all shortcuts to unicode in shortcutFromSetting (a.k.a strokeFromSetting)

- Removed g.safeStringCompare.  This function was a bad idea.

Important: Leo is supposed to convert all characters to unicode, so there should
never be a need for safeStringCompare. The proper way to avoid UnicodeError's is
to call g.toUnicode(s,g.app.tkEncoding).
#@+node:ekr.20060328171518.135: *6* Made Open With shortcuts work again
http://sourceforge.net/forum/message.php?msg_id=3607355
#@+node:ekr.20060328171518.151: *6* Made sure autocompleter and calltip text stick
#@+node:ekr.20060328171518.152: *6* Fixed a bug in c.openWith
http://sourceforge.net/forum/message.php?msg_id=3573148

c.openWith now calls g.enableIdleTimeHook
#@+node:ekr.20060328171518.169: *6* Import/export commands now set directory for next open
These commands now set g.app.globalOpenDir.
#@+node:ekr.20060328171518.190: *6* Investigated colorizer problems: can not reproduce
http://sourceforge.net/forum/message.php?msg_id=3585710
#@+node:ekr.20060328171518.248: *6* Removed support @ifgui: it doesn't and can't work
Alas, @if-gui can't be made to work. The problem is that plugins can set
g.app.gui, but plugins need settings so the leoSettings.leo files must be parsed
before g.app.gui.guiName() is known.
#@+node:ekr.20060328171518.249: *6* Removed autocompletion for self
It's not ready for prime time.
#@+node:ekr.20060414071350.1: *6* Rewrote g.importExtension to simplify startup logic
#@+node:ekr.20060414071350.8: *6* Removed calls to lstrip and rstrip for compatibility with Python 2.2.1
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3671350

Change aString.lstrip and aString.rstrip to the aString.replace.
@color
#@+node:ekr.20060414071350.47: *6* Fixed Crash after undoing clearRecentFiles command
exception executing command
Traceback (most recent call last):
  File "C:\prog\leoCVS\leo\src\leoCommands.py", line 264, in doCommand
    val = command(event)
  File "C:\prog\leoCVS\leo\src\leoCommands.py", line 884, in clearRecentFiles
    u.afterClearRecentFiles(bunch)
  File "C:\prog\leoCVS\leo\src\leoUndo.py", line 621, in afterClearRecentFiles
    u.pushBead(bunch)
  File "C:\prog\leoCVS\leo\src\leoUndo.py", line 192, in pushBead
    u.setUndoTypes()
  File "C:\prog\leoCVS\leo\src\leoUndo.py", line 341, in setUndoTypes
    u.cutStack()
  File "C:\prog\leoCVS\leo\src\leoUndo.py", line 136, in cutStack
    if bunch.kind == 'beforeGroup':
AttributeError: 'Bunch' object has no attribute 'kind'
#@+node:ekr.20060414071350.58: *6* Fixed minor problems reported by Pychecker
# No change for now
C:\prog\tigris-cvs\leo\src\leoKeys.py:1050: Parameter (thread) not used

# Fixed
C:\prog\tigris-cvs\leo\src\leoTkinterFrame.py:1428: Function returns a value and also implicitly returns None
C:\prog\tigris-cvs\leo\src\leoTkinterTree.py:1222: Local variable (delta) not used
C:\prog\tigris-cvs\leo\src\leoKeys.py:1931: Local variable (f) not used
C:\prog\tigris-cvs\leo\src\leoGlobals.py:5246: Local variable (buttonList) not used
C:\prog\tigris-cvs\leo\src\leoCommands.py:493: No global (enableIdleTimeHook) found
#@+node:ekr.20060328171518.191: *5* Plugins
#@+node:ekr.20060328171518.238: *6* Changed path to stylesheet in the rst3 plugin
http://sourceforge.net/forum/message.php?msg_id=3637393

I'm trying to set up a default stylesheet for a project and want this to be
held relative to the project directory (where the .leo file is). The default
is to place it in the same directory as the output, which is a couple of levels
down.

http://sourceforge.net/forum/message.php?msg_id=3639216

g.os_path_dirname(self.outputFileName) with self.c.frame.openDirectory. This
makes the path relative to the project. Not 100% as the stylesheet filename
would need a path embedded in it to move the location down the tree. However,
it is consistent with the way the output file is named.
#@+node:ekr.20060328171518.240: *6* Fixed problems with chapters plugin
See the chapters2 in leoPlugins.leo.

See also:

http://sourceforge.net/forum/message.php?msg_id=3626542

https://sourceforge.net/forum/message.php?msg_id=3629055

http://sourceforge.net/forum/message.php?msg_id=3632004
#@+node:ekr.20060328171518.244: *6* Improved groupoperations plugin
Cleaned up the code and added support minibuffer commands:

group-operations-clear-marked       = Alt-Ctrl-Shift-l
group-operations-mark-for-copy      = Alt-Ctrl-Shift-c
group-operations-mark-for-move      = Alt-Ctrl-Shift-m
group-operations-mark-for-clone     = Alt-Ctrl-`
group-operations-mark-target        = Alt-Ctrl-Shift-t
group-operations-operate-on-marked  = Alt-Ctrl-Shift-o
group-operations-transfer           = Alt-Ctrl-Shift-d

This code has not been tested with the chapters2 plugin.
#@+node:ekr.20060328171518.245: *6* Fixed crasher in Word (and other) plugins
http://sourceforge.net/forum/message.php?msg_id=3617936

The fix was to plugins_menu.py: the cmd_callback must have an event argument.
#@+node:ekr.20060328171518.246: *6* Fixed problem with labels plugin
The fix: all menu commands now have event=None in their argument list.
#@+node:ekr.20060417092536: *4* 4.4 b4
Leo 4.4 beta 4                                             April 21, 2006

This version fixes a long-standing MacOS bug.  It is likely to be the last
beta release before 4.4 final.  This release also adds several new commands
and contains a script for updating leoSettings.leo.

Warning: The previous beta was not widely distributed. Please do some testing in
your environment before recommending this version of Leo to others, (such as
your students).

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Autocompletion and calltips.  Autocompletion works much like tab completion.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://sourceforge.net/cvs/?group_id=3458
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060421070409.1: *5* Bugs
#@+node:ekr.20060421070602: *6* Fixed rename-buffer command
#@+node:ekr.20060421070409.2: *6* Investigated problems with legacy bindings
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3688804
By: paulpaterson

It seems that copying and pasting nodes with CTRL-SHIFT-C, V is not working.
- (legacy bindings)
- select a node
- CTRL-SHIFT-C
- CTRL-SHIFT-V
- Vim opens up! I expect to paste the node. The clipboard doesn't seem to contain
any XML
- The menu items show that these keys are bound to the copy and paste node
commands

*** Also on legacy bindings the arrow keys don't seem to move the cursor in the
body.
#@+node:ekr.20060421070409.3: *6* Fixed bug when cutting text in headline
#@+node:ekr.20060421070409.4: *7* Report
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3692247
By: vpe

After cutting selection in the headline, headline area shrinks too much.  Example:
headline is 'NewHeadline', select last 'e', ctrl-x, it shrinks to 'Ne'

To fix by hand: add

s=g.app.gui.getAllText(w)

Just before

w.configure(width=f.tree.headWidth(s=s))

in cutText in leoTkFrame.py
#@+node:ekr.20060421070409.9: *6* Fixed crasher in open-find-dialog
#@+node:ekr.20060421070409.10: *7* Report
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3692247

Find panel cannot be re-opened. Run open-find-dialog. Close it. Run open-find-dialog
again -- crash.

The fix was to move the line:

self.top.protocol("WM_DELETE_WINDOW", self.onCloseWindow)

from createBindings to createFrame in the leoTkinterFind class.
#@+node:ekr.20060421070409.11: *7* Traceback
TclError Exception in Tk callback
  Function: <function bindKeyCallback at 0x0169B170> (type: <type 'function'>)
  Args: (<Tkinter.Event instance at 0x01865EB8>,)
  Event type: KeyPress (type num: 2)
Traceback (innermost last):
  File "C:\prog\tigris-cvs\leo\extensions\Pmw\Pmw_1_2\lib\PmwBase.py", line 1752, in __call__
    return apply(self.func, args)
  File "c:\prog\tigris-cvs\leo\src\leoKeys.py", line 1991, in bindKeyCallback
    return k.masterKeyHandler(event,stroke=stroke)
  File "c:\prog\tigris-cvs\leo\src\leoKeys.py", line 2931, in masterKeyHandler
    val = self.masterKeyHandlerHelper(event,stroke)
  File "c:\prog\tigris-cvs\leo\src\leoKeys.py", line 2990, in masterKeyHandlerHelper
    val = k.callStateFunction(event) # Calls end-command.
  File "c:\prog\tigris-cvs\leo\src\leoKeys.py", line 2208, in callStateFunction
    val = k.state.handler(event)
  File "c:\prog\tigris-cvs\leo\src\leoKeys.py", line 2289, in fullCommand
    k.callAltXFunction(k.mb_event)
  File "c:\prog\tigris-cvs\leo\src\leoKeys.py", line 2327, in callAltXFunction
    func(event)
  File "C:\prog\tigris-cvs\leo\src\leoCommands.py", line 2801, in showFindPanel
    c.frame.findPanel{|{ingToFront()
  File "C:\prog\tigris-cvs\leo\src\leoTkinterFind.py", line 469, in bringToFront
    self.top.withdraw() # Helps bring the window to the front.
  File "c:\python24\lib\lib-tk\Tkinter.py", line 1562, in wm_withdraw
    return self.tk.call('wm', 'withdraw', self._w)
TclError: bad window path name ".25637872"

================================================
  Event contents:
    char:
    delta: 13
    height: ??
    keycode: 13
    keysym: Return
    keysym_num: 65293
    num: ??
    serial: 1486
    state: 0
    time: 1717970
    type: 2
    widget: .17570752.17571352.19882152.minibuffer
    width: ??
    x: 183
    x_root: 576
    y: -62
    y_root: 859

#@+node:ekr.20060421070409.33: *6* Don't do typing completion for numbers
# getLeadinWord must clear self.membersList to disable completion.
#@+node:ekr.20060421070409.36: *6* Fixed crash in undo
leoID = ekr (in c:\Documents and Settings\Ed)
reading settings in C:\prog\tigris-cvs\leo\config\leoSettings.leo
reading settings in C:\Documents and Settings\Ed\My Documents\ekr.leo
rst3 plugin: SilverCity not loaded
exception executing command
Traceback (most recent call last):

  File "C:\prog\tigris-cvs\leo\src\leoCommands.py", line 264, in doCommand
    val = command(event)

  File "C:\prog\tigris-cvs\leo\src\leoCommands.py", line 2969, in pasteOutline
    u.afterInsertNode(pasted,undoType,undoData)

  File "C:\prog\tigris-cvs\leo\src\leoUndo.py", line 750, in afterInsertNode
    u.pushBead(bunch)

  File "C:\prog\tigris-cvs\leo\src\leoUndo.py", line 182, in pushBead
    if bunch2 and bunch2.kind == 'beforeGroup':

AttributeError: 'Bunch' object has no attribute 'kind'
#@+node:ekr.20060421070409.37: *5* New features
#@+node:ekr.20060417092825.1: *6* Added script to update new copies of leoSettting.leo from previous copies
See the (presently disabled) script button in scripts.leo at:

Buttons-->@@button updateSettings

From the docstring:

Here is a **preliminary** script that updates a new leoSettings.leo file
(path2) from the settings in a previous leoSettings.leo file (path1).
Presumably, the path2 file is the leoSettings.leo file from a new distribution,
and the path1 file a leoSettings.leo file containing settings that you have
modified.  You must specify the full path of both files in the top-level @button node.

**Warning**: This script modifies the path2 file. Make sure that you don't mind
modifying this file.

**Warning**: This script is unsophisticated in its update algorithm. If if finds
corresponding nodes (node with the same settings name) in both outlines it simply
replaces the node in the path2 file with the node in the path1 file. In
particular, it does not keep track of individual shortcuts: it replaces the body
of one @shortcuts node with the body of the corresponding @shortcuts node.

**Note**: If the path1 file contains a settings node not in the path2 file it
attempts to create a new node in the corresponding place in the path2 file. If
this is not possible, say because the structures of the files are different, the
script places the new node as the last child of the @settings node in the path2
file.
#@+node:ekr.20060421070409.41: *6* Added new commands
New commands:

add-space-to-lines,
add-tab-to-lines
clean-lines
clear-selected-text
goto-global-line
help-for-command
open-outline-by-name (filename completion)
remove-space-from-lines
remove-tab-from-lines
#@+node:ekr.20060421070409.40: *6* Made all edit command undoable
#@+node:ekr.20060428084553: *4* 4.4 rc1
Leo 4.4 release candidate 1                                 April 28, 2006

This version fixes a few minor bug reported in 4.4b4 and adds 9 new commands.
The open-outline-by-name command supports filename completion.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Autocompletion and calltips.  Autocompletion works much like tab completion.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060428084553.2: *5* Bugs
#@+node:ekr.20060428084957: *6* Fixed rename-buffer command
#@+node:ekr.20060428084553.4: *6* Fixed bug when cutting text in headline
http://sourceforge.net/forum/message.php?msg_id=3692247

After cutting selection in the headline, headline area shrank too much.  
#@+node:ekr.20060428084553.10: *6* Fixed crasher in open-find-dialog
http://sourceforge.net/forum/message.php?msg_id=3692247

Find panel cannot be re-opened. Run open-find-dialog. Close it. Run open-find-dialog
again -- crash.
#@+node:ekr.20060428084553.34: *6* Suppressed typing completion for numbers
# getLeadinWord must clear self.membersList to disable completion.
#@+node:ekr.20060428084553.37: *6* Fixed crash in undo
Traceback (most recent call last):

  File "C:\prog\tigris-cvs\leo\src\leoCommands.py", line 264, in doCommand
    val = command(event)

  File "C:\prog\tigris-cvs\leo\src\leoCommands.py", line 2969, in pasteOutline
    u.afterInsertNode(pasted,undoType,undoData)

  File "C:\prog\tigris-cvs\leo\src\leoUndo.py", line 750, in afterInsertNode
    u.pushBead(bunch)

  File "C:\prog\tigris-cvs\leo\src\leoUndo.py", line 182, in pushBead
    if bunch2 and bunch2.kind == 'beforeGroup':

AttributeError: 'Bunch' object has no attribute 'kind'
#@+node:ekr.20060428084711: *6* Fixed crash in datenodes plugin
https://sourceforge.net/forum/message.php?msg_id=3699799
#@+node:ekr.20060428084553.38: *5* New features
#@+node:ekr.20060428084553.39: *6* Added clear-selection command
Useful, e.g., after a find.
#@+node:ekr.20060428084553.41: *6* Made all edit command undoable
self.beginCommand(undoType='xxx')
...
self.endCommand(changed=True,setLabel=True)
#@+node:ekr.20060428084553.42: *6* Added new commands
New commands:

add-space-to-lines
add-tab-to-lines
clean-lines
clear-selected-text
goto-global-line
help-for-command
remove-space-from-lines
remove-tab-from-lines
#@+node:ekr.20060428084553.273: *6* Added filename completion
At present, only the open-outline-by-name command supports filename completion.
#@+node:ekr.20060511074853: *4* 4.4 final
Leo 4.4 Final                                                     May 11, 2006

Leo 4.4 Final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4:
--------------------------
- An Emacs-like mini-buffer: you can now execute any command by typing its long
name, with tab completion.

- Many new commands, including cursor and screen movement, basic character, word
and paragraph manipulation, and commands to manipulate buffers, the kill ring,
regions and rectangles. You can use Leo without using a mouse.

- Flexible key bindings and input modes. You can emulate the operation of Emacs,
Vim, or any other editor.

- A tabbed log pane. The Find and Spell Check commands now use tabs instead of
dialogs, making those commands much easier to use. Plugins or scripts can easily
create new tabs. The Completion tab shows possible typing completions.

- Autocompletion and calltips.  Autocompletion works much like tab completion.
  To enable autocompletion, bind a key to the auto-complete command.

- Dozens of other new features and bug fixes since Leo 4.3.3.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080311060457.214: *3* 4.4.x
#@+node:ekr.20060822140418: *4* 4.4.1...new colorizer, slideshow, multiple editors
#@+node:ekr.20060830141224: *5* 4.4.1 final
Leo 4.4.1 final                                            August 30, 2006

Leo 4.4.1 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.1:
----------------------------
- Leo outputs decorators correctly, provided that the decorator is not a Leo directive.
- A new colorizer plugin controlled by jEdit language description files.
- A new shadow files plugin that allows external files not to have sentinel lines.
- Multiple editors in Leo's body pane.
- Search commands now support regex replace patterns: \1, \2, etc.
- Support for external debuggers: see http://leoeditor.com/debuggers.html
- The scripting plugin now creates a Debug Script button.
- Several new commands including run-unit-test, python-help, toggle-invisibles,
  and scroll-outline-left/right.
- The help-for-command commands now contains information for almost all commands.
- A new shortcut_button plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060830141224.2: *6* Removed warning about changed nodes
# Possibly a less intrusive warning should be used.
#@+node:ekr.20060830141224.13: *6* Bugs fixed
#@+node:ekr.20060830141224.14: *7* Fixed serious bug in Paste Node as Clone
#@+node:ekr.20060830141224.15: *8* Report
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3885494
By: mikecrowe

OK, I found out how to duplicate this one.  This caused me a lot of grief until
I found out what is causing it.

NodeA:
...Child1
...Child2
...Child3

NodeB:
...CloneChild1
...CloneChild2
...CloneChild3

Now, put cursor on NodaA.  Ctrl-Shift-C (copy node).
Next, put cursor on CloneChild3.  Paste Node as Clone
You should get an invalid paste clone message.

Now, first cursor move (for me) puts NodeB as top node, ERASING all other nodes.
Warning:  DO NOT SAVE NOW.  It will erase all other nodes.
#@+node:ekr.20060830141224.16: *8* What I did
@nocolor

- Created getLeoOutlineHelper.  This simplifies the code.
- Init self.checking in getLeoFile and getLeoOutline.
- Use self.checking in getVnodes, getVnode and createVnode.
  Using self.checking in getVnode complicates an already way-too-complex method, but it can't be helped.
#@+node:ekr.20060830141224.37: *7* Fixed minor .leoID.txt bug
#@+node:ekr.20060830141224.38: *8* Report
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3886250
By: znafets

A .leoID.txt with a \n behind the idstring creates a problem. 
It will be read in g.app.leoID and being used as is when writing the Leo file.

The fix is in app.setLeoID -> << return if we can set leoID from "leoID.txt" >>
#@+node:ekr.20060830141224.45: *7* Improved speed of unmark-all and corresponding undo/redo
#@+node:ekr.20060830141224.46: *8* Report
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3890031
By: terry_n_brown

I have a tree of some 2500 nodes, run a script that marks
probably 1500-2000 of them, and that's quick (2-3 seconds max.).

I can clear all the marks with:

for p in c.all_positions():
    p.v.clearMarked()

and that also is quick (2-3 seconds max.).  But when I use the menu option Unmark
All, that takes forever (1-2 minutes :-) running 100% CPU all the while.
#@+node:ekr.20060822140418.1: *5* 4.4.1 b4
Leo 4.4.1 beta 4                                            August 24, 2006

Leo 4.4.1 beta 4 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.1:
----------------------------
- Leo outputs decorators correctly, provided that the decorator is not a Leo directive.
- A new colorizer plugin controlled by jEdit language description files.
- A new shadow files plugin that allows external files not to have sentinel lines.
- Multiple editors in Leo's body pane.
- Search commands now support regex replace patterns: \1, \2, etc.
- Support for external debuggers: see http://leoeditor.com/debuggers.html
- The scripting plugin now creates a Debug Script button.
- Several new commands including run-unit-test, python-help, toggle-invisibles,
  and scroll-outline-left/right.
- The help-for-command commands now contains information for almost all commands.
- A new shortcut_button plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060822140418.3: *6* Bugs fixed
#@+node:ekr.20060822140418.4: *7* Added bindings to text panes for show-font command
http://sourceforge.net/forum/forum.php?thread_id=1542384&forum_id=10228
#@+node:ekr.20060822140418.26: *7* Fixed kill-line, kill-word, kill-sentence, etc
http://sourceforge.net/forum/message.php?msg_id=3839322
#@+node:ekr.20060822140418.29: *7* Fixed minor scrolling problem
http://sourceforge.net/forum/message.php?msg_id=3805745
#@+node:ekr.20060822140418.36: *7* Fixed bug in backward-kill-word
http://sourceforge.net/forum/message.php?msg_id=3841115

There is still some doubt about what the best operation of this command should be.
#@+node:ekr.20060822140418.39: *7* Fixed unicode bug in forward-word and backward-word commands
http://leo.zwiki.org/9RussianUnicodeWordsAreNotDetectedProperlyInBodyPane
#@+node:ekr.20060822140418.41: *7* Fixed problem setting body background color
http://sourceforge.net/forum/message.php?msg_id=3874380

Setting a value for background color in the body pane had no effect.

There were several problems, among which conflicting and confusing settings.
In particular, the insert_mode_bg_color setting overrides the body_text_background_color setting.

I changed the code so that insert_mode_bg_color defaults to
body_text_background_color, and put all the settings for the body text in one
place.
#@+node:ekr.20060822140418.49: *7* Disabled incremental colorizing in new colorizer when there are multiple editors
#@+node:ekr.20060822140418.97: *7* Removed component classes
These were overly complicated an not useful.
#@+node:ekr.20060822140418.69: *6* New features
#@+node:ekr.20060822140418.76: *7* Added scroll-outline-left/right commands
http://sourceforge.net/forum/message.php?msg_id=3834645
#@+node:ekr.20060822140418.77: *7* Generalized bracket flasher
http://sourceforge.net/forum/message.php?msg_id=3802513

Added these settings:

@string open_flash_brackets = ([{
@string close_flash_brackets = )]}
#@+node:ekr.20060822140418.88: *7* Leo *already* supports Python decorators
Leo *already* outputs decorators correctly, assuming the decorator does not conflict with a Leo directive.
#@+node:ekr.20060822140418.92: *7* Wrote script to convert g.es to g.et where appropriate
http://sourceforge.net/forum/message.php?msg_id=3858363
#@+node:ekr.20060822140418.70: *7* Created menu font settings
http://sourceforge.net/forum/message.php?msg_id=3802624

Added @font menu font setting
#@+node:ekr.20060601101643: *5* 4.4.1 b1
Leo 4.4.1 beta 1                                            June 3, 2006

Leo 4.4.1 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.1:
----------------------------
- A new colorizer plugin controlled by jEdit language description files.
  At present this plugin only reliably colors @language python code.
- Multiple editors in Leo's body pane.
- Search commands now support regex replace patterns: \1, \2, etc.
- Support for external debuggers: see http://leoeditor.com/debuggers.html
- The scripting plugin now creates a Debug Script button.
- Several new commands including run-unit-test, python-help and toggle-invisibles.
- The help-for-command commands now contains information for almost all commands.
- A new shortcut_button plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060601101958.1: *6* Fixed bugs
#@+node:ekr.20060601101958.56: *7* The Open Python Window command runs Idle in a separate process
This fixes all conflicts between Leo and Idle.
#@+node:ekr.20060601101958.2: *7* Fixed crasher in searchbox plugin
http://sourceforge.net/forum/message.php?msg_id=3729858

Fixed crasher in Leo 4.4 by initing self.p in Quickfind ctor.
#@+node:ekr.20060601101958.6: *7* Fixed binding problems in leoSettings.leo reported by Check bindings script.
http://sourceforge.net/forum/message.php?msg_id=3737879
#@+node:ekr.20060601101958.13: *7* Fixed crasher in macros plugin
http://sourceforge.net/forum/message.php?msg_id=3737745

- Added event keyword argument to parameterize function.
#@+node:ekr.20060601101958.14: *7* Fixed crasher in  UNL plugin
http://sourceforge.net/forum/message.php?msg_id=3737745

The fix was to add a c argument to g.findTopLevelNode and g.findNodeInTree.
#@+node:ekr.20060601101958.16: *7* Suppressed traceback in g.callers when the call stack isn't deep enough
#@+node:ekr.20060603082009: *7* Fixed long-standing bug involving @comment and @language
http://sourceforge.net/forum/message.php?msg_id=3761285

There were actually two bugs:

- parseLeoSentinel was not recognizing the closing comment delim (!!)

- putDirective was incorrectly setting delims for @language and @comment delims.
  This is wrong: the init code calls scanAllDirectives, and the comment delims
  **must not change** in the file (except as the result of @delims.)
#@+node:ekr.20060601102802: *6* New features, commands & plugins
#@+node:ekr.20060601101958.245: *7* Support for multiple editors in the body pane
The add-editor command adds a new editor, the delete-editor command deletes the
presently selected editor, and the cycle-editor-focus command cycles focus
between editors in the body text.
#@+node:ekr.20060601101958.70: *7* Improved searches
- Allow \1, \2, etc. replacements in re searches.

- Allow \n and \t in plain searches.

- The shortcut for the replace-string command now changes from the find command
to the replace command.
#@+node:ekr.20060601101958.52: *7* Added debug command
This runs the winpdb debugger in a separate process.

The winpdb debugger must be installed for this command to work.

For more details, see: http://leoeditor.com/debuggers.html
#@+node:ekr.20060601101958.58: *7* Added Debug button to scripting plugin
#@+node:ekr.20060603072938: *7* Added python-help command
This prompts for a string s, then puts the result of help(s) in Leo's log pane.
#@+node:ekr.20060601101958.277: *7* Added toggle-invisibles and hide-invisibles commands
#@+node:ekr.20060601101958.172: *7* Added run-unit-test command
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3575014

Actually, the run-unit-tests command first appeared in Leo 4.4, but it never got
properly announced.
#@+node:ekr.20060601101958.234: *7* The help-for-command command now works for almost all commands
#@+node:ekr.20060603081537: *7* Added shortcut_button plugin
This plugin creates a 'Shortcut' button in the icon area. Pressing the Shortcut
button creates *another* button which when pressed will select the presently
selected node at the time the button was created.
#@+node:ekr.20060601102802.2: *6* New and improved settings
#@+node:ekr.20060601101958.174: *7* Added @bool idle_redraw setting
http://sourceforge.net/forum/message.php?msg_id=3729823

This is intended to help with redraw problems on Linux.
#@+node:ekr.20060601101958.264: *7* Added autoindent_in_nocolor_mode setting
@nocolor

leoSettings.leo now contains the following setting, with default as shown:

@bool autoindent_in_nocolor_mode = True


True:  auto-indent regardless of how text is colored.
False: disable auto-indenting if in range @nocolor or @kill.

This will make the default action work as Roger Erens requested, and will allow
you to make Leo work exactly as before if you want.
#@+node:ekr.20060601101958.244: *7* Added warnings about the expanded_click_area setting
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3737745

Added warnings in various places that the setting:

@bool expanded_click_area = True

interferes with the  Universal Scrolling plugin.
#@+node:ekr.20060601101958.276: *7* Removed support for @shortcut (@shortcuts remains)
@shortcut nodes never worked and apparently nobody ever used them.
#@+node:ekr.20060601101958.28: *6* Minor improvements
#@+node:ekr.20060601101958.218: *7* Finished Cmds menu
#@+node:ekr.20060601101958.235: *7* Improved show-fonts command
It is now clearer what the selected values are.
#@+node:ekr.20060601101958.238: *7* Strip quotes from color, font settings.
#@+node:ekr.20060601101958.239: *7* Warn about invalid Enter and Leave key bindings
#@+node:ekr.20060620094645: *5* 4.4.1 b2
Leo 4.4.1 beta 2                                            June 23, 2006

Leo 4.4.1 beta 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.1:
----------------------------
- A new colorizer plugin controlled by jEdit language description files.
  At present this plugin only reliably colors @language python code.
- Multiple editors in Leo's body pane.
- Search commands now support regex replace patterns: \1, \2, etc.
- Support for external debuggers: see http://leoeditor.com/debuggers.html
- The scripting plugin now creates a Debug Script button.
- Several new commands including run-unit-test, python-help and toggle-invisibles.
- The help-for-command commands now contains information for almost all commands.
- A new shortcut_button plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060620094645.34: *6* Bugs fixed
#@+node:ekr.20060620094645.35: *7* Made sure calltip always adds '('
#@+node:ekr.20060620094645.43: *7* word matches now succeed if first character of the pattern is not in word-chars.
#@+node:ekr.20060620094645.44: *7* Dialogs now bring the Leo window back to the front
Called c.bringToFront() after open/save/import dialogs.
#@+node:ekr.20060620094645.45: *7* Fixed unit test: ensure that body gets focus after ending editing
FAIL: @test return ends editing of headline

----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\prog\tigris-cvs\leo\src\leoTest.py", line 155, in runTest
    exec script + '\n' in {'c':c,'g':g,'p':p}
  File "<string>", line 14, in ?
AssertionError: oops2

----------------------------------------------------------------------
Ran 438 tests in 193.628s

FAILED (failures=1)
>>>
#@+node:ekr.20060620094645.46: *7* Remember scrolling postion, insert point and selection range in multiple editors
http://sourceforge.net/forum/message.php?msg_id=3764077
#@+node:ekr.20060620094645.50: *7* Fix crasher in kill-region command
#@+node:ekr.20060620094645.52: *7* Fixed bug: cycle-editor hung Leo
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3771032
By: paulpaterson

The cycle-editor-focus command causes Leo to lock up  on my machine (WinXP,
Python 2.4).

@color
#@+node:ekr.20060620094645.64: *7* Fixed crasher in init code
http://sourceforge.net/forum/message.php?msg_id=3771014
#@+node:ekr.20060620094645.68: *7* use g.stripBrackets instead of lstrip and rstrip
lstrip and rstrip do not exist in Python 2.2.1.
#@+node:ekr.20060620094645.76: *7* Restore cursor when changing focus in editors
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3778764
By: davidmcnab

When I hit my 'change-editor-focus' binding, the cursor jumps
to unpredictable places within the next editor pane.
#@+node:ekr.20060620094645.77: *7* Undo restores focus again
#@+node:ekr.20060622130815: *7* Updated row/col indicators when using arrow keys
http://sourceforge.net/forum/message.php?msg_id=3790857
#@+node:ekr.20060622130815.3: *7* Fixed show-invisibles crasher
http://sourceforge.net/forum/message.php?msg_id=3790814
#@+node:ekr.20060620094645.78: *6* Code level
#@+node:ekr.20060620094645.79: *7* Simplified gui bindings
Added makeMasterGuiBinding.
#@+node:ekr.20060622130815.9: *7* Created g.app.gui.makeScriptButton
#@+node:ekr.20060620094645.85: *6* New & improved features
#@+node:ekr.20060620094645.86: *7* Improved filename completion
#@+node:ekr.20060620094645.96: *7* Added support for --> command-name in @mode nodes
#@+node:ekr.20060620094645.97: *7* Better listings for print-commands and print-bindings & mode-help commands
#@+node:ekr.20060620094645.103: *7* Fixed find-character & find-word commands
#@+node:ekr.20060620094645.106: *7* Better printing of bindings (period -> .) etc
#@+node:ekr.20060620094645.107: *7* Added support for !command, !insert and !overwrite bindings
Leo now supports bindings of the form:

command-name !command = shortcut

You will find examples in leoSettings.leo in the node

@keys EKR bindings: vim mode bindings-->Shortcuts-->@shortcuts top-level keys

Such bindings are essential for all plain key bindings that are *only* to be executed in command mode.  Most, but *not* all plain key bindings should be bound in the !command 'pane'.  The two exceptions presently are '.' which *always* invokes the autocompleter code and '(' which *always* invokes the calltips code.

It is now possible to have a *single* set of key bindings be 'Emacs-like' and
'Vim-like' at the same time. See the node EKR bindings: vim mode bindings in
leoSettings.leo.

One setting switches between emacs-like operation and vim-like operation:

For emacs, use:
@strings  [ignore,insert,overwrite] top_level_unbound_key_action = insert

For vim, use:
@strings  [ignore,insert,overwrite] top_level_unbound_key_action = ignore

Vim-like modes are made possible by two new features:

1. Entry commands in @mode nodes. In the body of @mode nodes, lines of the form

--> command-name

tell Leo to execute the command when entering the mode. More than one such lines
may exist; Leo executes them in the order they appear. Entry commands are
potentially a very powerful feature. To avoid chaos, entry commands should not
alter the minibuffer :-)

2. Silent modes. In order to keep the selected text visible, Leo must *not* move
focus into the minibuffer for editing commands. The set-silent-mode command
tells Leo to treat the mode described in the @mode node as a silent mode. A true
mode is created, but it only affects key bindings and the minibuffer never
becomes active.

Thus, all @mode nodes for vim-like modes contain the following line:

--> set-silent-mode.
#@+node:ekr.20060620094645.108: *7* Improved check bindings script in leoSettings.leo
All sets of key bindings in leoSettings.leo now start with @keys in the headline
of the root node. The @keys convention is used *only* by the Check Bindings
script. So now, instead of having a static list of key bindings sets (which is
guaranteed to get out-of-date), the Check Bindings script can scan all of
leoSettings.leo for sets of key bindings.

Another improvement to the Check Bindings script. Besides doing a better job of
checking, you may now specify optional commands, such as commands defined in
plugins. The Check Bindings will not complain if the commands don't presently
exists in k.commandsDict. You specify such commands by adding items to the
following lists in the root node of the Check Bindings script, i.e., the node
Buttons-->@button Check Bindings.

optionalCommandPrefixes = ['group-operations']
optionalCommandNames = []
#@+node:ekr.20060620094645.109: *7* Improved isearch & added isearch-with-present-options command
- added isearch-with-present-options.
- many small improvements to isearch code.
- regex searches now highlighted properly.
- isearches are (and should be) confined to a single body text.
- Backspace now handled properly.

A small glitch. Starting a regexp pattern with '.' will cause the entire pattern
to turn red initially, which is technically correct but perhaps a bit
confusing.
#@+node:ekr.20060620094645.194: *7* Use last shortcut defined
http://sourceforge.net/forum/message.php?msg_id=3767016
#@+node:ekr.20060620094645.225: *7* selfInsertCommand sets the column used by up/down arrows
#@+node:ekr.20060620094645.231: *7* Added toggle-autocompleter and toggle-calltips commands
The commands that enable and disable calltips now update the status line.
#@+node:ekr.20060620094645.232: *7* Script buttons now create press-xxx-button commands
Creating a script button creates the press-xxx-button command,
and you can specify settings for such commands using @shortcuts nodes.
#@+node:ekr.20060620094645.233: *7* print-bindings command now properly sorts bindings
#@+node:ekr.20060620094645.234: *7* Allow @shortcuts bindings to apply to press-xxx-commands
@nocolor

The scripting plugin now creates a press-x-button command for each scripting button named x.
You can bind shortcuts to such commands by placing @shortcuts nodes in an @setting tree in the outline containing the @button nodes.  test.leo shows an example.

What I did:

- The scripting plugin now defines button bindings with the 'button' pane specifier.
  This takes precedence over all other specifiers.

- k.bindKeyToDict now does a better job of detecting and warning about redefinitions.

- k.printBindings now properly sorts entries.
  This was causing me a great deal of confusion.

- k.registerCommand now properly gets shortcuts from settings if possible,
  and makes bindings in the new 'button' pane specifier.

- masterKeyHandlerHelper now supports the 'button' pane specifier,
  which overrides all others.

@color
#@+node:ekr.20060620094645.242: *7* Added support for @abbrev nodes in leoSettings.leo
#@+node:ekr.20060620094645.243: *7* Created open-users-guide command
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3772475

Maybe put a link to the html TOC into the Help Menu,
"%leodir%/doc/html/leo_TOC.html".

This is more intuitive (to newbies) than the LeoDocs.leo link.  I found this
very confusing in the beginning.

What I did:

- Created open-users-guide command.
- Created Open Users Guide menu item.
- Removed Open Offline Tutorial menu item.

@color
#@+node:ekr.20060620094645.252: *7* scroll-up/down commands now scroll the outline if focus is in outline pane
# Important: this can be done better using per-pane bindings as in the default leoSettings.leo.
#@+node:ekr.20060620094645.258: *7* Cycle-focus command cycles through tabs and editors
#@+node:ekr.20060620094645.286: *7* Allow @mode outside of leoSettings.leo
#@+node:ekr.20060622130553: *7* Added section about upgrading settings

http://sourceforge.net/forum/message.php?msg_id=3784292

http://leoeditor.com/installing.html#updating-settings-from-previous-versions-of-leo
#@+node:ekr.20060622130553.2: *7* Documented how to turn @buttons into plugins
http://sourceforge.net/forum/message.php?msg_id=3778946

http://leoeditor.com/writingPlugins.html#turning-script-buttons-into-plugins
#@+node:ekr.20060620094645.302: *6* Plugins
#@+node:ekr.20060620094645.303: *7* Added doc-only option to rst3
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3767601
http://sourceforge.net/forum/message.php?msg_id=3768413
Craig

I have an @thin file with @Doc and @Code sections scattered though out the tree,
where each node has one or more doc and code sections.

I would like to be able to use the rst3 plugin to produce an html file containing
only info from the doc sections, ignoring the code sections.

I added the 
#@+node:ekr.20060620094645.304: *7* Fixed bug in rst doc_only_mode
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3770732
By: ktenney

In << Theory of operation of find/change >> 
the opening paragraph does not appear in the html,
#@+node:ekr.20060620094645.305: *7* Support show_headlines options in doc-only mode in rst3 plugin
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3780216
Craig

In Doc_Only_Mode the rst3 plugin outputs headlines irrespective of the show_headlines
setting.  The other modes do honor this setting.

I scratched around and managed to fix this by changing the node: rst3.py-->class
rstClass-->write methods-->writeBody & helpers-->handleDocOnlyMode

In Line 25 I added a new statement:
     if showHeadlines:
and indented the following 3 lines to make them conditional on this if:
        if result or showThisHeadline or showOrganizers or p == self.topNode:
            # g.trace(len(result),p.headString())
            self.writeHeadlineHelper(p)
#@+node:ekr.20060620094645.306: *7* Fixed bug in UNL plugin
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3785400
By: craigj3


I have a @url node pointing to a Leo file which has a filename with %20 in it.
When I double-click this node I get:

"can not open: \\\Documents%20and%20Settings\tftcj1.EDCON\My%20Documents\Proj\RI
CAA\PcasCellLink.leo"

Taking a look with a debugger, I see that Plugins-->Enhancing the icon and status
areas-->@thin UNL.py-->onUrl1 line 29ish does not covert %20 to spaces before
calling openWithFileName.
#@+node:ekr.20060620094645.307: *7* Improved image plugin
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3783225
Craig

I am looking at the image plugin for organizing photos, and discovered that
it is limited to gif files only.  I found this a bit silly as installing the
ImageTk module from the Python Imaging Library and making a two line change
to the plugin enables it to be used on practically any image type.

The two line are:
1.  a new import:-
import ImageTk

2. In <<select image>> line 9 change 
photo = Tk.PhotoImage(master=a.root, file=filename)

to

photo = ImageTk.PhotoImage(master=a.root, file=filename)
#@+node:ekr.20060620094645.308: *7* Fixed path problem with rst3 plugin
@nocolor
http://sourceforge.net/forum/message.php?msg_id=3779706
By: mstarzyk

My point was not about not found CSS, but that .html files are written to
default_path directory, but .txt files are not written to default_path
directory.
#@+node:ekr.20060620094645.309: *7* Fixed crashers in scheduler plugin
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3784636
By: craigj3

I note that the scheduler plugin is currently broken.

The problem was that all commands now get an event arg.

The Begin Recording and End Recording commands do not seem to work...
#@+node:ekr.20060622132524: *6* Settings
#@+node:ekr.20060620094645.299: *7* Added editor_orientation setting
http://sourceforge.net/forum/message.php?msg_id=3778744

Added editor_orientation setting: valid values are vertical and horizontal.
#@+node:ekr.20060629083400.1: *5* 4.4.1 b3
Leo 4.4.1 beta 3                                            June 29, 2006

Leo 4.4.1 beta 3 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.1:
----------------------------
- A new colorizer plugin controlled by jEdit language description files.
  At present this plugin only reliably colors @language python code.
- Multiple editors in Leo's body pane.
- Search commands now support regex replace patterns: \1, \2, etc.
- Support for external debuggers: see http://leoeditor.com/debuggers.html
- The scripting plugin now creates a Debug Script button.
- Several new commands including run-unit-test, python-help and toggle-invisibles.
- The help-for-command commands now contains information for almost all commands.
- A new shortcut_button plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060629083935.2: *6* Bugs fixed
#@+node:ekr.20060629083935.3: *7* Fixed recent bug: Ctrl-g does not work in @mode nodes
#@+node:ekr.20060629083935.8: *7* Update column display when typing
http://sourceforge.net/forum/message.php?msg_id=3795258

The column display doesn't change while typing.

#@+node:ekr.20060629083935.15: *7* Fixed long-standing problem reporting indentation errors
http://sourceforge.net/forum/message.php?msg_id=3510448

The fix was to getLastTracebackFileAndLineNumber.

I also created handleScriptException.
#@+node:ekr.20060629083935.25: *7* Fixed long-standing bug in Remove Sentinels command
http://sourceforge.net/forum/message.php?msg_id=3413805
#@+node:ekr.20060629083935.32: *7* Fixed long-standing bugs in import code
- Underindented comments do not end the scan of Python classes or methods.
- Handles continued signature lines properly.
#@+node:ekr.20060629083935.61: *7* Overwrite mode now works in headllines
Note: Editing headline text will happen in insert mode unless

@strings top_level_unbound_key_action = overwrite
#@+node:ekr.20060629083935.70: *7* Fixed crasher in masterCommand
After executing a command we must be careful to test c.exists.
#@+node:ekr.20060629083935.71: *7* Improved view-lossage command
- A better trace, and the trace goes to the log pane.

- Eliminated k.keysymHistory: Tk keysyms are pretty useless.
#@+node:ekr.20060629083935.74: *6* New features
#@+node:ekr.20060629083935.75: *7* Finished repeat-complex-command
@nocolor

- Improved prompt.
- Added message if no previous complex command.
- Added mode entries.
#@+node:ekr.20060629083935.76: *7* Read leoSettings.leo from the directory containing the .leo file
http://sourceforge.net/forum/message.php?msg_id=3794854
#@+node:ekr.20060629083935.93: *7* Flash matching parens & corresponding settings
@killcolor

Here are the relevant settings:

@bool flash_matching_brackets: True: flash matching bracket when typing (, ), [, ], { or }.

@color flash_brackets_background_color and @color flash_brackets_foreground_color.

@int flash_brackets_count: The number of times to flash matching brackets.

@int flash-brackets-delay: One half the total cycle time of bracket flashes, in milliseconds.
#@+node:ekr.20060629083935.96: *6* New settings
#@+node:ekr.20060629083935.97: *7* Added standard bindings for Ctrl-y (yank) and Ctrl-k (kill-line)
# Ctrl-k is no longer needed by the match-brackets command now that brackets flash automatically.
#@+node:ekr.20060629083935.98: *7* Added @bool warn_about_redefined_shortcuts setting
#@+node:ekr.20060629083935.99: *7* Added @bool trace_bind_key_exceptions setting
When True, this provides a full traceback for all exceptions taken when binding keyboard shortcuts.
#@+node:ekr.20060629083935.100: *7* Added bracket flash settings
@killcolor

@bool flash_matching_brackets: True: flash matching bracket when typing (, ), [, ], { or }.

@color flash_brackets_background_color and @color flash_brackets_foreground_color.

@int flash_brackets_count: The number of times to flash matching brackets.

@int flash-brackets-delay: One half the total cycle time of bracket flashes, in milliseconds.
#@+node:ekr.20060903102158: *5* 4.4.1.1 final
Leo 4.4.1.1 final                                       September 3, 2006

Leo 4.4.1.1 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.4.1.1 corrects a serious last-minute unicode bug in Leo 4.4.1.
This version also adds the new slideshow plugin.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.1:
----------------------------
- Leo outputs decorators correctly, provided that the decorator is not a Leo directive.
- A new colorizer plugin controlled by jEdit language description files.
- A new shadow files plugin that allows external files not to have sentinel lines.
- A new slide show plugin allows you to use Leo outlines as slide shows.
- Multiple editors in Leo's body pane.
- Search commands now support regex replace patterns: \1, \2, etc.
- Support for external debuggers: see http://leoeditor.com/debuggers.html
- The scripting plugin now creates a Debug Script button.
- Several new commands including run-unit-test, python-help, toggle-invisibles,
  and scroll-outline-left/right.
- The help-for-command commands now contains information for almost all commands.
- A new shortcut_button plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20061008190905: *4* 4.4.2... opml, zodb, sax, myLeoSettings, leoPymacs, autocontract, outline nav
#@+node:ekr.20060928172040: *5* 4.4.2 beta 1
Leo 4.4.2 beta 1                                  September 29, 2006

Leo 4.4.2 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.2:
----------------------------
- You can now store settings in myLeoSettings.leo without fear of those settings
  being changed by cvs updates or in future versions of Leo.
- Leo's vnode and tnode classes are now completely independent of the rest of Leo.
  Some api's have been changed.  This 'big reorg' and may affect scripts and plugins.
- Leo's vnode and tnode classes can optionally be compatible with ZODB databases,
  i.e., they can optionally derive from ZODB.Persistence.Persistent.
  See Chapter 17: Using ZODB with Leo for details.
- The leoOPML plugin defines commands to read and write OPML files.
- The slideshow plugin allows Leo to run slideshows defined by @slideshow and @slide nodes.
- The leo_to_rtf and leo_to_html plugins create rtf and html files from Leo outlines.
- Much faster navigation through the outline using Alt-arrow keys.
- When focus is in the outline pane, you can move to headlines by typing the first letter of headlines.
- The find command now closes nodes not needed to show the node containing the present match.
- Numerous changes that make Leo easier to use without using a mouse.
- Many new minibuffer commands now appear in the Cmds menu.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20060928172525.81: *6* The 'big reorg':  vnode, tnode and position classes are independent of the rest of Leo
What I did:

- Removed c argument from t, v and p ctors.
- Removed c argument from most position methods.
    - In particular, p.link, p.unlink, v.link and v.unlink no longer update c.currentPosition()
    - Moved all position methods that still had a c argument to the Commands class.
- Removed p.all_positions.
- Added c.findRootPosition and c.findRootVnode.
- c.rootPosition now returns c.findRootPosition(c.currentPosition())

As a result:

- The tnode, vnode and position classes are *completely* independent of Leo.
  In particular, no tnode, vnode or position method gets a c argument.
- The p.link, p.unlink, v.link and v.unlink are significantly simpler.
- The machinery for keeping the root position up-to-date is
  simple and confined to one place in the Commands class.
#@+node:ekr.20060928195040: *6* New features
#@+node:ekr.20060928194633.1: *7* myLeoSettings.leo
The myLeoSettings.leo file is a way of ensuring that your customized settings
are not altered when updating Leo from cvs or while installing a new version of
Leo. The myLeoSettings.leo acts much like Python's site-customize.py file. The
myLeoSettings.leo file will never be part of any Leo distribution. This solution
is *much* better than trying to update leoSettings.leo with scripts.

Leo loads settings from myLeoSettings.leo *after* loading settings from
leoSettings.leo files but *before* loading settings from the .leo file being
opened.
#@+node:ekr.20060928172525.195: *7* Created simple support for ZODB databases
@nocolor

My present thinking is that scripts should be able to store/retrieve persistent
objects to/from the zodb. That is, the zodb plugin is likely to be retired.

Leo's vnode and tnode classes now derive from ZODB.Persistence.Persistent if
leoNodes.use_zodb is True. It remains to be seen whether having use_zodb = True
will cause any serious problems.

See the posting below (Scripting using zodb) for latest details.

See the node 'zodb get/put buttons' in test.leo for examples of how scripts can access zodb easily.

Created g.init_zodb and v.detach.
#@+node:ekr.20060928172525.197: *8* Scripting using zodb
> Do you see zodb as persisting Leo files or Leo nodes?

Interesting question.  I now see the zodb plugin as a proof-of-concept for *user-defined* scripts.  The zodb plugin is probably going to go away.

Let us suppose that db is a ZODB.DB instance. (To see how to create such an instance, see the init_zodb method in the zodb plugin.  Perhaps I'll defines something like g.openZodb to make this easier.)  Then the statements:

connection = db.open()
root = connection.root()
root[aKey] = v
get_transaction().commit()
connection.close()

will write all of v's data (all vnodes and tnodes) to the zodb.  This is true whatever v is: it can be the root of an entire outline, or any suboutline.  If you want to write a single node, you would have to 'detach' that node from the outline.  You can do this by copying the node and then unlinking the node from its descendants. Perhaps I could add a convenience method to the vnode class to make this easier.

>Do you see zodb work as providing enhanced access to nodes across multiple files?

Scripts could do so easily.  Happily, the distinction between 'long-lived' and 'short-lived' connections is not important for scripts: a script should hold a connection open only for as long as needed.  So it would be easy to write any number of vnode trees to the zodb.  Later, another script could access any of the data in the zodb by zodb key.  Like this:

connection = db.open()
root = connection.root()
v = root.get(aKey)
p = leoNodes.position(v,[])

After running this script, p is a position representing the root of the tree of 'imported' vnodes.  The script above does not 'connect' the imported trees to an outline, nor should it do so.  As I write this, I realize that the position ctor should make the second argument optional, so that leoNodes.position(v) would be equivalent to leoNodes.position(v,[]).

Each script should open at most connection at a time and be sure to close any zodb connection it creates.  The proper way to do this is in a finally statement, like this:

try:
....connection = db.open()
....root = connection.root()
....v = root.get(aKey)
....p = leoNodes.position(v,[])
....<< do something with the nodes in p's tree>>
finally:
....get_transaction().commit()
....connection.close()

In short, the recent changes to Leo's vnode and tnode classes give scripts the ability to save/retrieve Leo data to/from the zodb in any way a script wants, without any further support from Leo, or from me.

I shall spend an hour or two more with the zodb plugin, but it looks to me that the plugin has served its purpose.  Rather than trying to guess how people will want to use the zodb, it will be simpler and more general to have people write scripts that do exactly what they want.  In particular, such scripts can easily sidestep the problems with multiple open connections.

Edward

P.S. Please note that the scripts shown above could not have been written without all the recent work with the zodb plugin and the big code reorg.

P.P.S. A couple of unit tests involving the new v/t.__hash__ methods just failed, so it may be just a little bit longer before the code on cvs is truly zodb ready.  I'll also be working on example scripts and the convenience methods described above.

EKR
#@+node:ekr.20060928172525.172: *7* Improved help-for-command
It now prints the binding for the command.
#@+node:ekr.20060928172525.180: *7* Improved  quick-find commands
Rewrote moveWordHelper. It now avoids Tk and regexes.  *Much* simpler.
#@+node:ekr.20060928172525.198: *7* Improved how Leo works w/o the mousre
- Removed all modes except Alt-C mode.
- Use Shift-arrows for outline moves when focus is in outline pane.
- Put help / apropos commands in help menu.
- Put focus commands in Cmds menu.
- When focus is in outline, normal character navigates like Windows explorer.
- Put Scrolling commands in Cmds menu.
- Screened out(some) unwanted characters from affecting outline navigation.More work is needed.
- Esc character is never inserted into text.
- Replaced @button clones-tab with @command clones-tab.
- Scripting plugins now sets verbose=True so @commands get shown.
* Alt keys (outline move commands) should set focus to outline even if nothing else happens.
- Closing a window no longer puts focus in limbo: added force argument to c.set_focus.
- New gui bindings: (I should actually be able to remember these).
    contract-pane                       = Alt+Ctrl+-
    expand-pane                         = Alt+Ctrl-=
    focus-to-tree                       = Alt-space
    scroll-outline-down-page            = Alt-PageDn
    scroll-outline-down-page            ! tree = PageDn
    scroll-outline-up-page              = Alt-PageUp
    scroll-outline-up-page              ! tree = PageUp
    scroll-outline-left                 = Alt+Ctrl+LtArrow
    scroll-outline-right                = Alt+Ctrl+RtArrow
- Put find-character and back-find-character in Edit:Find menu.
- Use Alt-S,Alt-R for incremental searches.
- Created find-character-extend-selection and back-find-character-extend-selection.
- Added binding (Ctrl-W) and entry in Cmds menu for select-word-at-cursor.
- Added binding (Ctrl-P) for repeat-complex-command.
- Added binding (Ctrl-B) for execute-script.
* Fixed bug in extend mode.
- Added binding (Ctrl-space) for toggle extend mode.
- Removed most cursor move bindings involving ctrl keys. Exception: ctrl-a and ctrl-e.
    ** The idea is that I'll use extend mode instead.
- Stay in outline mode: added @bool stayInTreeAfterEditHeadline setting.
- Added Cmds:Toggle Settings submenu.
- Use emacs names in Cmds menu (and in some other places): allow single item in menu tables.
#@+node:ekr.20060928172525.237: *7* Increased speed of arrow keys
http://sourceforge.net/forum/message.php?msg_id=3935368
#@+node:ekr.20060928172525.240: *7* Find command now collapses nodes during searches
http://sourceforge.net/forum/message.php?msg_id=3935780

This greatly speeds searches that used to open many nodes.
#@+node:ekr.20060928172525.252: *7* Added support  -- comments in @url nodes
http://sourceforge.net/forum/message.php?msg_id=3935981

@url nodes of the form::

    @url -- aComment

now get the actual url from the entire first line of body text.
Such url's need not be quoted if they contain spaces.

#@+node:ekr.20060928172525.167: *7* Added many new commands to Cmds menu
#@+node:ekr.20060928195040.1: *6* New plugins
The following plugins are new in Leo 4.4.2 b2:

leo_to_rtf
leo_to_html
leoOPML  (At present, contained in leoOPML.leo instead of leoPlugins.leo)
paste_as_headlines
slideshow
word_count

The __saxRead__.py plugin is an **experimental** for use by EKR.
It will be folded into Leo's core in the near future.
#@+node:ekr.20061008190655: *5* 4.4.2 beta 2
Leo 4.4.2 beta 2                                  October 9, 2006

Leo 4.4.2 beta 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.2:
----------------------------
- You can now store settings in myLeoSettings.leo without fear of those settings
  being changed by cvs updates or in future versions of Leo.
- Leo's vnode and tnode classes are now completely independent of the rest of Leo.
  Some api's have been changed.  This 'big reorg' and may affect scripts and plugins.
- Leo's vnode and tnode classes can optionally be compatible with ZODB databases,
  i.e., they can optionally derive from ZODB.Persistence.Persistent.
  See Chapter 17: Using ZODB with Leo for details.
- The leoOPML plugin defines commands to read and write OPML files.
- The slideshow plugin allows Leo to run slideshows defined by @slideshow and @slide nodes.
- The leo_to_rtf and leo_to_html plugins create rtf and html files from Leo outlines.
- Much faster navigation through the outline.
- When focus is in the outline pane, you can move to headlines by typing the first letter of headlines.
- The find command now optionally closes nodes not needed to show the node containing the present match.
- Numerous changes that make Leo easier to use without using a mouse, including new commands and options.
- Many new minibuffer commands now appear in the Cmds menu.
- A sax parser can now optionally read .leo files.
- Fixed numerous bugs.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20061008190633.248: *6* Bugs
#@+node:ekr.20061008190633.249: *7* Fixed rst3 problem
http://sourceforge.net/forum/message.php?msg_id=3932641

Leo *always* outputs the first line of a node without indentation even if it is indented in the node.
#@+node:ekr.20061008190633.250: *7* Fixed apparent bug in pmw
This was a very weird one.  It's not clear why it wasn't biting before.

Traceback (most recent call last):
  File "c:\prog\tigris-cvs\leo\src\leo.py", line 321, in <module>
    run(fileName)
  File "c:\prog\tigris-cvs\leo\src\leo.py", line 151, in run
    g.app.gui.runMainLoop()
  File "c:\prog\tigris-cvs\leo\src\leoTkinterGui.py", line 182, in runMainLoop
    self.root.mainloop()
  File "c:\python25\lib\lib-tk\Tkinter.py", line 1023, in mainloop
    self.tk.mainloop(n)
  File "C:\prog\tigris-cvs\leo\extensions\Pmw\Pmw_1_2\lib\PmwBase.py", line 1756, in __call__
    _reporterror(self.func, args)
  File "C:\prog\tigris-cvs\leo\extensions\Pmw\Pmw_1_2\lib\PmwBase.py", line 1782, in _reporterror
    msg = exc_type + ' Exception in Tk callback\n'
TypeError: unsupported operand type(s) for +: 'type' and 'str'
#@+node:ekr.20061008190633.257: *7* Fixed various unicode word-select problems
- created g.isWordChar.  It does proper test for letters and numbers.
- Used g.isWordChar in extendToWord and moveWordHelper.
- OnBodyDoubleClick now just calls c.editCommands.extendToWord.

So Russian characters, e.g., no longer 'interrupt' words.

Another fix: extend-to-word now works properly at the very end of a word.
#@+node:ekr.20061008190633.261: *7* Installed installer patch
Installer does not complain about missing Python and does not install anything
either. Here is a fix to this behavior. In most user-friendly way it would be
better to provide a clickable link to Python site and a way to specify the path
manually, but for now it is just that - a fix.
#@+node:ekr.20061008190633.262: *7* Use letter accellerators for recent files after 9
#@+node:ekr.20061008190633.264: *7* Made yank work in minibuffer
w was set to self.w, rather than event.widget.
#@+node:ekr.20061008190633.265: *7* Mass change to edit commands: made sure w is a text widget
Added self.editWidget.  This sets self.w and makes sure w is a text widget.
#@+node:ekr.20061008190633.283: *7* Do full recolor after cut/paste/yank
This fixes a long-standing, annoying bug.
#@+node:ekr.20061008190633.294: *7* Fixed crash when pasting a node
The solution was to call setTimestamp if needed in getNewIndex.

#@+node:ekr.20061008192040: *6* Settings
#@+node:ekr.20061008190633.298: *7* Completed support for myLeoSettings.leo
New in beta 2: Leo looks for myLeoSettings.leo files in the same place Leo looks for leoSettings.leo files.
#@+node:ekr.20061008190633.306: *7* Added settings for all mod_scripting switches
#@+node:ekr.20061008190633.307: *7* Added @bool collapse_nodes_during_finds
http://sourceforge.net/forum/message.php?msg_id=3935780

This greatly speeds searches that used to open many nodes.

Added support for @bool collapse_nodes_during_finds setting.
#@+node:ekr.20061008190633.325: *7* Added @bool outline_pane_has_initial_focus
#@+node:ekr.20061008190633.362: *7* Added @bool sparse_move_outline_left





#@+node:ekr.20061008190633.360: *7* Added bindings for Alt-Shift-Arrow keys to force an outline move
#@+node:ekr.20061009112808: *7* Added @bool use_sax_based_read
True:  Use a sax-based parser to read .leo files.
       This is slower than using Leo's legacy xml parser, but may solve some unicode problems.

False: Use Leo's legacy xml parser code.
#@+node:ekr.20061008192040.1: *6* New commands
#@+node:ekr.20061008190633.354: *7* Added extend-to-line command
#@+node:ekr.20061008190633.356: *7* Improved print-bindings command
The bindings are sorted by prefix: this is a big help in understanding bindings.
For each prefix, first print items with only a single character after the prefix.
#@+node:ekr.20061008190633.364: *7* Created extend-to-sentence and extend-to-paragraph commands
Possibly define kill-sentence and kill-paragraph in terms of these.
#@+node:ekr.20061008190633.371: *7* Created runEditCommandTest
#@+node:ekr.20061008190633.295: *6* Features
#@+node:ekr.20070622180342: *7* Added chapters
- Added support for chapters to Leo's core

  Chapters are regions of a Leo outline whose root is an @chapter node. @chapter
  nodes may appear anywhere in an outline, but the create-chapter command (see
  below) creates @chapter nodes as children of a single @chapters node.

  Selecting a chapter shows only then nodes in the selected chapter; in this
  respect, chapters are like hoists. The main chapter represents the entire
  outline and can not be deleted by name. When chapters are in effect, Leo
  creates a hidden @chapters node containing one @chapter node for every chapter
  except the 'main' chapter.

  Associated settings:

  - The @bool use_chapters setting determines whether chapters are enabled.
  - The @bool use_chapter_tabs setting determines whether the chapters
    pop-up menu appears in the icon area. Choosing a chapter name from this list selects a chapter.

  When chapters are enabled, the Cmds:Chapters menu shows all available chapter commands:

  - The create-chapter command creates an @chapter node and with a single node.
  - The delete-chapter command deletes the presently selected chapter.
  - The select-chapter command makes only the nodes of the selected chapter visible.
  - The move-node-to-chapter, clone-node-to-chapter and copy-node-to-chapter commands
    add a node (and its descendants) to another chapter.
#@+node:ekr.20061008190633.296: *7* Improved the mod_scripting plugin
- Make showing the Run Script button optional.
- The Script Button button now creates the press-script-button-button command.
- A new utility method does a much better job of massaging button and command names.
#@+node:ekr.20061008190633.297: *7* rst3 plugin now registers the rst3-process-tree command
#@+node:ekr.20061008190633.311: *7* Made writing .leo files faster
The code that writes .leo files is now almost exactly twice as fast as the old code.
#@+node:ekr.20061008190633.347: *7* Generalized navigation in outline pane to ignore @file, @thin, etc prefixes
#@+node:ekr.20061008190633.351: *7* Made outline navigation cumulative
http://sourceforge.net/forum/message.php?msg_id=3941670

The code on cvs now supports the 'extended' character search. When keystrokes
(in the outline pane) are typed 'close' together in time Leo first tries to look
for prefix + ch, where ch is the character just typed and prefix is the previous
match.

By 'close together' I mean the time interval specified by the new setting:

@float outline_nav_extend_delay = 2.0

The unit of time is seconds.

The outline nav search revers to a single-character if the extended search
fails, so in fact the delay is not too significant. In practice everything works
well without me thinking at all about what is happening.
#@+node:ekr.20061008190633.353: *7* added p.archivedPosition
#@+node:ekr.20061008190633.382: *7* (Integrated sax with read logic)
#@+node:ekr.20061009074305: *6* Leap 204. "New" positions allow Leo outlines to represent arbitrary directed graphs
Leo's theory of relativity

1. We can archive any position p by saving the list [p.childIndex() for p in
   p.self_and_parents_iter()]. Let us call the *reverse* of this list the
   **parents index list**. Clearly, this list provides an unambiguous way of
   reaching position p from the root node. Archived positions, like all other
   positions, become invalid when the outline changes. 

2. Leo's position class can be based on parents index lists. Let us call such
   positions **new positions**. Replacing legacy positions with new position
   will have important benefits: 

- The only structure information in vnodes will be a v.links field. Two
  interpretations of v.links are possible. When Leo's data is a DAG (the clone
  world), v.links is a lists of v's children. This is the legacy world we all
  know and love. When Leo's data is an arbitrary graph, v.links is simply the
  list of all vnodes to which v points, with *no* necessary restrictions on what
  nodes may be contained in v.links. 

- New positions provide a self contained way of traversing an arbitrary graphs
  **largely independently** of the data. This is Leo's theory of relativity. The
  notions of 'parent' and 'sibling' have meaning *only* in the context of a
  particular position. The v.links field appears to be the absolute minimum
  amount of structure information that vnodes must contain. v.links defines the
  children or linked-to nodes in a general graph. 

- Leo's data can be considered an unrooted tree: *any* node could be considered
  the root. New positions provide enough information to traverse an arbitrary
  graph starting at any node. 

- The fundamental p.moveToX methods should be significantly faster. All of Leo's
  iterators use p.moveToX methods. 

3. The changeover to new positions can be done easily. Initially, the api of the
   new position class will be identical to the api of the present position
   class. Later, the api for the new position class might be extended in an
   upward compatible manner. The api's for the vnode and tnode class will remain
   strictly unchanged. 

4. These changes imply no change to the separation of data into vnodes and
   tnodes. This separation is required to handle clones. Furthermore, the format
   of .leo files is a separate issue from the internal representation of Leo's
   data, as proved by the opml plugin. Thus, the transition to new positions
   will have *no* effect on file formats, and no effect of scripts. All scripts
   will continue to work *exactly* as they have before, *except* scripts, e.g.
   unit tests, that probe Leo's internals. 

Summary 

Leo's theory of relativity is this: the position class provides a 'frame of
reference' for traversing data. **Only in a particular frame of reference** do
the notions of 'parent' and 'siblings' have meaning. Leo's theory of relatively
is the ultimate expression of LeoUser's notion of a 'sea of nodes'. It provides
a solid context on which to base traversals of either outlines with clones
(DAG's) or general directed graphs. 

Leo's position class, far from being just a technical tool, is important
theoretically. The position class (old or new) provides the essential tool
needed to separate data from traversals of the data. The re-visioning of the
position and vnode classes brings that potential into reality. 
#@+node:ekr.20061020155306: *5* 4.4.2 beta 3
Leo 4.4.2 beta 3                                  October 20, 2006

Leo 4.4.2 beta 3 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

The beta release fixed dozens of bugs and smoothed many rough edges.  There
are no known major bugs in Leo.  This will be the last beta release before
Leo 4.4.2 final.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.2:
----------------------------
- You can now store settings in myLeoSettings.leo without fear of those settings
  being changed by cvs updates or in future versions of Leo.
- Leo's vnode and tnode classes are now completely independent of the rest of Leo.
  Some api's have been changed.  This 'big reorg' and may affect scripts and plugins.
- Leo's vnode and tnode classes can optionally be compatible with ZODB databases,
  i.e., they can optionally derive from ZODB.Persistence.Persistent.
  See Chapter 17: Using ZODB with Leo for details.
- The leoOPML plugin defines commands to read and write OPML files.
- The slideshow plugin allows Leo to run slideshows defined by @slideshow and @slide nodes.
- The leo_to_rtf and leo_to_html plugins create rtf and html files from Leo outlines.
- Much faster navigation through the outline.
- When focus is in the outline pane, you can move to headlines by typing the first letter of headlines.
- The find command now optionally closes nodes not needed to show the node containing the present match.
- Numerous changes that make Leo easier to use without using a mouse, including new commands and options.
- Many new minibuffer commands now appear in the Cmds menu.
- A sax parser can now optionally read .leo files.
- Fixed numerous bugs.

Links:
------
Leo:        http://leoeditor.com
What's new: http://leoeditor.com/new-4-4-2.html
Home:       http://sourceforge.net/projects/leo/
Download:   http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:        http://leo.tigris.org/source/browse/leo/
Quotes:     http://leoeditor.com/testimonials.html
#@+node:ekr.20061020155235.1: *6* Bugs
#@+node:ekr.20061020155235.2: *7* Fixed crash when searching for headllines containing unicode chars
#@+node:ekr.20061020155235.27: *7* Fixed bug with Alt-n keys
@command whatever @key Alt-1 didn't work
Actually, no Alt-n keys worked for n in (1,2,3,4,5) in any context.
#@+node:ekr.20061020155235.36: *7* Fix bug: closing a window after removing a script button can crash
#@+node:ekr.20061020155235.37: *7* The end-of-script message no longer yanks focus from tabs
#@+node:ekr.20061020155235.41: *7* Fixed  warning if minibuffer command does not exist when making menus
The warning was disabled due to a programming error (not not)
Enabling this found two errors: view-lossage (missing comma) and
find-with-present-options --> search-with-present-options.
#@+node:ekr.20061020155235.47: *7* Fixed new unicode bug
https://sourceforge.net/forum/message.php?msg_id=3957980

This was a major effort.  What I did:

- Defined g.isWordChar in terms of ch.isalnum()

- Replace almost all instances of string.letters and string.digits by calls to
  ch.isalnum(), ch.isalpha(), ch.isdigit(), etc.

- Similarly, replaced word_chars.

- The new code uses string literals only for

a) small constants like '+-' and
b) constants in a very limited context, as in the input to regexp.
#@+node:ekr.20061020155235.123: *7* Made 'About Plugin' dialog scrollable
http://sourceforge.net/forum/message.php?msg_id=3960993
#@+node:ekr.20061020155235.124: *7* Removed unwanted key-state message
https://sourceforge.net/forum/message.php?msg_id=3961623
#@+node:ekr.20061020155235.126: *7* Made sure all kill commands do a full recolor
#@+node:ekr.20061020155235.149: *7* Fixed bug in new colorizer
Did not restore selection after indent/undent commands.
#@+node:ekr.20061020155235.180: *7* Removed set-mark-command and all calls to removeRKeys
The 'hang' was due to removeRKeys, which removes the bindings create by
setRegion (set-mark-command) by *also* cleared all the other bindings!
For now I have simply disabled the set-mark-command and commented out all
calls to removeRKeys.

Note that toggle-extend-mode (Alt-3) is a good way to define regions.
#@+node:ekr.20061020155235.185: *7* Fixed body editor problems
onFocusIn and its associated binding were a very bad idea.  It is not needed:
k.masterClickHandler simply calls the new onClick method.

What I did:

- Eliminating onFocusIn and its associated binding.
  Hurray: this also fixed the Find problem.
- Fixed problem with deleting nodes when multiple editors are present.
- Removed title bar when penultimate editor is deleted.
#@+node:ekr.20061020155235.254: *7* Moved @import to top of doc/default.css
#@+node:ekr.20061020155235.255: *7* Fixed focus problem when double-clicking @url nodes
Double-clicking  @url <leo-file> did not bring Leo file to top.
#@+node:ekr.20061020155235.263: *6* Features
#@+node:ekr.20061020155235.271: *7* Added minibuffer and Settings menus
http://sourceforge.net/forum/message.php?msg_id=3588148

One way to make Leo more newbie friendly is to add menu items for key features
that are likely to cause confusion in the beginning.
#@+node:ekr.20061020155235.292: *7* Toggling autocompleter and calltips now write to log (in red) instead of the statusLine
This is much more visible.
#@+node:ekr.20061020155235.294: *7* Finished collapse-on-move-left
Added support for @bool sparse_move_outline_left

When True, Leo collapses the (former) parent of a node when moving that node left.
Takes getting used to, but I like it.

Note that the move-outline-up/down commands can have the effect of moving an outline left.
#@+node:ekr.20061020155235.304: *7* Properly create Help menu on the Mac
At long last Leo creates a proper help menu on the Mac.
#@+node:ekr.20061020155235.307: *7* '*command-name' in headline means convert '-' to blanks
This would greatly simplify menu entries.
#@+node:ekr.20061020155235.308: *7* Removed all references to commands from menu tables
This is an important step towards making all menus configurable.
#@+node:ekr.20061020155235.335: *7* Add Open scripts.leo to help menu
The open-scripts-leo command.
#@+node:ekr.20061020155235.337: *7* The spell tab now uses ctypes for Python 2.5
#@+node:ekr.20061020155235.385: *7* Simulated x-windows middle-button paste
#@+node:ekr.20061020155235.393: *6* Plugins
#@+node:ekr.20061020155235.394: *7* Fixed keyBindings plugin
http://sourceforge.net/forum/message.php?msg_id=3958380
#@+node:ekr.20061020155235.395: *7* The scripting plugin now creates a delete-x-script-button command for each script button
http://sourceforge.net/forum/message.php?msg_id=3423121
#@+node:ekr.20061020155235.396: *7* Fixed the nodenavigator plugin
http://sourceforge.net/forum/message.php?msg_id=3959003
#@+node:ekr.20061020155235.397: *7* Rewrote the multifile plugin for the 4.x code base.
#@+node:ekr.20061020155235.398: *7* Replaced __name__ with __plugin_name__ in four plugins
http://sourceforge.net/forum/message.php?msg_id=3962632
#@+node:ekr.20061020155235.399: *7* Improved the scripting plugin
- Every button created by the plugin creates a corresponding command. The
command name is the 'cleaned' version of the button name.

- Every button created by the plugin also creates a delete-x-button command,
where x is the command name as just discussed. So now you can delete script
buttons without right-clicking.

- I took the time to revise, refactor, clean up, reorganize and better document
the code. This was overdue: the previous code had grown difficult to understand
through multiple small accretions. I can actually understand the new code.
#@+node:ekr.20061020155235.400: *7* Fixed bugs in multi-file plugin
#@+node:ekr.20061020155235.402: *7* Fix bug in shortcut_button plugin
http://sourceforge.net/forum/message.php?msg_id=3963657
#@+node:ekr.20061020155235.125: *7* Removed datenodes.ini from cvs
No longer needed now that the datenodes plugins gets settings from cvs.
#@+node:ekr.20061020155235.34: *7* Fix bug in ops plugin
http://sourceforge.net/forum/message.php?msg_id=3956836
#@+node:ekr.20061020155235.35: *7* Fixed crasher on script button balloons
http://sourceforge.net/forum/message.php?msg_id=3958333
#@+node:ekr.20061020155235.403: *6* Settings
#@+node:ekr.20061020155235.404: *7* Made unlimited undo the default
As always, you can set max_undo_stack_size in myLeoSettings.leo.
#@+node:ekr.20061020155235.405: *7* Added @bool select_all_text_when_editing_headlines
A highly useful option.
However, creating a new node always selects the entire text, regardless of this option.
#@+node:ekr.20061020155235.410: *7* Added bindings to toggle-autocompleter and toggle-calltips
- Added bindings for toggle-autocompleter (Alt-1) and toggle-calltips (Alt-2)

- Ctrl-. and ctrl-( do not seem to do anything.

** Mystery solved: there was a trace in the calltip logic!

Disabled these binding:

auto-complete-force         = None # This command needs work before it is useful. Ctrl-period
show-calltips-force         = None # This command needs work before it is useful. Alt-parenleft

The problem is that autocompletion depends on state: self.leadinWord,
prevObjects, etc. Thus, it's not presently possible to start the process
anywhere. Similar remarks apply to calltips, which relies on autocompleter
state.

This is a complex problem, and not very serious now that there is an easy way of
toggling autocompleter and calltips on and off. It's been added to a 'later'
section of the to-do list.
#@+node:ekr.20061020155235.411: *7* Added 'Candidates for myLeoSettings.leo' to leoSettings.leo
Added the node: Candidates for settings in myLeoSettings.leo. This lists the
most 'controversial' settings in leoSetting.leo, and is a quick-start to
creating myLeoSettings.leo."
#@+node:ekr.20061020155235.412: *7* Recent changes to settings
- Added shift-ctrl keys to extend the selection.
focus-to-body = Alt-D
focus-to-tree = Alt-T
toggle-extend-mode = Alt-3
#@+node:ekr.20061020155235.413: *7* Added @bool insert_new_nodes_at_end
#@+node:ekr.20061020155235.264: *7* Removed .leoRecentFiles.txt from distribution and cvs
What I did

- @bool write_recent_files_as_needed = True

People who don't want Leo to update .leoRecentFiles.txt can set this to False.

- Remove .leoRecentFiles from cvs
- Remove .leoRecentFiles from distribution list.
#@+node:ekr.20061026095728: *5* 4.4.2 final and 4.4.2.1 final
Leo 4.4.2.1 final                                October 29, 2006

Leo 4.4.2.1 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.4.2.1 final fixes a recent bug that caused Leo not to create the
.leoRecentFiles.txt file properly in some situations. There are no known
significant bugs in this version of Leo.

Leo 4.4.2 final fixes a few bugs and adds support for pymacs. 

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.2:
----------------------------
- You can now store settings in myLeoSettings.leo without fear of those settings
  being changed by cvs updates or in future versions of Leo.
- Leo's vnode and tnode classes are now completely independent of the rest of Leo.
  Some api's have been changed.  This 'big reorg' and may affect scripts and plugins.
- Leo's vnode and tnode classes can optionally be compatible with ZODB databases,
  i.e., they can optionally derive from ZODB.Persistence.Persistent.
  See Chapter 17: Using ZODB with Leo for details.
- The leoOPML plugin defines commands to read and write OPML files.
- The slideshow plugin allows Leo to run slideshows defined by @slideshow and @slide nodes.
- The leo_to_rtf and leo_to_html plugins create rtf and html files from Leo outlines.
- Much faster navigation through the outline.
- When focus is in the outline pane, you can move to headlines by typing the first letter of headlines.
- The find command now optionally closes nodes not needed to show the node containing the present match.
- Numerous changes that make Leo easier to use without using a mouse, including new commands and options.
- Many new minibuffer commands now appear in the Cmds menu.
- A sax parser can now optionally read .leo files.
- Fixed numerous bugs.

Links:
------
Leo:        http://leoeditor.com
What's new: http://leoeditor.com/new-4-4-2.html
Home:       http://sourceforge.net/projects/leo/
Download:   http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:        http://leo.tigris.org/source/browse/leo/
Quotes:     http://leoeditor.com/testimonials.html
#@+node:ekr.20061026095922.1: *6* Bugs
#@+node:ekr.20061026095922.2: *7* Changed leo_rst.css to pass the w3 validator
#@+node:ekr.20061026095922.3: *7* Fixed 'Run on string' message when typing
#@+node:ekr.20061026095922.15: *7* Fixed problem with c++ extensions
http://sourceforge.net/forum/message.php?msg_id=3971242
#@+node:ekr.20061026095922.17: *7* Move on if regexp matches an empty string
#@+node:ekr.20061026095922.19: *7* Fixed several bugs related to multiple body panes
#@+node:ekr.20061026095922.25: *7* Fixed multipath plugin so it works with new colorizier
The new colorizer was innocent: the problem is that at.directiveKind4 uses leoColor.leoKeywords,
so multipath must add entries to leoColor.leoColors.
#@+node:ekr.20061026095922.32: *7* Fixed bug in new colorizer
It required a space after the '@'
#@+node:ekr.20061026095922.33: *7* Fixed config bug
http://sourceforge.net/forum/message.php?msg_id=3975898
#@+node:ekr.20061026095922.35: *6* New features
#@+node:ekr.20061026095922.51: *7* Added forward-end-word/-extend-selection commands
http://sourceforge.net/forum/message.php?msg_id=3980193

#@+node:ekr.20061026095922.36: *7* Created leoPymacs.py for interaction with pymacs
For full details, see Chapter 18 of Leo's Users Guide: Emacs and Leo.
#@+node:ekr.20070316182323: *4* 4.4.3... winpdb, leoBridge, gui reorg, chapters
#@+node:ekr.20070122070619: *5* 4.4.3 alpha 1
Leo 4.4.3 alpha 1                                  January 26, 2006

Leo 4.4.3 alpha 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Important: the wxGui plugin is still alpha-quality code at present.

The highlights of Leo 4.4.3:
----------------------------
- A functional wxWidgets plugin.
- Removed all gui-dependent code from Leo's core.
- Better support for the winpdb debugger.
- Many minor improvements, new settings and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070122070634.1: *6* Bugs
#@+node:ekr.20070122070634.2: *7* Fixed an escape bug in new colorizer
Example:

print "\\" + " this is a test"

The escape mechanism must treat an even number of trailing escapes as not an escape.
#@+node:ekr.20070122070634.4: *7* Treat escaped characters in find patterns as a single character
#@+node:ekr.20070122070634.13: *7* Fixed undo problems with yank/kill
http://sourceforge.net/forum/message.php?msg_id=3924236

Added unit tests for yank and all kill commands.
#@+node:ekr.20070122070634.40: *7* Fixed clone-drag problem
http://sourceforge.net/forum/message.php?msg_id=3991369

The bindings to f.f.OnControlKeyDown/Up were mistakenly deleted in createOuterFrames.
#@+node:ekr.20070122070634.51: *7* Made sure all ancestors expanded when select a body editor with multiple body editors
#@+node:ekr.20070122070634.54: *7* Fixed bug in CheckVersion
http://sourceforge.net/forum/message.php?msg_id=4112347
#@+node:ekr.20070122070634.305: *6* Code reorg for wxGui plugin
Leo's core is now largely free of gui-dependent code, and should be completely
free of such code by the time Leo 4.4.3 final is released.
#@+node:ekr.20070122070634.58: *6* Features
#@+node:ekr.20070122070634.59: *7* Added handleUrlInUrlNode helper for OnIconDoubleClick
#@+node:ekr.20070122070634.66: *7* Only do one message re writing recent files
#@+node:ekr.20070122070634.69: *7* Made escape in the minibuffer work like ctrl-g
#@+node:ekr.20070122070634.81: *7* Clear status line in repeat-complex-command
This is much less confusing.
#@+node:ekr.20070122070634.82: *7* Added shortcuts for goto-first/last-sibling
#@+node:ekr.20070122070634.83: *7* Made copied nodes valid Leo files
http://sourceforge.net/forum/message.php?msg_id=4014079
#@+node:ekr.20070122070634.89: *7* Added support for chdir_to_relative_path setting
http://sourceforge.net/forum/message.php?msg_id=4005750

I like the option @string relative_path_base_directory = .

which puts @file nodes in the same directory as the current Leo file.

I would like it if 
open('file.txt','w').close()

put file.txt in the same directory as the current Leo file.
#@+node:ekr.20070122070634.91: *7* changeAll now works like findAll
#@+node:ekr.20070122070634.209: *7* Added Find & Spell tabs to log pane on startup

#@+node:ekr.20070122070634.220: *7* Created standard pluginsManager.txt only if it does not exist
http://sourceforge.net/forum/message.php?msg_id=3987635
#@+node:ekr.20070122070634.223: *7* Improved support for the winpdb debugger
New settings

The following two new settings now control whether the execute-script and debug commands write the script to an external file.

- @bool write_script_file = True

True: The execute script command writes the script to be executed to a file, then executes the script using Python's execFile function. The script_file_path setting specifies the path to this file.

False (legacy): The execute script command uses Python's exec command to execute the script. 

- @string script_file_path = ../test/scriptFile.py

The path to the file to be written by the execute-script command.

Notes:

- This setting has effect only if the write_script_file setting is True.
- Use / to as the path delimiter, regardless of platform.
- The default path is ../test/scriptFile.py if no path is given.
- The path starts at g.app.loadDir, so for example ../test/scriptFile.py is equivalent to leo/test/scriptFile.py
- The filename should end in .py.

From here on, let us assume the settings are as shown above.  There are at least three ways of debugging scripts, depending on your preferences and whether the script contains leo-specific code (g, c or p) or not.

First way:  The debug command

The debug command now works almost exactly like Kent's original @button node. This way of debugging can only be used for general scripts, not leo-specific scripts.  

The debug command writes the script to scriptFile.py and invokes the debugger as specified by the existing @string debugger_kind option.  winpdb opens and is already 'attached' to the script to be debugged.  You can single-step as you like.  Leo continues to run, but killing the debugger will also kill Leo.  When started this way, winpdb is really 'attached' to *all* of Leo, which means you can single step past the end of the script into Leo's executeScript code and from there into all of Leo(!)

As I write this I realize that the code uses arguments specific to winpdb.  That may have to be generalized, though I am not sure why anyone would want to use another debugger...

Second way: @button winpdb

This is almost exactly equivalent to the debug command, except that the script file must be *different* from the script file specified by the  script_file_path setting (The @button code *itself* uses the execute-script command, so we have to pass the script code, not the @button code to the debugger).

Third way: The execute-script command with explicit debugger breaks

The third way of debugging scripts allows winpdb to debug scripts that use c, g and p.  I'm actually not sure of exactly how and why it works, but it certainly does work.

In contrast to the previous two ways, a little more work is needed because winpdb does not start automatically.  But I am getting ahead of myself.

To use this way, insert the following two lines of code at the start of the script to be debugged::

import rpdb2
rpdb2.start_embedded_debugger('go',fAllowUnencrypted=True)

Now just execute the execute-script command (*not* the debug command)  Leo will appear to hang.  Indeed, the  start_embedded_debugger command is waiting for *another* copy of winpdb to 'attach' to the script's process.  This process is all of Leo!  The default timeout is 5 minutes: I'm not sure what happens when the timeout happens: probably an exception gets thrown.

So you must start winpdb explicitly.  On XP just do something like

python c:\python25\Scripts\_winpdb.py -t

The -t option tells winpdb that no encoding of password is necessary.  The password is specified in the call to rpdb2.start_embedded_debugger in your script.  In this example, the password is 'go'.  Use the File:Attach command in winpdb to attach winpdb to Leo.  Specify the password as 'go' and you will see the scriptFile.py containing your entire script.  You can execute or single-step through the script. 

To repeat, the big difference is that c, g and p are defined, so you can debug any script this way.  As before, killing winpdb also kills Leo.

P.S.  winpdb and its documentation has been improved recently.  See

http://www.digitalpeers.com/pythondebugger/  and especially

http://www.digitalpeers.com/pythondebugger/embedded.htm

The discussion of embedded debugging may have been written specifically with Leo in mind.  It certainly could have been.
#@+node:ekr.20070122104240: *7* Added \runAskOkCancelStringDialog
http://sourceforge.net/forum/message.php?msg_id=4113315
#@+node:ekr.20070122070634.298: *6* Plugins
#@+node:ekr.20070122072110: *7* The wxGui plugin is now functional
#@+node:ekr.20070122070634.299: *7* Changed bindings in UniversalScrolling pluing
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3991223

I assigned both Control and Shift modifiers to do scrolling: this is so my
finger can hit a key in the lower left corner of the keyboard, and I don't have
to worry too much about my aim (I have LARGE fingers). Also, I stop the
scrolling on the JUST button release -- less worry about my finger slipping off
the key.
#@+node:ekr.20070122070634.300: *7* Registered write-restructured-text command in rst3 plugin
#@+node:ekr.20070122070634.301: *6* Settings
#@+node:ekr.20070122070634.302: *7* Added @bool center_selected_tree_node
@nocolor

http://sourceforge.net/forum/message.php?msg_id=3916155

When a node is among several other nodes at the same level of hierarchy, which
are all children of a node, and the "MOVE LEFT" command is executed, the node
does move left in the outline hierarchy, but it also move down to just before
the next node at the higher hierarchy level - the level to which it is moving
left.

EKR: I love this new option: how did we ever live without it?

@color
#@+node:ekr.20070122070634.303: *7* Added @bool invisible_outline_navigation = False
@nocolor

This option tells how to treat an uppercase letter typed when the outline pane
is active but no headline is being edited. In such situations Leo searches for an
node whose headline starts with the present prefix, ignoring case The prefix
starts with the first letter typed and other letters are added if they are typed
within a 'short' period of time, as specified by the outline_nav_extend_delay

True: Look in invisible nodes.
False: Look only in visible nodes.

I set this option to False because it is too easy form me to type Shift-whatever
when I meant Ctrl-whatever.

@color
#@+node:ekr.20070122070634.304: *7* Added @bool show_full_tracebacks_in_scripts
http://sourceforge.net/forum/message.php?msg_id=3985382

#@+node:ekr.20070316182323.1: *5* 4.4.3 alpha 2
Leo 4.4.3 alpha 2                                  March 17, 2006

Leo 4.4.3 alpha 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version of Leo should be safe enough for production use. It is an alpha
distribution because not all plugins have been tested on the reorganized code
base.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.3:
----------------------------
- A leoBridge module that allows full access to all of Leo's capabilities
  from programs running outside of Leo.
- Added support for @enabled-plugins nodes in settings files.
- The__wx_gui plugin is now functional.
- Removed all gui-dependent code from Leo's core.
- Better support for the winpdb debugger.
- Many minor improvements, new settings and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070316182341.1: *6* Fixed Bugs
#@+node:ekr.20070316182341.2: *7* Fixed bugs in undo/redoNodeContents
#@+node:ekr.20070316182341.6: *7* Fixed minor xml problem
@nocolor
http://sourceforge.net/forum/message.php?msg_id=4132529

I'm generating Leo files with ElementTree and ran into a minor issue.

ElementTree generates an empty tag with a space before the closing slash:

<globals />

in Leo's code for dummy elements to allow copied nodes to be valid Leo files,
the empty tags are generated without the space

leoFileCommands.py 2917
        self.put('<globals/>\n')
        self.put('<preferences/>\n')
        self.put('<find_panel_settings/>\n')

it then checks for these tags in getDummyElements() leoFileCommands.py 1298

Since ElementTree has the space before the slash, 
it's XML is considered invalid by Leo according to
this test.

I would like it if the space could be added in Leo's
self.put(...) and the check in getDummyElements()

The XML specs show the space as optional.

@color
#@+node:ekr.20070316182341.10: *7* Fixed C++ import bug
http://sourceforge.net/forum/message.php?msg_id=4134384
#@+node:ekr.20070316182341.39: *7* Fixed recent bug in next-line command
Down arrow wasn't handled properly.
#@+node:ekr.20070316182341.41: *7* Made standalone plugins manager work again
#@+node:ekr.20070316182341.42: *7* Fixed wiki markup bug
http://sourceforge.net/forum/message.php?msg_id=3994218
#@+node:ekr.20070316182341.43: *7* Fixed bugs in regular expressions
#@+node:ekr.20070316182341.54: *7* Fixed memory error in leoBridge
#@+node:ekr.20070316182341.56: *7* Fixed backspace in headline bug
# The buggy code only happens when there is no binding for backward-delete-char.
# http://sourceforge.net/forum/forum.php?thread_id=1681392&forum_id=10227
#@+node:ekr.20070316182341.66: *7* Made sure alt-arrow keys honor focus settings
#@+node:ekr.20070316182341.112: *7* Fixed bug in nav button plugin
It's about Nav_buttons v1.5 (cvs version from last Saturday) 

Pressing the green back button causes 

Error: 1 
AttributeError Exception in Tk callback 
Function: <bound method Commands.goPrevVisitedNode of Commander 39717104: u'F:\\D\\PIM\\PIM_main.leo'> (type: <type 'instancemethod'>) 
Args: () 
Traceback (innermost last): 
File "F:\C\Programs\Leo_cvs\extensions\Pmw\Pmw_1_2\lib\PmwBase.py", line 1752, in __call__ 
return apply(self.func, args) 
File "F:\C\Programs\Leo_cvs\src\leoCommands.py", line 4435, in goPrevVisitedNode 
c.treeCommandHelper(v) 
AttributeError: Commands instance has no attribute 'treeCommandHelper' 
#@+node:ekr.20070316182341.113: *7* Fixed yet another cursor down bug
http://sourceforge.net/forum/message.php?msg_id=4201463
#@+node:ekr.20070316182341.137: *7* Improved special case in moveOutlineUp
http://sourceforge.net/forum/message.php?msg_id=4205072
#@+node:ekr.20070316182341.138: *7* Fixed crasher in rclicker plugin
Traceback (most recent call last):

  File "c:\prog\tigris-cvs\leo\src\leoGlobals.py", line 2474, in doHook
    return f(tag,keywords)

  File "c:\prog\tigris-cvs\leo\src\leoPlugins.py", line 92, in doPlugins
    return doHandlersForTag(tag,keywords)

  File "c:\prog\tigris-cvs\leo\src\leoPlugins.py", line 70, in doHandlersForTag
    val = callTagHandler(bunch,tag,keywords)

  File "c:\prog\tigris-cvs\leo\src\leoPlugins.py", line 49, in callTagHandler
    result = handler(tag,keywords)

  File "C:\prog\tigris-cvs\leo\plugins\rClick.py", line 156, in rClicker
    n0,p0=ind0.split('.',2)

AttributeError: 'int' object has no attribute 'split'
#@+node:ekr.20070316182341.139: *7* Fixed recent problem with settings report
Leo did not write to the log pane that settings, either present
in myLeoSettings.leo or the current file, were read.
#@+node:ekr.20070316182341.437: *6* New Features
#@+node:ekr.20070316182341.440: *7* Added leoBridge module
The leoBridge module allows complete access to all aspects of Leo from programs
running independently of Leo. Let us call such a program a **host** program.
Using the leoBridge module, foreign programs can get access to:

- all of Leo's source code,
- the contents of any .leo file,
- the commander of any .leo file.

Host programs use the leoBridge module as follows::

    import leoBridge
    controller = leoBridge.controller(gui='nullGui')
    g = controller.globals()
    c = controller.openLeoFile(path)

Let us look at these statements in detail.  The statements::

    import leoBridge
    controller = leoBridge.controller(gui='nullGui')

import the leoBridge module and create a **bridge controller**. In effect, these
statements embed an 'invisible' copy Leo into the host program. This embedded
copy of Leo uses a 'null' gui, which simulates all aspects of Leo's normal gui
code without creating any screen objects.

The statement::

    g = controller.globals()

provides access to Leo's leoGlobals module, and properly inits globals such as g.app, g.app.gui, etc.  Host programs **should not** import leoGlobals directly, because doing so would not init the g.app object properly.

The statement::

    c = controller.openLeoFile(path)

invisibly opens the .leo file given by the path argument. This call returns a
completely standard Leo commander, properly inited. This is the big payoff from
the leoBridge module: the host program gets instant access to c.config.getBool,
etc. Do you see how sweet this is?

The following script runs leo/test/leoBridgeTest.py outside of Leo.
leoBridgeTest.py uses the leoBridge module to run all unit tests in leo/test/unitTest.leo.
Try it::

    import os,sys

    path = g.os_path_abspath(
        g.os_path_join(
            g.app.loadDir,'..','test','leoBridgeTest.py'))

    os.system('%s %s' % (sys.executable,path))
#@+node:ekr.20070316182341.723: *7* Added support for @enabled-plugins in settings files
Any .leo file may now contain an @enabled-plugins node as a child of an
@settings node.

Notes:

A) Leo attempts to load all plugins every time an @enabled-plugins node is seen.
   If the plugin has already been loaded, Leo silently ignores the
   request to re-enable the plugin.
   Leo never attempts to disable a plugin while processing enabled plugin
   strings. Thus, plugins enabled in an @enabled-plugins node in leoSettings.leo
   *will* be enabled regardless of the contents of any other @enabled-plugins node.

B) The default plugins will be enabled in an @enabled-plugins
   node in leoSettings.leo.

C) g.app.gui.getEnabledPlugins contains the last value last processed @enabled-plugins node.
#@+node:ekr.20070316182341.718: *7* Added new search path for pluginsManager.txt
http://sourceforge.net/forum/message.php?msg_id=4169720
#@+node:ekr.20070316182341.155: *7* Made Leo's core gui-indenpendent
#@+node:ekr.20070316182341.438: *7* Warn on dubious section brackets
http://sourceforge.net/forum/message.php?msg_id=4162357
#@+node:ekr.20070317044545: *6* Plugins
The __wx_gui.py plugin is now minimally functional. All significant unit tests
pass with this plugin in effect. However, problems remain. See the bug list in
the plugin for details.
#@+node:ekr.20070513111132: *5* 4.4.3 beta 1
Leo 4.4.3 beta 1                                May 18, 2006

Leo 4.4.3 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.3:
----------------------------
- Added support for chapters in Leo's core.
  Chapters are disabled by default.  To enable, set @bool use_chapters = True.
- Added support for zipped .leo files.
- Added a leoBridge module that allows full access to all of Leo's capabilities
  from programs running outside of Leo.
- Removed all gui-dependent code from Leo's core.
- Better support for the winpdb debugger.
- Added support for @enabled-plugins nodes in settings files.
- Added support for @openwith nodes in settings files.
- The__wx_gui plugin is now functional.
- Many minor improvements, new settings, commands and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070513111526.1: *6* New features
#@+node:ekr.20070513112414: *7* Added support for chapters to Leo's core
- Added support for chapters to Leo's core

  Chapters are regions of a Leo outline whose root is an @chapter node. @chapter
  nodes may appear anywhere in an outline, but the create-chapter command (see
  below) creates @chapter nodes as children of a single @chapters node.

  Selecting a chapter shows only then nodes in the selected chapter; in this
  respect, chapters are like hoists. The main chapter represents the entire
  outline and can not be deleted by name. When chapters are in effect, Leo
  creates a hidden @chapters node containing one @chapter node for every chapter
  except the 'main' chapter.

  Associated settings:

  - The @bool use_chapters setting determines whether chapters are enabled.
  - The @bool use_chapter_tabs setting determines whether the chapters
    pop-up menu appears in the icon area. Choosing a chapter name from this list selects a chapter.

  When chapters are enabled, the Cmds:Chapters menu shows all available chapter commands:

  - The create-chapter command creates an @chapter node and with a single node.
  - The delete-chapter command deletes the presently selected chapter.
  - The select-chapter command makes only the nodes of the selected chapter visible.
  - The move-node-to-chapter, clone-node-to-chapter and copy-node-to-chapter commands
    add a node (and its descendants) to another chapter.
#@+node:ekr.20070513111526.2: *7* Added @bool force_newlines_in_at_nosent_bodies setting
It is True by default. In effect, this setting was False in previous versions
of Leo, which might be considered a bug.
#@+node:ekr.20070513111526.7: *7* Added apropos-debugging-commands command
#@+node:ekr.20070513111526.8: *7* Added print-plugins & print-plugin-handlers commands
#@+node:ekr.20070513111526.10: *7* Added print-settings command
#@+node:ekr.20070513111526.14: *7* Added support for @openwith nodes in leoSettings.leo
http://sourceforge.net/forum/message.php?msg_id=3737745

http://sourceforge.net/forum/message.php?msg_id=3785897

Would it be possible to have the table of "Open With" editors to be part of
the config system? I find myself patching the list every time I D/L a new Leo
version to add the editor I use. This would also help isolate the user from
the "guts" of Leo, thereby being less intimidating.
#@+node:ekr.20070513111526.39: *7* Created clean-all-lines command
#@+node:ekr.20070513111526.42: *7* Support for compressed .leo files
Leo now supports zipped .leo files:

- Leo now has save-file-as-zipped and save-file-as-unzipped commands, and
corresponding Save File As Zipped and Save File as Unzipped items in the File
menu. These are exactly the same as Leo's Save As commands except that they
temporarily force Leo to write the file in either zipped or unzipped format.

- Leo remembers whether a file was originally zipped. The read logic handles
either zipped or unzipped .leo files automatically. The write logic will zip the
file if it was originally zipped or if the save-file-as-zipped command is being
executed.

- Leo writes files with .leo extension, regardless of whether the file is zipped
or not. Zipped .leo files contain a single archive, whose name is the same as
the .leo file itself.

Notes:

- The new save commands suffice to compress and expand .leo files on a
file-by-file basis. In particular, there is no need for any user settings.

- Outside of Leo you can change the extension to .leo.zip and use stuffit or
other program to expand the .leo file contained within. I've only tested this on
XP, but it should work everywhere...

- At present the code uses Python's zipfile module to read and write zipped files.
In turn, the zipfile module uses the zlib module to do the compression.
Conceivably somebody might want Leo to use some other compression technique, say
Python's tarfile module. However, I think the present way should suffice for
most people.
#@+node:ekr.20070513111526.77: *6* Fixed bugs
#@+node:ekr.20070513111526.78: *7* Fixed bug: new-file doesn't allow edit of initial headline
# Found via unit test.  Happens regardless of chapters.
#@+node:ekr.20070513111526.80: *7* Removed all returns from finally clauses
# Returns in finally clauses prevent the re-raising of the saved exception(!!)
#@+node:ekr.20070513111526.105: *7* Fixed repeatComplexCommand weirdness
#@+node:ekr.20070513111526.198: *7* Fixed minor chapter hoist bug
http://sourceforge.net/forum/message.php?msg_id=4215654

There was a bug with ordinary hoisting: in the "Outline" menu the "Delete Node"
menu item was not disabled when the local root is selected.
#@+node:ekr.20070513111526.200: *7* Fixed crasher in plugins_menu.py
#@+node:ekr.20070610063456: *5* 4.4.3 beta 2
Leo 4.4.3 beta 2                                June 12, 2006

Leo 4.4.3 beta 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.3:
----------------------------
- Added support for chapters in Leo's core.
  Chapters are disabled by default.  To enable, set @bool use_chapters = True.
- Added support for zipped .leo files.
- Added a leoBridge module that allows full access to all of Leo's capabilities
  from programs running outside of Leo.
- Removed all gui-dependent code from Leo's core.
- Better support for the winpdb debugger.
- Added support for @enabled-plugins nodes in settings files.
- Added support for @openwith nodes in settings files.
- Added support for @bool write_strips_blank_lines setting.
- The__wx_gui plugin is now functional.
- Leo can use aspell on Linux when using Python 2.5 or later.
- Many minor improvements, new settings, commands and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070610063538.1: *6* Fixed bugs
#@+node:ekr.20070610063538.2: *7* Fixed noweb hangs
http://sourceforge.net/forum/message.php?msg_id=4315027

The fix was to g.skip_to_end_of_line (!)

All such functions now return len(s) as a boundary condition.
This is a major change.  All unit tests pass.
#@+node:ekr.20070610063538.151: *7* Alt-4 did not work in tree pane in unitTest.leo
#@+node:ekr.20070610063538.163: *7* Investigated problem with subprocess (works for me)
http://sourceforge.net/forum/message.php?msg_id=4320971
#@+node:ekr.20070610063538.164: *7* Fixed crashers in leoupate plugin
@nocolor

http://sourceforge.net/forum/message.php?msg_id=4309448

Still to do: update urls for tigris.
#@+node:ekr.20070610063538.165: *7* Fixed automatic directory creation
http://sourceforge.net/forum/message.php?msg_id=4301021
#@+node:ekr.20070610063538.168: *7* Fixed bug: shift-arrow keys not bound properly when node is clicked
- Select a node by clicking on it.
- The node is selected, but shift-arrow does not work.

However, clicking the canvas does work.

The fix was to give the canvas, not the headline focus when clicking on a headline.
This results in canvas bindings, not text bindings, having priority.
This is not a kludge: the text widget isn't active, so text bindings should not be in effect.
#@+node:ekr.20070610063538.171: *7* Made sure the new outlines aren't marked dirty
#@+node:ekr.20070610063538.175: *7* Fix crasher in maximizeNewWindows
http://sourceforge.net/forum/message.php?msg_id=4340244
#@+node:ekr.20070610063538.209: *7* Don't change focus in the save command
http://sourceforge.net/forum/message.php?msg_id=4341644
#@+node:ekr.20070610063538.212: *7* downcase-region and upcase-region didn't color body text.
#@+node:ekr.20070611161859: *7* Fixed *major* demote bug
http://sourceforge.net/forum/message.php?msg_id=4356197
#@+node:ekr.20070610063538.280: *6* Features
#@+node:ekr.20070610063538.281: *7* Supported write_strips_blank_lines option
#@+node:ekr.20070610063538.334: *7* Completed chapters
The following chapter commands now exist:

clone-node-to-chapter
convert-node-to-chapter
copy-node-to-chapter
create-chapter
create-chapter-from-node
move-node-to-chapter
remove-chapter
rename-chapter
select-chapter
#@+node:ekr.20070610063538.366: *7* Improved dynamic abbreviations
http://sourceforge.net/forum/message.php?msg_id=4255709

Added globalDynamicAbbrevs setting.
Added tab completion for dabbrev-expand.
#@+node:ekr.20070610063538.377: *7* Created the hoist-changed hook
This for the use of the hoist plugin.
#@+node:ekr.20070610173300: *7* Enabled more plugins by default
@nocolor

http://sourceforge.net/forum/message.php?msg_id=4134565

The following are now enabled by default:

# Plugin_manager.py needs plugins_menu.py
plugins_menu.py
plugin_manager.py
open_with.py
mod_scripting.py
rst3.py
UNL.py

# Enabled by default in Leo 4.4.3. (order is important)
nav_buttons.py
hoist.py
image.py
leo_to_html.py

I left out cleo because it has been reported not to be fully functional with Leo 4.4.3.
#@+node:ekr.20070622090350: *5* 4.4.3 beta 3
Leo 4.4.3 beta 3                                June 23, 2006

Leo 4.4.3 beta 3 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This release fixes all known bugs and adds several new features.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.3:
----------------------------
- Added support for chapters in Leo's core.
- Added support for zipped .leo files.
- Added a leoBridge module that allows full access to all of Leo's capabilities
  from programs running outside of Leo.
- Removed all gui-dependent code from Leo's core.
- Better support for the winpdb debugger.
- Added support for @enabled-plugins nodes in settings files.
- Added support for @openwith nodes in settings files.
- Added support for @bool write_strips_blank_lines setting.
- The__wx_gui plugin is now functional.
- Leo can use aspell on Linux when using Python 2.5 or later.
- @test nodes can now be run from any .leo file.
- Many minor improvements, new settings, commands and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070622090350.1: *6* Fixed bugs
#@+node:ekr.20070622090350.8: *7* Fixed a bug that disabled icon button colors on Linux
#@+node:ekr.20070622090350.22: *7* Switch chapters if new position isn't in current chapter
http://sourceforge.net/forum/message.php?msg_id=4362825
#@+node:ekr.20070622090350.42: *7* Improved goto-next/prev-node commands
Selecting a node now never truncates the beadList.
#@+node:ekr.20070622090350.57: *7* Fixed failing bridge unit test
CleanLines was adding a trailing newline.
The fix was to suppress this during unit tests.
#@+node:ekr.20070622090350.59: *6* New features & settings
#@+node:ekr.20070622090350.60: *7* Added @bool contractVisitedNodes setting
#@+node:ekr.20070622090350.61: *7* Added goto-first-visible-node command
#@+node:ekr.20070622090350.62: *7* Changed binding of Alt-Home
Alt-home is now bound to goto-first-visible rather than goto-first.
#@+node:ekr.20070622090350.65: *7* Added @button dynamic-tests.
This script runs all @test nodes as follows:

- Copies all @suite and @tests nodes to dynamicUnitTests.leo.

- Runs leoDynamicTest.py in a separate process. In turn, leoDynamicTest.py
  use the leoBridge module to run dynamicUnitTests.leo.
  (test.leo contains the source code for leoDynamicTest.py.)

Thus, all unit tests will be run with the latest Leo sources.

Allowing @test nodes in leoPy.leo is important: unit tests can be placed near
the code they are intended to test.
#@+node:ekr.20070622090350.66: *7* created g.unitTesting and g.getTestVars
The test 'if g.unitTesting:' is a shorter replacement for the test 'if g.app and g.app.unitTesting:'.

Using g.getTestVars eliminates pychecker warnings about undefined c and p variables.
#@+node:ekr.20070622090350.9: *7* Made alt menu keys work
# Created menu-command-key command that just returns 'continue'.
#@+node:ekr.20070626082732: *5* 4.4.3 final
Leo 4.4.3 final                                  June 26, 2006

Leo 4.4.3 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.3:
----------------------------
- Added support for chapters in Leo's core.
- Added support for zipped .leo files.
- Added a leoBridge module that allows full access to all of Leo's capabilities
  from programs running outside of Leo.
- Removed all gui-dependent code from Leo's core.
- Better support for the winpdb debugger.
- Added support for @enabled-plugins nodes in settings files.
- Added support for @openwith nodes in settings files.
- Added support for @bool write_strips_blank_lines setting.
- The__wx_gui plugin is now functional.
- Leo can use aspell on Linux when using Python 2.5 or later.
- @test nodes can now be run from any .leo file.
- Many minor improvements, new settings, commands and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070702162421: *5* 4.4.3.1
Leo 4.4.3.1                                 July 3, 2006

Leo 4.4.3.1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.3.1:
----------------------------
- Fixed a few minor bugs reported since Leo 4.4.3 was released.
- Added better support for unit testing in Leo.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070703095207.1: *6* Bugs
#@+node:ekr.20070703095207.2: *7* Fixed improper can not open myLeoSettings message
#@+node:ekr.20070703095207.5: *7* Fixed import problem in leoDynamicTest.py
It's a bit tricky to ensure that leo/src is in sys.path
The code now changes the working directory to leo/src,
and leoDynamicTest.py adds os.getcwd() to sys.path if it is not there.

#@+node:ekr.20070703095207.34: *7* Fixed cleo crasher
https://sourceforge.net/forum/message.php?msg_id=4385604
#@+node:ekr.20070703095207.35: *7* Fixed spell-check bug
Misspelled words were not selected properly on Linux.
#@+node:ekr.20070703095207.40: *7* Fixed several crashers in the group operations plugin
http://sourceforge.net/forum/message.php?msg_id=4385699
#@+node:ekr.20070703095207.41: *7* Fixed chapters bug
Moving into a chapters node from the main chapter did an automatic hoist.
#@+node:ekr.20070703095207.43: *7* Fixed problems in groupOperations plugin
- Made inter-outline moves & copies work again.
- Also, warn that inter-outline clones transfer have no effect.
- Note: none of these operations are presently undoable.

In short, this code is no worse than it has ever been.
#@+node:ekr.20070703095207.50: *7* Fixed pychecker complaints
# Added calls to c,p = g.getTestVars()

(fixed) leoNodes.py:2801: No global (p) found
(fixed) leoNodes.py:2804: No global (c) found

(fixed) leoConfig.py:1739: No global (c) found

(fixed) leoKeys.py:4446: No global (c) found

(fixed) leoEditCommands.py:7823: No global (c) found
(fixed) leoEditCommands.py:8508: No global (e) found
#@+node:ekr.20070703095207.51: *7* Fixed editor bug: deleting an editor did not always select the proper body pane
#@+node:ekr.20070703095207.55: *6* Features
#@+node:ekr.20070703095207.56: *7* g.es and g.es_print print only to console during unit tests
#@+node:ekr.20070703095207.61: *7* Run unit tests in a separate process
For full details, see Chapter 20: Unit testing with Leo.
#@+node:ekr.20070703095207.72: *7* Move most unit tests into external files
It is essential to protect them with::

     if g.unitTesting:

A new unit test ensures that this is so.
#@+node:ekr.20070806090235: *4* 4.4.4 @auto, @menus, threading syntax colorer, the Great Graph Aha
#@+node:ekr.20070806090235.1: *5* 4.4.4 b1
Leo 4.4.4 beta 1                                August 10, 2007

Leo 4.4.4 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.4:
----------------------------

- A threading_colorizer plugin replaces the __jEdit_colorizer__ plugin.
  This plugin features much better performance.

- Support for @auto nodes.  Such nodes allow people to collaborate using Leo
  without inserting Leo sentinels in the files Leo generates.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070806090226.1: *6* Added support for @mark-for-unit-tests node
The run-unit-tests command now includes *all* @mark-for-unit-test trees.
#@+node:ekr.20070806090226.14: *6* Created threading_colorizer
The old __jEdit_colorizer__.py plugin has been retired.
#@+node:ekr.20070806090226.15: *6* Added support for @auto files
#@+node:ekr.20070806095535.1: *7* What @auto does
@auto trees allows people to use Leo in collaborative environments without using
sentinels in the files Leo generates. In contrast to @nosent, @auto trees can
change when the corresponding file changes outside of Leo.

Leo will automatically recreate (import) all @auto trees when reading a .leo
file, and will write all dirty @auto trees when saving a .leo file. There are
two exceptions to this statement:

1. Leo will never read (import) or write an @auto tree if
the root @auto tree is under the influence of an @ignore directive.

2. Saving a .leo file does not save @auto nodes if a) they haven't been changed
or b) they do not contain a **significant** amount of information. An @auto tree
contains a significant amount of information if it has  children or if the
root node contains more than 10 characters.

Leo creates @auto trees by parsing the corresponding external file. Parsers
create descendant nodes of the @auto tree: one node for each class, method and
function in the external file.

Parsers presently exist for C, elisp, Java, Pascal, PHP and Python. Leo
determines the language using the file's extension. If no parser exists for a
language, the entire body of an @auto tree contains a significant amount of
information if it has any children or if the root node contains more than 10
non-blank lines. the external file is copied to the body of the @auto node.

Leo does not write the contents of @auto trees to .leo files. In this respect,
@auto trees work much like @file trees. @auto trees whose root node is under the
scope of an @ignore directive *will* be written to the .leo, just like @file
trees.
#@+node:ekr.20070809141529: *7* Perfect import checks
Leo performs several checks to ensure that the result of importing an external
file will be equivalent to the file that writing the @auto tree would produce.

These checks can produces **errors** or **warnings**. Errors indicate a
potentially serious problem. Leo inserts an @ignore directive in the @auto tree
if any error is found. This @ignore directive prevents the @auto tree from
modifying the external file. If you @ignore directive, a later write of the
@auto tree will attempt to fix the problems that gave rise to the errors. There
are no guarantees however.

**Strict languages** are languages like Python for which leading whitespace is
especially significant. Before importing a file for a strict language, Leo
**regularizes** the leading whitespace of all lines of the original source file.
That is, Leo converts blanks to tabs or tabs to blanks depending on the value of
the @tabwidth directive in effect for the @auto node. Leo cannot guarantee to
reproduce the original source file exactly if problems are discovered while
regularizing leading whitespace.

After importing a file, Leo verifies that writing the @auto node would create
the same file as the original file. For strict languages, the comparison must be
exact, or nearly so. For non-strict languages, differences in leading whitespace
generate warnings, not errors.

File comparison mismatches can arise for several reasons:

1. Bugs in the import parsers. Please report any suspected bugs immediately.

2. Underindented lines in classes, methods or functions in strict languages. An
   **underindented line** is a line that is indented less then the starting line
   of the class, method or function in which it appears. Leo outlines can not
   represent such lines exactly: every line of node implicitly has at least the
   indentation of any unindented line of the node.

Leo will issue a warning (not an error) for underindented Python comment lines.
Such lines can not change the meaning of Python programs.
#@+node:ekr.20070806101412: *7* Commands related to @auto
Three new commands in the File:Read/Write menu allow you to manually read and
write @auto nodes from the presently selected outline. As always, an @ignore
directive in the @auto node or its ancestors will suppress any of these
commands:

- The Read @auto Nodes (read-at-auto-nodes) command reads all @auto nodes in the
  presently selected outline. An @ignore directive will suppress this import.

- The Write @auto Nodes (write-at-auto-nodes) command writes all @auto nodes. An
  @ignore directive will suppress this import. Caution: the write will occur even
  if Leo has not previously read the @auto node.

- The Write Dirty @auto Nodes (write-dirty-at-auto-nodes) is the same as the
  write-at-auto-nodes command, except that only changed @auto trees are written.

Most users will rarely use these explicit commands, because reading and writing
.leo files handles @auto nodes well enough. However, you can use the
read-at-auto-nodes command to update @auto nodes without having to reload the
.leo file.
#@+node:ekr.20070806100055: *7* Extending the code: adding new parsers
All present parsers are short overrides of a powerful base parser class. Thus,
it would be simple to add support for other languages. See the node::

    @file leoImport.py-->Import-->Scanners for createOutline

in leoPy.leo to see how easy it is to create new parsers.

#@+node:ekr.20070915101216: *5* 4.4.4 b2
Leo 4.4.4 beta 2                                September 19, 2007

Leo 4.4.4 beta 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.4:
----------------------------

- A threading_colorizer plugin replaces the __jEdit_colorizer__ plugin.
  This plugin features much better performance.

- Support for @auto nodes.  Such nodes allow people to collaborate using Leo
  without inserting Leo sentinels in the files Leo generates.

- New commands for resolving cvs conflicts.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20070915101157.1: *6* Bug fixes
#@+node:ekr.20070915101157.3: *7* Fixed UNL bug1
Email from Terry Brown

A softish bug, but the use of findNodeInTree() in the UNL code can 
take you to the wrong place if more than one node in the tree has 
the same headString.  Patch below - can still go wrong if more than 
one sibling has the same name, but the UNL system doesn't have a 
solution for that.

An observation - the UNL jumping code will drop you as far down the 
path as it gets, i.e. you're moved to the last node that was one the 
path, even if the path ends before the last part of the UNL is 
reached.  This is ok, i.e. "this is as far as I could follow the 
UNL", the alternative would be to not move at all if the whole UNL 
can't be followed.

Cheers -Terry

anon_cvs> cvs diff leo/plugins/UNL.py
Index: leo/plugins/UNL.py
===================================================================
RCS file: /cvs/leo/plugins/UNL.py,v
retrieving revision 1.14
diff -r1.14 UNL.py
183c183,186
<                             p = g.findNodeInTree(c2,p,headline)
---
>                             for tmpp in p.copy().children_iter():
>                                 if tmpp.headString() == headline:
>                                     p = tmpp
>                                     break
206c209,212
<                             p = g.findNodeInTree(c,p,headline)
---
>                             for tmpp in p.copy().children_iter():
>                                 if tmpp.headString() == headline:
>                                     p = tmpp
>                                     break

#@+node:ekr.20070915101157.5: *7* Fixed how @auto handles paths
http://sourceforge.net/forum/message.php?msg_id=4444579
#@+node:ekr.20070915101157.14: *7* Fixed another path bug
http://sourceforge.net/forum/message.php?msg_id=4445685
#@+node:ekr.20070915101157.16: *7* fixed c parser so it handles non-ascii declaratsions
http://sourceforge.net/forum/message.php?msg_id=4446937
#@+node:ekr.20070915101157.17: *7* Fixed colorizing bug and moved calls to w.toGuiIndex out of some loops
# The code that was removing tags was not working properly.
#@+node:ekr.20070915101157.18: *7* Fixed unicode bug in http plugin
http://sourceforge.net/forum/message.php?msg_id=4437415
#@+node:ekr.20070915101157.19: *7* Fixed new @path problem
http://sourceforge.net/forum/message.php?msg_id=4462693
#@+node:ekr.20070915101157.40: *7* Fixed @auto path bug
http://sourceforge.net/forum/message.php?msg_id=4464980
#@+node:ekr.20070915101157.45: *7* Improved messages on @import failure
@nocolor

http://sourceforge.net/forum/message.php?msg_id=4465132
By: terry_n_brown

So I changed all my indentation to multiples of four, having decided I like
the extra line space this buys over aligning with the opening (.

leo said this when it read the file:

@auto did not import the file perfectly

but never mentioned @ignore or anything.  I made a trivial change and saved
and diff could find no difference except my trivial change... which seems perfect
to me...?

@color
#@+node:ekr.20070915101157.48: *7* Fixed problem with space in path names in runLeoDynamicTest
https://sourceforge.net/forum/message.php?msg_id=4459798
#@+node:ekr.20070915101157.50: *7* Fixed bad drag & drop bug
http://sourceforge.net/forum/message.php?msg_id=4509897
#@+node:ekr.20070915101157.70: *7* Fixed bug 'node note selected' bug
http://sourceforge.net/forum/message.php?msg_id=4514130
#@+node:ekr.20070915101157.81: *7* Retain dirty bit after write @auto fails
http://sourceforge.net/forum/message.php?msg_id=4468174
#@+node:ekr.20070915101157.82: *6* Features
#@+node:ekr.20070915101157.168: *7* Read @auto nodes during saves if the node has not been read previously
When saving a .leo file, Leo now *reads* an @auto node if

1) the external file exists,
2) an 'insignificant' amount of data exists in the @auto tree, and
3)the @auto node has not been read previously.

This promises to fix some quite awkward use cases.

The 'perfect import' code now is a bit more relaxed, especially for 'non-strict'
languages (all languages except Python):

- Leo leaves leading whitespace alone for non-strict languages.

- Leo complains about intermixed tabs and blanks in leading whitespace only for
strict languages.

- Leo ignores leading whitespace in the perfect import tests for non-strict
languages.

These changes mean that Leo might change a external file if such a change occurs
only in leading whitespace in a non-strict language.
#@+node:ekr.20070920092716: *7* New commands for resolving cvs conflicts
The so-called resolve-cvs-conflict project has resolved itself into small,
easily understood commands.

The **read-file-into-node** command prompts for a filename, and creates an node
whose headline is @read-file-into-node <filename> and whose body text is the
entire contents of the file.

The **write-file-from-node** command writes the body text of the selected not to a file.
If the headline of the presently selected node starts with @read-file-into-node
the command use the filename that follows in the headline. Otherwise, the
command prompts for a filename.

When a cvs conflict occurs, the user will:

- read the file into a node using the read-file-into-node command,

- fix the conflict, as with any other editor, and

- write the file with the write-file-from-node command.

Any file can be fixed in this way, including external files and .leo files. The
only complication is that the user must not change sentinel lines. Two new
commands check the contents of a node: The **check-derived-file** and
**check-leo-file** commands tell whether a trial read of the presently selected
node can be done successfully. The check-derived-file command assumes the body
text is a external file; the check-leo-file command assumes the body text is an
entire .leo file.

The **compare-leo-outlines** command prompts for another (presumably similar)
.leo file that will be compared with the presently selected outline file (main
window). It then creates clones of all inserted, deleted and changed nodes.
#@+node:ekr.20071004101349: *5* 4.4.4 b3
Leo 4.4.4 beta 3                            October 23, 2007

Leo 4.4.4 beta 3 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.4.4 contains many important features originally planned for later releases.
It's been a good month :-)

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.4:
----------------------------

- The Great Graph Aha (tm): simple scripts allow Leo outlines to represent
  arbitrary directed graphs. There is no need for a separate 'graph world'. The
  graphed.py plugin is a direct result of this Aha. The graphed.py plugin allows
  you to create general graphs from Leo outlines.

- @menus trees in settings files create all of Leo's menus.  It is now dead
  easy to make Leo's menus look the way you want.

- @buttons trees in settings files create common @button nodes created in all
  Leo outlines.

- @auto nodes eliminate sentinels in external files, thereby allowing people to
  collaborate using Leo more easily.

- New commands for resolving cvs conflicts.

- A threading_colorizer plugin replaces the __jEdit_colorizer__ plugin.
  This plugin features much better performance and a new, elegant algorithm.

- Leo is now compatible with jython.

- The usual assortment of bug fixes and other minor improvements.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20071004101443.1: *6* Bugs fixed
#@+node:ekr.20071004101443.18: *7* Greatly improved speed of unmark-all
#@+node:ekr.20071004101443.26: *7* Made sure dirty bits get updated in xemacs plugin
http://sourceforge.net/forum/message.php?msg_id=4543844
#@+node:ekr.20071021111856.20: *7* Fixed backward find bug
In some cases the find-previous command did not work.

After much investigation, the cause of the bug was found to be a blunder in backwardsHelper.  Changed:

pattern.lower()

to:

pattern = pattern.lower()
#@+node:ekr.20071021111856.83: *7* Fixed cursor up/down problem
There were at least 3 bugs:

At least three bugs.

- Place cursor on last (blank) line.  Cursor up goes one line too far.
- Place cursor at end of line 1.  Second cursor down does nothing.
- Place cursor at end of xxxx line.  Second cursor down goes one line too far.

xxxxxxxxx
line 1
line 2

The fix was to g.getLine--potentially a major change.
#@+node:ekr.20071021111856.124: *7* Fixed unicode bug in trace
This should have been done long ago.
#@+node:ekr.20071021111856.127: *7* Fixed chapter crasher
http://sourceforge.net/forum/message.php?msg_id=4573990
#@+node:ekr.20071021111856.252: *7* Installed patch to fix Fedora Tk.Text bug
https://sourceforge.net/forum/message.php?msg_id=4576436
#@+node:ekr.20071021111856.437: *7* Fixed bug in rst3 plugin
Suppressed doc-part-delims when show_doc_parts_as_paragraphs is True.
#@+node:ekr.20071021111856.461: *7* Allow unicode characters in Leo file names
#@+node:ekr.20071023080957: *7* Fixed bugs when running unit tests externally
The run-unit-tests command runs tests using the bridge, which uses a nullGui and a stringTextWidget.

Added a hack to g.getScript so it always gets the script from p.bodyString when
g.app.gui.inBridge is True.
#@+node:ekr.20071004101443.29: *6* New Features
#@+node:ekr.20071004103659: *7* The Great Graph Aha
The Great Graph Aha is:

A Leo outline doesn't have to *be* an arbitrary graph in order to *represent* an arbitrary graph.

So the graph world is unnecessary because we can use Leo nodes and trees as data
to other graphing packages.** That is, Python scripts can build arbitrary graphs
using Leo's existing nodes and trees. And Python scripts can manipulate those
graphs. And Python scripts could do the reverse: manipulate the Leo outline by
traversing general graphs. So there is no need to complicate Leo's fundamental
data structures. Hurray! Instead, we build on the strengths of already existing
graphing packages.

The Great Graph Aha created the opportunity for immediate action:

1. test.leo contains the essential scripts to implement graphs in Leo files.
   These short, simple, self-contained, easily modifiable scripts make possible
   everything ever envisaged by the (now-defunct) graph world project::

    leo2graph: convert a normal Leo tree to a NetworkX graph. 
    at-graph2graph: convert an @graph tree to a NetworkX graph. 
    at-networkx2graph: convert an @networkx tree to a NetworkX graph 
    at-networkx2at-graph: create an @graph tree from an @networkx tree.

2. The graphed plugin allows users to manipulate parts of Leo outlines as if
they were general graphs. It is still early days for this exciting plugin.
#@+node:ekr.20071021111856.441: *7* Rewrote threading colorizer
The new code is simple and elegant.  Almost all flash is gone.
#@+node:ekr.20070806090226.15: *7* Added support for @auto files
#@+node:ekr.20070806095535.1: *8* What @auto does
@auto trees allows people to use Leo in collaborative environments without using
sentinels in the files Leo generates. In contrast to @nosent, @auto trees can
change when the corresponding file changes outside of Leo.

Leo will automatically recreate (import) all @auto trees when reading a .leo
file, and will write all dirty @auto trees when saving a .leo file. There are
two exceptions to this statement:

1. Leo will never read (import) or write an @auto tree if
the root @auto tree is under the influence of an @ignore directive.

2. Saving a .leo file does not save @auto nodes if a) they haven't been changed
or b) they do not contain a **significant** amount of information. An @auto tree
contains a significant amount of information if it has  children or if the
root node contains more than 10 characters.

Leo creates @auto trees by parsing the corresponding external file. Parsers
create descendant nodes of the @auto tree: one node for each class, method and
function in the external file.

Parsers presently exist for C, elisp, Java, Pascal, PHP and Python. Leo
determines the language using the file's extension. If no parser exists for a
language, the entire body of an @auto tree contains a significant amount of
information if it has any children or if the root node contains more than 10
non-blank lines. the external file is copied to the body of the @auto node.

Leo does not write the contents of @auto trees to .leo files. In this respect,
@auto trees work much like @file trees. @auto trees whose root node is under the
scope of an @ignore directive *will* be written to the .leo, just like @file
trees.
#@+node:ekr.20070809141529: *8* Perfect import checks
Leo performs several checks to ensure that the result of importing an external
file will be equivalent to the file that writing the @auto tree would produce.

These checks can produces **errors** or **warnings**. Errors indicate a
potentially serious problem. Leo inserts an @ignore directive in the @auto tree
if any error is found. This @ignore directive prevents the @auto tree from
modifying the external file. If you @ignore directive, a later write of the
@auto tree will attempt to fix the problems that gave rise to the errors. There
are no guarantees however.

**Strict languages** are languages like Python for which leading whitespace is
especially significant. Before importing a file for a strict language, Leo
**regularizes** the leading whitespace of all lines of the original source file.
That is, Leo converts blanks to tabs or tabs to blanks depending on the value of
the @tabwidth directive in effect for the @auto node. Leo cannot guarantee to
reproduce the original source file exactly if problems are discovered while
regularizing leading whitespace.

After importing a file, Leo verifies that writing the @auto node would create
the same file as the original file. For strict languages, the comparison must be
exact, or nearly so. For non-strict languages, differences in leading whitespace
generate warnings, not errors.

File comparison mismatches can arise for several reasons:

1. Bugs in the import parsers. Please report any suspected bugs immediately.

2. Underindented lines in classes, methods or functions in strict languages. An
   **underindented line** is a line that is indented less then the starting line
   of the class, method or function in which it appears. Leo outlines can not
   represent such lines exactly: every line of node implicitly has at least the
   indentation of any unindented line of the node.

Leo will issue a warning (not an error) for underindented Python comment lines.
Such lines can not change the meaning of Python programs.
#@+node:ekr.20070806101412: *8* Commands related to @auto
Three new commands in the File:Read/Write menu allow you to manually read and
write @auto nodes from the presently selected outline. As always, an @ignore
directive in the @auto node or its ancestors will suppress any of these
commands:

- The Read @auto Nodes (read-at-auto-nodes) command reads all @auto nodes in the
  presently selected outline. An @ignore directive will suppress this import.

- The Write @auto Nodes (write-at-auto-nodes) command writes all @auto nodes. An
  @ignore directive will suppress this import. Caution: the write will occur even
  if Leo has not previously read the @auto node.

- The Write Dirty @auto Nodes (write-dirty-at-auto-nodes) is the same as the
  write-at-auto-nodes command, except that only changed @auto trees are written.

Most users will rarely use these explicit commands, because reading and writing
.leo files handles @auto nodes well enough. However, you can use the
read-at-auto-nodes command to update @auto nodes without having to reload the
.leo file.
#@+node:ekr.20070806100055: *8* Extending the code: adding new parsers
All present parsers are short overrides of a powerful base parser class. Thus,
it would be simple to add support for other languages. See the node::

    @file leoImport.py-->Import-->Scanners for createOutline

in leoPy.leo to see how easy it is to create new parsers.

#@+node:ekr.20071004101443.52: *7* Added @buttons trees in @settings trees
@button nodes in the @buttons tree in settings file define **global buttons** that appear in all Leo outlines.
#@+node:ekr.20071004101443.105: *7* Added @menus trees in @settings trees
Leo creates its menus using @menus trees. Within @menus trees,
@menu nodes create menus and @item nodes create menu items.

Notes:

- The menu name always follows @menu. If the menu name is 'Plugins', Leo will
  create the Plugins menu and populate the menu by calling the
  'create-optional-menus' hook. This creates the Plugins menu as usual.

- Nested @menu nodes contain submenus.

- The command name follows @item. If the body text of an @item node exists, this
  body text is the menu name. Otherwise, the menu name is the command name.
  However, if the command name starts with a '*', hyphens are removed from the
  menu name.

- Menu names and command names may contain a single ampersand (&). If present,
  the following character is underlined in the name.

- If the command name in an @item node is just a hyphen (-), the item represents
  a menu separator.

- Unicode characters, e.g., Chinese characters *are* allowed.
#@+node:ekr.20070920092716: *7* New commands for resolving cvs conflicts
The so-called resolve-cvs-conflict project has resolved itself into small,
easily understood commands.

The **read-file-into-node** command prompts for a filename, and creates an node
whose headline is @read-file-into-node <filename> and whose body text is the
entire contents of the file.

The **write-file-from-node** command writes the body text of the selected not to a file.
If the headline of the presently selected node starts with @read-file-into-node
the command use the filename that follows in the headline. Otherwise, the
command prompts for a filename.

When a cvs conflict occurs, the user will:

- read the file into a node using the read-file-into-node command,

- fix the conflict, as with any other editor, and

- write the file with the write-file-from-node command.

Any file can be fixed in this way, including external files and .leo files. The
only complication is that the user must not change sentinel lines. Two new
commands check the contents of a node: The **check-derived-file** and
**check-leo-file** commands tell whether a trial read of the presently selected
node can be done successfully. The check-derived-file command assumes the body
text is a external file; the check-leo-file command assumes the body text is an
entire .leo file.

The **compare-leo-outlines** command prompts for another (presumably similar)
.leo file that will be compared with the presently selected outline file (main
window). It then creates clones of all inserted, deleted and changed nodes.
#@+node:ekr.20071004105000: *7* Added the graphed plugin
The graphed plugin allows users to manipulate parts of Leo outlines as if
they were general graphs. It is still early days for this exciting plugin.
#@+node:ekr.20071004101443.178: *7* New convenience methods
The c.frame.logcreateCanvas convenience method create a canvas tab in the log pane.
Here is a sample script:

log = c.frame.log ; tag = 'my-canvas'

w = log.canvasDict.get(tag)
if not w:
..w = log.createCanvas(tag)
..w.configure(bg='yellow')

log.selectTab(tag)
#@+node:ekr.20071004101443.30: *7* Added button font settings
See the node:

@settings-->Fonts-->@font button font

in leoSettings.leo.
#@+node:ekr.20071005095907: *7* Leo's core is now compatible with jython
- Replaced all 'yield' statements with iterators.

- Added 'jyLeo' keyword to leo.run.

- All of Leo's startup code works with the swing gui enabled (jyLeo = True in leo.run).
#@+node:ekr.20071006093614: *7* Added the insert-child command
This inserts a child node.
#@+node:ekr.20071006155647: *7* @bool add_ws_to_kill_ring setting
#@+node:ekr.20071021111856.412: *7* Improved yank and yank-pop commands
Optimized yank, by using yanked leading whitespace if it exists

New option: add-ws-to-kill-ring (or kill-ws-adds-to-kill-ring)
#@+node:ekr.20071021111856.458: *7* Improved debug command
http://sourceforge.net/forum/message.php?msg_id=4568499
#@+node:ekr.20071021111856.459: *7* Added the @bool rst3 strip_at_file_prefixes setting
From the documentation at: http://leoeditor.com/rstplugin3.html#options

strip_at_file_prefixes (default: True)

True: remove @auto, @file, @nosent and @thin from the start of headlines.
#@+node:ekr.20071021111856.476: *7* Added g.app.inBridge ivar
This is used, at present, by g.getScript.  It is a natural status ivar in any case.
#@+node:ekr.20071021111856.477: *7* Improved the scripting and plugins chapters of Leo's Users Guide
- Use the term 'event handler' for hook.  This is much better terminology.

- Move the discussion of event handlers to the scripting chapter.

- Removed the discussion of all menu convenience routines: they are not needed now that Leo supports @menus nodes.

- The 'writing plugins' chapter is now very simple.
#@+node:ekr.20071026053825: *5* 4.4.4 b4
Leo 4.4.4 beta 4                            October 27, 2007

Leo 4.4.4 beta 4 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This beta 4 version fixes all bugs reported against Leo 4.4.4 beta 3.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Leo 4.4.4 contains many important features originally planned for later releases.

The highlights of Leo 4.4.4:
----------------------------

- The Great Graph Aha (tm): simple scripts allow Leo outlines to represent
  arbitrary directed graphs. There is no need for a separate 'graph world'. The
  graphed.py plugin is a direct result of this Aha. The graphed.py plugin allows
  you to create general graphs from Leo outlines.

- @menus trees in settings files create all of Leo's menus.  It is now dead
  easy to make Leo's menus look the way you want.

- @buttons trees in settings files create common @button nodes created in all
  Leo outlines.

- @auto nodes eliminate sentinels in external files, thereby allowing people to
  collaborate using Leo more easily. **Warning**: for now, please make backup
  copies of files imported with @auto.

- New commands for resolving cvs conflicts.

- A threading_colorizer plugin replaces the __jEdit_colorizer__ plugin.
  This plugin features much better performance and a new, elegant algorithm.

- Leo is now compatible with jython.

- Better support for icons in headlines.

- The usual assortment of bug fixes and other minor improvements.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20071026053931.1: *6* Fixed bugs
#@+node:ekr.20071026053931.13: *7* Fixed bug: utf-8 files now get imported properly
http://sourceforge.net/forum/message.php?msg_id=4574271
#@+node:ekr.20071026053931.156: *7* Replaced c.frame.body with c.frame.body.bodyCtrl
This should have been done a long time ago.
#@+node:ekr.20071026053931.157: *7* Fixed (maybe) multi-editor bug
http://sourceforge.net/forum/message.php?msg_id=4585396

The threading colorizer must be run with interruptible=False when there are multiple body editors.
#@+node:ekr.20071026053931.219: *7* Made sure proper node is visible when deleting a body editor
#@+node:ekr.20071026053931.220: *7* Fixed colorizer end-of-text bug
#@+node:ekr.20071026075016: *7* Added support for fastGotoNode plugin to leoKeyEvent classes
This fixes a fairly old crasher in the fastGotoNode plugin.
#@+node:ekr.20071026092552: *7* Fixed bug that disabled multiple occurances of the same user icon
#@+node:ekr.20071026182824: *6* Added features
#@+node:ekr.20071026053931.221: *7* Added @bool big_outline_pane setting
False (legacy): Top pane contains outline and log panes.
True: Top pane contains only the outline pane.  Bottom pane contains body and log panes.
#@+node:ekr.20071026053931.234: *7* Can print *can* handle unicode
To allow Python's print statement to print unicode characters properly, you must
change Python's default encoding to something other than 'ascii'. To do this,
put the following in your sitecustomize.py file in Python's Lib folder::

    import sys 
    sys.setdefaultencoding('utf-8') # 'iso-8859-1' is another choice.

You must restart Python after doing this: sys.setdefaultencoding can not be
called after Python starts up.

Leo's g.es_print function attempts to convert incoming arguments to unicode
using the default encoding. For example, the following Leo script always prints
La Peña::

    @first # -*- coding: utf-8 -*-
    # The line above is required for Python 2.5

    for s in (u'La Pe\xf1a','La Peña',u'La Peña'): 
        g.es_print(s)

For still more details, see:

http://www.diveintopython.org/xml_processing/unicode.html 
#@+node:ekr.20071026180804.1: *7* Improved the prototype of icon handling
The prototype in test.leo now uses PIL (Python Imaging Library) if available,
so many more kinds of icons can be used.

Buttons now exist to add icons to do the following:

- Add any icon to any node.
- Delete all icons from a single node or the entire tree.
- Print the icon files associated with a node.
- Print the sizes of icons in a directory.

In addition, fixed a bug in the icon handling in the outline widget that caused
duplicate icons not to be drawn properly.
#@+node:ekr.20071101162646: *5* 4.4.4 Final
Leo 4.4.4 Final                           November 2, 2007

Leo 4.4.4 Final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Leo 4.4.4 contains many important features originally planned for later releases.

The highlights of Leo 4.4.4:
----------------------------

- The Great Graph Aha (tm): simple scripts allow Leo outlines to represent
  arbitrary directed graphs. There is no need for a separate 'graph world'. The
  graphed.py plugin is a direct result of this Aha. The graphed.py plugin allows
  you to create general graphs from Leo outlines.

- @menus trees in settings files create all of Leo's menus.  It is now dead
  easy to make Leo's menus look the way you want.

- @buttons trees in settings files create common @button nodes created in all
  Leo outlines.

- @auto nodes eliminate sentinels in external files, thereby allowing people to
  collaborate using Leo more easily. **Warning**: for now, please make backup
  copies of files imported with @auto.

- New commands for resolving cvs conflicts.

- A threading_colorizer plugin replaces the __jEdit_colorizer__ plugin.
  This plugin features much better performance and a new, elegant algorithm.

- Leo is now compatible with jython.

- Better support for icons in headlines.

- Many bug fixes and other minor improvements.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20071101162751: *6* Fixed bugs
#@+node:ekr.20071101162751.2: *7* Fixed bug that caused rClick plugin to crash
http://sourceforge.net/forum/message.php?msg_id=4591494
#@+node:ekr.20071101162751.4: *7* Fixed scrolling problem with chapters
#@+node:ekr.20071101162751.19: *7* Fixed bug: select a chapter containing the initially selected node
The fix doesn't actually remember which chapter was previously selected; it
picks some chapter containing the initially selected node. This works exactly
for non-cloned nodes, but can select the 'wrong' chapter for cloned nodes.
Still, this is a big improvement over the previous code, which would not select
any node if the selected node was not in the main chapters.
#@+node:ekr.20071101162751.28: *7* Fixed Apple help menu reversion
#@+node:ekr.20071101162751.32: *7* Disabled the plugins manage plugin
It is too confusing at present, because it doesn't support @enabled-plugins nodes.
#@+node:ekr.20071101162751.33: *7* Made sure plugins work if frame.iconFrame is None
#@+node:ekr.20071101162751.34: *7* Fixed @auto java bug
#@+node:ekr.20071101162751.97: *7* Fixed spell-check problem on Linux
http://sourceforge.net/forum/forum.php?thread_id=1853660&forum_id=10228
#@+node:ekr.20071101162751.149: *7* Use the default spell tab
The spell tab now uses the same font as the find tab.
#@+node:ekr.20071101162751.150: *7* Fixed long-standing and important body editor bug
http://sourceforge.net/forum/message.php?msg_id=4596477
#@+node:ekr.20071101162751.178: *7* Non-ignored @auto trees do not get saved to the .leo file
#@+node:ekr.20071101162751.184: *7* Fixed bug that cause the import of PyParse.py to fail
#@+node:ekr.20071101163257: *7* Improved error reporting in rst3 plugins for code_block directive
#@+node:ekr.20071115102421: *4* 4.4.5 bug fixes
#@+node:ekr.20071115102156: *5* Leo 4.4.5 b1
Leo 4.4.5 beta 1                          November 16, 2007

Leo 4.4.5 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Leo 4.4.5 fixes several long-delayed bug fixes and adds several new features.

The highlights of Leo 4.4.5:
----------------------------

- Fixes all known bugs.
- Leo now recognizes directives in headlines.
- Adds 3 new sort-lines commands.
- Adds commands to insert and delete icons from headlines.
- Adds all the Tango 16x16 icons to Leo's icon library.
- Adds support for @rst-preformat nodes to the rst3 plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20071115102156.5: *6* Fixed bugs
#@+node:ekr.20071115102156.2: *7* Removed all references to pluginsManager.txt
#@+node:ekr.20071115102156.6: *7* Fixed hung windows
@nocolor

https://sourceforge.net/forum/message.php?msg_id=3768494
By: ktenney

I'm using current CVS, W2k

1 open a Leo file (I'm using a batch file / console)

2 click Edit->Open   <-- Having this dialog open is the problem.

3 return focus to the Leo window

4 click Help->Open leoDocs.leo

Zombie!

@color
#@+node:ekr.20071115102156.11: *7* Warn on resurrected (vampire) nodes
http://sourceforge.net/forum/message.php?msg_id=3525277

The atFile read logic only **adds** nodes, it never deletes nodes. Thus,
the 'changed2' node 'survived' the atFile read logic. The 'changed2' node became
a 'vampire' node that couldn't be killed.

The fix will require some care. The present atFile.read logic is robust because
it *doesn't* delete nodes. I suspect the solutions will be as follows:

A. The atFile.read code can not delete the subtree of @thin nodes initially,
because it doesn't know whether there will be read errors later. If there are
read errors absolutely nothing must change. This ensures that read errors never
destroy information.

B. A new post-pass will look for vampire nodes: nodes that were not actually
read from the external file. I think (but haven't proven) that all descendants of
vampire nodes are also vampire nodes. If that is so the post-pass will simply
delete vampire nodes without worrying about whether they have descendants.
#@+node:ekr.20071115102156.21: *7* Fixed new @auto bug (python)
@nocolor

From: Terry Brown <terry_n_brown@yahoo.com>

** Also, no ignore inserted.

Current CVS, ubuntu

From the code below I get:

reading: /mnt/removable/bkup_proj/Mammals/mammaldb/mammaldb.leo
*** first mismatch at line 119
original line:      def provide(self, what):
generated line: def provide(self, what):
@auto did not import the file perfectly
first mismatched line: 119
u'def provide(self, what):\n'
inserting @ignore
Errors inhibited read
@auto /mnt/removable/bkup_proj/Mammals/mammaldb/mammalShow.py

In the code below line 119 is not the first "def provide(self, what):"
but the second, the one in class mainPages - I've included the preceding
class def because context seems to be important.

@color
#@+node:ekr.20071115102156.78: *7* Fixed new @auto bug: c++
@nocolor

In the following code:

extern  "C"
{
#include "stuff.h"
void    init(void);
#include "that.h"
}

produces the following in the log window:

Leo Log Window...
Leo 4.4.4 final, build  1.216 , November 2, 2007
Python 2.5.1, Tk 8.4.14, Pmw 1.2
Windows 5, 1, 2600, 2, Service Pack 2

leoID = rshanley (in C:\)
global config dir: C:\Program Files\Leo\config
home dir: C:\
reading settings in C:\Program Files\Leo\config\leoSettings.leo
*** first mismatch at line 2
original line:  {
generated line:
import command did not import the file perfectly
first mismatched line: 2
u'\n'
input...
  0 extern  "C"
  1 {
  2 #include "stuff.h"
  3 void    init(void);
  4 #include "that.h"
  5 }
output...
  0 extern  "C"
  1
inserting @ignore
imported C:/test/aa.cc

@color
#@+node:ekr.20071115102156.79: *7* Fixed various @auto comparison problems
@bool at_auto_warns_about_leading_whitespace
#@+node:ekr.20071115102156.81: *7* Retain relative paths in recent files menu
http://sourceforge.net/forum/message.php?msg_id=4464649
By: terry_n_brown

An argument I'm always having with leo has to do with its conversion of file
paths to 'absolute' forms.

In the file browser I select '/home/tbrown/misc/foo.leo'.
Leo reinterprets this as '/media/hda2/usr1/home/tbrown/misc/foo.leo'

Then I switch machines, and while
'/home/tbrown/misc/foo.leo' would still be valid,
'/media/hda2/usr1/home/tbrown/misc/foo.leo' isn't - on the other machine it
would be '/media/hdb1/home/tbrown/misc/foo.leo'.

I end up with the two entries in recent files, having to identify the right one.

If the Tk dialog is returning '/home/tbrown/misc/foo.leo', which I assume it is
because that's what it's displaying, I wish leo would use and store that.
#@+node:ekr.20071115102156.123: *7* Fixed windows registry problem
http://sourceforge.net/forum/message.php?msg_id=4615931
#@+node:ekr.20071115102156.124: *7* Fixed paste node as clone crasher
http://sourceforge.net/forum/message.php?msg_id=4618014
#@+node:ekr.20071115102156.141: *7* Fixed hoist crasher
http://sourceforge.net/forum/message.php?msg_id=4620890
#@+node:ekr.20071115102156.146: *7* Ignore unpickling problems in getUa
From email from Terry Brown

python /home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leo.py /home/tbrown/.tnb.leo

(should be all on one line, i.e. run and open /home/tbrown/.tnb.leo)

gives the traceback below.  Opening the file from within Leo works fine.

Bah - I just now looked at it closely enough to realize it's the evil
pickled Tk classes in cleo uAs.  So I don't know whether you want to
fix that or not, it makes sense Leo would read the file specified on
the command line before Tk is initialized - if it's just scanning for
settings maybe it could catch and ignore failed uA reads at that time?

At some point I want to take pickled Tk vars out of cleo, I was
thinking when that guy was working on the wx gui would be a good time,
too bad he got sick.

reading settings in /mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/config/leoSettings.leo
reading settings in /home/tbrown/leoSettings.leo
reading settings in /home/tbrown/myLeoSettings.leo
reading settings in /home/tbrown/.tnb.leo
Traceback (most recent call last):
  File "/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leo.py", line 398, in <module>
    run(fileName)
  File "/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leo.py", line 118, in run
    g.app.config.readSettingsFiles(fileName,verbose)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoConfig.py", line 1649, in readSettingsFiles
    c = self.openSettingsFile(path)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoConfig.py", line 1674, in openSettingsFile
    theFile,path,readAtFileNodesFlag=False,silent=True) # closes theFile.
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 892, in open
    silent=silent)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 779, in getLeoFile
    self.getAllLeoElements(fileName,silent)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1317, in getAllLeoElements
    self.getVnodes()
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1898, in getVnodes
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1781, in getVnode
    appendToCurrentStack=append1,appendToTopStack=append2)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1738, in getVnode
    attr,val = self.getUa("vnode")
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/src/leoFileCommands.py", line 1658, in getUa
    val2 = pickle.loads(binString)
  File "/usr/lib/python2.5/pickle.py", line 1374, in loads
    return Unpickler(file).load()
  File "/usr/lib/python2.5/pickle.py", line 858, in load
    dispatch[key](self)
  File "/usr/lib/python2.5/pickle.py", line 1217, in load_build
    setstate(state)
  File "/mnt/removable/bkup_usr1/home/tbrown/.gnome-desktop/Package/leo/cvs/leo/plugins/cleo.py", line 130, in __setstate__
    Tk.Variable.__init__(self)
  File "/usr/lib/python2.5/lib-tk/Tkinter.py", line 188, in __init__
    self._tk = master.tk
AttributeError: 'NoneType' object has no attribute 'tk'
Exception exceptions.AttributeError: "TkPickleVar instance has no attribute '_tk'" in <bound method TkPickleVar.__del__ of <cleo.TkPickleVar instance at 0xb73a876c>> ignored
#@+node:ekr.20071116081521: *6* New commaneds
#@+node:ekr.20071115102156.238: *7* toggle-collapse_nodes_during_finds
#@+node:ekr.20071115102156.256: *7* 3 new sort-lines commands
Added sort-lines-ignoring-case, reverse-sort-lines and reverse-sort-lines-ignoring-case.
#@+node:ekr.20071115102156.303: *7* Added Cmd:Icons menu and commands
The code now remembers the relative file name as well as the full path name.
This allows Leo to find the icon when multiple machines are involved.
#@+node:ekr.20071115102156.148: *6* New features
#@+node:ekr.20071115102156.149: *7* Leo now recognizes directives in headlines
#@+node:ekr.20071115102156.301: *7* Moved all unit tests to unitTest.leo
And reorganized the unit tests by Leo source file.
#@+node:ekr.20071115102156.320: *7* Added @rst-preformat
http://sourceforge.net/forum/message.php?msg_id=4614081
#@+node:ekr.20071115102156.321: *7* Installed small icon set from Tango library
http://tango.freedesktop.org/Tango_Icon_Library

These icons are now part of Leo's distribution.
#@+node:ekr.20071116081521.1: *6* New settings
#@+node:ekr.20071115102156.237: *7* @bool at_auto_warns_about_leading_whitespace
This option has effect only when importing so-called non-strict languages,
for which leading whitespace is not terribly significant.

True: @auto warns about mismatches that occur solely in leading whitespace.
#@+node:ekr.20071115102156.302: *7* @bool vim_plugin_opens_url_nodes
http://sourceforge.net/forum/message.php?msg_id=4622384

vim.py does not open url nodes if the new setting: 

@bool vim_plugin_opens_url_nodes 

is False (or does not exist). 
#@+node:ekr.20071115102156.289: *7* @bool warn_when_plugins_fail_to_load
There is also an @bool trace_plugins setting.
#@+node:ekr.20071206093346: *5* Leo 4.4.5 b2
Leo 4.4.5 beta 2                          December 7, 2007

Leo 4.4.5 beta 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This beta 2 release fixes several recently reported bugs.  A final release
is due in about a week.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Leo 4.4.5 fixes several long-delayed bug fixes and adds several new features.

The highlights of Leo 4.4.5:
----------------------------

- Fixes all known bugs.
- Leo now recognizes directives in headlines.
- Adds 3 new sort-lines commands.
- Adds commands to insert and delete icons from headlines.
- Adds all the Tango 16x16 icons to Leo's icon library.
- Adds support for @rst-preformat nodes to the rst3 plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20071206093323.1: *6* Fixed bugs
#@+node:ekr.20071206093323.2: *7* Fixed two crashers in the @noref logic
pylint reported the following errors:

E1101:1877:atFile.readEndNode: Instance of 'atFile' has no 'correctedLines' member
E1101:2725:atFile.norefWrite:  Instance of 'atFile' has no 'putBuffered' member
#@+node:ekr.20071206093323.3: *7* Fixed crasher in regularizeWhitespace
#@+node:ekr.20071206093323.4: *7* Fixed paste-node-as-clone
http://sourceforge.net/forum/message.php?msg_id=4632695
#@+node:ekr.20071206093323.29: *7* Fixed threading colorizer hang with perl
http://sourceforge.net/forum/message.php?msg_id=4646055
#@+node:ekr.20071206093323.30: *7* Fixed C++ importer crash
https://sourceforge.net/forum/message.php?msg_id=4643992
#@+node:ekr.20071206093323.31: *7* Reorganized leoImport.py
The init base classes can now be inited in a more standard way.
#@+node:ekr.20071206093323.59: *7* Fixed command lockout problem
http://sourceforge.net/forum/message.php?msg_id=4639872
#@+node:ekr.20071206093323.72: *7* Improved @auto code
Several problems still remain:

- Files that contain what look like section references.

- Underindented docstrings.
#@+node:ekr.20071206093323.76: *7* Simplified perl colorizer and added progress checks
#@+node:ekr.20071206093323.80: *7* Fixed problem with decorators
http://sourceforge.net/forum/message.php?msg_id=4652514
#@+node:ekr.20071206093323.87: *7* Fixed @auto bug
http://sourceforge.net/forum/message.php?msg_id=4654762
#@+node:ekr.20071206093323.96: *7* Fixed  focus problem with goto-next clone command
@nocolor

I have clones that traverse chapters.

Given the following Chapters:

> Main
> Big Picture
> Smaller Chunk

I have in Main, my organization, with my group in it.  It's also cloned around
all the other views (really, everything starts in the Big Picture).

This is the layout of my clone:

1:  Chapter:Main > me
2:  Chapter:Main > MyOrg > me
3:  Chapter:Big Picture > CEO > Some Big Honcho > MyOrg > me
4:  Chapter:Smaller Chunk > Some Big Honcho > MyOrg > me

If I Go-To-Next-Clone  (ALT-N) from (1), focus will move to the selected node
in Chapter:Main, namely (2).

So here's the issue: 

Let each successive line below represent a starting focus, and the next line
the node that ALT-N selects.  If focus changes in the Outline pane (including
Chapter pane change) to match the Node, that case is marked with [f] - a successful
focus transition.

The issue are the lines w/o [f];  Here's a couple of test runs.

1: [f] (starting node / focus)
2: [f]
3:
4:
1: [f]

Next test:

3: [f]
1: [f]
1: [f]
4:
3:
1: [f]

Next test:

4: [f]
3:
1: [f]
2: [f]
4:
3:
1: [f]
2: [f]
... and so on...

In cases with NO [f], the outline pane seems moved to the "end", but no node
selected.

Not a show stopper, but a bug nonetheless.

@color
#@+node:ekr.20071211083251: *5* Leo 4.4.5 final
Leo 4.4.5 final                               December 11, 2007

Leo 4.4.5 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.4.5 fixes several long-delayed bug fixes and adds several new features.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.5:
----------------------------

- Fixes all known bugs.
- Leo now recognizes directives in headlines.
- Adds 3 new sort-lines commands.
- Adds commands to insert and delete icons from headlines.
- Adds all the Tango 16x16 icons to Leo's icon library.
- Adds support for @rst-preformat nodes to the rst3 plugin.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080106114331: *4* 4.4.6 bug fixes
#@+node:ekr.20071217092250: *5* leo 4.4.6 b1
Leo 4.4.6 beta 1                           December 17, 2007

Leo 4.4.6 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.4.6 fixes several recently reported bugs, all minor.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.6:
----------------------------
- Fixes all known bugs.
- Added @auto importers for javascript and xml files.
- Added find-next-clone and toggle-sparse-move commands.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20071217092203.1: *6* Bugs fixed
#@+node:ekr.20071217092203.2: *7* Fixed undo (dirty bit) problem)
http://sourceforge.net/forum/message.php?msg_id=4668960

It seems in external files you can delete some text and save, causing the derived
file to be written and all dirty flags cleared.  But then undo makes the text
come back, as expected, but save only saves the outline, because the dirty flag
wasn't set on the node in which the text was restored by undo.
#@+node:ekr.20071217092203.30: *7* Fixed cursesGui  plugin
#@+node:ekr.20071217092203.31: *7* Fixed script_io_to_body plugin
Added k.overrideCommand.
#@+node:ekr.20071217092203.45: *7* Make Import to @file create @file nodes
http://sourceforge.net/forum/message.php?msg_id=4671771
#@+node:ekr.20071217092203.51: *7* Fixed bug: rst3 plugin now finds default.css file correctly
http://sourceforge.net/forum/message.php?msg_id=4667105
#@+node:ekr.20071217092203.52: *7* Fixed bug with clear-recent-files
The command now clears all .leoRecentFiles.txt files and write a message.
#@+node:ekr.20071217092203.64: *7* Fixed bug: replace didn't always start in the correct place
This was a very long-standing bug: the most annoying in all of Leo.
#@+node:ekr.20071217092203.127: *7* fixed colorizer bug
The last char was not colored in the following doc part:

@

<tag />
#@+node:ekr.20071217092203.128: *7* Fixed clone focus bug
http://sourceforge.net/forum/message.php?msg_id=4676037
#@+node:ekr.20071217092203.130: *7* Removed call to printLine in change-all logic
This prevents over-long traces.
#@+node:ekr.20071217092203.131: *7* Fixed crash when copying or cloning to non-exisitent chapter
#@+node:ekr.20071217092203.161: *7* Added text bindings to status area
This fixes a focus problem.
#@+node:ekr.20071217092203.136: *7* Repaired damaged minusnode.gif icon
#@+node:ekr.20071217092203.137: *6* New features
#@+node:ekr.20071217092203.138: *7* Applied Terry Brown's config patch
The patch attached against leoConfig.py (current CVS) adds a machine
specific config file to the config files Leo loads.

I synchronize files between multiple (3) machines. This means I can't
use different myLeoSettings files on each.

Tk fonts are screen dpi sensitive.  But (in Linux at least)
Tk's attempts to switch a font you picked to something equivalent at a
different dpi always result in a font that looks terrible.

So every time I switch machines I edit ~/myLeoSettings.leo to move the
font defs I picked for the current machine to the bottom of the body
text for the appropriate settings node, and then restart Leo.

This patch means I don't have to do that any more.  I'm sure there are
other uses for it.  Python doesn't seem to have a generic machine name
finding function, hence the sequence of alternatives.
#@+node:ekr.20071217092203.145: *7* Applied plumloco's patch to plugins_menu.py
The version of plugins_menu.py at http://leo.zwiki.org/Plumloco separates out
the gui dependent dialogs (the menus are already gui independent) and made them
general purpose dialogs available to all plugins.

I have also slightly enhanced the dialogs to provide user defined buttons. 
#@+node:ekr.20071217092203.146: *7* Upgraded to Pmw 1.3
#@+node:ekr.20071217092203.147: *7* Added find-next-clone command
The finds the next cloned node, regardless of whether the presently selected node is a clone or not.
#@+node:ekr.20071217092203.149: *7* Added toggle-sparse-move command
The command toggles whether moving a node left collapses the outline.
#@+node:ekr.20071217092203.152: *7* Added support for @data nodes in @settings trees
#@+node:ekr.20071217092203.154: *7* Added @auto xml script
Use @data import_xml_tags setting to specify the xml tags that act as organizers.
#@+node:ekr.20071217092203.163: *7* Added @import scanners for javascript and xml files
Javascript regexps that look like section references cause problems, but that can not be helped.
#@+node:ekr.20080106114225: *5* leo 4.4.6 b2
Leo 4.4.6 beta 2                           January 15, 2008

Leo 4.4.6 beta 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.4.6 fixes several recently reported bugs, all minor.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.6:
----------------------------
- Fixes all known bugs.
- Added @auto importers for javascript and xml files.
- Added find-next-clone and toggle-sparse-move commands.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080106114648: *6* Fixed bugs
#@+node:ekr.20080106114203.1: *7* Fixed bug in nav_buttons plugin
http://sourceforge.net/forum/message.php?msg_id=4682598
#@+node:ekr.20080106114203.2: *7* Fixed problems with modes/rest.py
http://sourceforge.net/forum/message.php?msg_id=4681175

- There was a horrendous bug in the match_seq_regexp matcher which could cause the colorizer to loop.
- There was another horrendous bug in match_regexp_helper that cause spurious matches.
- Added some more defensive code to have the colorizer recover more gracefully in this case. 
- The jedit2py script was not associating regexp rules whose regex starts with
  '\' with the proper character. The proper character is the hash_char
  character, not the '\' character. As a result, regexp's that start with '\'
  never got matched.

The following colorizers are affected by the change:

modes/apacheconf.py
modes/erlang.py
modes/moin.py
modes/perl.py
modes/php.py
modes/pl1.py
modes/rest.py
modes/shell.py
modes/shellscript.py
#@+node:ekr.20080106114203.3: *7* Replaced delete-all-icons command with a script in script.leo
#@+node:ekr.20080106114203.4: *7* Leo issues better messages if Image can not be imported
http://sourceforge.net/forum/message.php?msg_id=4687706
#@+node:ekr.20080115093848.18: *7* Added convenience methods for icons
See http://leoeditor.com/scripting.html#inserting-and-deleting-icons
#@+node:ekr.20080115093848.19: *7* Fixed undo bug
http://sourceforge.net/forum/message.php?msg_id=4712329
#@+node:ekr.20080115093848.23: *7* Don't mark nodes dirty if insert-icon is cancelled
http://sourceforge.net/forum/message.php?msg_id=4714779
#@+node:ekr.20080126090039: *5* leo 4.4.6 final
Leo 4.4.6 final                           January 26, 2008

Leo 4.4.6 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.4.6 fixes several recently reported bugs, all minor.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.6:
----------------------------
- Fixes all known bugs.
- Added @auto importers for javascript and xml files.
- Added find-next-clone and toggle-sparse-move commands.

Links:
------
Leo:      http://leoeditor.com
Home:     http://sourceforge.net/projects/leo/
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080218154129: *4* 4.4.7 ipython plugin
#@+node:ekr.20080212221734: *5* leo 4.4.7 b1
Leo 4.4.7 beta 1                           February 12, 2008

Leo 4.4.7 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version features the ipython plugin that provides a two-way bridge
between Leo and IPython.  See http://leoeditor.com/IPythonBridge.html

Leo's main discussion is now at: http://groups.google.com/group/leo-editor

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.7:
----------------------------
- The ipython plugin creates a simple, powerful, effective bridge between IPython and Leo.
  See http://leoeditor.com/IPythonBridge.html
- Improved handling of unicode encodings in @auto files.
- All import commands now support @path directives in ancestor nodes.
- Fixed several minor bugs.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080212221711.1: *6* Fixed bugs
#@+node:ekr.20080212221711.2: *7* Fixed perl syntax coloring bug
#@+node:ekr.20080212221711.4: *7* Removed warnings while typing @language directives
#@+node:ekr.20080212221711.15: *7* Fixed pascal import bug
http://groups.google.com/group/leo-editor/browse_thread/thread/4fa4709969fc04d
#@+node:ekr.20080212221711.35: *7* write-outline-only command now prints a 'done' message
#@+node:ekr.20080213094948.1: *7* Worked around problems with winpdb
There appear to be problems with Python's subprocess module on Ubuntu.
#@+node:ekr.20080213094948.4: *7* Fixed new problem with image.py
The version of PIL that ships with Ubuntu (and presumably Debian and maybe some
other distributions) no longer includes the ImageTk module. ImageTk is now
located in the python- imaging-tk package.
#@+node:ekr.20080212221711.32: *6* New features
#@+node:ekr.20080212221711.33: *7* All import commands now honor @path
#@+node:ekr.20080212221711.34: *7* Added ipython plugin
#@+node:ekr.20080212221711.47: *7* Added support for @bool open_with_save_on_update setting
If the @bool open_with_save_on_update setting is True,
Leo will automatically save the outline whenever an external editor
changes the outline.
#@+node:ekr.20080212221711.26: *7* Improved handling of unicode for @auto files
When reading an @auto tree, createOutline now does the following:

1. When importing Python files, createOutline uses the encoding implied by
Python's # -*- coding line. This line must be the first line of the imported file.

2. Otherwise, createOutline scans the @auto node and its ancestors for Leo's @encoding directive.

3. If no such @encoding directive is found, createOutline uses the encoding specified by the setting: @string default_at_auto_file_encoding = utf-8

4. If this setting does not exist, the utf-8 encoding is used.
#@+node:ekr.20080218153931: *5* leo 4.4.7 final
Leo 4.4.7 final                           February 18, 2008

Leo 4.4.7 final is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version features a new ipython plugin that provides a two-way bridge
between Leo and IPython.  See http://leoeditor.com/IPythonBridge.html

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.7:
----------------------------
- The ipython plugin creates a simple, powerful, effective bridge between IPython and Leo.
  See http://leoeditor.com/IPythonBridge.html
- Improved handling of unicode encodings in @auto files.
- All import commands now support @path directives in ancestor nodes.
- Fixed several minor bugs.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
CVS:      http://leo.tigris.org/source/browse/leo/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080218153931.1: *6* Fixed bugs
#@+node:ekr.20080218153931.2: *7* Fixed perl syntax coloring bug
#@+node:ekr.20080218153931.3: *7* Removed warnings while typing @language directives
#@+node:ekr.20080218153931.4: *7* Fixed pascal import bug
http://groups.google.com/group/leo-editor/browse_thread/thread/4fa4709969fc04d
#@+node:ekr.20080218153931.5: *7* write-outline-only command now prints a 'done' message
#@+node:ekr.20080218153931.6: *7* Worked around problems with winpdb
There appear to be problems with Python's subprocess module on Ubuntu.
#@+node:ekr.20080218153931.7: *7* Fixed new problem with image.py
The version of PIL that ships with Ubuntu (and presumably Debian and maybe some
other distributions) no longer includes the ImageTk module. ImageTk is now
located in the python- imaging-tk package.
#@+node:ekr.20080218154129.1: *7* Leo's old colorizer now colorizes Leo directives properly
#@+node:ekr.20080218153931.8: *6* New features
#@+node:ekr.20080218153931.9: *7* All import commands now honor @path
#@+node:ekr.20080218153931.10: *7* Added ipython plugin
#@+node:ekr.20080218153931.11: *7* Added support for @bool open_with_save_on_update setting
If the @bool open_with_save_on_update setting is True,
Leo will automatically save the outline whenever an external editor
changes the outline.
#@+node:ekr.20080218153931.12: *7* Improved handling of unicode for @auto files
When reading an @auto tree, createOutline now does the following:

1. When importing Python files, createOutline uses the encoding implied by
Python's # -*- coding line. This line must be the first line of the imported file.

2. Otherwise, createOutline scans the @auto node and its ancestors for Leo's @encoding directive.

3. If no such @encoding directive is found, createOutline uses the encoding specified by the setting: @string default_at_auto_file_encoding = utf-8

4. If this setting does not exist, the utf-8 encoding is used.
#@+node:ekr.20080311060457.215: *4* 4.4.8 translating args to g.es and g.es_print
#@+node:ekr.20080304112808: *5* 4.4.8 b1
Leo 4.4.8 beta 1                           March 5, 2008

Leo 4.4.8 beta 1 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version features a new ipython plugin that provides a two-way bridge
between Leo and IPython.  See http://leoeditor.com/IPythonBridge.html

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.8:
----------------------------
- Leo's source code is now managed by bzr.
  See the Bzr link below.
- Leo's discussion is now hosted by Google Groups:
  See the Forum link below.
- The first, third, fifth etc. arguments to g.es and g.es_print
  can now be translated using Python's gettext.gettext function.
- Completed ILeo: a bridge between IPython and Leo.
  See http://leoeditor.com/IPythonBridge.html
- Added support for arguments to minibuffer commands.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080304112802.1: *6* Allow arguments to minibuffer commands
http://mail.google.com/mail/#inbox/1184b70ea10f5aa3

Leo now contains minimal support for arguments to minibuffer commands.

- k.simulateCommand now puts arguments following the command name in k.givenArgs.
  Whitespace separates arguments.

- k.simulateCommand knows nothing about what the arguments mean. That is up to
  the individual commands.

- At present, only the following minibuffer commands now support k.givenArgs:
  open-outline, open-outline-by-name, save-file, save-file-as,
  save-file-as-unzipped and save-file-as-zipped.

  These commands use ''.join(k.givenArgs) to get the file name,
  which may cause problems if the file name contains whitespace.

- At present, the repeat-complex-command command does not support arguments.
#@+node:ekr.20080304112802.25: *6* Added translation services
#@+node:ekr.20080310093038.4: *7* Translating Leo's menus and messages
.. _gettext: http://docs.python.org/lib/module-gettext.html

It is easy to translate Leo's menu strings: simply create an @menus tree in
leoSettings.leo or myLeoSettings.leo that contains the translated menu names.

**New in Leo 4.4.8**:
Leo now contains support for translating messages sent to Leo's log:

- Rather than using an '_' function to denote strings to be translated, Leo's
  g.es and g.es_print functions translate "odd" (first, third, fifth) arguments,
  leaving "even" arguments untranslated. Keyword arguments, color, newline, etc.
  are never translated.

- All calls to g.es and g.es_print in Leo's core follow this convention.

- g.translateString does the actual translation using Python's `gettext`_ module.

- You can use the script in the node "@button print g.es stats" in scripts.leo
  to create catalogs of all scripts that need to be translated. Such catalogs
  are used by Python's gettext module. (This script was also used to check that
  the proper arguments to g.es and g.es_print were translated.)
#@+node:ekr.20080311060457.1: *5* 4.4.8 b2
Leo 4.4.8 beta 2                           March 14, 2008

Leo 4.4.8 beta 2 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version features a new ipython plugin that provides a two-way bridge
between Leo and IPython.  See http://leoeditor.com/IPythonBridge.html

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.8:
----------------------------
- Leo's source code is now managed by bzr.
  See the Bzr link below.
- Leo's discussion is now hosted by Google Groups:
  See the Forum link below.
- The first, third, fifth etc. arguments to g.es and g.es_print
  can now be translated using Python's gettext.gettext function.
- Completed ILeo: a bridge between IPython and Leo.
  See http://leoeditor.com/IPythonBridge.html
- Added support for arguments to minibuffer commands.
- @menu trees can now refer to commands created by
  @command and @button nodes
- Added support for common @commands nodes in settings files.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080311060457.210: *6* b1
#@+node:ekr.20080311060457.211: *7* Allow arguments to minibuffer commands
http://mail.google.com/mail/#inbox/1184b70ea10f5aa3

Leo now contains minimal support for arguments to minibuffer commands.

- k.simulateCommand now puts arguments following the command name in k.givenArgs.
  Whitespace separates arguments.

- k.simulateCommand knows nothing about what the arguments mean. That is up to
  the individual commands.

- At present, only the following minibuffer commands now support k.givenArgs:
  open-outline, open-outline-by-name, save-file, save-file-as,
  save-file-as-unzipped and save-file-as-zipped.

  These commands use ''.join(k.givenArgs) to get the file name,
  which may cause problems if the file name contains whitespace.

- At present, the repeat-complex-command command does not support arguments.
#@+node:ekr.20080311060457.212: *7* Added translation services
#@+node:ekr.20080311060457.213: *8* Translating Leo's menus and messages
.. _gettext: http://docs.python.org/lib/module-gettext.html

It is easy to translate Leo's menu strings: simply create an @menus tree in
leoSettings.leo or myLeoSettings.leo that contains the translated menu names.

**New in Leo 4.4.8**:
Leo now contains support for translating messages sent to Leo's log:

- Rather than using an '_' function to denote strings to be translated, Leo's
  g.es and g.es_print functions translate "odd" (first, third, fifth) arguments,
  leaving "even" arguments untranslated. Keyword arguments, color, newline, etc.
  are never translated.

- All calls to g.es and g.es_print in Leo's core follow this convention.

- g.translateString does the actual translation using Python's `gettext`_ module.

- You can use the script in the node "@button print g.es stats" in scripts.leo
  to create catalogs of all scripts that need to be translated. Such catalogs
  are used by Python's gettext module. (This script was also used to check that
  the proper arguments to g.es and g.es_print were translated.)
#@+node:ekr.20080311060457.216: *6* b2
#@+node:ekr.20080311060457.2: *7* Bug fixes
#@+node:ekr.20080311060457.3: *8* Assigned g.fileIndex on the fly
@nocolor

Eureka! I have just discovered an elegant solution to this problem!

The Aha is this:  we can create a "base" timestamp just *once*, when
the commander (i.e. the NodeIndices class) is created.  Thereafter,
code that writes gnx's simply calls NodeIndices.getIndex if the node
doesn't already have an index (or if indices are being reassigned in a
copied tree).

In other words, there is no need to be picky about timestamps, the
base timestamp will do, so there is no need to assign indices before
writing nodes!

I didn't see this before because computing timestamps is quite time
consuming.  In fact, we can't do so "on the fly".  That being so, the
old code computed the "new" timestamp once in assignFileIndices, which
lead me away from getting gnx's as needed.  But if there is only *one*
timestamp everything becomes easy.  There is no need to "batch" the
computation of gnx's.  In other words, timestamps don't have to be up-
to-the-second accurate.  They simply guarantee that two nodes (in a
particular outline) created by the *same* person can't collide.

This is the way it is written in "The Book". All calls to
assignFileIndices disappear!  All the code I wrote this morning that
remembers whether indices have been assigned disappears.  I'll keep a
do-nothing assignFileIndices around for compatibility with old
scripts.

This is *so* important.  It eliminates forever a source of serious
file write problems.  Furthermore, NodeIndices.getIndex becomes
substantially simpler. Even though the code was short, it implied some
very tricky assumptions.  Every time I read it I had to recreate why
it worked.  Those mental gymnastics should disappear.

A great day for Leo. 

@color
#@+node:ekr.20080311060457.28: *8* Allow tkFrame to complete before killing it
#@+node:ekr.20080311060457.38: *8* Renamed self.fileIndex to  readBufferIndex in file read logic
# This should have been done long ago.
#@+node:ekr.20080311060457.125: *8* Made sure that all fileIndex fields get converted on read
#@+node:ekr.20080311060457.128: *7* Features
#@+node:ekr.20080311060457.188: *8* Compile regexp's once in findNextMatch
http://sourceforge.net/forum/message.php?msg_id=4677335
#@+node:ekr.20080311060457.198: *8* Created menus very late in the creation process
This allows @menu items to refer to commands created by @button.
#@+node:ekr.20080314081157.1: *8* Improved marks/recent buttons plugin
- Added show-marks-dialog and show-recent-sections-dialog commands.
- Select an item initially.
- Added bindings for up and down arrows.
#@+node:ekr.20080314081157.2: *8* Added support for @commands trees in settings files
#@+node:ekr.20080328074117.340: *5* 4.4.8 b3
Leo 4.4.8 beta 3                           March 28, 2008

Leo 4.4.8 beta 3 is available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version features a new ipython plugin that provides a two-way bridge
between Leo and IPython.  See http://leoeditor.com/IPythonBridge.html

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.8:
----------------------------
- Leo's source code is now managed by bzr: see link below.
- Leo's discussion is now hosted by Google Groups: see link below.
- Arguments to g.es and g.es_print can be translated using gettext.
- Completed ILeo: a bridge between IPython and Leo.
  See http://leoeditor.com/IPythonBridge.html
- Minibuffer commands may have arguments.
- @menu trees can now refer to commands created by
  @command and @button nodes.
- Added support for common @commands nodes in settings files.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080328074117.2: *6* Fixed bugs
#@+node:ekr.20080328074117.3: *7* Corrected docs: unit tests are in test/unitTest.leo
#@+node:ekr.20080328074117.4: *7* Removed '.' from leoID
This fixes a bug that can corrupt .leo files.
#@+node:ekr.20080328074117.12: *7* Fixed Open With menu
http://groups.google.com/group/leo-editor/browse_thread/thread/62fe73901d14f6c3
#@+node:ekr.20080328074117.30: *7* Fixed @lineending botch
http://groups.google.com/group/leo-editor/browse_thread/thread/f802b083dee96312
#@+node:ekr.20080328074117.76: *7* Fixed undo problem with mutliple editors
http://mail.google.com/mail/#inbox/11899019a43f74ca

When you have two editors open on the same node most actions show up in both
editors, however, if you do an undo the change only show up in the selected
editor. (The change shows up in the other editor when you select it).
#@+node:ekr.20080328074117.77: *7* Write dirty bit if write fails
http://groups.google.com/group/leo-editor/browse_thread/thread/71822f48720e71bc/6e0fd1c72fa39817#6e0fd1c72fa39817
#@+node:ekr.20080328074117.135: *7* Fixed bug involving default_target_language
The new setting is @string target_language, not @language default_target_language.
#@+node:ekr.20080328074117.215: *7* Fixed plugins that create new menu items
@nocolor

http://groups.google.com/group/leo-editor/browse_thread/thread/6a5087a59d6d23

- Changed menu1 to menu2 in several plugins.
- Changed menu2 to menu-update.
- Moved after-create-leo-frame to after menu2.
#@+node:ekr.20080328074117.216: *6* Features
#@+node:ekr.20080328074117.217: *7* Added @bool collapse_nodes_while_spelling setting
This hugely speeds up spelling when there are lots of misspelled words.
#@+node:ekr.20080328074117.220: *7* Errors reading external files give line numbers
#@+node:ekr.20080328074117.262: *7* Added @bool allow_middle_button_paste
@nocolor

http://groups.google.com/group/leo-editor/browse_thread/thread/62fe73901d14f6c3

And, while you're looking at the editor code :-) - in linux when you paste in
text to a body editor with a middle mouse button click, it's not stored unless
you follow that with a key stroke or some other action in the body editor. If
you instead middle button paste to the editor and then click on another node in
the tree, the text's forgotten.

To do-->@thin ../doc/leoToDoLater.txt-->Can't or won't-->Known Bugs: can't be fixed or can wait-->Bug: can't be fixed-->Cut/paste bug on X windows (waiting for help)

@color
#@+node:ekr.20080328074117.297: *7* Added support for @popup settings
#@+node:ekr.20080403065258.10: *5* 4.4.8 rc1
Leo 4.4.8 rc1                        April 3, 2008

Leo 4.4.8 rc1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version features a new ipython plugin that provides a two-way bridge
between Leo and IPython.  See http://leoeditor.com/IPythonBridge.html

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.8:
----------------------------
- Leo's source code is now managed by bzr: see link below.
- Leo's discussion is now hosted by Google Groups: see link below.
- Arguments to g.es and g.es_print can be translated using gettext.
- Completed ILeo: a bridge between IPython and Leo.
  See http://leoeditor.com/IPythonBridge.html
- Minibuffer commands may have arguments.
- @menu trees can now refer to commands created by
  @command and @button nodes.
- Added support for common @commands nodes in settings files.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080403065258.6: *6* Fixed delete-editor problem
http://groups.google.com/group/leo-editor/browse_thread/thread/ed5d82429e1ec821

The following sequence of commands caused problems:

add-editor
add-editor
delete-editor
delete-editor
add-editor
#@+node:ekr.20080405074410.4: *4* 4.4.8 final
Leo 4.4.8 final                        April 6, 2008

Leo 4.4.8 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

This version features a new ipython plugin that provides a two-way bridge
between Leo and IPython.  See http://leoeditor.com/IPythonBridge.html

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.4.8:
----------------------------
- Leo's source code is now managed by bzr: see link below.
- Leo's discussion is now hosted by Google Groups: see link below.
- Arguments to g.es and g.es_print can be translated using gettext.
- Completed ILeo: a bridge between IPython and Leo.
  See http://leoeditor.com/IPythonBridge.html
- Minibuffer commands may have arguments.
- @menu trees can now refer to commands created by
  @command and @button nodes.
- Added support for common @commands nodes in settings files.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080405074410.7: *5* Open leoPluginsRef.leo in help menu if leoPlugins.leo does not exist
#@+node:ekr.20080405074410.9: *5* Fixed big performance bug in find/spell commands.
#@+node:ekr.20080405074410.38: *5* Fixed several unit testing bugs relating to doTests(all=True)
#@+node:ekr.20080730095710.1: *3* 4.5 code reorgs, vim bindings, @shadow
#@+node:ekr.20080624093059.1: *4* 4.5 b1
Leo 4.5 beta 1                      June 28, 2008

Leo 4.5 beta 1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.5:
--------------------------
- A major revision of Leo's node structures, compatible with so-called unified nodes.
- A major revision of Leo's key-handling code.  Most per-pane key bindings have been eliminated.
- A major revision of Leo's outline drawing and focus handling code.
  Calls to c.beginUpdate and c.endUpdate simply request later redrawing in c.outerUpdate.
- The beginning of usable vim-like bindings.  More support is coming.
- Many small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080624093059.2: *5* Bug fixes
#@+node:ekr.20080624093059.3: *6* Fixed bug in appendToRecentFiles
#@+node:ekr.20080624093059.4: *6* Fixed bug in install script
On Mon, Apr 7, 2008 at 7:07 PM, SegundoBob <bhossley@ieee.org> wrote:

I installed Leo 4.4..8 final on Ubuntu.  The installation failed
because the installation put files in /usr/lib/leo/leo.  The
duplicated leo is a mistake.
On line 13 of install I changed:
LEO_LIB_DIR="${LEO_PREFIX}/lib/leo"
to
LEO_LIB_DIR="${LEO_PREFIX}/lib"

With the change the installation worked.
#@+node:ekr.20080624093059.5: *6* Fixed bug: no focus after save-as and save-to commands
#@+node:ekr.20080624093059.6: *6* Fixed find bug
http://groups.google.com/group/leo-editor/browse_thread/thread/294866696257802e
#@+node:ekr.20080624093059.7: *6* Fixed find completion bug
Trying to edit the minibuffer, when I backspace to a character and
press delete the cursor moves to the end of the buffer and deletes the
last character instead.
#@+node:ekr.20080624093059.8: *6* Fixed how-many, find-word and goto-character commands
find-word
=========
This command is supposed to:

"Put the cursor at the next word (on a line) that starts with a
character"

It does not. You have to type in a whole word to get any result and
even then
it only selects the word it does not move the cursor to it.


goto-character
==============
'''Put the cursor at the n'th character of the buffer.'''

Doesn't do anything.
#@+node:ekr.20080624093059.9: *6* Fixed import PHP bug
http://groups.google.com/group/leo-editor/browse_thread/thread/b068e88a577a0547
#@+node:ekr.20080624093059.10: *6* Fixed keyword handling in g.es and g.es_print
#@+node:ekr.20080624093059.11: *6* Fixed new @auto bug
Leo's running, so I create a new outline with File->New

Then I save as in a location where foo.py exists.

The I create a node '@auto foo.py'

Then I use File->Read/Write->Read @auto (with that node selected)

Leo says it can't read it.

I close the leo file, re-open in from the recent files menu of the
outline that spawned it, and the @auto file is read no problems.
#@+node:ekr.20080624093059.12: *6* Fixed recent files bug
http://groups.google.com/group/leo-editor/browse_thread/thread/c6c4faf6fdead672
#@+node:ekr.20080624093059.14: *6* Greatly increased speed of undo clone-find-all
findAll now just creates undo info for clone-find-all for one inserted node.
#@+node:ekr.20080624093059.15: *6* Temporary fix for php import bug
#@+node:ekr.20080624093059.16: *6* Fixed unbounded loop in autocompleter.findAnchor
#@+node:ekr.20080624093059.17: *6* Fixed insert-newline bug
exception executing command
Traceback (most recent call last):
 File "C:\_Proj\Leo\key-handling\leo\src\leoCommands.py", line 298, in doCommand
   val = command(event)
 File "C:\_Proj\Leo\key-handling\leo\src\leoEditCommands.py", line 2946, in insertNewLine
   self.insertNewlineHelper(w=w,oldSel=oldSel,undoType=None)
 File "C:\_Proj\Leo\key-handling\leo\src\leoEditCommands.py", line 3104, in insertNewlineHelper
   w.setInsertPoint(i+1)
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
truncating headline to one line
#@+node:ekr.20080624093059.18: *6* Single click did not color body correctly
#@+node:ekr.20080624093059.19: *6* Body not colored correctly after find
#@+node:ekr.20080624093059.20: *6* Fixed big performance bug in contract-all command
#@+node:ekr.20080624093059.21: *6* Changed bindings so Home and end keys work as expected when editing a headline
#@+node:ekr.20080624093059.22: *6* Fixed bug: myLeoSettings.leo sometimes read twice
http://groups.google.com/group/leo-editor/browse_thread/thread/35a8ea2024036623s
#@+node:ekr.20080624093059.23: *6* Compute menus list for each c
http://sourceforge.net/forum/forum.php?thread_id=1858451&forum_id=10228
#@+node:ekr.20080624093059.24: *6* Fixed minor spelling bug
http://groups.google.com/group/leo-editor/browse_thread/thread/d2a9aeac0d0082f6
#@+node:ekr.20080624093059.25: *6* Fixed spell bug: words containing unicode characters aren't saved properly
#@+node:ekr.20080624093059.26: *6* Fixed coloring bugs in reformatParagraph and c.redraw
#@+node:ekr.20080624093059.27: *6* Fixed missing redraw problem
Changed c.outerUpdate and added c.bind and c.bind2.
#@+node:ekr.20080624093059.28: *6* Fixed new-headline problem
#@+node:ekr.20080624093059.29: *6* Fixed recent crasher
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 311, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\core\leoEditCommands.py", line 4781, in selectAllText
    return w.selectAllText()
AttributeError: Canvas instance has no attribute 'selectAllText'
#@+node:ekr.20080624093059.30: *6* Fixed encoding problems with paste from clipboard
#@+node:ekr.20080624093059.31: *6* Changed installer to support leo-as-a-package
http://groups.google.com/group/leo-editor/browse_thread/thread/8edc4e7b809189cf
#@+node:ekr.20080628062747.69: *6* Fixed undo problem
http://groups.google.com/group/leo-editor/browse_thread/thread/794ca596f7c58ae5

The fix was to call c.redraw_now in undo() and redo().  This allows the undo interlock to work.
#@+node:ekr.20080628062747.70: *6* Fixed insert-file bug
Minor nit - insert-file to load a file into a node, text appears in the
body pane.  Without doing anything else to the body pane click on
another node.  Inserted text is lost - body for node is empty.  As long
as you move the cursor into the body frame and press a key after
inserting the contents, it's retained.
#@+node:ekr.20080628062747.71: *6* Fixed script button bug
@nocolor

c.beginUpdate()
try:
 add / change icons on some nodes
 c.setChanged(True)
finally:
 c.endUpdate()

seems not to give a redraw *after* a script button is pressed.

It does give one before the action is taken, so pressing the button
twice shows the change.

EKR: The fix was to mod_scripting.py.

@color
#@+node:ekr.20080628062747.72: *6* Fixed dragging bug
The fix was a major addition to p._adjustPositionBeforeUnlink.

Report:

Run this script:

t = p.insertAfter()
c.setHeadString(t, 'test node 1')
t = t.insertAfter()
c.setHeadString(t, 'test node 2')
t = t.insertAfter()
c.setHeadString(t, 'test area')
for i in range(200):
   n = t.insertAsLastChild()
   c.setHeadString(n, str(i))
   if i == 3: x = n

for i in range(100):
   n = x.insertAsLastChild()
   c.setHeadString(n, str(i+500))

t.expand()

It creates an outline, you might need to click on the node from which
the script was run to see what was added.  It should look like this:

test node 1
test node 2
test area
   1
   2
  +3
   4
   5
   etc.

Now, use the mouse to drag test node 1 down to a position after node
4... for me at least this results in the outline view leaping to the
bottom of the tree, which it shouldn't do.

Scroll back up to the top, and drag test node 2 down to a position
after node 4, this time no leap.

It appears that the first time you drag something into the test area it
reacts as if 3 is expanded and repositions to allow for all those
actually not visible lines, but the second time you drag something in
it's ok, as if it has an accurate count on visible lines now.
#@+node:ekr.20080624093059.32: *5* Features
#@+node:ekr.20080624093059.33: *6* Remove useTextWidget option from leoKeys.py
#@+node:ekr.20080624093059.34: *6* Set use_sax = True always
#@+node:ekr.20080624093059.35: *6* Added g.unified_nodes
- Made t arg optional in vnode ctor.

- Removed the t arg from insertAsX.  Affects these plugins:

wrote:     base64Packager.py
wrote:     macros.py
wrote:     table.py
wrote:     templates.py
wrote:     xsltWithNodes.py

Search for tnode.
#@+node:ekr.20080624093059.36: *6* Added install nodes re Leo's home directory
Leo puts several files in the home directory: .leoID.txt,
.leoRecentFiles.txt, and myLeoSettings.leo.  There are various fallback directories if there is no home directory.

If you want more details, you can do what I did: do a clone-find-all for homeDir.

As for how the home directory is set, the code to do this is g.computeHomeDir.  We get the home directory with

home = os.getenv('HOME',default=None)

There are some mind-numbing details to be handled if there os.getenv does, in fact, return a directory.
#@+node:ekr.20080624093059.37: *6* Added support for @bool fixedWindow option
Leo suppresses marks, expansion state, orphan bits and current
position bits when writing fixed .leo files.  As a result, all nodes
will be collapsed and the root node will always be selected when Leo
opens a fixed .leo file.

When writing fixed .leo files, Leo writes fixed, immutable, reasonable
defaults for window size, position and body-outline ratio.
Specifically, width,height,left,top = 700,500,50,50 and the ratio is
0.5. These values are written so older versions of Leo can read fixed
files.

You make a file fixed by putting '@bool fixedWindow = True' in the
@settings tree of a particular .leo file.  The file will be fixed
after you save the file, reload the file, and save the file again.
Yes, this is clumsy, but it only has to be done once.  A toggle-fixed
file command doesn't seem that useful: using an @bool node is simple
and clear.

You can optionally specify the size and position on the screen of
fixed .leo files by putting an '@data fixedWindowPosition' node in the
@settings tree of myLeoSettings.leo or leoSettings.leo.  You should
**not** put such a node in the fixed .leo file itself--everyone who
opens the file would get that fixed position.

The body of the '@data fixedWindowPosition' node should contain
something like this:

# Must be four entries: width,height,left,top.
# Put this in myLeoSettings.leo, **not** in individual .leo files.

1200
800
50
50

Leo uses reasonable defaults for fixed .leo files if this node does
not exist, or contains something other than 4 numbers, one per line. 
#@+node:ekr.20080624093059.38: *6* Added new key-handling
This allows substantially simpler key bindings. Indeed, most per-pane bindings
have been eliminate.
#@+node:ekr.20080624093059.39: *6* New drawing/focus code
#@+node:ekr.20080624093059.40: *6* Improved end of calltips
# Added ')' at end.
#@+node:ekr.20080624093059.41: *6* Find character crosses lines
#@+node:ekr.20080624093059.42: *6* Added os.curdir to sys.path if possible
This is necessary to simulate operation as a package.
#@+node:ekr.20080624093059.43: *6* Added support for single-config option
This code appears to have been reverted in such a way that it never got pushed to launchpad.
#@+node:ekr.20080624093059.44: *6* Finished Tracer class
This is a Python 'debugger' that computes a call graph.

To trace a function and its callers, put the following at the function's start::

    g.startTracer()
#@+node:ekr.20080624093059.45: *6* Rewrote option-parsing code using optparse
#@+node:ekr.20080624093059.46: *6* Added @bool cleo_color_ignore = True
This determines whether cleo colors @ignore headlines. The default is True.
#@+node:ekr.20080624093059.47: *6* Set cwd in read/write commands
This affect the following commands:

open, save, save-as, save-to, read-outline-only, read-file-into-node, write-file-from-node and all the import/export commands.
#@+node:ekr.20080624093059.48: *6* Added  vim patches
Headline pane:

- Prevented "--> exit-named-modes" from switching focus to the Body pane.
    Removed 'c.frame.log.deleteTab('Mode') from endMode

Body pane:

- Enabled search for 'space' character in text
    Removed 'if ch.isspace(): return' in zapToCharacter:

- Eliminated delete-word from removing trailing white space
    Removed 'self.killWs(event)' in killWord and backwardKillWord

- Put zapped text to clipboard
    Added 'g.app.gui.replaceClipboardWith(s[ins:i])' after 'sel.addToKillBuffer(s[ins:i])' in zapToCharacter

@nocolor
#@+node:ekr.20080624093059.49: *7* Realization
Leo Configuration:
    | The following configuration was used for all testing:
        @strings  top_level_unbound_key_action = command
        @bool stayInTreeAfterEditHeadline = True
        @bool stayInTreeAfterSelect = True
        @bool outline_pane_has_initial_focus = True

Leo's Panes:
    | A "pane" is a area of the screen containing a user interface
    | dedicated to supporting a common set of tasks.  Vi key mappings are
    | associated with the Outline pane, the Body pane, or to the Leo
    | program.  See the no pane (see "General Commands" below). (Outline
    | pane, Body pane)

Leo's Command/Insert States:
    Command state - Denoted by a blue background color (Outline,Body pane)
        | Keys are mapped to commands.
    Insert state - Denoted by a red background color (Outline,Body pane)
        | Keys pressed are inserted into the text.
    Grayed state - Denoted by a gray background color (Outline pane)
        | Keys pressed will cause the next node with a headline starting
        | with that key to be selected.  This "select node by first
        | character" feature is built into Leo. It is not part of the vi
        | support.
        | 
        | This state is intentionally avoided in the vi based outline key
        | mappings. If in the "Grayed" state, enter Ctrl-i to switch to the
        | "Command" state.  The "Grayed" state can be entered from the
        | outline's "Command" state by pressing the Ctrl-] key.

Leo's modes:
| Most vi commands are implemented using Leo's "mode" functionality.
| Modes beginning with "vi-" denote a vi command for the body pane.
| Modes beginning with "tree-" denote a vi-like command for the outline.
| Modes beginning with "body-" denote outline commands that can be called
| from the body pane (and return focus back to the body pane)
| 
| Modes are used both for managing multi-key vi commands and for defining
| macros.

    Multi-key command modes:
    | Vi has many commands that require multiple keys to invoke.  Each key
    | accept the last in the command are assigned to a mode that, when
    | executed, maps the subsequent allowed keys in the command sequence.
    | The last key in the sequence is mapped directly to a Leo command or
    | to a "Macro" mode (see below). Any modes mapped to a key by another
    | mode are located in a child node of the mode node doing the mapping.
    | 
    | Example:
    |     dtw = Delete To the 'W' character (note the capital letters)
    |   The 'd' key is mapped to vi-delete-object
    |   vi-delete-object maps the 't' key to vi-delete-to-char
    |   vi-delete-to-char contains Leo commands to perform the vi command.

    Macros modes:
    | Most vi commands do not have an equivalent Leo command.  Instead, a
    | series of Leo commands must be issued to emulate the vi command.
    | The Leo commands needed to emulate a vi command are placed in a
    | single @mode node.

Code limitations:
    Current character:
    | Vi implementation normally use two different "current character"
    | designators depending on the current state.

        Insert state:
        | In the Insert state, a vertical bar is placed between two
        | characters to indicate where the next key will be inserted.
        | Leo's cursor is of this type.

        Command state: 
        | In the Command state, vi expects that the cursor is highlighting
        | a current character and provides commands to enter the insert
        | state or paste text either before or after that current
        | character.  Leo's vi emulation currently does not support a
        | "current character" cursor. As a result, inserting and pasting
        | before or after is replaced by inserting or pasting "at" the
        | current cursor location.  For example, the 'i' and 'a' command
        | are both mapped to enter the insert state at the current cursor
        | location.

    Conditional code execution:
    | No conditional command invocation exits.  Instead, conditional
    | branching is replace by setup commands that insure that, regardless
    | of current state, the command performs correctly.  For example,
    | Beginning-of-line command will go to previous line if called when
    | cursor is at beginning of line.  Vi requires that '|' always goes to
    | beginning of current line.  Problme is solved by issueing
    | forward-char command to insure cursor is moved off of the beginning
    | of the line before beginning-of-line command is issued.

    Commands requesting user input:
    | Commands getting user input must be the last command within the
    | mode.  See "Commands getting user input" in Problems section below.

    Edit headings using modes:
    | Commands modifying or selecting headline text do not work correctly
    | within a mode.  See "Editing headlines within modes" in Problems
    | section below.  This eliminates accurate implementation of vi's
    | delete/change/substitute/yank object commands.  Instead, the
    | commands are modified to only select text.
#@+node:ekr.20080624093059.50: *7* Problems
Binding numeric keys:
| Mapping a number to a command or mode prevents the number from being
| entered as text while in the insert state.

Binding '?' key:
| No response when key pressed.

Binding 'bksp' key:
| Binding 'bksp' key to back-char to move back a character in command mode
| prevents 'bksp' from deleting characters in text edit mode.

Commands getting user input:
| Commands requesting user input must be the last command executed.  These
| commands include: find-character and zap-to-character.

Editing headlines within modes:
| Text editing commands do not work within modes assigned to outline key
| mappings.

Undo command:
| The 'undo' command sometimes does not work when returning to a node's
| command mode.  Moving to another node fixes the problem.(i.e. delete-char, set-insert-state, ...)

Matching bracket command:
| Performs bracket matching on Body text when in node's headline command
| state.

Word definition:
| "Word" related commands determine boundries of a word differently.

Toggle case:
| Leo provides support for switching to upper or lower case but no method |
| exists to toggle between cases.

Find settings
| Leo commands only allow toggling of search settings.  If specific "set"
| and "clear" search setting commands were available then searches from the
| body pane could be restricted to the body pane and searches from the
| outline could be restricted to the outline.
Forward and backward sentences:
| Leo's forwardSentenceHelper and backSentenceHelper functions do not stop
| at empty lines nor do they skip over periods within words nor do they stop
| at sentences ending in non-periods nor do they stop at the end or
| beginning of the buffer.

Focus to Body pane:
| Leo functions exist which unconditionally set focus to the body pane
| regardless of the active pane.
    deleteTab() function:
        | Issuing "--> exit-named-mode" calls "endMode" function which calls
        | "c.frame.log.deleteTab('Mode')" function which sets the focus to the
        | body pane.  

Displaying mode help:
| The "--> mode-help" command displays all mapped keys using a capitol
| letter regardless of the actual binding.
    Recommendations:
    | To better support narrow tab cards, display the mode's label without
    | the "enter-" and "-mode" text and place key label before mode label.
    | Results in change from:
    |                enter-vi-delete-line-mode D
    |    enter-vi-delete-to-begin-of-word-mode B 
    | to:
    |    D : vi-delete-line
    |    B : vi-delete-to-begin-of-word
#@+node:ekr.20080624093059.51: *7* Notes
Yank vs. Yank
| A vi "yank" operation copies the selected text TO the clipboard.
| A Leo "yank" operation inserts text FROM the clipboard.

copy-text in modes:
| Leo's copy-text does not work within a mode.  As a result, all "copy to
| clipboard" capability is being implemented using kill-<object> command
| followed by a "yank" command.

paste-text in modes:
| paste-text in modes does not work.  Use Leo's "yank" instead.

delete-node does not copy node to clipboard:
| Issue copy-node command followed by delete-node
#@+node:ekr.20080624093059.52: *6* Added 'kill' bindings
#@+node:ekr.20080624093059.53: *6* Added check for empty @nosent nodes
These are now treated much like empty @auto nodes
#@+node:ekr.20080730095710.2: *4* 4.5 b2
Leo 4.5 beta 2                      August 7, 2008

Leo 4.5 beta 2 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.5 contains many important new features.  See below for details.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.5:
--------------------------

- Full support for @shadow files in Leo's core.
- Major improvements to Leo's key binding code.
- The beginning of usable vim-like bindings.
- uA's may now be associated with vnodes in @thin and @shadow files.
- Several major reorganizations of Leo's code:
  including sax-based parsing, support for the Graph world (unified nodes),
  simplified drawing code.
- Leo is now an installable package.
- Prepared code to be ready for Python 3.0.
- Many small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080806211440.188: *5* Major new features
.. _`v.uA's`: http://groups.google.com/group/leo-editor/browse_thread/thread/750bb3099090f5b

- Added support for @shadow files.
  This is a major breakthrough.
  See the `Using @shadow`_ chapter for full details.

- Added much improved support for vim bindings.

- Allow `v.uA's`_ in @file and @shadow nodes.
#@+node:ekr.20080806211440.253: *5* Major code reorganizations
- Leo now uses a sax-based parser to read .leo files.
  This makes it possible to extend Leo's file format without invalidating previous versions of Leo.

- Leo now supports the so-called 'Graph World'.
  When g.unified_nodes is True, Leo moves all information from tnodes into vnodes.

- Leo now uses a new key binding scheme.
  This allows substantially simpler key bindings. Indeed, most per-pane bindings
  have been eliminated.
  Added support for kill bindings.

- Leo is now an installable package.
  To make this work, Leo adds os.curdir to sys.path if needed on startup.

- Reorganized Leo's drawing and focus code.
  As a result, calls to c.beginUpdate and c.endUpdate are no longer needed.

- Leo is now ready for Python 3.x:
  Change most print statements to calls to g.pr.
#@+node:ekr.20080806211440.256: *5* Minor new features
- Added g.Tracer class.  This is a Python 'debugger' that computes a call graph.
  To trace a function and its callers, put the following at the function's start::

    g.startTracer()

- The find-character command now finds characters across line boundaries.

- Set cwd in read/write commands. This affect the following commands:
  open, save, save-as, save-to, read-outline-only, read-file-into-node,
  write-file-from-node and all the import/export commands.

- Leo creates the .leo folder in the user's HOME directory, and puts several configuration files there.
  Leo looks for myLeoSettings.leo in HOME/.leo.
  Leo uses os.path.expanduser("~") if there is no home setting.
#@+node:ekr.20080806211440.189: *5* New settings
- The default settings for @shadow files are now located in leoSettings.leo in the node::

        @settings-->File options-->Shadow files

    The defaults for these settings are::

        @string shadow_prefix = x
        @string shadow_subdir = .leo_shadow

- Added support for @bool fixedWindow option.

    Leo suppresses marks, expansion state, orphan bits and current position bits
    when writing fixed .leo files. As a result, all nodes will be collapsed and
    the root node will always be selected when Leo opens a fixed .leo file.

    You can optionally specify the size and position on the screen of fixed .leo
    files by putting an '@data fixedWindowPosition' node in the
    \@settings tree of myLeoSettings.leo or leoSettings.leo.  You should
    **not** put such a node in the fixed .leo file itself--everyone who
    opens the file would get that fixed position.

    The body of the '@data fixedWindowPosition' node should contain
    something like this::

        # Must be four entries: width,height,left,top.
        # Put this in myLeoSettings.leo, **not** in individual .leo files.

        1200
        800
        50
        50

- Added @bool cleo_color_ignore = True

    This determines whether cleo colors @ignore headlines. The default is True.
#@+node:ekr.20080815093141.89: *4* 4.5 b3
Leo 4.5 beta 3                      August 15, 2008

Leo 4.5 beta 3 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.5 contains many important new features.  See below for details.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.5:
--------------------------

- Full support for @shadow files in Leo's core.
- Major improvements to Leo's key binding code.
- The beginning of usable vim-like bindings.
- uA's may now be associated with vnodes in @thin and @shadow files.
- Several major reorganizations of Leo's code:
  including sax-based parsing, support for the Graph world (unified nodes),
  simplified drawing code.
- Leo is now an installable package.
- Prepared code to be ready for Python 3.0.
- Many small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080815093141.90: *5* Major new features
- Added support for @shadow files.
  This is a major breakthrough.
  See `Chapter 23`_ for full details.

- Added much improved support for vim bindings.

- Allow v.uA's in @thin and @shadow nodes.
  See http://groups.google.com/group/leo-editor/browse_thread/thread/750bb3099090f5b
#@+node:ekr.20080815093141.91: *5* Major code reorganizations
- Leo now uses a sax-based parser to read .leo files.
  This makes it possible to extend Leo's file format without invalidating previous versions of Leo.

- Leo now supports the so-called 'Graph World'.
  When g.unified_nodes is True, Leo moves all information from tnodes into vnodes.

- Leo now uses a new key binding scheme.
  This allows substantially simpler key bindings. Indeed, most per-pane bindings
  have been eliminated.
  Added support for kill bindings.

- Leo is now an installable package.
  To make this work, Leo adds os.curdir to sys.path if needed on startup.

- Reorganized Leo's drawing and focus code.
  As a result, calls to c.beginUpdate and c.endUpdate are no longer needed.

- Leo is now ready for Python 3.x:
  Change most print statements to calls to g.pr.
#@+node:ekr.20080815093141.92: *5* Minor new features
- Added g.Tracer class.  This is a Python 'debugger' that computes a call graph.
  To trace a function and its callers, put the following at the function's start::

    g.startTracer()

- The find-character command now finds characters across line boundaries.

- Set cwd in read/write commands. This affect the following commands:
  open, save, save-as, save-to, read-outline-only, read-file-into-node,
  write-file-from-node and all the import/export commands.

- Create myLeoSettings.leo if it does not exist.
  Leo create a simple template myLeoSettings.leo in the home directory if no other
  copy of myLeoSettings.leo exists.

- Added support for @args list for @button nodes.
  See the docstring for the mod_scripting plugin for details.

#@+node:ekr.20080815093141.93: *5* New settings
- The default settings for @shadow files are now located in leoSettings.leo in the node::

    @settings-->File options-->Shadow files

  The defaults for these settings are::

    @string shadow_prefix = x
    @string shadow_subdir = .leo_shadow

- Added support for @bool fixedWindow option. Leo suppresses marks, expansion
  state, orphan bits and current position bits when writing fixed .leo files. As
  a result, all nodes will be collapsed and the root node will always be
  selected when Leo opens a fixed .leo file.

  You can optionally specify the size and position on the screen of fixed .leo
  files by putting an '@data fixedWindowPosition' node in the
  @settings tree of myLeoSettings.leo or leoSettings.leo.  You should
  **not** put such a node in the fixed .leo file itself--everyone who
  opens the file would get that fixed position.

  The body of the '@data fixedWindowPosition' node should contain
  something like this::

    # Must be four entries: width,height,left,top.
    # Put this in myLeoSettings.leo, **not** in individual .leo files.

    1200
    800
    50
    50

- Added @bool cleo_color_ignore = True
  This determines whether cleo colors @ignore headlines. The default is True.

- Added @bool suppress_import_parsing setting
  When True, @auto and @shadow import the entire file into a single node.
#@+node:ekr.20080827175609.55: *4* 4.5 rc1
Leo 4.5 release candidate 1                      August 28, 2008

Leo 4.5 rc1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.5 contains many important new features.  See below for details.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.5:
--------------------------

- Full support for @shadow files in Leo's core.
- Major improvements to Leo's key binding code.
- The beginning of usable vim-like bindings.
- uA's may now be associated with vnodes in @thin and @shadow files.
- Several major reorganizations of Leo's code:
  including sax-based parsing, support for the Graph world (unified nodes),
  and simplified drawing code.
- Leo is now an installable package.
- Prepared code to be ready for Python 3.0.
- Many small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080827175609.56: *5* Major new features
- Added support for @shadow files.
  This is a major breakthrough.
  See `Chapter 23`_ for full details.

- Added much improved support for vim bindings.

- Allow v.uA's in @thin and @shadow nodes.
  See http://groups.google.com/group/leo-editor/browse_thread/thread/750bb3099090f5b
#@+node:ekr.20080827175609.57: *5* Major code reorganizations
- Leo now uses a sax-based parser to read .leo files.
  This makes it possible to extend Leo's file format without invalidating previous versions of Leo.

- Leo now supports the so-called 'Graph World'.
  When g.unified_nodes is True, Leo moves all information from tnodes into vnodes.

- Leo now uses a new key binding scheme.
  This allows substantially simpler key bindings. Indeed, most per-pane bindings
  have been eliminated.
  Added support for kill bindings.

- Leo is now an installable package.
  To make this work, Leo adds os.curdir to sys.path if needed on startup.

- Reorganized Leo's drawing and focus code.
  As a result, calls to c.beginUpdate and c.endUpdate are no longer needed.

- Leo is now ready for Python 3.x:
  Change most print statements to calls to g.pr.
#@+node:ekr.20080827175609.58: *5* Minor new features
- Added g.Tracer class.  This is a Python 'debugger' that computes a call graph.
  To trace a function and its callers, put the following at the function's start::

    g.startTracer()

- The find-character command now finds characters across line boundaries.

- Set cwd in read/write commands. This affect the following commands:
  open, save, save-as, save-to, read-outline-only, read-file-into-node,
  write-file-from-node and all the import/export commands.

- Added support for @args list for @button nodes.
  See the docstring for the mod_scripting plugin for details.

- Leo creates the .leo folder in the user's HOME directory, and puts several configuration files there.
  Leo looks for myLeoSettings.leo in HOME/.leo.
#@+node:ekr.20080827175609.59: *5* New settings
- The default settings for @shadow files are now located in leoSettings.leo in the node::

    @settings-->File options-->Shadow files

  The defaults for these settings are::

    @string shadow_prefix = x
    @string shadow_subdir = .leo_shadow

- Added support for @bool fixedWindow option. Leo suppresses marks, expansion
  state, orphan bits and current position bits when writing fixed .leo files. As
  a result, all nodes will be collapsed and the root node will always be
  selected when Leo opens a fixed .leo file.

  You can optionally specify the size and position on the screen of fixed .leo
  files by putting an '@data fixedWindowPosition' node in the
  @settings tree of myLeoSettings.leo or leoSettings.leo.  You should
  **not** put such a node in the fixed .leo file itself--everyone who
  opens the file would get that fixed position.

  The body of the '@data fixedWindowPosition' node should contain
  something like this::

    # Must be four entries: width,height,left,top.
    # Put this in myLeoSettings.leo, **not** in individual .leo files.

    1200
    800
    50
    50

- Added @bool cleo_color_ignore = True
  This determines whether cleo colors @ignore headlines. The default is True.

- Added @bool suppress_import_parsing setting
  When True, @auto and @shadow import the entire file into a single node.
#@+node:ekr.20080830082008.1: *4* 4.5 rc2
Leo 4.5 release candidate 2                     August 30, 2008

Leo 4.5 rc2 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.5 contains many important new features.  See below for details.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.5:
--------------------------

- Full support for @shadow files in Leo's core.
- Major improvements to Leo's key binding code.
- The beginning of usable vim-like bindings.
- uA's may now be associated with vnodes in @thin and @shadow files.
- Several major reorganizations of Leo's code:
  including sax-based parsing, support for the Graph world (unified nodes),
  and simplified drawing code.
- Leo is now an installable package.
- Prepared code to be ready for Python 3.0.
- Many small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080830082008.2: *5* Major new features
- Added support for @shadow files.
  This is a major breakthrough.
  See `Chapter 23`_ for full details.

- Added much improved support for vim bindings.

- Allow v.uA's in @thin and @shadow nodes.
  See http://groups.google.com/group/leo-editor/browse_thread/thread/750bb3099090f5b
#@+node:ekr.20080830082008.3: *5* Major code reorganizations
- Leo now uses a sax-based parser to read .leo files.
  This makes it possible to extend Leo's file format without invalidating previous versions of Leo.

- Leo now supports the so-called 'Graph World'.
  When g.unified_nodes is True, Leo moves all information from tnodes into vnodes.

- Leo now uses a new key binding scheme.
  This allows substantially simpler key bindings. Indeed, most per-pane bindings
  have been eliminated.
  Added support for kill bindings.

- Leo is now an installable package.
  To make this work, Leo adds os.curdir to sys.path if needed on startup.

- Reorganized Leo's drawing and focus code.
  As a result, calls to c.beginUpdate and c.endUpdate are no longer needed.

- Leo is now ready for Python 3.x:
  Change most print statements to calls to g.pr.
#@+node:ekr.20080830082008.4: *5* Minor new features
- Added g.Tracer class.  This is a Python 'debugger' that computes a call graph.
  To trace a function and its callers, put the following at the function's start::

    g.startTracer()

- The find-character command now finds characters across line boundaries.

- Set cwd in read/write commands. This affect the following commands:
  open, save, save-as, save-to, read-outline-only, read-file-into-node,
  write-file-from-node and all the import/export commands.

- Added support for @args list for @button nodes.
  See the docstring for the mod_scripting plugin for details.

- Leo creates the .leo folder in the user's HOME directory, and puts several configuration files there.
  Leo looks for myLeoSettings.leo in HOME/.leo.
#@+node:ekr.20080830082008.5: *5* New settings
- The default settings for @shadow files are now located in leoSettings.leo in the node::

    @settings-->File options-->Shadow files

  The defaults for these settings are::

    @string shadow_prefix = x
    @string shadow_subdir = .leo_shadow

- Added support for @bool fixedWindow option. Leo suppresses marks, expansion
  state, orphan bits and current position bits when writing fixed .leo files. As
  a result, all nodes will be collapsed and the root node will always be
  selected when Leo opens a fixed .leo file.

  You can optionally specify the size and position on the screen of fixed .leo
  files by putting an '@data fixedWindowPosition' node in the
  @settings tree of myLeoSettings.leo or leoSettings.leo.  You should
  **not** put such a node in the fixed .leo file itself--everyone who
  opens the file would get that fixed position.

  The body of the '@data fixedWindowPosition' node should contain
  something like this::

    # Must be four entries: width,height,left,top.
    # Put this in myLeoSettings.leo, **not** in individual .leo files.

    1200
    800
    50
    50

- Added @bool cleo_color_ignore = True
  This determines whether cleo colors @ignore headlines. The default is True.

- Added @bool suppress_import_parsing setting
  When True, @auto and @shadow import the entire file into a single node.
#@+node:ekr.20080902080930.2: *4* 4.5 final
Leo 4.5 final                                  September 2, 2008

Leo 4.5 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.5:
--------------------------

- Full support for @shadow files in Leo's core.
- Major improvements to Leo's key binding code.
- The beginning of usable vim-like bindings.
- uA's may now be associated with vnodes in @thin and @shadow files.
- Several major reorganizations of Leo's code:
  including sax-based parsing, support for the Graph world (unified nodes),
  and simplified drawing code.
- Leo is now an installable package.
- Prepared code to be ready for Python 3.0.
- Many small improvements and bug fixes.

Quote of the month:
-------------------
Squeak and Leo have been two of the most significant technologies to
redefine my personal computer experience and the ideas behind computing.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080902080930.3: *5* Major new features
- Added support for @shadow files.
  This is a major breakthrough.
  See `Chapter 23`_ for full details.

- Added much improved support for vim bindings.

- Allow v.uA's in @thin and @shadow nodes.
  See http://groups.google.com/group/leo-editor/browse_thread/thread/750bb3099090f5b
#@+node:ekr.20080902080930.4: *5* Major code reorganizations
- Leo now uses a sax-based parser to read .leo files.
  This makes it possible to extend Leo's file format without invalidating previous versions of Leo.

- Leo now supports the so-called 'Graph World'.
  When g.unified_nodes is True, Leo moves all information from tnodes into vnodes.

- Leo now uses a new key binding scheme.
  This allows substantially simpler key bindings. Indeed, most per-pane bindings
  have been eliminated.
  Added support for kill bindings.

- Leo is now an installable package.
  To make this work, Leo adds os.curdir to sys.path if needed on startup.

- Reorganized Leo's drawing and focus code.
  As a result, calls to c.beginUpdate and c.endUpdate are no longer needed.

- Leo is now ready for Python 3.x:
  Change most print statements to calls to g.pr.
#@+node:ekr.20080902080930.5: *5* Minor new features
- Added g.Tracer class.  This is a Python 'debugger' that computes a call graph.
  To trace a function and its callers, put the following at the function's start::

    g.startTracer()

- The find-character command now finds characters across line boundaries.

- Set cwd in read/write commands. This affect the following commands:
  open, save, save-as, save-to, read-outline-only, read-file-into-node,
  write-file-from-node and all the import/export commands.

- Added support for @args list for @button nodes.
  See the docstring for the mod_scripting plugin for details.

- Leo creates the .leo folder in the user's HOME directory, and puts several configuration files there.
  Leo looks for myLeoSettings.leo in HOME/.leo.
#@+node:ekr.20080902080930.6: *5* New settings
- The default settings for @shadow files are now located in leoSettings.leo in the node::

    @settings-->File options-->Shadow files

  The defaults for these settings are::

    @string shadow_prefix = x
    @string shadow_subdir = .leo_shadow

- Added support for @bool fixedWindow option. Leo suppresses marks, expansion
  state, orphan bits and current position bits when writing fixed .leo files. As
  a result, all nodes will be collapsed and the root node will always be
  selected when Leo opens a fixed .leo file.

  You can optionally specify the size and position on the screen of fixed .leo
  files by putting an '@data fixedWindowPosition' node in the
  @settings tree of myLeoSettings.leo or leoSettings.leo.  You should
  **not** put such a node in the fixed .leo file itself--everyone who
  opens the file would get that fixed position.

  The body of the '@data fixedWindowPosition' node should contain
  something like this::

    # Must be four entries: width,height,left,top.
    # Put this in myLeoSettings.leo, **not** in individual .leo files.

    1200
    800
    50
    50

- Added @bool cleo_color_ignore = True
  This determines whether cleo colors @ignore headlines. The default is True.

- Added @bool suppress_import_parsing setting
  When True, @auto and @shadow import the entire file into a single node.
#@+node:ekr.20080912143702.137: *4* 4.5.1 final
Leo 4.5.1 final                                  September 14, 2008

Leo 4.5.1 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.5.1 final fixes several important bugs in Leo 4.5 final:

- Eliminated spurious error messages in the goto-global-line command.
- @shadow files with unknown file extensions now work properly.
- Improved Leo's installer.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.5:
--------------------------

- Full support for @shadow files in Leo's core.
- Major improvements to Leo's key binding code.
- The beginning of usable vim-like bindings.
- uA's may now be associated with vnodes in @thin and @shadow files.
- Several major reorganizations of Leo's code:
  including sax-based parsing, support for the Graph world (unified nodes),
  and simplified drawing code.
- Leo is now an installable package.
- Prepared code to be ready for Python 3.0.
- Many small improvements and bug fixes.

Quote of the month:
-------------------
Squeak and Leo have been two of the most significant technologies to
redefine my personal computer experience and the ideas behind computing.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20080912143702.138: *5* Fixed line number problems
# goToLineNumber was always complaining about a missing private shadow file.
#@+node:ekr.20080912143702.139: *5* Fixed problems with @shadow files with unknown file extensions
@

adjustTargetLanguage, a helper of writeOneAtShadowNode, no longer sets
c.target_language to 'unknown_language' when the file extension is unknown.
#@+node:ekr.20080912143702.140: *5* Fixed bug in Leo's pre-install script
The script failed for paths such as c:\xp\python25\python.exe
for which python was not the top-most directory.
#@+node:ekr.20090717084250.10704: *3* 4.6 file caching, qt gui, @edit, @auto-rst
#@+node:ekr.20090324085713.2: *4* 4.6 b1
Leo 4.6 beta 1                                       March 23, 2009

Leo 4.6 b1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.6:
--------------------------

- Leo now requires Python 2.4 or later.
- Leo now features a modern Qt interface;
  Leo's legacy Tk interface can also be used.
- New --config --file and --gui command-line options.
- Dozens of small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20090324085713.285: *5* Bugs fixed
#@+node:ekr.20090324085713.292: *6* Fixed goto-global-line crasher
#@+node:ekr.20090324085713.326: *6* Fixed bug that prevented Leo from opening files on the XP desktop
#@+node:ekr.20090324085713.350: *6* Save/restore tnodeList in atFile.write
The code should save/restore, just as in the clean_file function (from scripts.leo)
#@+node:ekr.20090324085713.358: *6* Paste outline problem
The problem was missing calls to initAfterLoad in c.new.
#@+node:ekr.20090324085713.395: *6* Made sure $Home works for @nosent
http://groups.google.com/group/leo-editor/browse_thread/thread/f27e3514310a5c90
#@+node:ekr.20090324085713.404: *6* Fixed atFile unicode bug
#@+node:ekr.20090324085713.513: *6* Fixed Mark Edgington's @shadow bug
#@+node:ekr.20090324085713.605: *6* Fixed whitespace problems with @auto/@shadow
Pulled trunk, got r1599

python launchLeo.py leo/plugins/leoPlugins.leo

go to

Plugins-->Graph world-->@shadow backlink.py-->backlink declarations

All I did was add the full stop at the end of the docstring, but see
the diff:

=== modified file 'leo/plugins/backlink.py'
--- leo/plugins/backlink.py     2009-02-19 18:16:01 +0000
+++ leo/plugins/backlink.py     2009-02-25 22:14:46 +0000
@@ -1,4 +1,4 @@
-'''Backlink - allow arbitrary links between nodes
+'''Backlink - allow arbitrary links between nodes.
 '''

 # Notes
@@ -296,7 +296,7 @@
                break
        else:
            self.showMessage("Error: no such link")
-
+
        gcc = getattr(self.c, 'graphcanvasController')
        if gcc:
            gcc.update()
#@+node:ekr.20090324085713.327: *6* Fixed nested @path problem
http://groups.google.com/group/leo-editor/browse_thread/thread/7d8325d055cbef30
#@+node:ekr.20090324085713.289: *6* Fixed encoding problems with rst3 plugin
http://groups.google.com/group/leo-editor/browse_thread/thread/5f5219fedd977ec2
#@+node:ekr.20090324085713.318: *6* Fixed new rst3 crash
http://groups.google.com/group/leo-editor/browse_thread/thread/414137b93c7e4b90

Calls g.makeAllNonExistentDirectories instead of os.mkdir.
#@+node:ekr.20090324085713.320: *6* Fixed two c syntax-coloring bugs
http://groups.google.com/group/leo-editor/browse_thread/thread/707a910f975f3715

http://groups.google.com/group/leo-editor/browse_thread/thread/74c6ab4809bde980

There were two separate bugs:

1. The eol_span and eol_span_regex now honor the mode's escape character.

2. colorRangeWithTag now colors delegates with the default tag color.

No changes were made in modes/c.py or modes/c.xml.
#@+node:ekr.20090324085713.690: *5* Improved file handling
#@+node:ekr.20090324085713.726: *6* Open a default .leo file if no other is specified
http://groups.google.com/group/leo-editor/browse_thread/thread/d6449236bc140713#

Added support for @string default_leo_file = ~/.leo/workbook.leo
#@+node:ekr.20090324085713.748: *6* Added escapes for underindented lines
@string underindent-escape-string = \-
#@+node:ekr.20090324085713.792: *6* Warn when writing an externally changed file
http://groups.google.com/group/leo-editor/browse_thread/thread/c80fd8375534afdf
#@+node:ekr.20090324085713.661: *5* New code features
#@+node:ekr.20090324085713.662: *6* Added autoCompleter.getExternalCompletions
@nocolor

http://groups.google.com/group/leo-editor/browse_thread/thread/4ad91984a6d0acac

> As I said, all I need would be is for leo to call callback/hook with
> signature like
> def complete(line-up-to-cursor, current_node) => list of strings

The actual signature is:

theObject,completionList = getExternalCompletions (self,s,p=None,language='python')

p is used only to get the language, or you can set the language by hand.

@color
#@+node:ekr.20090324085713.663: *6* Added g.PosList
#@+node:ekr.20090324085713.666: *6* Better plugin info
c.config.doEnabledPlugins sets g.app.config.enabledPluginsFileName
#@+node:ekr.20090324085713.672: *6* Added properties to leoNodes.py
p.b, p.h and p.gnx
t.b, t.h, t.gnx and t.u
v.b, v.h, v.gnx, and v.u
#@+node:ekr.20090324085713.688: *6* Added script to leoSettings.leo to ensure all menu items are valid
#@+node:ekr.20090324085713.689: *6* Added c.config.getSettingSource
c.config.getSettingSource('show_full_tracebacks_in_scripts')
returns the name of the file which Leo used to determine the setting

- D indicates default settings.
- F indicates the file being loaded
- L indicates leoSettings.leo
- M indicates myLeoSettings.leo
#@+node:ekr.20090324085713.272: *6* Predefined 'self' in @test/@suite nodes
#@+node:ekr.20090324085713.745: *6* Added c.getNodePath and c.getNodeFileName
http://groups.google.com/group/leo-editor/browse_thread/thread/3b5f1232ecc6bba7
#@+node:ekr.20090324105223.15: *5* New command-line options
#@+node:ekr.20090324085713.849: *6* Added -c option to specify config files
@nocolor

The setting is called -c or --config.  The one-config-file arg no longer exists.

http://groups.google.com/group/leo-editor/browse_thread/thread/f3f95d93bcd93b94

Personally, I'd like to see another config file available via -c on
the command line:
(a common idiom)

leo myproject.leo -c /usr/lib/myproject/myLeoSettings.leo

or better yet:

leo myproject.leo -c /etc/leo/style01.leo
leo myotherproject.leo -c /etc/leo/style02.leo
leo anotherproject.leo -c /etc/leo/style23.leo

Each file opens in an editor with the shortcuts, buttons, commands,
plugins, appearance etc.  that has been tuned for that data management task.

or best yet:

leo myproject.leo -c /usr/lib/python2.5/site-packages/leo/config/style94.leo

==================

http://groups.google.com/group/leo-editor/browse_thread/thread/b5a736089079acaf#

Please, I think each file has a distinct and required role.

- config/leoSettings.leo = Edward's base, required for a sane starting point

- home/.leo/myLeoSettings.leo = adjust Edwards suggestions to taste

- cwd/myLeoSettings.leo = provide a customized working environment in
this folder

- leo -c /usr/lib/leo-editor/src/config/zope3_ide.leo =
  - open this file in a specialized environments, mine or community contributed
  - ...

- currentfile/@settings =
  - I'm working on some customization ideas
  - Here, try out this Leo file I sent you, check out all the spiffy
modifications 

@color
#@+node:ekr.20090324085713.835: *6* Added support for --file=fileName command-line option
Only .zip and .leo extensions are allowed at present.
#@+node:ekr.20090324085713.867: *6* Added support for --gui option
#@+node:ekr.20090324105223.9: *5* New commands
#@+node:ekr.20090324085713.747: *6* Added smart home (back-to-home) command
#@+node:ekr.20090324085713.817: *6* The open command creates @edit nodes when opening non-.leo files
http://groups.google.com/group/leo-editor/browse_thread/thread/3417ff5e9c02c626

The open file dialog now shows all files by default.
Selecting a non-.leo file will load that file into a new node in the present outline.

This plugs what may have been the biggest hole in Leo's history.
#@+node:ekr.20090324085713.836: *6* added pdb minibuffer command
This works, but stops Leo in the middle of the command-handling logic.

However, it is possible to pick up the commander by stepping out into
k.masterKeyHandler or k.masterCommandHandler. Using c, one can then get all
other info.
#@+node:ekr.20090324085713.837: *6* Added support for smart_tab setting
- Tab = indent when there is a text selection
- Shift-Tab unindents always
#@+node:ekr.20090324085713.847: *6* Improved isearch commands
Escape now ends isearch
#@+node:ekr.20090324105223.10: *5* New and improved directives
#@+node:ekr.20090324085713.740: *6* Added @nocolor-node directive
# Useful: we don't need a closing @color to enable coloring in descendants.
#@+node:ekr.20090324085713.691: *6* Improved @path handling
#@+node:ekr.20090324085713.848: *5* New settings
#@+node:ekr.20090324085713.732: *6* Added better default fonts for Leo on Linux
http://groups.google.com/group/leo-editor/browse_thread/thread/f1c7c5134b95c77e
#@+node:ekr.20090324085713.850: *6* Added support for @int icon_bar_widgets_per_row setting
#@+node:ekr.20090324085713.746: *6* Added support for meta keys
http://groups.google.com/group/leo-editor/browse_thread/thread/b6a39ed672a28c65?pli=1
#@+node:ekr.20090324085713.814: *6* Use myLeoSettings when opening leoSettings.leo
Changed config.get so that settings in leoSettings.leo are read *last*.
This means that myLeoSettings.leo will override leoSettings.leo,
even when leoSettings.leo is the local file.
#@+node:ekr.20090324085713.868: *5* Plugins
#@+node:ekr.20090324085713.869: *6* Improved nav_buttons plugin and corresponding nodeHistory class
#@+node:ekr.20090324085713.881: *6* Created qtGui and tkGui plugins
#@+node:ekr.20090324085713.890: *6* Created leoGuiPluginsRef.leo
This contains all gui plugins.
#@+node:ekr.20090620073906.11072: *4* 4.6 b2
Leo 4.6 beta 2                                  June 22, 2009

Leo 4.6 b2 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.6:
--------------------------

- Cached external files *greatly* reduces the time to load .leo files.
- Leo now features a modern Qt interface by default.
  Leo's legacy Tk interface can also be used.
- New --config, --file and --gui command-line options.
- Leo tests syntax of .py files when saving them.
- Leo can now open any kind of file into @edit nodes.
- @auto-rst nodes support "round-tripping" of reStructuredText files.
- Properties of commanders, positions and nodes simplify programming.
- Improved Leo's unit testing framework.
- Leo now requires Python 2.5 or later.
- Dozens of small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20090620073906.11073: *5* Bugs
#@+node:ekr.20090620073906.11083: *6* Added patch for startup logic
A patch at the start of loadOnePlugin prevents leo from crashing and allows the
gui prompt for a leoID to come up.
#@+node:ekr.20090620073906.11087: *6* Allocate gnx's when nodes are created
This is reasonable now that old-style file indices are rare.
#@+node:ekr.20090620073906.11960: *6* Allow block comments in private shadow files
Html files are a good test case.
#@+node:ekr.20090620073906.11590: *6* Compute delims from private shadow file as needed
#@+node:ekr.20090620073906.11376: *6* Don't copy @edit trees to outline
http://bugs.launchpad.net/leo-editor/+bug/376634

The fix was to putVnodes.
#@+node:ekr.20090620073906.11981: *6* Don't expand ancestors of @chapter node when selecting chapter
#@+node:ekr.20090620073906.12044: *6* Entries in recent files menu now have absolute paths
http://bugs.launchpad.net/leo-editor/+bug/383204
#@+node:ekr.20090620073906.11865: *6* Fixed (worked around) tk chapters bug
http://groups.google.com/group/leo-editor/browse_thread/thread/981c27d5c24c90f8
#@+node:ekr.20090620073906.11850: *6* Fixed @edit bug
The generated @nocolor line now ends with a newline.
#@+node:ekr.20090620073906.11564: *6* Fixed @shadow crasher
http://groups.google.com/group/leo-editor/browse_thread/thread/6cab5e676d4d75a0
#@+node:ekr.20090620073906.11296: *6* Fixed @thin bug
- Removed forceGnxOnPosition from leoImport.py and leoAtFile.py.

- readStartNode now always uses root.v for the first node
  instead of calling createThinChild4
#@+node:ekr.20090620073906.11081: *6* Fixed back-to-home so it works as expected
https://bugs.launchpad.net/leo-editor/+bug/367462

The expected/customary behavior (one you get used to in almost every editor) is:

End: always move to end of line
Home: Move to first visible character on the line. When pressing home again, move to column zero. If Home is pressed one more time, move to first visible character again.

This is also the way emacs behaves, though ctrl+a always moves to column zero.
#@+node:ekr.20090620103431.5601: *6* Fixed bad @verbatim bug
The @verbatim was being inserted into the outline.
#@+node:ekr.20090620073906.11833: *6* Fixed binding problem with notebook
#@+node:ekr.20090620073906.11374: *6* Fixed bug: sorting could revert headline changes
#@+node:ekr.20090620073906.11521: *6* Fixed crash when reading .zip files
The problem arose when reading a zipped file:

 File "C:\Programme\Leo-4-6-b1\leo\core\leoFileCommands.py", line
1265, in parse_leo_file
   s = theFile.read()
TypeError: read() takes at least 2 arguments (1 given)
saved: [zipped] Dive-into-Python-3.leo
#@+node:ekr.20090620073906.11091: *6* Fixed crasher when creating .leoID.txt
exception loading plugin
Traceback (most recent call last):

  File "C:\leo.repo\trunk\leo\core\leoPlugins.py", line 429, in loadOnePlugin
    loadedModulesFilesDict[moduleName] = g.app.config.enabledPluginsFileName

AttributeError: StubConfig instance has no attribute 'enabledPluginsFileName'

leoID='ekr'
.leoID.txt created in C:\Documents and Settings\HP_Administrator\My Documents\Edward\.leo
load 
#@+node:ekr.20090620073906.11380: *6* Fixed dabbrev-expands bug
http://bugs.launchpad.net/leo-editor/+bug/362048

I have 'dabbrev-expands' bound to the F4 key. When I press F4 after
the word "freq" in a body pane containing the word "frequency" then
Leo 4.5.1 shows a hour-glass for a while before giving an empty
dabbrev-expand: prompt in the minibuffer.

If I back up one character, putting point between the e and q and then
type F4, I get the expected behavior: the word "frequency" is inserted
immediately.

What I did:

- Removed "not ready messages".
- Made the code undoable.
- Added wimpy unit test.
#@+node:ekr.20090620073906.11074: *6* Fixed elisp importer problem
#@+node:ekr.20090620073906.11137: *6* Fixed F10/11/12 key bug
Added call to isFKey in k.handleUnboundKeys.
#@+node:ekr.20090620073906.11387: *6* Fixed file bug re unicode characters
http://bugs.launchpad.net/leo-editor/+bug/376189
#@+node:ekr.20090620073906.11776: *6* Fixed hoist problems
http://bugs.launchpad.net/leo-editor/+bug/382221
#@+node:ekr.20090620073906.11707: *6* Fixed lost anchor bug page up/down
http://bugs.launchpad.net/leo-editor/+bug/363403

With a long body text you might place the cursor on a line, hold down Shift, and
PgDn several pages to select a large block of text. The last PgDn may overshoot
the range you want selected, so you should be able to use UpArrow to bring the
bottom of the range back up to where you want it. However, on the first UpArrow
the selection is lost and restarted from the current cursor position. I.e. you
end up with just one line selected, instead of trimming one line of the
selection of several pages, as intended.
#@+node:ekr.20090620073906.11377: *6* Fixed minor @auto bug
http://bugs.launchpad.net/leo-editor/+bug/306671

If a Leo editor window is opened, and the "NewHeadline" node is renamed to
"@auto <path to some valid file>", and then the "File->Read/Write->Read @auto
nodes" menu option is selected, the renamed node reverts to its previous name
("NewHeadline"), and nothing is loaded into the node.
#@+node:ekr.20090620073906.11864: *6* Fixed multiple-editor focus problems
http://groups.google.com/group/leo-editor/browse_thread/thread/21bddd50f3400bdc?hl=en
#@+node:ekr.20090620073906.11352: *6* Fixed new command
The outline wasn't being redrawn properly.
#@+node:ekr.20090620073906.11740: *6* Fixed problems with change-all command
http://groups.google.com/group/leo-editor/browse_thread/thread/430287018f9d773d

The fix to minibufferFind.changeAll fixes a bug that is several years old.
The fix to findNextMatch fixes a bug that is likely much older than that.
#@+node:ekr.20090620073906.11818: *6* Fixed read clone bug
#@+node:ekr.20090620073906.11390: *6* Fixed rst import bug
#@+node:ekr.20090620073906.11086: *6* Fixed rst3 problem
http://mail.google.com/mail/#inbox/11ef0076a3f4d866
#@+node:ekr.20090620073906.11760: *6* Fixed seg-fault bug
The crash happened inside the call to::

    c.widgetWantsFocusNow(event.widget)

in callAltXFunction. Actually, the crash happened later, in c.outerUpdate.

A better fix would be to use wrappers for all edit widgets, and recalculate the
edit widget any it needs to be used.
#@+node:ekr.20090620073906.11666: *6* Fixed Shift-Arrow in headlines
#@+node:ekr.20090620073906.11866: *6* Fixed startup problem
http://groups.google.com/group/leo-editor/browse_thread/thread/606277d73b193037
#@+node:ekr.20090620073906.11349: *6* Fixed stubConfig problems
#@+node:ekr.20090620073906.11107: *6* Fixed undo bug
onTextChanged in the qt gui was calling setUndoTypingParams, in many case
redundantly and with bad params.

It remains to be seen whether onTextChanged is ever needed. If it is, it may be
difficult to set the old selection properly.
#@+node:ekr.20090620073906.11378: *6* Fixed vim bindings (dd) bug
http://bugs.launchpad.net/leo-editor/+bug/353925

The "kill-region" function did nothing when using the qt gui.

The fix was to replace tag_ranges with w.getSelectionRange, etc.
This was the only call to tag_ranges in the core.
#@+node:ekr.20090620073906.11759: *6* Investigated bug: File->Export->write failed due to incorrect path
http://bugs.launchpad.net/leo-editor/+bug/377907

I'm going to mark this invalid, although the behavior is way too confusing.

I added the following to the plugin's docstring:

Configuration
~~~~~~~~~~~~~

At present, the file leo/plugins/leo_to_html.ini contains configuration settings.
In particular, the default export path, "c:\" must be changed for *nix systems.
#@+node:ekr.20090620073906.11094: *6* Investigated speed of external unit tests
The problem is imports in the Commands ctor. When executed the first time from
the bridge the imports take about 3/4 sec. on my machine. There is nothing that
can or should be done. Ctrl-5 is still hugely faster than opening unitTest.leo!
#@+node:ekr.20090620073906.11612: *6* Made @url nodes work with qt gui
#@+node:ekr.20090620073906.11620: *6* Mark @<file> nodes dirty when @path nodes change
#@+node:ekr.20090620073906.11824: *6* Removed duplicate messages when opening non-existent .leo file
#@+node:ekr.20090620073906.11771: *6* Reversed messages about redefined keys
http://groups.google.com/group/leo-editor/browse_thread/thread/a04dcefbb672078f
#@+node:ekr.20090620073906.11973: *6* Scroll commands now affect only scrollbars
#@+node:ekr.20090620073906.11870: *5* New features
#@+node:ekr.20090620073906.11923: *6* Allow Leo to open any file
Leo can now open, for example, any .py file.
It will be put in an @edit node in an otherwise-empty outline.

This allows Leo to be associated with the edit action of .py files.
Something like this::

C:\Python26\python.exe "c:\leo.repo\trunk\launchLeo.py" --gui=qt %1 %2
#@+node:ekr.20090620073906.11873: *6* Improved unit testing
- leoDynamicTest.py now supports a --path argument giving the .leo file.
  This is so useful!

- leoDynamicTest.py now honors the --silent argument.

- leoTest.runUnitTestLeoFile runs all unit tests in a given .leo file
  in a separate process.

- leoTest.runTestsExternally calls runUnitTestLeoFile after creating
  dynamicUnitTest.leo.

- When reporting that no unit tests were found, all unit tests commands tell
  whether the entire outline or just the selected outline was searched.
  This fixes sometimes-misleading error messages.

- test.leo contains a 'run-test.leo-tests' button.

- leoPy.leo contains a 'run-all-core-tests' button.
#@+node:ekr.20090620073906.11898: *6* Leo tests syntax of .py files when saving them
#@+node:ekr.20090620073906.12061: *6* Made qt gui the default
#@+node:ekr.20090620073906.11935: *6* Support @auto-rst
#@+node:ekr.20090709084001.5944: *4* 4.6 rc1
Leo 4.6 release candidate 1                             July 9, 2009

Leo 4.6 rc1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.6:
--------------------------

- Cached external files *greatly* reduces the time to load .leo files.
- Leo now features a modern Qt interface by default.
  Leo's legacy Tk interface can also be used.
- New --config, --file and --gui command-line options.
- Leo tests syntax of .py files when saving them.
- Leo can now open any kind of file into @edit nodes.
- @auto-rst nodes allow easy editing of reStructuredText files.
- Properties of commanders, positions and nodes simplify programming.
- Improved Leo's unit testing framework.
- Leo now requires Python 2.5 or later.
- Dozens of small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20090709084001.5945: *5* Bugs
#@+node:ekr.20090709084001.5968: *6* Fixed unicode problem with spell checker
#@+node:ekr.20090709084001.6086: *6* Ensure newline at end of each @auto node
#@+node:ekr.20090709084001.6096: *6* Fixed bugs with goto-global-line and @auto
#@+node:ekr.20090709084001.6119: *6* Added key bindings in log pane
#@+node:ekr.20090709084001.6138: *6* Honor split ratios
#@+node:ekr.20090709084001.6140: *6* Click in body after editing activates body
#@+node:ekr.20090709084001.6144: *6* Rewrote string-rectangle command for speed
#@+node:ekr.20090709084001.6149: *6* Fixed read-at-auto-nodes bug
#@+node:ekr.20090709084001.6153: *6* Fixed major focus problems
Various get-focus methods must translate from wrapped widget to wrapper widget.
This happens in g.app.gui.get_focus, which needs a c arg to work properly in some cases!
#@+node:ekr.20090709084001.6156: *6* Fixed problem with read-at-file/shadow-nodes
#@+node:ekr.20090709084001.6164: *6* Fixed major icon/t.uA bug
https://bugs.launchpad.net/leo-editor/+bug/345917
#@+node:ekr.20090709084001.6192: *6* Fixed rst bug
Exact repro steps (using trunk):

Help -> open quickstart.leo

Go to Programming-->External files-->reStructuredText (@auto-
rst)-->@path ~-->@@auto-rst myfile_rst.txt

Remove first @ from @auto-rst

Save => exception occurs.
#@+node:ekr.20090709084001.6204: *6* Made alt-6 run all unit tests
@test nodes in the generated file were being run when modules were imported.

The fix was to set g.unitTesting = False while importing in safeImportModule.
#@+node:ekr.20090709084001.6238: *6* Fixed crasher in dynamicExpanderHelper
#@+node:ekr.20090709084001.6241: *6* Don't collapse initial node automatically
#@+node:ekr.20090709084001.6254: *6* Fixed bug: don't duplicate standard buttons
@nocolor-node

https://bugs.launchpad.net/leo-editor/+bug/394965

Several changes:

- Fixed bug in runLeo.py.completeFileName.
  Do not add ".leo" suffix if the file exists without it!

- Fixed (???) the bug by not calling g.doHook("new"...) in g.openWrapperFile.
  This **might** be a perfect fix, but maybe not.
  But if a bug remains, it might be less bad than the duplicated buttons bug :-)
#@+node:ekr.20090709084001.6283: *6* Fixed critical @file data-loss problem
The culprit was the code in atFile.read that deleted all children.

Added several important new unit tests.
#@+node:ekr.20090709084001.6291: *6* Added hasSelection to leoQtBody
Also added test for leoQtBody to existing test.
#@+node:ekr.20090709084001.6296: *5* Features
#@+node:ekr.20090709084001.6297: *6* Added open-quickstart-leo command
#@+node:ekr.20090709084001.6300: *6* Added tree bindings for page-up/down commands
This was a binding issue. Leo has a full range of scrolling commands. They work.

The old bindings bound the PageUp/Down keys to back/forward page commands, and
these commands work only for text.

The new default bindings in leoSettings.leo: @keys EKR bindings are:

back-page                       ! text = PageUp
back-page-extend-selection      ! text = Shift-PageUp
forward-page                    ! text = PageDn
forward-page-extend-selection   ! text = Shift-PageDn

scroll-down-half-page   ! tree = Shift-PageDn
scroll-down-page        ! tree = PageDn
scroll-up-half-page     ! tree = Shift-PageUp
scroll-up-page          ! tree = PageUp         
#@+node:ekr.20090709084001.6301: *6* Issue error message re non-existent plugins
Leo now prints an error message when @enabled-plugins node contains a plugin
that does not exist.
#@+node:ekr.20090709084001.6304: *6* Expanded Alt-lt/rt arrows
#@+node:ekr.20090709084001.6307: *6* Added important @auto warning
Warn if the file exists and has never been read. This prevents a newly-created
@auto node from overwriting an existing file.
#@+node:ekr.20090717084250.10808: *4* 4.6 final
Leo 4.6 final                             July 15, 2009

Leo 4.6 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.6:
--------------------------

- Cached external files *greatly* reduces the time to load .leo files.
- Leo now features a modern Qt interface by default.
  Leo's legacy Tk interface can also be used.
- New --config, --file and --gui command-line options.
- Leo tests syntax of .py files when saving them.
- Leo can now open any kind of file into @edit nodes.
- @auto-rst nodes allow easy editing of reStructuredText files.
- Properties of commanders, positions and nodes simplify programming.
- Improved Leo's unit testing framework.
- Leo now requires Python 2.5 or later.
- Dozens of small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20090717084250.10809: *5* Bug fixes
#@+node:ekr.20090717084250.10810: *6* Bugs fixed in 4.6 b2
#@+node:ekr.20090717084250.10811: *7* Added patch for startup logic
A patch at the start of loadOnePlugin prevents leo from crashing and allows the
gui prompt for a leoID to come up.
#@+node:ekr.20090717084250.10812: *7* Allocate gnx's when nodes are created
This is reasonable now that old-style file indices are rare.
#@+node:ekr.20090717084250.10813: *7* Allow block comments in private shadow files
Html files are a good test case.
#@+node:ekr.20090717084250.10814: *7* Compute delims from private shadow file as needed
#@+node:ekr.20090717084250.10815: *7* Don't copy @edit trees to outline
http://bugs.launchpad.net/leo-editor/+bug/376634

The fix was to putVnodes.
#@+node:ekr.20090717084250.10816: *7* Don't expand ancestors of @chapter node when selecting chapter
#@+node:ekr.20090717084250.10817: *7* Entries in recent files menu now have absolute paths
http://bugs.launchpad.net/leo-editor/+bug/383204
#@+node:ekr.20090717084250.10818: *7* Fixed (worked around) tk chapters bug
http://groups.google.com/group/leo-editor/browse_thread/thread/981c27d5c24c90f8
#@+node:ekr.20090717084250.10819: *7* Fixed @edit bug
The generated @nocolor line now ends with a newline.
#@+node:ekr.20090717084250.10820: *7* Fixed @shadow crasher
http://groups.google.com/group/leo-editor/browse_thread/thread/6cab5e676d4d75a0
#@+node:ekr.20090717084250.10821: *7* Fixed @thin bug
- Removed forceGnxOnPosition from leoImport.py and leoAtFile.py.

- readStartNode now always uses root.v for the first node
  instead of calling createThinChild4
#@+node:ekr.20090717084250.10822: *7* Fixed back-to-home so it works as expected
https://bugs.launchpad.net/leo-editor/+bug/367462

The expected/customary behavior (one you get used to in almost every editor) is:

End: always move to end of line
Home: Move to first visible character on the line. When pressing home again, move to column zero. If Home is pressed one more time, move to first visible character again.

This is also the way emacs behaves, though ctrl+a always moves to column zero.
#@+node:ekr.20090717084250.10823: *7* Fixed bad @verbatim bug
The @verbatim was being inserted into the outline.
#@+node:ekr.20090717084250.10824: *7* Fixed binding problem with notebook
#@+node:ekr.20090717084250.10825: *7* Fixed bug: sorting could revert headline changes
#@+node:ekr.20090717084250.10826: *7* Fixed crash when reading .zip files
The problem arose when reading a zipped file:

 File "C:\Programme\Leo-4-6-b1\leo\core\leoFileCommands.py", line
1265, in parse_leo_file
   s = theFile.read()
TypeError: read() takes at least 2 arguments (1 given)
saved: [zipped] Dive-into-Python-3.leo
#@+node:ekr.20090717084250.10827: *7* Fixed crasher when creating .leoID.txt
exception loading plugin
Traceback (most recent call last):

  File "C:\leo.repo\trunk\leo\core\leoPlugins.py", line 429, in loadOnePlugin
    loadedModulesFilesDict[moduleName] = g.app.config.enabledPluginsFileName

AttributeError: StubConfig instance has no attribute 'enabledPluginsFileName'

leoID='ekr'
.leoID.txt created in C:\Documents and Settings\HP_Administrator\My Documents\Edward\.leo
load 
#@+node:ekr.20090717084250.10828: *7* Fixed dabbrev-expands bug
http://bugs.launchpad.net/leo-editor/+bug/362048

I have 'dabbrev-expands' bound to the F4 key. When I press F4 after
the word "freq" in a body pane containing the word "frequency" then
Leo 4.5.1 shows a hour-glass for a while before giving an empty
dabbrev-expand: prompt in the minibuffer.

If I back up one character, putting point between the e and q and then
type F4, I get the expected behavior: the word "frequency" is inserted
immediately.

What I did:

- Removed "not ready messages".
- Made the code undoable.
- Added wimpy unit test.
#@+node:ekr.20090717084250.10829: *7* Fixed elisp importer problem
#@+node:ekr.20090717084250.10830: *7* Fixed F10/11/12 key bug
Added call to isFKey in k.handleUnboundKeys.
#@+node:ekr.20090717084250.10831: *7* Fixed file bug re unicode characters
http://bugs.launchpad.net/leo-editor/+bug/376189
#@+node:ekr.20090717084250.10832: *7* Fixed hoist problems
http://bugs.launchpad.net/leo-editor/+bug/382221
#@+node:ekr.20090717084250.10833: *7* Fixed lost anchor bug page up/down
http://bugs.launchpad.net/leo-editor/+bug/363403

With a long body text you might place the cursor on a line, hold down Shift, and
PgDn several pages to select a large block of text. The last PgDn may overshoot
the range you want selected, so you should be able to use UpArrow to bring the
bottom of the range back up to where you want it. However, on the first UpArrow
the selection is lost and restarted from the current cursor position. I.e. you
end up with just one line selected, instead of trimming one line of the
selection of several pages, as intended.
#@+node:ekr.20090717084250.10834: *7* Fixed minor @auto bug
http://bugs.launchpad.net/leo-editor/+bug/306671

If a Leo editor window is opened, and the "NewHeadline" node is renamed to
"@auto <path to some valid file>", and then the "File->Read/Write->Read @auto
nodes" menu option is selected, the renamed node reverts to its previous name
("NewHeadline"), and nothing is loaded into the node.
#@+node:ekr.20090717084250.10835: *7* Fixed multiple-editor focus problems
http://groups.google.com/group/leo-editor/browse_thread/thread/21bddd50f3400bdc?hl=en
#@+node:ekr.20090717084250.10836: *7* Fixed new command
The outline wasn't being redrawn properly.
#@+node:ekr.20090717084250.10837: *7* Fixed problems with change-all command
http://groups.google.com/group/leo-editor/browse_thread/thread/430287018f9d773d

The fix to minibufferFind.changeAll fixes a bug that is several years old.
The fix to findNextMatch fixes a bug that is likely much older than that.
#@+node:ekr.20090717084250.10838: *7* Fixed read clone bug
#@+node:ekr.20090717084250.10839: *7* Fixed rst import bug
#@+node:ekr.20090717084250.10840: *7* Fixed rst3 problem
http://mail.google.com/mail/#inbox/11ef0076a3f4d866
#@+node:ekr.20090717084250.10841: *7* Fixed seg-fault bug
The crash happened inside the call to::

    c.widgetWantsFocusNow(event.widget)

in callAltXFunction. Actually, the crash happened later, in c.outerUpdate.

A better fix would be to use wrappers for all edit widgets, and recalculate the
edit widget any it needs to be used.
#@+node:ekr.20090717084250.10842: *7* Fixed Shift-Arrow in headlines
#@+node:ekr.20090717084250.10843: *7* Fixed startup problem
http://groups.google.com/group/leo-editor/browse_thread/thread/606277d73b193037
#@+node:ekr.20090717084250.10844: *7* Fixed stubConfig problems
#@+node:ekr.20090717084250.10845: *7* Fixed undo bug
onTextChanged in the qt gui was calling setUndoTypingParams, in many case
redundantly and with bad params.

It remains to be seen whether onTextChanged is ever needed. If it is, it may be
difficult to set the old selection properly.
#@+node:ekr.20090717084250.10846: *7* Fixed vim bindings (dd) bug
http://bugs.launchpad.net/leo-editor/+bug/353925

The "kill-region" function did nothing when using the qt gui.

The fix was to replace tag_ranges with w.getSelectionRange, etc.
This was the only call to tag_ranges in the core.
#@+node:ekr.20090717084250.10847: *7* Investigated bug: File->Export->write failed due to incorrect path
http://bugs.launchpad.net/leo-editor/+bug/377907

I'm going to mark this invalid, although the behavior is way too confusing.

I added the following to the plugin's docstring:

Configuration
~~~~~~~~~~~~~

At present, the file leo/plugins/leo_to_html.ini contains configuration settings.
In particular, the default export path, "c:\" must be changed for *nix systems.
#@+node:ekr.20090717084250.10848: *7* Investigated speed of external unit tests
The problem is imports in the Commands ctor. When executed the first time from
the bridge the imports take about 3/4 sec. on my machine. There is nothing that
can or should be done. Ctrl-5 is still hugely faster than opening unitTest.leo!
#@+node:ekr.20090717084250.10849: *7* Made @url nodes work with qt gui
#@+node:ekr.20090717084250.10850: *7* Mark @<file> nodes dirty when @path nodes change
#@+node:ekr.20090717084250.10851: *7* Removed duplicate messages when opening non-existent .leo file
#@+node:ekr.20090717084250.10852: *7* Reversed messages about redefined keys
http://groups.google.com/group/leo-editor/browse_thread/thread/a04dcefbb672078f
#@+node:ekr.20090717084250.10853: *7* Scroll commands now affect only scrollbars
#@+node:ekr.20090717084250.10854: *6* Bugs fixed in 4.6 b1
#@+node:ekr.20090717084250.10855: *7* Fixed goto-global-line crasher
#@+node:ekr.20090717084250.10856: *7* Fixed bug that prevented Leo from opening files on the XP desktop
#@+node:ekr.20090717084250.10857: *7* Save/restore tnodeList in atFile.write
The code should save/restore, just as in the clean_file function (from scripts.leo)
#@+node:ekr.20090717084250.10858: *7* Paste outline problem
The problem was missing calls to initAfterLoad in c.new.
#@+node:ekr.20090717084250.10859: *7* Made sure $Home works for @nosent
http://groups.google.com/group/leo-editor/browse_thread/thread/f27e3514310a5c90
#@+node:ekr.20090717084250.10860: *7* Fixed atFile unicode bug
#@+node:ekr.20090717084250.10861: *7* Fixed Mark Edgington's @shadow bug
#@+node:ekr.20090717084250.10862: *7* Fixed whitespace problems with @auto/@shadow
Pulled trunk, got r1599

python launchLeo.py leo/plugins/leoPlugins.leo

go to

Plugins-->Graph world-->@shadow backlink.py-->backlink declarations

All I did was add the full stop at the end of the docstring, but see
the diff:

=== modified file 'leo/plugins/backlink.py'
--- leo/plugins/backlink.py     2009-02-19 18:16:01 +0000
+++ leo/plugins/backlink.py     2009-02-25 22:14:46 +0000
@@ -1,4 +1,4 @@
-'''Backlink - allow arbitrary links between nodes
+'''Backlink - allow arbitrary links between nodes.
 '''

 # Notes
@@ -296,7 +296,7 @@
                break
        else:
            self.showMessage("Error: no such link")
-
+
        gcc = getattr(self.c, 'graphcanvasController')
        if gcc:
            gcc.update()
#@+node:ekr.20090717084250.10863: *7* Fixed nested @path problem
http://groups.google.com/group/leo-editor/browse_thread/thread/7d8325d055cbef30
#@+node:ekr.20090717084250.10864: *7* Fixed encoding problems with rst3 plugin
http://groups.google.com/group/leo-editor/browse_thread/thread/5f5219fedd977ec2
#@+node:ekr.20090717084250.10865: *7* Fixed new rst3 crash
http://groups.google.com/group/leo-editor/browse_thread/thread/414137b93c7e4b90

Calls g.makeAllNonExistentDirectories instead of os.mkdir.
#@+node:ekr.20090717084250.10866: *7* Fixed two c syntax-coloring bugs
http://groups.google.com/group/leo-editor/browse_thread/thread/707a910f975f3715

http://groups.google.com/group/leo-editor/browse_thread/thread/74c6ab4809bde980

There were two separate bugs:

1. The eol_span and eol_span_regex now honor the mode's escape character.

2. colorRangeWithTag now colors delegates with the default tag color.

No changes were made in modes/c.py or modes/c.xml.
#@+node:ekr.20090717084250.10867: *5* New features
#@+node:ekr.20090717084250.10868: *6* New features in 4.6 b1
#@+node:ekr.20090717084250.10869: *7* Improved file handling
#@+node:ekr.20090717084250.10870: *8* Open a default .leo file if no other is specified
http://groups.google.com/group/leo-editor/browse_thread/thread/d6449236bc140713#

Added support for @string default_leo_file = ~/.leo/workbook.leo
#@+node:ekr.20090717084250.10871: *8* Added escapes for underindented lines
@string underindent-escape-string = \-
#@+node:ekr.20090717084250.10872: *8* Warn when writing an externally changed file
http://groups.google.com/group/leo-editor/browse_thread/thread/c80fd8375534afdf
#@+node:ekr.20090717084250.10873: *7* New code features
#@+node:ekr.20090717084250.10874: *8* Added autoCompleter.getExternalCompletions
@nocolor

http://groups.google.com/group/leo-editor/browse_thread/thread/4ad91984a6d0acac

> As I said, all I need would be is for leo to call callback/hook with
> signature like
> def complete(line-up-to-cursor, current_node) => list of strings

The actual signature is:

theObject,completionList = getExternalCompletions (self,s,p=None,language='python')

p is used only to get the language, or you can set the language by hand.

@color
#@+node:ekr.20090717084250.10875: *8* Added g.PosList
#@+node:ekr.20090717084250.10876: *8* Better plugin info
c.config.doEnabledPlugins sets g.app.config.enabledPluginsFileName
#@+node:ekr.20090717084250.10877: *8* Added properties to leoNodes.py
p.b, p.h and p.gnx
t.b, t.h, t.gnx and t.u
v.b, v.h, v.gnx, and v.u
#@+node:ekr.20090717084250.10878: *8* Added script to leoSettings.leo to ensure all menu items are valid
#@+node:ekr.20090717084250.10879: *8* Added c.config.getSettingSource
c.config.getSettingSource('show_full_tracebacks_in_scripts')
returns the name of the file which Leo used to determine the setting

- D indicates default settings.
- F indicates the file being loaded
- L indicates leoSettings.leo
- M indicates myLeoSettings.leo
#@+node:ekr.20090717084250.10880: *8* Predefined 'self' in @test/@suite nodes
#@+node:ekr.20090717084250.10881: *8* Added c.getNodePath and c.getNodeFileName
http://groups.google.com/group/leo-editor/browse_thread/thread/3b5f1232ecc6bba7
#@+node:ekr.20090717084250.10882: *7* New command-line options
#@+node:ekr.20090717084250.10883: *8* Added -c option to specify config files
@nocolor

The setting is called -c or --config.  The one-config-file arg no longer exists.

http://groups.google.com/group/leo-editor/browse_thread/thread/f3f95d93bcd93b94

Personally, I'd like to see another config file available via -c on
the command line:
(a common idiom)

leo myproject.leo -c /usr/lib/myproject/myLeoSettings.leo

or better yet:

leo myproject.leo -c /etc/leo/style01.leo
leo myotherproject.leo -c /etc/leo/style02.leo
leo anotherproject.leo -c /etc/leo/style23.leo

Each file opens in an editor with the shortcuts, buttons, commands,
plugins, appearance etc.  that has been tuned for that data management task.

or best yet:

leo myproject.leo -c /usr/lib/python2.5/site-packages/leo/config/style94.leo

==================

http://groups.google.com/group/leo-editor/browse_thread/thread/b5a736089079acaf#

Please, I think each file has a distinct and required role.

- config/leoSettings.leo = Edward's base, required for a sane starting point

- home/.leo/myLeoSettings.leo = adjust Edwards suggestions to taste

- cwd/myLeoSettings.leo = provide a customized working environment in
this folder

- leo -c /usr/lib/leo-editor/src/config/zope3_ide.leo =
  - open this file in a specialized environments, mine or community contributed
  - ...

- currentfile/@settings =
  - I'm working on some customization ideas
  - Here, try out this Leo file I sent you, check out all the spiffy
modifications 

@color
#@+node:ekr.20090717084250.10884: *8* Added support for --file=fileName command-line option
Only .zip and .leo extensions are allowed at present.
#@+node:ekr.20090717084250.10885: *8* Added support for --gui option
#@+node:ekr.20090717084250.10886: *7* New commands
#@+node:ekr.20090717084250.10887: *8* Added smart home (back-to-home) command
#@+node:ekr.20090717084250.10888: *8* The open command creates @edit nodes when opening non-.leo files
http://groups.google.com/group/leo-editor/browse_thread/thread/3417ff5e9c02c626

The open file dialog now shows all files by default.
Selecting a non-.leo file will load that file into a new node in the present outline.

This plugs what may have been the biggest hole in Leo's history.
#@+node:ekr.20090717084250.10889: *8* added pdb minibuffer command
This works, but stops Leo in the middle of the command-handling logic.

However, it is possible to pick up the commander by stepping out into
k.masterKeyHandler or k.masterCommandHandler. Using c, one can then get all
other info.
#@+node:ekr.20090717084250.10890: *8* Added support for smart_tab setting
- Tab = indent when there is a text selection
- Shift-Tab unindents always
#@+node:ekr.20090717084250.10891: *8* Improved isearch commands
Escape now ends isearch
#@+node:ekr.20090717084250.10892: *7* New and improved directives
#@+node:ekr.20090717084250.10893: *8* Added @nocolor-node directive
# Useful: we don't need a closing @color to enable coloring in descendants.
#@+node:ekr.20090717084250.10894: *8* Improved @path handling
#@+node:ekr.20090717084250.10895: *7* New settings
#@+node:ekr.20090717084250.10896: *8* Added better default fonts for Leo on Linux
http://groups.google.com/group/leo-editor/browse_thread/thread/f1c7c5134b95c77e
#@+node:ekr.20090717084250.10897: *8* Added support for @int icon_bar_widgets_per_row setting
#@+node:ekr.20090717084250.10898: *8* Added support for meta keys
http://groups.google.com/group/leo-editor/browse_thread/thread/b6a39ed672a28c65?pli=1
#@+node:ekr.20090717084250.10899: *8* Use myLeoSettings when opening leoSettings.leo
Changed config.get so that settings in leoSettings.leo are read *last*.
This means that myLeoSettings.leo will override leoSettings.leo,
even when leoSettings.leo is the local file.
#@+node:ekr.20090717084250.10900: *7* Plugins
#@+node:ekr.20090717084250.10901: *8* Improved nav_buttons plugin and corresponding nodeHistory class
#@+node:ekr.20090717084250.10902: *8* Created qtGui and tkGui plugins
#@+node:ekr.20090717084250.10903: *8* Created leoGuiPluginsRef.leo
This contains all gui plugins.
#@+node:ekr.20090717084250.10904: *6* New features in 4.6 b2
#@+node:ekr.20090717084250.10905: *7* Allow Leo to open any file
Leo can now open, for example, any .py file.
It will be put in an @edit node in an otherwise-empty outline.

This allows Leo to be associated with the edit action of .py files.
Something like this::

C:\Python26\python.exe "c:\leo.repo\trunk\launchLeo.py" --gui=qt %1 %2
#@+node:ekr.20090717084250.10906: *7* Improved unit testing
- leoDynamicTest.py now supports a --path argument giving the .leo file.
  This is so useful!

- leoDynamicTest.py now honors the --silent argument.

- leoTest.runUnitTestLeoFile runs all unit tests in a given .leo file
  in a separate process.

- leoTest.runTestsExternally calls runUnitTestLeoFile after creating
  dynamicUnitTest.leo.

- When reporting that no unit tests were found, all unit tests commands tell
  whether the entire outline or just the selected outline was searched.
  This fixes sometimes-misleading error messages.

- test.leo contains a 'run-test.leo-tests' button.

- leoPy.leo contains a 'run-all-core-tests' button.
#@+node:ekr.20090717084250.10907: *7* Leo tests syntax of .py files when saving them
#@+node:ekr.20090717084250.10908: *7* Made qt gui the default
#@+node:ekr.20090717084250.10909: *7* Support @auto-rst
#@+node:ekr.20090717084250.10910: *6* New features in 4.6 final
Leo now warns on dangerous writes to @thin and @file nodes.
#@+node:ekr.20090718092032.10405: *4* 4.6.1 final
Leo 4.6.1 final                             July 30, 2009

Leo 4.6.1 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Leo 4.6.1 fixes several minor bugs in Leo 4.6.


The highlights of Leo 4.6
--------------------------

- Cached external files *greatly* reduces the time to load .leo files.
- Leo now features a modern Qt interface by default.
  Leo's legacy Tk interface can also be used.
- New --config, --file and --gui command-line options.
- Leo tests syntax of .py files when saving them.
- Leo can now open any kind of file into @edit nodes.
- @auto-rst nodes allow easy editing of reStructuredText files.
- Properties of commanders, positions and nodes simplify programming.
- Improved Leo's unit testing framework.
- Leo now requires Python 2.5 or later.
- Dozens of small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20090718092032.10406: *5* Bug fixes
#@+node:ekr.20090718092032.10407: *6* Bugs fixed in 4.6 b2
#@+node:ekr.20090718092032.10408: *7* Added patch for startup logic
A patch at the start of loadOnePlugin prevents leo from crashing and allows the
gui prompt for a leoID to come up.
#@+node:ekr.20090718092032.10409: *7* Allocate gnx's when nodes are created
This is reasonable now that old-style file indices are rare.
#@+node:ekr.20090718092032.10410: *7* Allow block comments in private shadow files
Html files are a good test case.
#@+node:ekr.20090718092032.10411: *7* Compute delims from private shadow file as needed
#@+node:ekr.20090718092032.10412: *7* Don't copy @edit trees to outline
http://bugs.launchpad.net/leo-editor/+bug/376634

The fix was to putVnodes.
#@+node:ekr.20090718092032.10413: *7* Don't expand ancestors of @chapter node when selecting chapter
#@+node:ekr.20090718092032.10414: *7* Entries in recent files menu now have absolute paths
http://bugs.launchpad.net/leo-editor/+bug/383204
#@+node:ekr.20090718092032.10415: *7* Fixed (worked around) tk chapters bug
http://groups.google.com/group/leo-editor/browse_thread/thread/981c27d5c24c90f8
#@+node:ekr.20090718092032.10416: *7* Fixed @edit bug
The generated @nocolor line now ends with a newline.
#@+node:ekr.20090718092032.10417: *7* Fixed @shadow crasher
http://groups.google.com/group/leo-editor/browse_thread/thread/6cab5e676d4d75a0
#@+node:ekr.20090718092032.10418: *7* Fixed @thin bug
- Removed forceGnxOnPosition from leoImport.py and leoAtFile.py.

- readStartNode now always uses root.v for the first node
  instead of calling createThinChild4
#@+node:ekr.20090718092032.10419: *7* Fixed back-to-home so it works as expected
https://bugs.launchpad.net/leo-editor/+bug/367462

The expected/customary behavior (one you get used to in almost every editor) is:

End: always move to end of line
Home: Move to first visible character on the line. When pressing home again, move to column zero. If Home is pressed one more time, move to first visible character again.

This is also the way emacs behaves, though ctrl+a always moves to column zero.
#@+node:ekr.20090718092032.10420: *7* Fixed bad @verbatim bug
The @verbatim was being inserted into the outline.
#@+node:ekr.20090718092032.10421: *7* Fixed binding problem with notebook
#@+node:ekr.20090718092032.10422: *7* Fixed bug: sorting could revert headline changes
#@+node:ekr.20090718092032.10423: *7* Fixed crash when reading .zip files
The problem arose when reading a zipped file:

 File "C:\Programme\Leo-4-6-b1\leo\core\leoFileCommands.py", line
1265, in parse_leo_file
   s = theFile.read()
TypeError: read() takes at least 2 arguments (1 given)
saved: [zipped] Dive-into-Python-3.leo
#@+node:ekr.20090718092032.10424: *7* Fixed crasher when creating .leoID.txt
exception loading plugin
Traceback (most recent call last):

  File "C:\leo.repo\trunk\leo\core\leoPlugins.py", line 429, in loadOnePlugin
    loadedModulesFilesDict[moduleName] = g.app.config.enabledPluginsFileName

AttributeError: StubConfig instance has no attribute 'enabledPluginsFileName'

leoID='ekr'
.leoID.txt created in C:\Documents and Settings\HP_Administrator\My Documents\Edward\.leo
load 
#@+node:ekr.20090718092032.10425: *7* Fixed dabbrev-expands bug
http://bugs.launchpad.net/leo-editor/+bug/362048

I have 'dabbrev-expands' bound to the F4 key. When I press F4 after
the word "freq" in a body pane containing the word "frequency" then
Leo 4.5.1 shows a hour-glass for a while before giving an empty
dabbrev-expand: prompt in the minibuffer.

If I back up one character, putting point between the e and q and then
type F4, I get the expected behavior: the word "frequency" is inserted
immediately.

What I did:

- Removed "not ready messages".
- Made the code undoable.
- Added wimpy unit test.
#@+node:ekr.20090718092032.10426: *7* Fixed elisp importer problem
#@+node:ekr.20090718092032.10427: *7* Fixed F10/11/12 key bug
Added call to isFKey in k.handleUnboundKeys.
#@+node:ekr.20090718092032.10428: *7* Fixed file bug re unicode characters
http://bugs.launchpad.net/leo-editor/+bug/376189
#@+node:ekr.20090718092032.10429: *7* Fixed hoist problems
http://bugs.launchpad.net/leo-editor/+bug/382221
#@+node:ekr.20090718092032.10430: *7* Fixed lost anchor bug page up/down
http://bugs.launchpad.net/leo-editor/+bug/363403

With a long body text you might place the cursor on a line, hold down Shift, and
PgDn several pages to select a large block of text. The last PgDn may overshoot
the range you want selected, so you should be able to use UpArrow to bring the
bottom of the range back up to where you want it. However, on the first UpArrow
the selection is lost and restarted from the current cursor position. I.e. you
end up with just one line selected, instead of trimming one line of the
selection of several pages, as intended.
#@+node:ekr.20090718092032.10431: *7* Fixed minor @auto bug
http://bugs.launchpad.net/leo-editor/+bug/306671

If a Leo editor window is opened, and the "NewHeadline" node is renamed to
"@auto <path to some valid file>", and then the "File->Read/Write->Read @auto
nodes" menu option is selected, the renamed node reverts to its previous name
("NewHeadline"), and nothing is loaded into the node.
#@+node:ekr.20090718092032.10432: *7* Fixed multiple-editor focus problems
http://groups.google.com/group/leo-editor/browse_thread/thread/21bddd50f3400bdc?hl=en
#@+node:ekr.20090718092032.10433: *7* Fixed new command
The outline wasn't being redrawn properly.
#@+node:ekr.20090718092032.10434: *7* Fixed problems with change-all command
http://groups.google.com/group/leo-editor/browse_thread/thread/430287018f9d773d

The fix to minibufferFind.changeAll fixes a bug that is several years old.
The fix to findNextMatch fixes a bug that is likely much older than that.
#@+node:ekr.20090718092032.10435: *7* Fixed read clone bug
#@+node:ekr.20090718092032.10436: *7* Fixed rst import bug
#@+node:ekr.20090718092032.10437: *7* Fixed rst3 problem
http://mail.google.com/mail/#inbox/11ef0076a3f4d866
#@+node:ekr.20090718092032.10438: *7* Fixed seg-fault bug
The crash happened inside the call to::

    c.widgetWantsFocusNow(event.widget)

in callAltXFunction. Actually, the crash happened later, in c.outerUpdate.

A better fix would be to use wrappers for all edit widgets, and recalculate the
edit widget any it needs to be used.
#@+node:ekr.20090718092032.10439: *7* Fixed Shift-Arrow in headlines
#@+node:ekr.20090718092032.10440: *7* Fixed startup problem
http://groups.google.com/group/leo-editor/browse_thread/thread/606277d73b193037
#@+node:ekr.20090718092032.10441: *7* Fixed stubConfig problems
#@+node:ekr.20090718092032.10442: *7* Fixed undo bug
onTextChanged in the qt gui was calling setUndoTypingParams, in many case
redundantly and with bad params.

It remains to be seen whether onTextChanged is ever needed. If it is, it may be
difficult to set the old selection properly.
#@+node:ekr.20090718092032.10443: *7* Fixed vim bindings (dd) bug
http://bugs.launchpad.net/leo-editor/+bug/353925

The "kill-region" function did nothing when using the qt gui.

The fix was to replace tag_ranges with w.getSelectionRange, etc.
This was the only call to tag_ranges in the core.
#@+node:ekr.20090718092032.10444: *7* Investigated bug: File->Export->write failed due to incorrect path
http://bugs.launchpad.net/leo-editor/+bug/377907

I'm going to mark this invalid, although the behavior is way too confusing.

I added the following to the plugin's docstring:

Configuration
~~~~~~~~~~~~~

At present, the file leo/plugins/leo_to_html.ini contains configuration settings.
In particular, the default export path, "c:\" must be changed for *nix systems.
#@+node:ekr.20090718092032.10445: *7* Investigated speed of external unit tests
The problem is imports in the Commands ctor. When executed the first time from
the bridge the imports take about 3/4 sec. on my machine. There is nothing that
can or should be done. Ctrl-5 is still hugely faster than opening unitTest.leo!
#@+node:ekr.20090718092032.10446: *7* Made @url nodes work with qt gui
#@+node:ekr.20090718092032.10447: *7* Mark @<file> nodes dirty when @path nodes change
#@+node:ekr.20090718092032.10448: *7* Removed duplicate messages when opening non-existent .leo file
#@+node:ekr.20090718092032.10449: *7* Reversed messages about redefined keys
http://groups.google.com/group/leo-editor/browse_thread/thread/a04dcefbb672078f
#@+node:ekr.20090718092032.10450: *7* Scroll commands now affect only scrollbars
#@+node:ekr.20090718092032.10451: *6* Bugs fixed in 4.6 b1
#@+node:ekr.20090718092032.10452: *7* Fixed goto-global-line crasher
#@+node:ekr.20090718092032.10453: *7* Fixed bug that prevented Leo from opening files on the XP desktop
#@+node:ekr.20090718092032.10454: *7* Save/restore tnodeList in atFile.write
The code should save/restore, just as in the clean_file function (from scripts.leo)
#@+node:ekr.20090718092032.10455: *7* Paste outline problem
The problem was missing calls to initAfterLoad in c.new.
#@+node:ekr.20090718092032.10456: *7* Made sure $Home works for @nosent
http://groups.google.com/group/leo-editor/browse_thread/thread/f27e3514310a5c90
#@+node:ekr.20090718092032.10457: *7* Fixed atFile unicode bug
#@+node:ekr.20090718092032.10458: *7* Fixed Mark Edgington's @shadow bug
#@+node:ekr.20090718092032.10459: *7* Fixed whitespace problems with @auto/@shadow
Pulled trunk, got r1599

python launchLeo.py leo/plugins/leoPlugins.leo

go to

Plugins-->Graph world-->@shadow backlink.py-->backlink declarations

All I did was add the full stop at the end of the docstring, but see
the diff:

=== modified file 'leo/plugins/backlink.py'
--- leo/plugins/backlink.py     2009-02-19 18:16:01 +0000
+++ leo/plugins/backlink.py     2009-02-25 22:14:46 +0000
@@ -1,4 +1,4 @@
-'''Backlink - allow arbitrary links between nodes
+'''Backlink - allow arbitrary links between nodes.
 '''

 # Notes
@@ -296,7 +296,7 @@
                break
        else:
            self.showMessage("Error: no such link")
-
+
        gcc = getattr(self.c, 'graphcanvasController')
        if gcc:
            gcc.update()
#@+node:ekr.20090718092032.10460: *7* Fixed nested @path problem
http://groups.google.com/group/leo-editor/browse_thread/thread/7d8325d055cbef30
#@+node:ekr.20090718092032.10461: *7* Fixed encoding problems with rst3 plugin
http://groups.google.com/group/leo-editor/browse_thread/thread/5f5219fedd977ec2
#@+node:ekr.20090718092032.10462: *7* Fixed new rst3 crash
http://groups.google.com/group/leo-editor/browse_thread/thread/414137b93c7e4b90

Calls g.makeAllNonExistentDirectories instead of os.mkdir.
#@+node:ekr.20090718092032.10463: *7* Fixed two c syntax-coloring bugs
http://groups.google.com/group/leo-editor/browse_thread/thread/707a910f975f3715

http://groups.google.com/group/leo-editor/browse_thread/thread/74c6ab4809bde980

There were two separate bugs:

1. The eol_span and eol_span_regex now honor the mode's escape character.

2. colorRangeWithTag now colors delegates with the default tag color.

No changes were made in modes/c.py or modes/c.xml.
#@+node:ekr.20090718092032.10464: *5* New features
#@+node:ekr.20090718092032.10465: *6* New features in 4.6 b1
#@+node:ekr.20090718092032.10466: *7* Improved file handling
#@+node:ekr.20090718092032.10467: *8* Open a default .leo file if no other is specified
http://groups.google.com/group/leo-editor/browse_thread/thread/d6449236bc140713#

Added support for @string default_leo_file = ~/.leo/workbook.leo
#@+node:ekr.20090718092032.10468: *8* Added escapes for underindented lines
@string underindent-escape-string = \-
#@+node:ekr.20090718092032.10469: *8* Warn when writing an externally changed file
http://groups.google.com/group/leo-editor/browse_thread/thread/c80fd8375534afdf
#@+node:ekr.20090718092032.10470: *7* New code features
#@+node:ekr.20090718092032.10471: *8* Added autoCompleter.getExternalCompletions
@nocolor

http://groups.google.com/group/leo-editor/browse_thread/thread/4ad91984a6d0acac

> As I said, all I need would be is for leo to call callback/hook with
> signature like
> def complete(line-up-to-cursor, current_node) => list of strings

The actual signature is:

theObject,completionList = getExternalCompletions (self,s,p=None,language='python')

p is used only to get the language, or you can set the language by hand.

@color
#@+node:ekr.20090718092032.10472: *8* Added g.PosList
#@+node:ekr.20090718092032.10473: *8* Better plugin info
c.config.doEnabledPlugins sets g.app.config.enabledPluginsFileName
#@+node:ekr.20090718092032.10474: *8* Added properties to leoNodes.py
p.b, p.h and p.gnx
t.b, t.h, t.gnx and t.u
v.b, v.h, v.gnx, and v.u
#@+node:ekr.20090718092032.10475: *8* Added script to leoSettings.leo to ensure all menu items are valid
#@+node:ekr.20090718092032.10476: *8* Added c.config.getSettingSource
c.config.getSettingSource('show_full_tracebacks_in_scripts')
returns the name of the file which Leo used to determine the setting

- D indicates default settings.
- F indicates the file being loaded
- L indicates leoSettings.leo
- M indicates myLeoSettings.leo
#@+node:ekr.20090718092032.10477: *8* Predefined 'self' in @test/@suite nodes
#@+node:ekr.20090718092032.10478: *8* Added c.getNodePath and c.getNodeFileName
http://groups.google.com/group/leo-editor/browse_thread/thread/3b5f1232ecc6bba7
#@+node:ekr.20090718092032.10479: *7* New command-line options
#@+node:ekr.20090718092032.10480: *8* Added -c option to specify config files
@nocolor

The setting is called -c or --config.  The one-config-file arg no longer exists.

http://groups.google.com/group/leo-editor/browse_thread/thread/f3f95d93bcd93b94

Personally, I'd like to see another config file available via -c on
the command line:
(a common idiom)

leo myproject.leo -c /usr/lib/myproject/myLeoSettings.leo

or better yet:

leo myproject.leo -c /etc/leo/style01.leo
leo myotherproject.leo -c /etc/leo/style02.leo
leo anotherproject.leo -c /etc/leo/style23.leo

Each file opens in an editor with the shortcuts, buttons, commands,
plugins, appearance etc.  that has been tuned for that data management task.

or best yet:

leo myproject.leo -c /usr/lib/python2.5/site-packages/leo/config/style94.leo

==================

http://groups.google.com/group/leo-editor/browse_thread/thread/b5a736089079acaf#

Please, I think each file has a distinct and required role.

- config/leoSettings.leo = Edward's base, required for a sane starting point

- home/.leo/myLeoSettings.leo = adjust Edwards suggestions to taste

- cwd/myLeoSettings.leo = provide a customized working environment in
this folder

- leo -c /usr/lib/leo-editor/src/config/zope3_ide.leo =
  - open this file in a specialized environments, mine or community contributed
  - ...

- currentfile/@settings =
  - I'm working on some customization ideas
  - Here, try out this Leo file I sent you, check out all the spiffy
modifications 

@color
#@+node:ekr.20090718092032.10481: *8* Added support for --file=fileName command-line option
Only .zip and .leo extensions are allowed at present.
#@+node:ekr.20090718092032.10482: *8* Added support for --gui option
#@+node:ekr.20090718092032.10483: *7* New commands
#@+node:ekr.20090718092032.10484: *8* Added smart home (back-to-home) command
#@+node:ekr.20090718092032.10485: *8* The open command creates @edit nodes when opening non-.leo files
http://groups.google.com/group/leo-editor/browse_thread/thread/3417ff5e9c02c626

The open file dialog now shows all files by default.
Selecting a non-.leo file will load that file into a new node in the present outline.

This plugs what may have been the biggest hole in Leo's history.
#@+node:ekr.20090718092032.10486: *8* added pdb minibuffer command
This works, but stops Leo in the middle of the command-handling logic.

However, it is possible to pick up the commander by stepping out into
k.masterKeyHandler or k.masterCommandHandler. Using c, one can then get all
other info.
#@+node:ekr.20090718092032.10487: *8* Added support for smart_tab setting
- Tab = indent when there is a text selection
- Shift-Tab unindents always
#@+node:ekr.20090718092032.10488: *8* Improved isearch commands
Escape now ends isearch
#@+node:ekr.20090718092032.10489: *7* New and improved directives
#@+node:ekr.20090718092032.10490: *8* Added @nocolor-node directive
# Useful: we don't need a closing @color to enable coloring in descendants.
#@+node:ekr.20090718092032.10491: *8* Improved @path handling
#@+node:ekr.20090718092032.10492: *7* New settings
#@+node:ekr.20090718092032.10493: *8* Added better default fonts for Leo on Linux
http://groups.google.com/group/leo-editor/browse_thread/thread/f1c7c5134b95c77e
#@+node:ekr.20090718092032.10494: *8* Added support for @int icon_bar_widgets_per_row setting
#@+node:ekr.20090718092032.10495: *8* Added support for meta keys
http://groups.google.com/group/leo-editor/browse_thread/thread/b6a39ed672a28c65?pli=1
#@+node:ekr.20090718092032.10496: *8* Use myLeoSettings when opening leoSettings.leo
Changed config.get so that settings in leoSettings.leo are read *last*.
This means that myLeoSettings.leo will override leoSettings.leo,
even when leoSettings.leo is the local file.
#@+node:ekr.20090718092032.10497: *7* Plugins
#@+node:ekr.20090718092032.10498: *8* Improved nav_buttons plugin and corresponding nodeHistory class
#@+node:ekr.20090718092032.10499: *8* Created qtGui and tkGui plugins
#@+node:ekr.20090718092032.10500: *8* Created leoGuiPluginsRef.leo
This contains all gui plugins.
#@+node:ekr.20090718092032.10501: *6* New features in 4.6 b2
#@+node:ekr.20090718092032.10502: *7* Allow Leo to open any file
Leo can now open, for example, any .py file.
It will be put in an @edit node in an otherwise-empty outline.

This allows Leo to be associated with the edit action of .py files.
Something like this::

C:\Python26\python.exe "c:\leo.repo\trunk\launchLeo.py" --gui=qt %1 %2
#@+node:ekr.20090718092032.10503: *7* Improved unit testing
- leoDynamicTest.py now supports a --path argument giving the .leo file.
  This is so useful!

- leoDynamicTest.py now honors the --silent argument.

- leoTest.runUnitTestLeoFile runs all unit tests in a given .leo file
  in a separate process.

- leoTest.runTestsExternally calls runUnitTestLeoFile after creating
  dynamicUnitTest.leo.

- When reporting that no unit tests were found, all unit tests commands tell
  whether the entire outline or just the selected outline was searched.
  This fixes sometimes-misleading error messages.

- test.leo contains a 'run-test.leo-tests' button.

- leoPy.leo contains a 'run-all-core-tests' button.
#@+node:ekr.20090718092032.10504: *7* Leo tests syntax of .py files when saving them
#@+node:ekr.20090718092032.10505: *7* Made qt gui the default
#@+node:ekr.20090718092032.10506: *7* Support @auto-rst
#@+node:ekr.20090718092032.10507: *6* New features in 4.6 final
Leo now warns on dangerous writes to @thin and @file nodes.
#@+node:ekr.20090802162204.5798: *4* 4.6.2 final
Leo 4.6.2 final                             August 3, 2009

Leo 4.6.2 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Leo 4.6.2 fixes several bugs reported since Leo 4.6 was released.

The highlights of Leo 4.6
--------------------------

- Cached external files *greatly* reduces the time to load .leo files.
- Leo now features a modern Qt interface by default.
  Leo's legacy Tk interface can also be used.
- New --config, --file and --gui command-line options.
- Leo tests syntax of .py files when saving them.
- Leo can now open any kind of file into @edit nodes.
- @auto-rst nodes allow easy editing of reStructuredText files.
- Properties of commanders, positions and nodes simplify programming.
- Improved Leo's unit testing framework.
- Leo now requires Python 2.5 or later.
- Dozens of small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20090803084828.5800: *5* Bugs fixed
- AltGr properly handled as Alt+Ctrl.
  Created a setting: @bool enable_alt_ctrl_bindings.
  The default is False, needed for AltGr functionality on Windows.

- Fixed unpickling problems in getDescendentUnknownAttributes

- Plugins that fail to import Pmw no longer prevent Leo from launching.

- Fixed bug 397433, tk chapter menu crash, on all platforms.
#@+node:ekr.20091006093902.6558: *4* 4.6.3 final
Leo 4.6.3 final                             September 4, 2009

Leo 4.6.3 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

Leo 4.6.3 fixes a significant caching bug in Leo 4.6.2.
Leo 4.6.3 also comes with an executable installer for Windows.
Leo 3.6.3 adds several new plugins.

The highlights of Leo 4.6
--------------------------

- Cached external files *greatly* reduces the time to load .leo files.
- Leo now features a modern Qt interface by default.
  Leo's legacy Tk interface can also be used.
- New --config, --file and --gui command-line options.
- Leo tests syntax of .py files when saving them.
- Leo can now open any kind of file into @edit nodes.
- @auto-rst nodes allow easy editing of reStructuredText files.
- Properties of commanders, positions and nodes simplify programming.
- Improved Leo's unit testing framework.
- Leo now requires Python 2.5 or later.
- Dozens of small improvements and bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20091006093902.6559: *5* Bugs fixed
- Leo marks nodes dirty if the nodes changed during read.

- Fixed a bug in g.adjustTripleString.
#@+node:ekr.20091006093902.6560: *5* New features
- Added --gui=qttabs command-line option

- Added new plugins: spydershell.py, qtframecommands.py, and mod_framesize.py.

- Added "show folder" in rclick menu.
#@+node:ekr.20100118181428.8827: *3* 4.7 One-node world, Leo-3k, @auto-rst, convert @file
#@+node:ekr.20090909083000.6547: *4* 4.7 beta 1
Leo 4.7 beta 1                          September 9, 2009

Leo 4.7 beta 1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

This version of Leo is labeled a beta version because it contains some new,
relatively untested plugins.  However, Leo's core should be quite reliable.

In particular, Leo 4.7 beta 1 fixes a bug that caused Leo 4.6 releases to crash
if .leoID.txt did not exist. Usually this file does exist, but Leo will prompt
for the contents of this file (a user id) the very first time somebody uses Leo.
Alas, an unfortunate reversion of code caused Leo to crash. Not exactly the best
introduction to Leo!

The highlights of Leo 4.7:
--------------------------

- A major simplification of internal data model: the so-called
  one-node world. Note: this is **disabled** in the beta 1 release.
- A new executable Windows installer, whose manifest is created from
  the files that bzr actively manages.
- Leo no longer adds directories to sys.path on startup.
- New plugins.
- The usual assortment of bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20090909083000.6556: *5* Added new Windows installer
Unlike previous installers, the manifest is created from the
@button make leo.nsi script in dist.leo.
#@+node:ekr.20090909083000.6555: *5* Added new plugins
@nocolor-node

New command-line option
    --gui=qttabs

new plugins:
    spydershell,
    qtframecommands
    mod_framesize.

Improved plugin:  "show folder" in rclick menu.

Improved plugin: contextmenu.py

    If you rclick on @thin / whatever item, you should see "open
    /home/ville/foo" (or equivalent) menu entry. It open up the file manager on
    that folder (using xdg-open on linux, os.startfile on windows). I have no
    idea what to do with mac, now it runs xdg-open and probably fails.
#@+node:ekr.20090909083000.6552: *5* Added options to vim plugin
The setting::

    @string vim_trigger_event = icondclick2

is the default.  It opens vim when the user double-clicks the icon box.

Alternatives are::

    @string vim_trigger_event = iconclick2
    @string vim_trigger_event = select2

The former opens vim on single clicks in the icon bar.
The latter opens vim whenever a new node is selected in Leo.
#@+node:ekr.20090909083000.6553: *5* Leo no longer adds directories to sys.path
http://groups.google.com/group/leo-editor/browse_thread/thread/b868abd65fb57759

Leo no longer adds directories to sys.path on startup.

(Merged the clean-sys-path branch into the trunk.)_
#@+node:ekr.20100118181428.8813: *4* 4.7 beta 2
Leo 4.7 beta 1                January 28, 2009

Leo 4.7 release beta 1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.7 beta 1 fixes all known serious bugs in Leo.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.7:
--------------------------

- Leo now uses the simplest possible internal data model.
  This is the so-called "one-node" world.
- Leo supports Python 3.x.
- Leo requires Python 2.6 or above.
- Several important improvements in file handling.
    - Leo converts @file nodes to @thin nodes automatically.
    - Leo creates a 'Recovered Nodes' node to hold data that
      otherwise might be lost due to clone conflicts.
    - @auto-rst now works much more reliably reliably.
    - Leo no longer @noref trees.  Such trees are not
      reliable in cooperative environments.
- A new Windows installer.
- Many other features, including new command line options and new plugins.
- Dozens of bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20100118181428.7557: *5* Bugs
#@+node:ekr.20100118181428.7559: *6* Fixed calltips on leo3k
They wiped out the newly-inserted selection range.
#@+node:ekr.20100118181428.7570: *6* Fixed headline scrolling
My biggest annoyance is the invalid bug 409442, I have to use the tk
GUI because of it.

I've also complained about it in this thread:
http://groups.google.com/group/leo-editor/browse_thread/thread/07cdbb... 

----- Ville +1
I feel your pain.

Please try this workaround (run with ctrl+b):

tree = c.frame.tree.treeWidget
tree.setColumnCount(2)

-----
> Isn't it possible to stick this tree.setColumnCount(2) into some
> constructor in the leo qt GUI plugin so the outline pane would have
> the horizontal scrollbar by default?

Yes, but it's not sure we want to have 2 columns in the tree widget -
and it would create scrollbar on many occasions when it's not
necessary.

So this is not a simple fix for your problem, it has implications
beyond your problem. 
#@+node:ekr.20100118181428.7571: *6* Fixed bug 498692: Undo renames headline
#@+node:ekr.20100118181428.7614: *6* Fixed bug 498688: Undo back to last saved content...
Fixed bug Bug 498688: Undo back to last saved content still shows file as
modified ("*" in title)
#@+node:ekr.20100118181428.7712: *6* Fixed bug: no log when notebook does not exist
#@+node:ekr.20100118181428.7715: *6* Fixed bug 362950: during body text undo selection goes nuts...
Bug 362950: during body text undo selection goes nuts and view moves
#@+node:ekr.20100118181428.7830: *6* Removed unsettling @auto warning
#@+node:ekr.20100118181428.7831: *6* Fixed at-auto-rst problems
#@+node:ekr.20100118181428.8070: *6* Fixed bug: at-nosent nodes were not being dirty when headline changes
#@+node:ekr.20100118181428.8077: *6* Allow hyphens in xml tags
Fixes bug 497332: importing xml via @data import_xml_tags does not allow dashes in tag.

For characters valid in names see:
www.w3.org/TR/2008/REC-xml-20081126/#NT-Name
#@+node:ekr.20100118181428.8090: *6* Fixed Alt-u bug and refactored k.masterKeyHandler
Bug 404993: alt+U (universal argument) "freezes" leo state

Press alt+U displays "Universal argument:" in minibuffer, and there is no
obvious way to get out of this state. It seems ctrl+G gets you out of it, but
that's not really obvious. ESC should do it.
#@+node:ekr.20100118181428.8109: *6* Fixed at-shadow error
http://groups.google.com/group/leo-editor/browse_thread/thread/81f7bb5060ed8b01
#@+node:ekr.20100118181428.8236: *6* Fixed bug 408886: qttabs gui doesn't mark commanders dirty properly
#@+node:ekr.20100118181428.8239: *6* Fixed bug 476653: @nowrap isn't working for qt / @edit nodes
#@+node:ekr.20100118181428.8240: *6* Fixed bug 480422: string-rectangle kills syntax highlighting
#@+node:ekr.20100118181428.8242: *6* Fixed bug in g.adjustTripleString
#@+node:ekr.20100118181428.8248: *6* Fixed bug in writeNodeToString
Leo now adds a leading period if needed.
#@+node:ekr.20100118181428.8252: *6* Fixed bug: @nosent should warn about orphan nodes
#@+node:ekr.20100118181428.8257: *6* Fixed bug: Sometimes 'redefining shortcut' message is backwards
#@+node:ekr.20100118181428.8262: *6* Fixed contract-or-go-right
#@+node:ekr.20100118181428.8275: *6* Fixed crasher when writing to a newly-deleted file
#@+node:ekr.20100118181428.8278: *6* Fixed double prompt in c.close()
#@+node:ekr.20100118181428.8281: *6* Fixed elisp parsing bug
#@+node:ekr.20100118181428.8294: *6* Fixed publish-argv-for-missing-stylesheets
#@+node:ekr.20100118181428.8297: *6* Fixed registerHandler bug
http://groups.google.com/group/leo-editor/browse_thread/thread/8616f4e171e1a24b
#@+node:ekr.20100118181428.8298: *6* Fixed scrolling problem with multiple editors
http://groups.google.com/group/leo-editor/browse_thread/thread/33e87adbff5d69d9
#@+node:ekr.20100118181428.8299: *6* Fixed startup reversion when .leoID.txt does not exist
#@+node:ekr.20100118181428.8302: *6* Handle Insert key properly
This is now bound in the EKR bindings to insert-node.
#@+node:ekr.20100118181428.8306: *6* Improved the install docs
http://groups.google.com/group/leo-editor/browse_thread/thread/add6242d6f4fc476
#@+node:ekr.20100118181428.8307: *6* Made add-comments and delete-comments commands work with shortcuts
#@+node:ekr.20100118181428.8334: *6* Marked @<file> nodes dirty if nodes change during read.
#@+node:ekr.20100118181428.8358: *6* Recover from bad chars in .leo files
Form-feed characters were causing problems with Python 3k.
#@+node:ekr.20100118181428.8362: *6* Select main chapter initially
It can be alarming to select a small chapter in a large outline.
#@+node:ekr.20100118181428.8363: *6* Suppressed dangerous write prompt for clones
#@+node:ekr.20100118181428.8365: *6* Use w.leoMoveCursorHelper if it exists
This fixes the following two bugs:

- 421957 When body_pane_wraps is set to true, Previous-Line and Next-Line do not
  work as expected.

- 489917 Cursor placement defect 
#@+node:ekr.20100118181428.8413: *6* Fixed bug 452303 @auto-rst can be dangerous
http://groups.google.com/group/leo-editor/browse_thread/thread/b84659e608ba44d5
#@+node:ekr.20100118181428.8447: *6* Fixed underlining problem in rst
http://groups.google.com/group/leo-editor/browse_thread/thread/cdf78cbca5c526be
#@+node:ekr.20100118181428.8449: *6* Fixed qt key problems
Shift-PageUp/Down were not working.
#@+node:ekr.20100118181428.8473: *6* Fixed bug: 381895 qtGui Split ratio is not saved in .leo file
http://bugs.launchpad.net/leo-editor/+bug/381895
#@+node:ekr.20100118181428.8481: *6* Applied patches to fix bug: 451377 Make Leo frienly to mac apps
https://bugs.launchpad.net/leo-editor/+bug/451377
#@+node:ekr.20100118181428.8485: *6* Fixed bug: 394445 Chapters selection button: in qt, missing, in Tk, only one option
The Tk part of this bug can not be fixed.
#@+node:ekr.20100118181428.8486: *6* Fixed bug: overwrite modified file message
http://groups.google.com/group/leo-editor/browse_thread/thread/b77b5260854ffbf6
#@+node:ekr.20100118181428.8497: *6* Fixed auto-save problem
http://groups.google.com/group/leo-editor/browse_thread/thread/b77b5260854ffbf6
#@+node:ekr.20100118181428.8502: *6* Fixed old at-shadow problem
http://groups.google.com/group/leo-editor/browse_thread/thread/c8f3edda9de05484
#@+node:ekr.20100118181428.8514: *6* Fixed ctrl-tab bug
ctrl-tab (currently binded to cycle-focus) didn't work in windows with pyqt.
#@+node:ekr.20100118181428.8517: *6* Fixed 349027: body doesn't get focus after headline edit
https://bugs.launchpad.net/leo-editor/+bug/349027
#@+node:ekr.20100118181428.8518: *6* Fixed bug 507559: Can't use End key while editing node headline
#@+node:ekr.20100118181428.8522: *6* Finished bug 486433: non-breaking space etc. are invisible
https://bugs.launchpad.net/leo-editor/+bug/486433
#@+node:ekr.20100118181428.8523: *6* Fixed bug: 420988 @tabwith 8 not honored
https://bugs.launchpad.net/leo-editor/+bug/420988
#@+node:ekr.20100118181428.8524: *6* Don't colorize @others and @all unless they start a line
#@+node:ekr.20100119145003.7319: *6* Gui bugs
#@+node:ekr.20100119145003.7320: *7* Fixed file-open focus problem
#@+node:ekr.20100119145003.7322: *7* Eliminate double close prompt
#@+node:ekr.20100119145003.7324: *7* Fixed scrolling problem with multiple editors
#@+node:ekr.20100119145003.7325: *7* Fixed crash in quicksearch plugin
#@+node:ekr.20100119145003.7327: *7* Fixed @nosent dirty bug
Note: changing a headline as *no effect* on an @nosent file!
The only bug was that redraw_after_head_changed must update icons.
#@+node:ekr.20100119145003.7358: *7* Allow horizontal scrolling in QtTree
#@+node:ekr.20100119145003.7531: *7* Correct binding of insert key
#@+node:ekr.20100119145003.7546: *7* Update tab names when the commander is dirty
#@+node:ekr.20100119145003.7612: *7* Made @nowrap work
#@+node:ekr.20100119145003.7618: *7* Added leoMoveCursorHelper
#@+node:ekr.20100119145003.7625: *7* Remember the ratios when the user moves splitters by hand.
#@+node:ekr.20100119145003.7629: *7* Chapter tabs require both_chapters and use_chapters_tabs
#@+node:ekr.20100119145003.7632: *7* Don't colorize directives unless they start a line
#@+node:ekr.20100119145003.7643: *7* Config coloring tags whenever the language changes
#@+node:ekr.20100119145003.7718: *7* Update qttabs when saving a new file
#@+node:ekr.20100124164700.11919: *6* Fixed colorizer bug affecting per-language @font settings
@nocolor-node

It looks like you should be able to put the following in an
@font node, and get restructured text bold to appear in bold on screen:

rest_keyword2_font_size = 16
rest_keyword2_font_family = Bitstream Charter
rest_keyword2_font_slant = roman
rest_keyword2_font_weight = bold

However nothing happens when I do this. The python examples in the
test.leo file work fine for me, so I'm not sure what's gone wrong.

I think that the following should also work, but it's also currently
not doing anything for me:

@color rest_keyword2_color = black

==================

Rev 2706 fixes a significant colorizer bug that caused your problem.
Previously, the colorizer inited the so-called configuration tags only
once, which is wrong. These tags are what the @font settings specify.
Now, the colorizer inits the tags when the language changes when
switching nodes.  Usually the language doesn't change, so the new code
will be approximately as fast as the old. 
#@+node:ekr.20100124164700.11920: *6* support extend-mode for several commands
'backward-find-character'
'find-character'
#@+node:ekr.20100124164700.11921: *6* Fixed qttab problem
@nocolor-node

On Mon, Jan 18, 2010 at 9:25 PM, tfer <tfetherston@aol.com> wrote:

cmd.exe /k C:\PyDev\leo-editor\trunk\launchLeo.py --gui=qttabs -- ipython

1) (??) the button removal menu just flash on right mouse click, disappears immediately.

2) Leo opens up the workbook, I open a new doc in a tab, 'untitled', save it,
   get saved ... in log, however, tab title does not change unless I close and
   reload it.
#@+node:ekr.20100124164700.11922: *6* <alt-x> select-all crashes python when focus is in headline
@
The problem occurs because the QtGui.QLineEdit object goes away
when the minibuffer gets focus and the QTreeWidget loses focus.

The fix: add a 'permanent' ivar to leoQtTextWidgets, and set
this ivar to False for headline widgets.
#@+node:ekr.20100124164700.11923: *6* Allow saving .leo files with undefined-sections
@nocolor-node

http://groups.google.com/group/leo-editor/browse_thread/thread/db797dd1d4dddffb

1) Create an @thin file based outline.
2) In the @thin file, create an unreferenced section (something like a
  header <<This Section Is Bogus>>).
3) Now, File->Exit
4) A dialog box pops up
  (Save changes to leo_file.leo before quitting? Yes/No/Cancel)
5) Click "Yes"
6) In the log pane, you will see: "undefined section" and "saved: leo_file.leo"
  and in the console window, you see "undefined section: ..."

The point is that I can't kill Leo if I keep saying "Yes" to the
"Save change before quitting" dialog. This is definitely not the
intended behavior. The correct behavior would be to save the file,
give me the warning about the undefined section, and exit.

EKR: The fix was simple: write_leo_file ignores the status returned from
c.atFileCommands.writeAll.

Note that Leo writes the write error to the console as well as the log pane,
so this should be safe enough.
#@+node:ekr.20100124164700.11924: *6* Refactored write_Leo_file
#@+node:ekr.20100124164700.11925: *6* Fixed print-bindings crasher w/ leo3k
#@+node:ekr.20100124164700.11926: *6* Fixed problem with already-existing .leo.bak files
@nocolor-node

I also unhappily discovered that any file named somedoc.leo.bak will
get deleted whenever you save a file named somedoc.leo.

===========

This turned into a major refactoring of write_Leo_file.
#@+node:ekr.20100124164700.11927: *6* Fixed sort children bug
https://bugs.launchpad.net/leo-editor/+bug/510148

The fix was in sortSiblings.
#@+node:ekr.20100124164700.11928: *6* Fixed unicode problems
@nocolor-node

- 'encoding' arg removed from appendStringToBody, setBodyString

- There are too many usages of _bodyString !!

- There is no way to give an encoding to setBodyString:
    It should give an internal error if the s arg is not unicode.
#@+node:ekr.20100124164700.11938: *6* Fixed crash in writeToFileHelper
#@+node:ekr.20100124164700.11944: *6* Add warnings when @file logic happens
#@+node:ekr.20100124164700.11946: *6* Fixed mkstemp bug
@nocolor-node

https://bugs.launchpad.net/leo-editor/+bug/510145

Current leo trunk, r2732, Slackware Linux

- I go to /tmp in terminal
- there is no aaa.leo there (this is important, see below why)
- I launch leo (the current working directory is /tmp)
- I select "File->Save as" menu item
- the save file dialog opens in /tmp, this is correct
- I type in the file name "aaa" then hit "Save" button
- leo dumps an error in the log pane:

exception renaming /tmp/aaa.leo to /tmp/tmpbNydoS
IOError: [Errno 2] No such file or directory: u'/tmp/aaa.leo'

=============

The solution was to create the backup file only if fileName exists.
#@+node:ekr.20100124164700.11951: *6* Removed most usage of _bodyString & _headString
@nocolor-node

Made sure _bodyString _headString used only in leoNodes.py.

We allow setting this vars in file reading code.

*** p.b/p.h setters call c.setBody/HeadString,
    which are very slow!
#@+node:ekr.20100124164700.11965: *6* Don't use tnodeList to separate old/new @file nodes
@nocolor-node

- Removed thinFile arg from atFile.read.
  atFile.read can uncache *any* cached file.
- Removed thinFile arg from initReadIvars.
- self.thinFile ivar set only in readOpenFile.
- atFile.read no longer calls scanHeaderForThin:
  we simply use the thinFile value returned by scanHeader.
- atFile.readOpenFile deletes children as needed.
#@+node:ekr.20100124164700.12027: *6* Eliminated warning re orphan nodes
#@+node:ekr.20100128094926.12524: *6* Eliminated node-changed marks
These marks were just annoying.
#@+node:ekr.20100128094926.12739: *6* Suppress path changed message in save-as and save-to
#@+node:ekr.20100128094926.12756: *6* Fixed Terry's unicode problem
Deleting a range of line containing unicode characters deletes too much.
#@+node:ekr.20100118181428.8525: *5* Features
#@+node:ekr.20100118181428.8815: *6* Leo supports Python 3.x
Leo requires Python 2.6 or above, including Python 3.0 and above.
#@+node:ekr.20100129054823.11928: *6* Improved file handling
- Leo now treats @file nodes just like it treats @thin nodes. This makes Leo
  much safer to use in cooperative environments that use source code control
  systems. As part of this change, Leo no longer supports @noref nodes.

- @auto-rst now works much more reliably.

- Leo now has a simple, robust, and extremely useful scheme to recover from
  clone conflicts, no matter how they may arise. This removes all the dread from
  "node changed" messages. It is easy to see what the changes were, and it is
  easy to choose what, if anything to do.

  When a clone conflict occurs, you will see a red message in the log pane and a
  "Recovered Nodes" node as the last top-level node. This node has one child per
  red message. Each of these children contains two nodes: an "old" node and a
  "new" node. Unless there are multiple conflicts for a single node, the "new"
  node will have "won": every clone contains the new node's headline and body
  text. All these nodes are plain nodes, *not* clones. It is up to you to change
  the corresponding clone nodes if you choose to do so.

- Leo minimizes unnecessary changes to .leo files. Leo writes outline-size and
  orientation to the cache in your .leo directory. This eliminates unnecessary
  changes to .leo files.

- Leo now creates temporary files in the systems standard temporary directory.
  This prevents Leo from over-writing user-generated .bak files.
#@+node:ekr.20100129054823.17683: *6* New command-line options
- The --debug command-line option sets g.debug.

- The --version command-line option causes Leo
  to print it's version and exit.

#@+node:ekr.20100129054823.11935: *6* Improved plugins
Added options for vim plugin. The setting::

    @string vim_trigger_event = icondclick2

is the default. It opens vim when the user double-clicks the icon box.
Alternatives are::

    @string vim_trigger_event = iconclick2
    @string vim_trigger_event = select2

The former opens vim on single clicks in the icon bar.
The latter opens vim whenever a new node is selected in Leo.

#@+node:ekr.20100129054823.17685: *6* New settings
The qt colorizer now supports font specifications in @font nodes.
#@+node:ekr.20100201192329.7018: *4* 4.7 beta 3
Leo 4.7 beta 3                       February 2, 2009

Leo 4.7 beta 3 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.7 beta 3 fixes all known serious bugs in Leo.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.7:
--------------------------

- Leo now uses the simplest possible internal data model.
  This is the so-called "one-node" world.
- Leo supports Python 3.x.
- Leo requires Python 2.6 or above.
- Several important improvements in file handling.
    - Leo converts @file nodes to @thin nodes automatically.
    - @auto-rst now works much more reliably reliably.
    - Leo no longer @noref trees.  Such trees are not
      reliable in cooperative environments.
- A new Windows installer.
- Many other features, including new command line options and new plugins.
- Dozens of bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20100201192329.7095: *5* Bugs fixed in Leo 4.7 b3
#@+node:ekr.20100201192329.7141: *6* Fixed unicode problems
'utf-8' is now the official, explicit unicode encoding unless overridden when
reading files.

This simplifies the code in several ways. In particular, the 'mbcs' encoding is
never used by default, and there is no g.app.defaultEncoding argument.

The rst3 command now uses 'utf-8' for all encodings unless explicitly overridden.
#@+node:ekr.20100201192329.7101: *6* paste-node-as-clone now sets dirty bits properly
This was a serious error.  It could cause clone clashes on later reloads.
#@+node:ekr.20100201192329.7106: *6* Fixed crasher in sort-siblings
This only happened if two nodes had the same headline.
#@+node:ekr.20100201192329.7108: *6* Fixed bug 515164: a crasher in p.positionExists
#@+node:ekr.20100201192329.7113: *6* Fixed problem with colon following @path
@nocolor-node

The problem arises because an @path directive ended with ':':

    @path: aPath

What I did:

- g.get_directives_dict now carefully checks for non-whitespace following a directive.
- The qt colorizer does the same.
- Added unit test to check for this.
#@+node:ekr.20100201192329.7116: *6* Code cleanup
Eliminated most imports from the leo/extensions folder.

#@+node:ekr.20100205152016.14053: *4* 4.7 rc 1
Leo 4.7 rc 1                    February 12, 2009

Leo 4.7 release candidate 1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.7 rc 1 fixes all known bugs in Leo, serious or minor.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.7:
--------------------------

- Leo now uses the simplest possible internal data model.
  This is the so-called "one-node" world.
- Leo supports Python 3.x.
- Leo requires Python 2.6 or above.
- Several important improvements in file handling.
    - Leo converts @file nodes to @thin nodes automatically.
    - Leo creates a 'Recovered Nodes' node to hold data that
      otherwise might be lost due to clone conflicts.
    - @auto-rst now works much more reliably reliably.
    - Leo no longer supports @noref trees.  Such trees are not
      reliable in cooperative environments.
- A new Windows installer.
- Many other features, including new command line options and new plugins.
- Dozens of bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20100205152016.14054: *5* Recovering from clone conflicts
Leo now has a simple, robust, and extremely useful scheme to recover from clone
battles, no matter how they may arise. This removes all the dread from "node
changed" messages. It is easy to see what the changes were, and it is easy to
choose what, if anything to do.

It is easy to test the code to see how it works:

1. Put a clone in an external file, and put another clone in Leo
outside of any external file.

2. Change the clone outside of Leo using an external editor.

3. Reload Leo.

When a clone conflict occurs, you will see a red message in the log pane and a
"Recovered Nodes" node as the last top-level node. This node has one child per
red message. Each of these children contains two nodes: an "old" node and a
"new" node. Unless there are multiple conflicts for a single node, the "new"
node will have "won": every clone contains the new node's headline and body
text. All these nodes are plain nodes, *not* clones. It is up to you to change
the corresponding clone nodes if you choose to do so.
#@+node:ekr.20100209160132.11690: *5* Bugs fixed
#@+node:ekr.20100209160132.11691: *6* Fixed unicode bug in setSelectionRangeHelper
#@+node:ekr.20100209160132.11692: *6* Home key no longer clears the minibuffer
@nocolor-node

The fix: back-to-home is now included in k.singleLineCommandList.
#@+node:ekr.20100209160132.11694: *6* Fixed bug in c.pasteOutline when run from unit tests
There was code in tnodeAttributes that did something brain-dead when unit
testing, just to support a unit test!
#@+node:ekr.20100209160132.11700: *6* Removed all references to isAtNorefFileNode
#@+node:ekr.20100209160132.11701: *6* Fixed inconsistency in how @path works
@nocolor-node

http://groups.google.com/group/leo-editor/browse_thread/thread/6d87d95ecbc3b986

If a @path directive is within the body text of an @thin node then the
file write uses the @path directive but the file read does not.  Since
the file read cannot know of the @path directive until after it has
read the file it has no choice but to not use it.  The @thin file
write code should not use any @path declarations found in its body
text.

What I did:

- Defined g.app.atPathInBodyWarning, set by g.get_directives_dict to p.h
- g.get_directives_dict also sets d['@path_in_body'] = p.h
- c.scanAtPathDirectives doesn't set the path if d['@path_in_body'] is true.
- atFile.scanAllDirectives issues a warning if g.app.atPathInBodyWarning is true,
  but only if the issuePathWarning keyword arg is true.
#@+node:ekr.20100209160132.11711: *6* Fixed crasher in path.py
@nocolor-node

Traceback (most recent call last):
  File "launchLeo.py", line 8, in <module>
    leo.core.runLeo.run()
  File "c:\leo.repo\trunk\leo\core\runLeo.py", line 95, in run
    ok = doPostPluginsInit(args,fn,relFn,script,versionFlag)
  File "c:\leo.repo\trunk\leo\core\runLeo.py", line 354, in doPostPluginsInit
    c,frame = createFrame(fileName,relativeFileName,script)
  File "c:\leo.repo\trunk\leo\core\runLeo.py", line 383, in createFrame
    ok, frame = g.openWithFileName(relativeFileName or fileName,None)
  File "c:\leo.repo\trunk\leo\core\leoGlobals.py", line 2439, in openWithFileName
    ok = g.handleOpenHooks(c,old_c,gui,fn,f,readAtFileNodesFlag)
  File "c:\leo.repo\trunk\leo\core\leoGlobals.py", line 2502, in handleOpenHooks
    readAtFileNodesFlag=readAtFileNodesFlag) # closes file.
  File "c:\leo.repo\trunk\leo\core\leoFileCommands.py", line 911, in open
    silent=silent)
  File "c:\leo.repo\trunk\leo\core\leoFileCommands.py", line 811, in getLeoFile
    c.atFileCommands.readAll(c.rootVnode(),partialFlag=False)
  File "c:\leo.repo\trunk\leo\core\leoAtFile.py", line 659, in readAll
    at.readOneAtAutoNode (fileName,p)
  File "c:\leo.repo\trunk\leo\core\leoAtFile.py", line 732, in readOneAtAutoNode
    self.writeCachedTree(p, cachefile)
  File "c:\leo.repo\trunk\leo\core\leoAtFile.py", line 593, in writeCachedTree
    elif cachefile in c.db:
  File "c:\leo.repo\trunk\leo\external\pickleshare.py", line 138, in __contains__
    return self.has_key(key)
  File "c:\leo.repo\trunk\leo\external\pickleshare.py", line 234, in has_key
    value = self[key]
  File "c:\leo.repo\trunk\leo\external\pickleshare.py", line 160, in __getitem__
    fil = self.root / key
  File "c:\leo.repo\trunk\leo\external\path.py", line 102, in __div__
    return path(os.path.join(self, rel))
  File "c:\python31\lib\ntpath.py", line 111, in join
    elif isabs(b):
  File "c:\python31\lib\ntpath.py", line 92, in isabs
    s = splitdrive(s)[1]
  File "c:\python31\lib\ntpath.py", line 198, in splitdrive
    if len(p) > 1:
TypeError: object of type 'NoneType' has no len()

c:\leo.repo\trunk>
#@+node:ekr.20100209160132.11712: *6* Fixed at-auto write bug
@nocolor-node

Adding a blank line did not change the file!

The culprit was the ignoreLineEndings logic in compareFiles.
A new unit test is needed.
#@+node:ekr.20100209160132.11718: *6* Fixed the critical 'file used by another process' bug
@nocolor-node

What I did:

- fc.createBackupFile now calls shutils.move directly,
  avoiding g.utils_rename which does way too much:
  it calls g.makeAllNonExistentDirectories(!!)

- Simplified g.utils_rename.  We can assume shutils exists.

- Removed an unwise call to g.utils_remove in g.utils_rename.
  This could cause havoc with the following call to
  shutils_move!!
#@+node:ekr.20100209160132.11736: *6* Alt-right should *not* go down
#@+node:ekr.20100209160132.11742: *6* Big change: simplified g.utils_rename
Removed call to g.makeAllNonExistentDirectories in g.utils_rename.

This has global effects. Happily, there were only three callers of g.utils_rename:

- handleWriteLeoFileException: should *not* create directories.

- x.rename: no longer used!
#@+node:ekr.20100209160132.11751: *6* Fixed cursor hangnail
Non-extending cursor moves now always clear the selection.
#@+node:ekr.20100209160132.11755: *6* Do a full redraw when contracting a cloned node
#@+node:ekr.20100209160132.11756: *6* Bug 399720: (fixed) goto-global-line doesn't work with @edit nodes
The title says it all.

This was likely fixed at rev 2438 of the trunk, in early October, 2009.
#@+node:ekr.20100209160132.11765: *6* Fixed unit test for leo_interface.py
@nocolor-node

The module imported correctly, but leoTest.checkFileSyntax was failing.

It was a whitespace problem--the fix was stripping '\r' characters in checkFileSyntax.
#@+node:ekr.20100209160132.11767: *6* Fixed g.getLastTracebackFileAndLineNubmer
#@+node:ekr.20100209160132.11770: *6* Fixed open-with crash
@nocolor-node

There may have been a bug in the (no-longer-existing) open_with plugin that allowed it to be active
when it shouldn't have been.
#@+node:ekr.20100209160132.11771: *7* Report
@nocolor-node

I am getting an exception when double-clicking to rename a node. The
exception does not occur when I rename a new node immediately
following creation while it is highlighted.

#---#
Leo Log Window
Leo 4.7 beta 3, build 2835, February 2, 2010
Python 3.1.1, qt version 4.6.1
Windows 6, 1, 7600, 2,
reading: C:\Users\skrivsm\Documents\toolbox\scratch\ruby_scratch.leo
creating:   newHeadline_LeoTemp_63898064.py
exception creating temp file
Traceback (most recent call last):
 File "C:\leo-editor\trunk\leo\core\leoCommands.py", line 1164, in
createOpenWithTempFile
   f.write(s)
TypeError: must be str, not bytes
recreating:   newHeadline_LeoTemp_63898064.py
exception creating temp file
Traceback (most recent call last):
 File "C:\leo-editor\trunk\leo\core\leoCommands.py", line 1164, in
createOpenWithTempFile
   f.write(s)
TypeError: must be str, not bytes
#---#
#@+node:ekr.20100209160132.11773: *6* Fixed bug 518823: clone headline updates
https://bugs.launchpad.net/leo-editor/+bug/518823

Clone headline modification not propagated after edit
#@+node:ekr.20100211125418.11596: *6* Removed duplicate can not open message for @auto file
#@+node:ekr.20100211125418.11599: *6* Fixed minor bug involving insertion point
This bug was highly annoying: it caused the newly-selected node to have the
insert point of a just-deleted node. This bug made it difficult, for example, to
delete nodes while examining the nodes created by clone-find-all.
#@+node:ekr.20100211125418.11602: *6* Fixed unicode crasher in write-recent-files logic
#@+node:ekr.20100211125418.11611: *5* New commands
#@+node:ekr.20100209160132.11888: *6* Created clear-cache and clear-all-caches commands
@nocolor-node

Global entries are in g.app.leoHomeDir/db/global

Per-leo-files entries are in g.app.homeLeoDir/db/<filename>_<hash>
#@+node:ekr.20100223063657.7262: *4* 4.7 final
Leo 4.7 final                    February 23, 2010

Leo 4.7 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.7 final fixes all known bugs in Leo.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.7:
--------------------------

- Leo now uses the simplest possible internal data model.
  This is the so-called "one-node" world.
- Leo supports Python 3.x.
- Leo requires Python 2.6 or above.
- Several important improvements in file handling.
    - Leo converts @file nodes to @thin nodes automatically.
    - Leo creates a 'Recovered Nodes' node to hold data that
      otherwise might be lost due to clone conflicts.
    - @auto-rst now works much more reliably reliably.
    - Leo no longer supports @noref trees.  Such trees are not
      reliable in cooperative environments.
- A new Windows installer.
- Many other features, including new command line options and new plugins.
- Dozens of bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20100223063657.7264: *5* Bug fixed
#@+node:ekr.20100223063657.7182: *6* Fixed calls to sort in 6 places
# This fixed a Python 3.x compatibility problem.
#@+node:ekr.20100223063657.7192: *6* Fix bug 363406: goto-global-line works with @auto files
#@+node:ekr.20100223063657.7212: *6* Put focus in a standard place after save commands
The edit pane lost focus after save commands.
#@+node:ekr.20100223063657.7232: *6* Fixed internal Leo error in atFile.read method
fileKey is needed even if force is True.
#@+node:ekr.20100223063657.7238: *6* Fixed wish-list bug 508108: No methods sub-nodes in PHP class import
https://bugs.launchpad.net/leo-editor/+bug/508108
#@+node:ekr.20100223063657.7245: *6* Fixed qt colorizer bug
Default fonts were not being properly restored after being overridden in another language.

For example, after colorizing php, python keywords looked like php keywords.
#@+node:ekr.20100223063657.7246: *6* Fixed ancient minibuffer bug
The bug: Find/change prompts were not fully protected after the user hit the
<home> key.
#@+node:ekr.20100223063657.7249: *6* Improved support for wrapping in the log pane
#@+node:ekr.20100223063657.7263: *6* Reformatted the output of the apropos commands
#@+node:ekr.20100225102026.7139: *4* 4.7.1 final
Leo 4.7.1 final                    February 26, 2010

Leo 4.7.1 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo 4.7.1 fixes a dangerous bug in Leo 4.7. When converting file-like sentinels
to thin-like sentinels in an external file, Leo now issues a warning and sets
the corresponding @file node dirty. This ensures that Leo will write the
converted external file and .leo file together, making it impossible to lose
data.

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.7:
--------------------------

- Leo now uses the simplest possible internal data model.
  This is the so-called "one-node" world.
- Leo supports Python 3.x.
- Leo requires Python 2.6 or above.
- Several important improvements in file handling.
    - Leo converts @file nodes to @thin nodes automatically.
    - Leo creates a 'Recovered Nodes' node to hold data that
      otherwise might be lost due to clone conflicts.
    - @auto-rst now works much more reliably reliably.
    - Leo no longer supports @noref trees.  Such trees are not
      reliable in cooperative environments.
- A new Windows installer.
- Many other features, including new command line options and new plugins.
- Dozens of bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20100225102026.7140: *5* Changes made to Leo 4.7.1
- Fixed a dangerous bug that could cause data loss when converting @file nodes
  from file-like to thin-like sentinels. The problem arose because it was too
  easy to save the .leo file (thus deleting the tnodeList) without forcing the
  converted external files to be saved. The next time Leo attempted to read the
  external files, the tnodeList would be missing and data would be lost.

  Leo's read logic now determines whether the file has file-like sentinels by
  reading the *uncached* contents of the file. When converting file-like
  sentinels to thin-like sentinels, Leo warns that it is converting the file and
  sets the @file node dirty. This ensures that Leo will write the converted
  external file whenever Leo writes the .leo file. This will make it impossible
  for a naive user to lose data. A sophisticated user might cause problems by
  using the write-outline-only command...

- Fixed expand/contract-pane commands.

- Fixed Python 3.x problems in delete-editor and cycle-editor-focus.

- Added a log message for show-colors saying the color picker does not exist for qt.

- Corrected date in trunk/license.txt.
#@+node:ekr.20101104091058.5045: *3* 4.8 Simpler sentinels, better installer, recovery nodes
#@+node:ekr.20101024234254.5433: *4* 4.8 a1
Leo 4.8 alpha 1                    October 29, 2010

Leo 4.8 alpha 1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.8:
--------------------------

- Leo now uses the simplest possible sentinel lines in external files.
  External files with sentinels now look like Emacs org-mode files.
- Leo Qt gui now supports Drag and Drop.
  This was one of the most frequently requested features.
- Improved abbreviation commands.
  You now define abbreviations in Leo settings nodes, not external files.
- @url nodes may contain url's in body text.
  This allows headlines to contain summaries: very useful.
- Leo now uses PyEnchant to check spelling.
- Leo can now open multiple files from the command line.
- Leo's ancient Tangle and Untangle commands are now deprecated.
  This will help newbies how to learn Leo.
- Leo now shows "Resurrected" and "Recovered" nodes.
  These protect data and show how data have changed.
  These fix several long-standing data-related problems.
- A new "screenshots" plugin for creating slide shows with Leo.
  I used this plugin to create Leo's introductory slide shows.
- A better installer.
- Many bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20101114081049.5004: *4* 4.8 b1
@nocolor

Leo 4.8 beta 1                               November 5, 2010

Leo 4.8 beta 1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.8:
--------------------------

- Leo now uses the simplest possible sentinel lines in external files.
  External files with sentinels now look like Emacs org-mode files.
- Leo Qt gui now supports Drag and Drop.
  This was one of the most frequently requested features.
- Improved abbreviation commands.
  You now define abbreviations in Leo settings nodes, not external files.
- @url nodes may contain url's in body text.
  This allows headlines to contain summaries: very useful.
- Leo now uses PyEnchant to check spelling.
- Leo can now open multiple files from the command line.
- Leo's ancient Tangle and Untangle commands are now deprecated.
  This will help newbies how to learn Leo.
- Leo now shows "Resurrected" and "Recovered" nodes.
  These protect data and show how data have changed.
  These fix several long-standing data-related problems.
- A new "screenshots" plugin for creating slide shows with Leo.
  I used this plugin to create Leo's introductory slide shows.
- Improved autocompletion: Ctrl-space starts a one-time completion.
- A better installer.
- Many bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20101104091058.4975: *4* 4.8 rc1
@nocolor

Leo 4.8 rc 1                               November 15, 2010

Leo 4.8 release candidate 1 is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.8:
--------------------------

- Leo now uses the simplest possible sentinel lines in external files.
  External files with sentinels now look like Emacs org-mode files.
- Leo Qt gui now supports Drag and Drop.
  This was one of the most frequently requested features.
- Improved abbreviation commands.
  You now define abbreviations in Leo settings nodes, not external files.
- @url nodes may contain url's in body text.
  This allows headlines to contain summaries: very useful.
- Leo now uses PyEnchant to check spelling.
- Leo can now open multiple files from the command line.
- Leo's ancient Tangle and Untangle commands are now deprecated.
  This will help newbies how to learn Leo.
- Leo now shows "Resurrected" and "Recovered" nodes.
  These protect data and show how data have changed.
  These fix several long-standing data-related problems.
- A new "screenshots" plugin for creating slide shows with Leo.
  I used this plugin to create Leo's introductory slide shows.
- Improved autocompletion: Ctrl-space starts a one-time completion.
- A better installer.
- Many bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20101104091058.4976: *5* Known problems
There are at least 2 installer issues outstanding:

1. Installing to the "Program Files" folder or the "Program Files
(x86)" folder can cause some unit tests to fail due to permission
issues.  I don't think this is too serious.

2. Installing to the "Program Files (x86)" folder can cause PyEnchant
not to find the spellpyx.txt folder.  This looks like a bug in
PyEnchant.
#@+node:ekr.20101104173324.5140: *5* New in 4.8 a1
#@+node:ekr.20101104091058.4977: *6* Bugs
#@+node:ekr.20101104091058.4978: *7* Significant bugs
#@+node:ekr.20101104091058.4979: *8* Fixed vampire nodes and created p.deletePositionsInList
# Also, created a "Resurrected Nodes" node to handle such nodes cleanly and safely.
#@+node:ekr.20101104091058.4980: *9* Post re vampire nodes
Vampire nodes from cvs

I've just discovered a major problem with cvs updates.  It is a subtle
consequence of how Leo writes outlines and reads derived files.  This
is a big bug in Leo, not cvs.  The effect of the bug is that nodes can
appear in derived files that were never written to them!

The discovery of this 'big bug' came about as the result of the
following Aha:

**@thin files that contain @all directives should be a cvs binary (-kb) files.**

The reason is straightforward:  cvs doesn't know enough to merge such
files.  Maybe all @thin derived files should be -kb files, but Leo's
users will never agree to that!

Anyway, leoProjects.txt is now a binary file as far as cvs is
concerned.  Other .txt files, like leoScripts.txt, should also be
binary files.  As we shall see, the fact that leoProjects.txt is now a
-kb file means that we can not possibly blame the cvs merge algorithm
for what is about to happen.

Ok, back to the 'big bug'.  Here is how I got bitten:

- I changed leoProjects.txt in two sandboxes 1 and 2.  In sandbox 1 I
added a node called 'changed in the main line'.  In sandbox 2 I added
a node called 'changed2'.

- I changed LeoPyRef.leo in sandbox 2, but *not* in sandbox 1.

- I did a update in sandbox 2.

As expected (now that leoProjects.txt is a binary file) I got the
following from cvs:

M src/LeoPyRef.leo
...
cvs update: nonmergeable file needs merge
cvs update: revision 1.448 from repository is now in src/
leoProjects.txt
cvs update: file from working directory is now in .#leoProjects.txt.
1.447

To summarize the update:

- LeoPyRef.leo has been marked as modified (M), but it has **not**
been changed by cvs.

- As expected, leoProjects.txt contains the version from sandbox **1**.

So far, so good.  But when I opened LeoPyRef.leo I got a huge
surprise: the outline contains **both** the node 'changed in main-
line' and the node 'changed2'!

How did this happen?  Well, obviously the 'changed in main-line' node
came from the cvs update.  I expected that.  The 'changed2' line must
have come from the local copy of LeoPyRef.leo.

Once I knew what to look for it wasn't too hard to discover what had
happened.  The 'changed2' is a descendant of a cloned node called '4.4
projects'.

- One clone of '4.4 projects' node is a descendant of the @thin
leoProjects.txt node.

- Another clone of the '4.4 project' is in the LeoPyRef.leo file but
outside of any @thin node.

So the 'resurrection' of the 'changed2' node happened while Leo was
reading leoProjects.txt into LeoPyRef.leo.  The '4.4 projects' node
**already existed in the outline** before Leo read leoProjects.txt,
and the present atFile read logic only **adds** nodes, it never
deletes nodes.  Thus, the 'changed2' node 'survived' the atFile read
logic.  The 'changed2' node became a 'vampire' node that couldn't be
killed.

The problem is far from benign.  Because of clones, the vampire node
became an orphan node in **another** file, namely leoKeys.py.  I tried
two or three times to remove the vampire/orphan node before realizing
what had happened.

The fix (there is *always* a fix) will require some care.  The present
atFile.read logic is robust because it *doesn't* delete nodes.  It is
essential that the read logic remain robust.  I suspect the solutions
will be as follows:

A. The atFile.read code can not delete the subtree of @thin nodes
initially, because it doesn't know whether there will be read errors
later.  If there are read errors absolutely nothing must change.  This
ensures that read errors never destroy information.

B. A new post-pass will look for vampire nodes: nodes that were not
actually read from the derived file.  I think (but haven't proven)
that all descendants of vampire nodes are also vampire nodes.  If that
is so the post-pass will simply delete vampire nodes without worrying
about whether they have descendants.

Warning: the new scheme will mean that cvs update can destroy
information that previously existed in the outline.  I believe this is
correct: we assume that derived files are the 'truly meaningful'
files.  Hey, if we are wrong we can always get the old info from
cvs :-)
QQQ

At present, atFile.read contains code to warn of "resurrected" nodes,
and I did indeed get such a warning when the recent problem arose.

After a quick look at atFile.read, I strongly suspect that the problem
remains today pretty much exactly as it was in 2003.  The only
difference is that the caching code (the call to
root.v.createOutlineFromCacheList(c,aList)) doesn't do the check:
\<\< advise user to delete all unvisited nodes \>\>
that is done later in read(). That probably should be fixed.

Finding a better solution to vampire nodes has been on the list since
2003.  It's not easy because it involves the dreaded "multiple delete"
problem.

Hmm.  The present read code *does* delete the tree before reading thin
external files.  So it appears that vampire nodes could only be
expected in external files derived from @file nodes.  It may be that
part of the problem is that somehow Leo thinks that it is reading an
@file node?? That's pretty weird, but messages about resurrected nodes
and missing tnode lists did happen.  It's quite a puzzle.

Edward
#@+node:ekr.20101104091058.4981: *8* Fixed bug 577047: Invalid @path directory does not warn user
Specifying a @path directory causes Leo to save an "@thin file.ext" node below
it in Leo's home directory without any warning. The next time Leo is opened it
issues an error that it can not find the file.

It should instead issue a warning that the @path directory does not exist.

If this occurs when the saving of @thin nodes to files is performed as part of
the user closing Leo, the closing of Leo should be aborted to prevent the loss
of data.

===== The Aha

The computation of at./ic.default_directory **must not** attempt to create
directories! It's too early for that!

This simplifies all aspects of the code:

- No need to report errors & no need to recover from errors.
- at.scanAllDirectives can call c.

===== The actual fix:

Due to a previous fix, at.writeAllAtFileNodesHelper does *not* report errors.
This causes Leo to clear all dirty bits.

The proper fix, therefore, is to force a write of the entire @edit tree in
putVnode if it is orphaned.

Similarly, putVnode now forces writes of @auto and @shadow trees.

#@+node:ekr.20101104091058.4986: *8* Fixed @shadow problem
http://groups.google.com/group/leo-editor/browse_thread/thread/dbe098206376ec8d

The fixes are marked # 2010/10/22 in << handle the opcode >>.
#@+node:ekr.20101104173324.4924: *8* Don't write tnodes of @file nodes!
putVnode must test for @file just like @thin.
#@+node:ekr.20101104091058.4988: *7* Minor bugs
#@+node:ekr.20101104091058.4989: *8* Fixed the @test logic for external files
#@+node:ekr.20101104091058.4990: *8* Fixed save scrolling bug
- Open a node with long (multi-page) body text
- Move cursor towards the end of the node
- Save (ctrl+s)
- Observe how window is scrolled, cursor is moved
#@+node:ekr.20101104091058.4991: *8* Fixed at-auto-rst crash
#@+node:ekr.20101104091058.4992: *8* Don't put &nbsp; in redirected log
https://bugs.launchpad.net/leo-editor/+bug/549319

Leo 4.7.1 final, build 3005, February 26, 2010
Python 2.6.2, qt version 4.5.2
Windows 5, 1, 2600, 2, Service Pack 3

When redirecting the output to the Log pane using g.redirectStderr() and
g.redirectStdout(), the output displays non-breaking space characters (&nbsp;)
everywhere there is supposed to be a space.

For example, if I run print 'Hello World' I get Hello&nbsp;World in the Log
pane. This is really hard to read when you have 50 or 100 lines of numbers from
the output of a program.
#@+node:ekr.20101104091058.4993: *8* Fixed crash in log pane
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 366, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\core\leoKeys.py", line 284, in autoComplete
    k.masterCommand(event,func=None,stroke=None,commandName=None)
  File "c:\leo.repo\trunk\leo\core\leoKeys.py", line 2606, in masterCommand
    val = k.handleDefaultChar(event,stroke)
  File "c:\leo.repo\trunk\leo\core\leoKeys.py", line 2664, in handleDefaultChar
    if stroke.lower() == 'return': stroke = '\n'
AttributeError: 'NoneType' object has no attribute 'lower'
#@+node:ekr.20101104091058.4994: *8* Fixed at-auto-rst bug
#@+node:ekr.20101104091058.4995: *8* Fixed erroneous error message in at-auto-rst read logic
#@+node:ekr.20101104091058.4996: *8* Fixed crasher in openFileForReading
#@+node:ekr.20101104091058.4997: *8* Fixed Java import problem
On Windows, using Leo trunk from a few days ago, I get "error: class
class does not end in a newline; one will be added [nl]" on what seems
to be every imported java chunk.

This issue seems to be line-ending related and I duplicated it with a
simple test.  When I run the following code from within a Leo node, I
get the same error as when I tried to import the file.
#@+node:ekr.20101104091058.4999: *8* Fixed gloto-global-line
#@+node:ekr.20101104091058.5000: *8* Fixed rst3 bug with docutils on py3k
#@+node:ekr.20101104091058.5001: *8* fixed bug 618474: show_leo_directives
https://bugs.launchpad.net/leo-editor/+bug/618474

in core/leoRst the method removeLeoDirectives seems not to remove the leo directives.
which results in @leo directives inside generated rst code.

The problematic code line is the statement "g.match_word(s, 0,key)" in the following block:

                for key in self.leoDirectivesList:
                    if g.match_word(s, 0,key):
                        #g.trace('removing %s' % s)
                        break

As far as I understand the function match_word, it returns 1 if s contains key at index 0,
The self.leoDirectivesList contains all directive like color, language, ... (without @) but
s is a complete body line that looks like: @language rest

That means language starts at index 1 not at 0.
changing the line to
  g.match_word(s, 1,key)

let it work correctly in my installation (4.7.1)
#@+node:ekr.20101104091058.5002: *8* fixed bug 618482: code-mode line feeds
https://bugs.launchpad.net/leo-editor/+bug/618482

in leoRst.py:

the method "handleCodeMode" does not preserve line linefeeds of the original code. While this is only annoying for code
parts it is fatal for doc parts, because rst directives does not work anymore.

The problem is in the line "elif not z.rstrip(): pass" of the following code block at the end of the method
        for z in result:
            if z == '': result2.append('\n\n')
            elif not z.rstrip(): pass
            elif z.endswith('\n\n'): result2.append(z) # Leave alone.
            else: result2.append('%s\n' % z.rstrip())

Commenting this line out, preserves the linefeeds in the doc part but doubles them in the code part.

The method "rstripList" is responsible for the doubling linefeeds:
   The lines arguments is a list of lines with (!) trailing linefeeds (\n),

   The statement s = '\n'.join(theList).rstrip() doubles therefore the linefeeds
    replacing the line with s = ''.join(theList).rstrip() works.
#@+node:ekr.20101104091058.5003: *8* Fixed weave (and many similar) commands
#@+node:ekr.20101104091058.5004: *8* Shorter warnings about incompatible gui type
#@+node:ekr.20101104091058.5005: *8* Improved @enabled-plugins: ignore lines starting with '@'
Also give calmer messages for non-existent plugins.
#@+node:ekr.20101104091058.5006: *8* Fixed bug in runUnitTestLeoFile
Replace ';' by os.pathsep.
#@+node:ekr.20101104091058.5007: *8* Fixed crasher with del in minibuffer
Changed w to self in leoQLineEditWidget.setInsertPoint.
#@+node:ekr.20101104091058.5008: *8* Ignore F-Keys & Ins in the minibuffer.
k.fullCommand now ignores fkeys and Ins.
#@+node:ekr.20101104091058.5009: *8* Fixed bug 618570: leoRst: option strip_at_file_prefixes...
leoRst: option strip_at_file_prefixes does not strip file prefixes in leo 4.7.1

The problematic code is in method underline of class rstCommands.
The last statement:

  return '%s\n%s\n\n' % (p.h.strip(),ch*n)

returns the full heading and not stripped one, (in the s parameter)
#@+node:ekr.20101104091058.5010: *8* Fixed bug 622802: Go to clone" switches to the first chapter
If one or more chapters exist (other than main), "Go to clone" switches to the
first chapter, whether or not the clone is in that chapter.

The new code always selects the main chapter.
This is the simplest thing that could possibly work.
Other approaches are fraught with difficulties.
#@+node:ekr.20101104091058.5011: *8* Fixed unicode bug in files
I created a file time.leo. When it's in the dir d:/Dmitry it's being
opened fine. But when I put it into the dir with Russian characters:
D:/Личное/Время leo prints squares at the window header and doesn't
open the file correctly. This problem existed in one of the revisions,
then it was fixed in the last official release. Now it emerged again
in my Leo 4.8 devel, build 3005

Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoGlobals.py", line 3307, in pr
    sys.stdout.write(s2)
  File "c:\python31\lib\encodings\cp437.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]

UnicodeEncodeError: 'charmap' codec can't encode character '\xc2' in position
31: character maps to <undefined> path changed for @thin
Unicode-Â-folder/unicode-Â-test2.txt created:
C:\Users\edreamleo\Unicode-Â-folder\unicode-Â-test2.txt
#@+node:ekr.20101104091058.5012: *8* Eliminated check python syntax commands, but retained code
@nocolor-node

Removed the check-all-python-code and check-python code commands
(and removed the references to these commands in menus.)

- Retained the actual code for scripts.
- Retained automatic syntax checking of python files on saves

The problem with separate commands is that they don't necessarily check an
entire file: things like 'return' in a node that doesn't look it is in a
function.

Directives and section references are not the problem:
they get translated to comments before the check.
#@+node:ekr.20101104091058.5013: *8* Improved handling of history
nav_qt.py just uses these:

    c.goPrevVisitedNode()
    c.goNextVisitedNode()

and these subsequently use leoCommand.py / class nodeHistory.

The fix would have to happen in leoFrame.py / selectHelper() which does this:

    c.nodeHistory.update(p) # Remember this position.

It shouldn't call update() there. Rather, the call should be moved to
wherever body focus code is.

The fix was to leoTree.selectHelper and qtBody.onFocusIn.

#@+node:ekr.20101104091058.5014: *8* Remember whether @asis/@nosent existed at read time
Removed all traces of the "significant change" logic. The read code remembers
whether a node existed when Leo loaded the outline.

Leo will warn when writing a node that didn't previously exist. This is a nice
simplification of the code.
#@+node:ekr.20101104091058.5015: *8* Added g.app.config.config_iter
This simplifies the print-settings command.
#@+node:ekr.20101104091058.5016: *6* Code features
#@+node:ekr.20101104091058.5017: *7* Added g.findTestScript
http://groups.google.com/group/leo-editor/browse_thread/thread/a108d70400b28dc9#

g.findTestScript is an important new pattern for sharing code in Leo scripts,
including scripts in @test nodes.

Suppose there is common code that I want to include in several unit tests::

    class Hello():
        def __init__(self,name='john'):
            self.name=name
            print('hello %s' % name)

I put this in a node called 'Common test code'.

The unit tests can "import" the code as follows::

    exec(g.findTestScript('Common test code'))

Now class Hello is available the test code!

This is something that I've wanted to do forever.  It's almost too
easy.  I suppose it's a small security problem, but so is every other
@test node!
#@+node:ekr.20101104091058.5018: *7* Added p.deletePositionsInList
http://groups.google.com/group/leo-editor/browse_thread/thread/e3c736bc9f545b7e#

This is an important new helper.
#@+node:ekr.20101104173324.4920: *7* Leo is more clever in putting up the Leo id dialog
g.app.setLeoID now calls createDefaultGui instead of createTkGui.

We can *not* put up the LeoID dialog later: it is needed to set
g.app.nodeIndices, which is used in the read logic for outlines, so it *must* be
set before we load any Leo file!

#@+node:ekr.20101104173324.4921: *7* Simplified leoPlugins code
There are some tricky issues here:

http://groups.google.com/group/leo-editor/browse_thread/thread/4da36f0d897a25e8

Important: g.loadOnePlugin calls the plugins onCreate method to make up for
events that have already been generated. pc.loadOnePlugin does not.
#@+node:ekr.20101104173324.4923: *7* Patched @test logic
# Begin patch

=== modified file 'leo/core/leoTest.py'
@@ -697,9 +696,10 @@

     # 2010/03/05: set the current directory so that importing leo.core.whatever works.
     leoDir = g.os_path_finalize_join(g.app.loadDir,'..','..')
-    os.chdir(leoDir)
-
-    os.spawnve(os.P_NOWAIT,sys.executable,args,os.environ)

+    #os.chdir(leoDir)
+    env = dict(os.environ)
+    env['PYTHONPATH'] = env.get('PYTHONPATH', '')+';'+leoDir
+    os.spawnve(os.P_NOWAIT,sys.executable,args,env)
#@+node:ekr.20101104091058.5019: *6* Commands
#@+node:ekr.20101104091058.5020: *7* Added legend for print-settings command
#@+node:ekr.20101104091058.5021: *7* Added code-to-rst command
# And deprecated code mode.
#@+node:ekr.20101104091058.5022: *7* Removed mark-clones command
It is useless in the one-node world.
#@+node:ekr.20101104091058.5023: *7* Improved abbreviation commands
http://groups.google.com/group/leo-editor/browse_thread/thread/24cb88a8c2a20a07#

- Space activates abbreviations.
- Multi-line abbreviations handled properly.
- add-global-abbrev command uses entire selected text as the value of the abbreviation.
- Inserted abbreviations are undoable.
- Added support for @data abbreviations and @data global-abbreviations.
- Added support for @bool enable-abbreviations.

apropos-abbreviations
=====================

When abbreviation mode is on (abbrev-mode toggles this mode) Leo will expand
abbreviations as you type. Type the name of an abbreviation, followed by a
space. As soon as you type the space, Leo will replace the name by the
abbreviations value. You can undo the replacement as usual.

Note that defining any abbreviation automatically turns on abbreviation mode.

The add-global-abbreviation command (<alt-x>add-gl<tab><return>) takes the
selected text as the replacement value of the abbreviation. The minibuffer
prompts you for the name of the abbreviation.
#@+node:ekr.20101104091058.5150: *7* Completed cascade-windows and minimize-all-windows commands
#@+node:ekr.20101104091058.5252: *7* Created head-to-prev-node and tail-to-next-node commands
@nocolor-node

https://bugs.launchpad.net/leo-editor/+bug/611413

These work around the lack of AI in Python's importer.

Added leoImport.findClass helper.

The head-to-prev-node command moves non-empty text preceding a class, method or
function definition to the end of the previous sibling node.

The tail-to-next-node command moves non-empty text following a class, method or
function definition to the start of the next sibling node.
#@+node:ekr.20101104091058.5024: *6* Documentation
#@+node:ekr.20101104091058.5025: *7* Created introductory slide shows
#@+node:ekr.20101104091058.5026: *7* Reorganized Users Guide
http://groups.google.com/group/leo-editor/browse_thread/thread/d02df89c0b831a7c

I created my own copy of the home page:

    Files-->@edit leo_toc.html

This allows me to group items without creating special pages.
#@+node:ekr.20101104091058.5027: *6* Features
#@+node:ekr.20101104091058.5028: *7* New sentinels
#@+node:ekr.20101104091058.5029: *7* Don't create @chapter node for new file
I think @chapters node shouldn't be in a new leo file, but it should
be created when the first chapter is created.

Ditto for the chapter selector toolbar button.
#@+node:ekr.20101104091058.5030: *7* Improved install instructions & logic
http://groups.google.com/group/leo-editor/browse_thread/thread/a5a47afa65af9a37

The following changes are on the trunk, and also on Leo's web site:

- In home page, added link to Install page, just above the Beginner's Guide.

- Added more explicit instructions for installing Tk and Qt.

- In step 6 of the Windows install steps, the "assoc .leo=LeoFile"
  is on a line by itself.

- Updated home page to indicate that Leo requires Python and PyQt.
  I also revised and simplified the introduction in other ways.
  Ditto for description of Leo on SourceForge.

- Changed "%1" to "%*" throughout the installation instructions.

- Made batch files given in Installing Leo and Running Leo the same.

- The dialogs that ask for the Leo ID now tells why Leo needs it.

- Just before raising the dialog that asks for the Leo ID, Leo attempts
  to create the Qt Gui first, and then the Tk Gui if Qt does not exist.
  This should make it much less likely that a prompt for the id
  will be sent to the console.


2. The readme.txt file for 4.7.1-final does not mention that Python and PyQt is
   required.

readme.txt does say it has a new Windows installer. This
led me to believe -- erroneously -- that the Windows installer is all
I would need to download and install, since it's typical for most open
source programs I've used to have everything needed for the install
(for example. .NET) in the single Windows download.

2b. And perhaps the readme.txt file as well?

Can the [install] page be updated to make this clearer?

4. When I first went to the Install page, I clicked on the link for
"Installing Leo on Windows", got to the end of the steps and saw the
next section was "Tracking the development version" which I wasn't
interested in doing so I didn't read any further.

Clicking on the installer-created Windows link for Leo on the Start
Menu did nothing. Eventually I found the Windows section under
"Running Leo" and learned it was required to run Leo the first time
from a console window and not by launching it from Windows.
#@+node:ekr.20101104091058.5031: *7* DnD outline nodes
DnD creates @file or @auto nodes if appropriate
#@+node:ekr.20101104091058.5032: *7* write @edit nodes like @nosent nodes
#@+node:ekr.20101104091058.5033: *7* Leo now uses PyEnchant to check spelling
http://groups.google.com/group/leo-editor/browse_thread/thread/62ac1977b3704590#

#@+node:ekr.20101104091058.5034: *7* Improved @url nodes
Having to type the url after @url in headline is annoying.

The @url handler should look into the first line of body for url, if the text in
the headline is not an url. This way, the headline could actually be
descriptive.

I know some plugin does this, but there is no reason why this couldn't be the
default behavior.
#@+node:ekr.20101104091058.5035: *7* Made sure that all @auto nodes end with a newline
The fix was to the "if not trailingNewlineFlag:" code at the end of at.putBody.
#@+node:ekr.20101104091058.5036: *7* Improved language support
- improved support for elisp.

    - Use @language lisp instead of @language elisp.

- added importer for .ini files.
#@+node:ekr.20101104091058.5037: *6* Settings
#@+node:ekr.20101104091058.5038: *7* Allow multiple files on the command line
Refactored g.app.config.readSettingsFiles.

Settings now honored in workbook.

* Window size not honored when opened from menu.
#@+node:ekr.20101104091058.5039: *7* Allow proportional fonts in plain text
http://groups.google.com/group/leo-editor/browse_thread/thread/e6075a699909db53

You can now set a proportional font to use in all "@language plain" nodes

Specify fonts in @font nodes:

@font plain null font

plain_null_font_family = Times New Roman
plain_null_font_size = 16
plain_null_font_slant = roman
plain_null_font_weight = bold

That is, the actual font specs are in the body text.  Everything
except @font is ignored in the headline.

Specify colors in @color nodes:

@color plain null color = black
#@+node:ekr.20101104091058.5040: *7* Allow changing minibuffer colors
Added the following options with the indicated defaults.

\@color minibuffer_background_color = lightblue
\@color minibuffer_warning_color = lightgrey
#@+node:ekr.20101104091058.5041: *7* Added support for @string qt-toolbar-location
Valid values are top,bottom,left,right
#@+node:ekr.20101104091058.5042: *7* Support @bool write_expansion_bits_in_leo_files
#@+node:ekr.20101104091058.5043: *7* Added support for slideshow plugin
Command-line args
#@+node:ekr.20101104091058.5044: *7* New settings for abbreviations
@bool enable-abbreviations (default: False)

  When true, enables substitution of abbreviations.

@data global-abbreviations
@data abbreviations

  In both cases, body text contains lines of
  the form::

   name=value

  name is the abbreviation name, value is the substituted text. Whitespace is
  ignore around the name, but is significant in the value. Abbreviation names
  may contain only alphabetic characters, but may start with the '@' sign.

  By *convention* @data global-abbreviations setting should be defined in
  myLeoSettings.leo, while @data abbreviations should be defined in other .leo
  files. Regardless of where they are defined, abbreviations in @data
  abbreviation nodes will override settings (with the same name) in @data
  global-abbreviations nodes.
#@+node:ekr.20101104173324.5021: *5* New in 4.8 b1
#@+node:ekr.20101104173324.5142: *6* Bugs
#@+node:ekr.20101104173324.5023: *7* Fixed bug 603720: @auto parsing error on dedented triple quote string
The code that calculates the end of a block of indented Python code now takes
take more care with backslashes.
#@+node:ekr.20101104173324.5028: *7* Fixed bug 597757: c.frame.body.getSelectedText() doesn't work in added editors
#@+node:ekr.20101104173324.5102: *7* Fixed bug 604115: chapter-{clone,copy}-node-to broken
- Added better prompts for move/copy/clone commands.

- Undo/redo of these commands select the main chapter.
#@+node:ekr.20101104173324.5138: *7* Made sure proper install.txt appears
@nocolor-node

http://groups.google.com/group/leo-editor/browse_thread/thread/dea95cd8ab976cac


> > * The file 'INSTALL.TXT' contains the outline text with sentinels from
> > 'Chapter 1: Installing Leo'

There are *two* files called install.txt: the one that should
contain installation instructions and the one that contains the
"Installing Leo" chapter.

The solution was to change install.txt to installing.txt in the users guide.
#@+node:ekr.20101104173324.5031: *6* Completed cascade-windows and minimize-all-windows commands
#@+node:ekr.20101104173324.5032: *6* Improved present autocompleter
Allow "always on" operation:

- Ctrl-space is now bound to force-auto-completion

- Remove Alt-1 and Alt-2 default bindings.
#@+node:ekr.20101104173324.5133: *6* Created head-to-prev-node and tail-to-next-node commands
http://bugs.launchpad.net/leo-editor/+bug/611413

These work around the lack of AI in Python's importer.

The head-to-prev-node command moves non-empty text preceding a class, method or
function definition to the end of the previous sibling node.

The tail-to-next-node command moves non-empty text following a class, method or
function definition to the start of the next sibling node.
#@+node:ekr.20101105082829.4917: *6* Put non-def code in their own node
Fixed wishlist bug 670744: add a setting to put inter-def code in its own node

Added support for @bool at_auto_separate_non_def_nodes option.
The default (legacy mode) is False.
#@+node:ekr.20101114081049.5090: *5* New in 4.8 rc1
#@+node:ekr.20101114081049.5101: *6* Revised many plugins
@nocolor-node

Removed the keybindings.py plugin.  The print-bindings command should suffice.

The plugins_menu.py has been renamed old_plugin_menu.py to indicate that it
needs a lot of work to become functional.

The following plugins are now gui-independent (the used to be Tk only):

at_produce.py
chapter_hoist.py
import_cisco_config.py
macros.py
mod_read_dir_outline.py
multifile.py
read_only_nodes.py
word_count.py
xsltWithNodes.py

I also registered the menu2 event instead of the open2 event in all plugins that
use this event to create menus. This is required because a relatively recent
change creates menus *after* the open2 event happens.
#@+node:ekr.20101114081049.5102: *6* Fixed crasher in UNL.py: recursiveUNLSearch
#@+node:ekr.20101114081049.5103: *6* Big improvement to execute-script command
execute-script now calls execfile (or its equivalent when using Python 3k)
when @bool write_script_file = True.

This allows pdb to show the text of scripts!
#@+node:ekr.20101114081049.5108: *6* Added extract-python-method command
This should have been done *ages* ago. The command makes it easy to put python
methods in separate nodes.

Select a range of text, the first line of which starts with 'def foo (...)'

Do alt-x extract-python-method (or ctrl-p if you are repeating the command).

What happens:

- Creates a new child node whose headline is 'foo'.

- The body of foo contains all the selected text, properly indented.

The command is undoable.
#@+node:ekr.20101115085632.4928: *6* Open the default leo file if possible
Leo opens the file specified by the default_leo_file setting if it exists.

New in 4.8 rc1: if default (workbook) file does not exist Leo will
open an empty file and name is to be the default file.
#@+node:ekr.20101115085632.4930: *6* Fixed problems with installer
The installer now makes proper entries in the Windows start menu.
#@+node:ekr.20101124102457.5135: *4* 4.8 final
@nocolor

Leo 4.8 final                               November 26, 2010

Leo 4.8 final is now available at:
http://sourceforge.net/project/showfiles.php?group_id=3458&package_id=29106

Leo is a text editor, data organizer, project manager and much more. See:
http://leoeditor.com/tutorial.html

The highlights of Leo 4.8:
--------------------------

- Leo now uses the simplest possible sentinel lines in external files.
  External files with sentinels now look like Emacs org-mode files.
- Leo Qt gui now supports Drag and Drop.
  This was one of the most frequently requested features.
- Improved abbreviation commands.
  You now define abbreviations in Leo settings nodes, not external files.
- @url nodes may contain url's in body text.
  This allows headlines to contain summaries: very useful.
- Leo now uses PyEnchant to check spelling.
- Leo can now open multiple files from the command line.
- Leo's ancient Tangle and Untangle commands are now deprecated.
  This will help newbies how to learn Leo.
- Leo now shows "Resurrected" and "Recovered" nodes.
  These protect data and show how data have changed.
  These fix several long-standing data-related problems.
- A new "screenshots" plugin for creating slide shows with Leo.
  I used this plugin to create Leo's introductory slide shows.
- Improved autocompletion: Ctrl-space starts a one-time completion.
- A better installer.
- Many bug fixes.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/project/showfiles.php?group_id=3458
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20101124102457.5136: *5* Known problems
There are at least 2 installer issues outstanding:

1. Installing to the "Program Files" folder or the "Program Files
(x86)" folder can cause some unit tests to fail due to permission
issues.  I don't think this is too serious.

2. Installing to the "Program Files (x86)" folder can cause PyEnchant
not to find the spellpyx.txt folder.  This looks like a bug in
PyEnchant.
#@+node:ekr.20101124102457.5137: *5* New in 4.8 a1
#@+node:ekr.20101124102457.5138: *6* Bugs
#@+node:ekr.20101124102457.5139: *7* Significant bugs
#@+node:ekr.20101124102457.5140: *8* Fixed vampire nodes and created p.deletePositionsInList
# Also, created a "Resurrected Nodes" node to handle such nodes cleanly and safely.
#@+node:ekr.20101124102457.5141: *9* Post re vampire nodes
Vampire nodes from cvs

I've just discovered a major problem with cvs updates.  It is a subtle
consequence of how Leo writes outlines and reads derived files.  This
is a big bug in Leo, not cvs.  The effect of the bug is that nodes can
appear in derived files that were never written to them!

The discovery of this 'big bug' came about as the result of the
following Aha:

**@thin files that contain @all directives should be a cvs binary (-kb) files.**

The reason is straightforward:  cvs doesn't know enough to merge such
files.  Maybe all @thin derived files should be -kb files, but Leo's
users will never agree to that!

Anyway, leoProjects.txt is now a binary file as far as cvs is
concerned.  Other .txt files, like leoScripts.txt, should also be
binary files.  As we shall see, the fact that leoProjects.txt is now a
-kb file means that we can not possibly blame the cvs merge algorithm
for what is about to happen.

Ok, back to the 'big bug'.  Here is how I got bitten:

- I changed leoProjects.txt in two sandboxes 1 and 2.  In sandbox 1 I
added a node called 'changed in the main line'.  In sandbox 2 I added
a node called 'changed2'.

- I changed LeoPyRef.leo in sandbox 2, but *not* in sandbox 1.

- I did a update in sandbox 2.

As expected (now that leoProjects.txt is a binary file) I got the
following from cvs:

M src/LeoPyRef.leo
...
cvs update: nonmergeable file needs merge
cvs update: revision 1.448 from repository is now in src/
leoProjects.txt
cvs update: file from working directory is now in .#leoProjects.txt.
1.447

To summarize the update:

- LeoPyRef.leo has been marked as modified (M), but it has **not**
been changed by cvs.

- As expected, leoProjects.txt contains the version from sandbox **1**.

So far, so good.  But when I opened LeoPyRef.leo I got a huge
surprise: the outline contains **both** the node 'changed in main-
line' and the node 'changed2'!

How did this happen?  Well, obviously the 'changed in main-line' node
came from the cvs update.  I expected that.  The 'changed2' line must
have come from the local copy of LeoPyRef.leo.

Once I knew what to look for it wasn't too hard to discover what had
happened.  The 'changed2' is a descendant of a cloned node called '4.4
projects'.

- One clone of '4.4 projects' node is a descendant of the @thin
leoProjects.txt node.

- Another clone of the '4.4 project' is in the LeoPyRef.leo file but
outside of any @thin node.

So the 'resurrection' of the 'changed2' node happened while Leo was
reading leoProjects.txt into LeoPyRef.leo.  The '4.4 projects' node
**already existed in the outline** before Leo read leoProjects.txt,
and the present atFile read logic only **adds** nodes, it never
deletes nodes.  Thus, the 'changed2' node 'survived' the atFile read
logic.  The 'changed2' node became a 'vampire' node that couldn't be
killed.

The problem is far from benign.  Because of clones, the vampire node
became an orphan node in **another** file, namely leoKeys.py.  I tried
two or three times to remove the vampire/orphan node before realizing
what had happened.

The fix (there is *always* a fix) will require some care.  The present
atFile.read logic is robust because it *doesn't* delete nodes.  It is
essential that the read logic remain robust.  I suspect the solutions
will be as follows:

A. The atFile.read code can not delete the subtree of @thin nodes
initially, because it doesn't know whether there will be read errors
later.  If there are read errors absolutely nothing must change.  This
ensures that read errors never destroy information.

B. A new post-pass will look for vampire nodes: nodes that were not
actually read from the derived file.  I think (but haven't proven)
that all descendants of vampire nodes are also vampire nodes.  If that
is so the post-pass will simply delete vampire nodes without worrying
about whether they have descendants.

Warning: the new scheme will mean that cvs update can destroy
information that previously existed in the outline.  I believe this is
correct: we assume that derived files are the 'truly meaningful'
files.  Hey, if we are wrong we can always get the old info from
cvs :-)
QQQ

At present, atFile.read contains code to warn of "resurrected" nodes,
and I did indeed get such a warning when the recent problem arose.

After a quick look at atFile.read, I strongly suspect that the problem
remains today pretty much exactly as it was in 2003.  The only
difference is that the caching code (the call to
root.v.createOutlineFromCacheList(c,aList)) doesn't do the check:
\<\< advise user to delete all unvisited nodes \>\>
that is done later in read(). That probably should be fixed.

Finding a better solution to vampire nodes has been on the list since
2003.  It's not easy because it involves the dreaded "multiple delete"
problem.

Hmm.  The present read code *does* delete the tree before reading thin
external files.  So it appears that vampire nodes could only be
expected in external files derived from @file nodes.  It may be that
part of the problem is that somehow Leo thinks that it is reading an
@file node?? That's pretty weird, but messages about resurrected nodes
and missing tnode lists did happen.  It's quite a puzzle.

Edward
#@+node:ekr.20101124102457.5142: *8* Fixed bug 577047: Invalid @path directory does not warn user
Specifying a @path directory causes Leo to save an "@thin file.ext" node below
it in Leo's home directory without any warning. The next time Leo is opened it
issues an error that it can not find the file.

It should instead issue a warning that the @path directory does not exist.

If this occurs when the saving of @thin nodes to files is performed as part of
the user closing Leo, the closing of Leo should be aborted to prevent the loss
of data.

===== The Aha

The computation of at./ic.default_directory **must not** attempt to create
directories! It's too early for that!

This simplifies all aspects of the code:

- No need to report errors & no need to recover from errors.
- at.scanAllDirectives can call c.

===== The actual fix:

Due to a previous fix, at.writeAllAtFileNodesHelper does *not* report errors.
This causes Leo to clear all dirty bits.

The proper fix, therefore, is to force a write of the entire @edit tree in
putVnode if it is orphaned.

Similarly, putVnode now forces writes of @auto and @shadow trees.

#@+node:ekr.20101124102457.5143: *8* Fixed @shadow problem
http://groups.google.com/group/leo-editor/browse_thread/thread/dbe098206376ec8d

The fixes are marked # 2010/10/22 in << handle the opcode >>.
#@+node:ekr.20101124102457.5144: *8* Don't write tnodes of @file nodes!
putVnode must test for @file just like @thin.
#@+node:ekr.20101124102457.5145: *7* Minor bugs
#@+node:ekr.20101124102457.5146: *8* Fixed the @test logic for external files
#@+node:ekr.20101124102457.5147: *8* Fixed save scrolling bug
- Open a node with long (multi-page) body text
- Move cursor towards the end of the node
- Save (ctrl+s)
- Observe how window is scrolled, cursor is moved
#@+node:ekr.20101124102457.5148: *8* Fixed at-auto-rst crash
#@+node:ekr.20101124102457.5149: *8* Don't put &nbsp; in redirected log
https://bugs.launchpad.net/leo-editor/+bug/549319

Leo 4.7.1 final, build 3005, February 26, 2010
Python 2.6.2, qt version 4.5.2
Windows 5, 1, 2600, 2, Service Pack 3

When redirecting the output to the Log pane using g.redirectStderr() and
g.redirectStdout(), the output displays non-breaking space characters (&nbsp;)
everywhere there is supposed to be a space.

For example, if I run print 'Hello World' I get Hello&nbsp;World in the Log
pane. This is really hard to read when you have 50 or 100 lines of numbers from
the output of a program.
#@+node:ekr.20101124102457.5150: *8* Fixed crash in log pane
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 366, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\core\leoKeys.py", line 284, in autoComplete
    k.masterCommand(event,func=None,stroke=None,commandName=None)
  File "c:\leo.repo\trunk\leo\core\leoKeys.py", line 2606, in masterCommand
    val = k.handleDefaultChar(event,stroke)
  File "c:\leo.repo\trunk\leo\core\leoKeys.py", line 2664, in handleDefaultChar
    if stroke.lower() == 'return': stroke = '\n'
AttributeError: 'NoneType' object has no attribute 'lower'
#@+node:ekr.20101124102457.5151: *8* Fixed at-auto-rst bug
#@+node:ekr.20101124102457.5152: *8* Fixed erroneous error message in at-auto-rst read logic
#@+node:ekr.20101124102457.5153: *8* Fixed crasher in openFileForReading
#@+node:ekr.20101124102457.5154: *8* Fixed Java import problem
On Windows, using Leo trunk from a few days ago, I get "error: class
class does not end in a newline; one will be added [nl]" on what seems
to be every imported java chunk.

This issue seems to be line-ending related and I duplicated it with a
simple test.  When I run the following code from within a Leo node, I
get the same error as when I tried to import the file.
#@+node:ekr.20101124102457.5155: *8* Fixed gloto-global-line
#@+node:ekr.20101124102457.5156: *8* Fixed rst3 bug with docutils on py3k
#@+node:ekr.20101124102457.5157: *8* fixed bug 618474: show_leo_directives
https://bugs.launchpad.net/leo-editor/+bug/618474

in core/leoRst the method removeLeoDirectives seems not to remove the leo directives.
which results in @leo directives inside generated rst code.

The problematic code line is the statement "g.match_word(s, 0,key)" in the following block:

                for key in self.leoDirectivesList:
                    if g.match_word(s, 0,key):
                        #g.trace('removing %s' % s)
                        break

As far as I understand the function match_word, it returns 1 if s contains key at index 0,
The self.leoDirectivesList contains all directive like color, language, ... (without @) but
s is a complete body line that looks like: @language rest

That means language starts at index 1 not at 0.
changing the line to
  g.match_word(s, 1,key)

let it work correctly in my installation (4.7.1)
#@+node:ekr.20101124102457.5158: *8* fixed bug 618482: code-mode line feeds
https://bugs.launchpad.net/leo-editor/+bug/618482

in leoRst.py:

the method "handleCodeMode" does not preserve line linefeeds of the original code. While this is only annoying for code
parts it is fatal for doc parts, because rst directives does not work anymore.

The problem is in the line "elif not z.rstrip(): pass" of the following code block at the end of the method
        for z in result:
            if z == '': result2.append('\n\n')
            elif not z.rstrip(): pass
            elif z.endswith('\n\n'): result2.append(z) # Leave alone.
            else: result2.append('%s\n' % z.rstrip())

Commenting this line out, preserves the linefeeds in the doc part but doubles them in the code part.

The method "rstripList" is responsible for the doubling linefeeds:
   The lines arguments is a list of lines with (!) trailing linefeeds (\n),

   The statement s = '\n'.join(theList).rstrip() doubles therefore the linefeeds
    replacing the line with s = ''.join(theList).rstrip() works.
#@+node:ekr.20101124102457.5159: *8* Fixed weave (and many similar) commands
#@+node:ekr.20101124102457.5160: *8* Shorter warnings about incompatible gui type
#@+node:ekr.20101124102457.5161: *8* Improved @enabled-plugins: ignore lines starting with '@'
Also give calmer messages for non-existent plugins.
#@+node:ekr.20101124102457.5162: *8* Fixed bug in runUnitTestLeoFile
Replace ';' by os.pathsep.
#@+node:ekr.20101124102457.5163: *8* Fixed crasher with del in minibuffer
Changed w to self in leoQLineEditWidget.setInsertPoint.
#@+node:ekr.20101124102457.5164: *8* Ignore F-Keys & Ins in the minibuffer.
k.fullCommand now ignores fkeys and Ins.
#@+node:ekr.20101124102457.5165: *8* Fixed bug 618570: leoRst: option strip_at_file_prefixes...
leoRst: option strip_at_file_prefixes does not strip file prefixes in leo 4.7.1

The problematic code is in method underline of class rstCommands.
The last statement:

  return '%s\n%s\n\n' % (p.h.strip(),ch*n)

returns the full heading and not stripped one, (in the s parameter)
#@+node:ekr.20101124102457.5166: *8* Fixed bug 622802: Go to clone" switches to the first chapter
If one or more chapters exist (other than main), "Go to clone" switches to the
first chapter, whether or not the clone is in that chapter.

The new code always selects the main chapter.
This is the simplest thing that could possibly work.
Other approaches are fraught with difficulties.
#@+node:ekr.20101124102457.5167: *8* Fixed unicode bug in files
I created a file time.leo. When it's in the dir d:/Dmitry it's being
opened fine. But when I put it into the dir with Russian characters:
D:/Личное/Время leo prints squares at the window header and doesn't
open the file correctly. This problem existed in one of the revisions,
then it was fixed in the last official release. Now it emerged again
in my Leo 4.8 devel, build 3005

Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoGlobals.py", line 3307, in pr
    sys.stdout.write(s2)
  File "c:\python31\lib\encodings\cp437.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]

UnicodeEncodeError: 'charmap' codec can't encode character '\xc2' in position
31: character maps to <undefined> path changed for @thin
Unicode-Â-folder/unicode-Â-test2.txt created:
C:\Users\edreamleo\Unicode-Â-folder\unicode-Â-test2.txt
#@+node:ekr.20101124102457.5168: *8* Eliminated check python syntax commands, but retained code
@nocolor-node

Removed the check-all-python-code and check-python code commands
(and removed the references to these commands in menus.)

- Retained the actual code for scripts.
- Retained automatic syntax checking of python files on saves

The problem with separate commands is that they don't necessarily check an
entire file: things like 'return' in a node that doesn't look it is in a
function.

Directives and section references are not the problem:
they get translated to comments before the check.
#@+node:ekr.20101124102457.5169: *8* Improved handling of history
nav_qt.py just uses these:

    c.goPrevVisitedNode()
    c.goNextVisitedNode()

and these subsequently use leoCommand.py / class nodeHistory.

The fix would have to happen in leoFrame.py / selectHelper() which does this:

    c.nodeHistory.update(p) # Remember this position.

It shouldn't call update() there. Rather, the call should be moved to
wherever body focus code is.

The fix was to leoTree.selectHelper and qtBody.onFocusIn.

#@+node:ekr.20101124102457.5170: *8* Remember whether @asis/@nosent existed at read time
Removed all traces of the "significant change" logic. The read code remembers
whether a node existed when Leo loaded the outline.

Leo will warn when writing a node that didn't previously exist. This is a nice
simplification of the code.
#@+node:ekr.20101124102457.5171: *8* Added g.app.config.config_iter
This simplifies the print-settings command.
#@+node:ekr.20101124102457.5172: *6* Code features
#@+node:ekr.20101124102457.5173: *7* Added g.findTestScript
http://groups.google.com/group/leo-editor/browse_thread/thread/a108d70400b28dc9#

g.findTestScript is an important new pattern for sharing code in Leo scripts,
including scripts in @test nodes.

Suppose there is common code that I want to include in several unit tests::

    class Hello():
        def __init__(self,name='john'):
            self.name=name
            print('hello %s' % name)

I put this in a node called 'Common test code'.

The unit tests can "import" the code as follows::

    exec(g.findTestScript('Common test code'))

Now class Hello is available the test code!

This is something that I've wanted to do forever.  It's almost too
easy.  I suppose it's a small security problem, but so is every other
@test node!
#@+node:ekr.20101124102457.5174: *7* Added p.deletePositionsInList
http://groups.google.com/group/leo-editor/browse_thread/thread/e3c736bc9f545b7e#

This is an important new helper.
#@+node:ekr.20101124102457.5175: *7* Leo is more clever in putting up the Leo id dialog
g.app.setLeoID now calls createDefaultGui instead of createTkGui.

We can *not* put up the LeoID dialog later: it is needed to set
g.app.nodeIndices, which is used in the read logic for outlines, so it *must* be
set before we load any Leo file!

#@+node:ekr.20101124102457.5176: *7* Simplified leoPlugins code
There are some tricky issues here:

http://groups.google.com/group/leo-editor/browse_thread/thread/4da36f0d897a25e8

Important: g.loadOnePlugin calls the plugins onCreate method to make up for
events that have already been generated. pc.loadOnePlugin does not.
#@+node:ekr.20101124102457.5177: *7* Patched @test logic
# Begin patch

=== modified file 'leo/core/leoTest.py'
@@ -697,9 +696,10 @@

     # 2010/03/05: set the current directory so that importing leo.core.whatever works.
     leoDir = g.os_path_finalize_join(g.app.loadDir,'..','..')
-    os.chdir(leoDir)
-
-    os.spawnve(os.P_NOWAIT,sys.executable,args,os.environ)

+    #os.chdir(leoDir)
+    env = dict(os.environ)
+    env['PYTHONPATH'] = env.get('PYTHONPATH', '')+';'+leoDir
+    os.spawnve(os.P_NOWAIT,sys.executable,args,env)
#@+node:ekr.20101124102457.5178: *6* Commands
#@+node:ekr.20101124102457.5179: *7* Added legend for print-settings command
#@+node:ekr.20101124102457.5180: *7* Added code-to-rst command
# And deprecated code mode.
#@+node:ekr.20101124102457.5181: *7* Removed mark-clones command
It is useless in the one-node world.
#@+node:ekr.20101124102457.5182: *7* Improved abbreviation commands
http://groups.google.com/group/leo-editor/browse_thread/thread/24cb88a8c2a20a07#

- Space activates abbreviations.
- Multi-line abbreviations handled properly.
- add-global-abbrev command uses entire selected text as the value of the abbreviation.
- Inserted abbreviations are undoable.
- Added support for @data abbreviations and @data global-abbreviations.
- Added support for @bool enable-abbreviations.

apropos-abbreviations
=====================

When abbreviation mode is on (abbrev-mode toggles this mode) Leo will expand
abbreviations as you type. Type the name of an abbreviation, followed by a
space. As soon as you type the space, Leo will replace the name by the
abbreviations value. You can undo the replacement as usual.

Note that defining any abbreviation automatically turns on abbreviation mode.

The add-global-abbreviation command (<alt-x>add-gl<tab><return>) takes the
selected text as the replacement value of the abbreviation. The minibuffer
prompts you for the name of the abbreviation.
#@+node:ekr.20101124102457.5183: *7* Completed cascade-windows and minimize-all-windows commands
#@+node:ekr.20101124102457.5184: *7* Created head-to-prev-node and tail-to-next-node commands
@nocolor-node

https://bugs.launchpad.net/leo-editor/+bug/611413

These work around the lack of AI in Python's importer.

Added leoImport.findClass helper.

The head-to-prev-node command moves non-empty text preceding a class, method or
function definition to the end of the previous sibling node.

The tail-to-next-node command moves non-empty text following a class, method or
function definition to the start of the next sibling node.
#@+node:ekr.20101124102457.5189: *6* Documentation
#@+node:ekr.20101124102457.5190: *7* Created introductory slide shows
#@+node:ekr.20101124102457.5191: *7* Reorganized Users Guide
http://groups.google.com/group/leo-editor/browse_thread/thread/d02df89c0b831a7c

I created my own copy of the home page:

    Files-->@edit leo_toc.html

This allows me to group items without creating special pages.
#@+node:ekr.20101124102457.5192: *6* Features
#@+node:ekr.20101124102457.5193: *7* New sentinels
#@+node:ekr.20101124102457.5194: *7* Don't create @chapter node for new file
I think @chapters node shouldn't be in a new leo file, but it should
be created when the first chapter is created.

Ditto for the chapter selector toolbar button.
#@+node:ekr.20101124102457.5195: *7* Improved install instructions & logic
http://groups.google.com/group/leo-editor/browse_thread/thread/a5a47afa65af9a37

The following changes are on the trunk, and also on Leo's web site:

- In home page, added link to Install page, just above the Beginner's Guide.

- Added more explicit instructions for installing Tk and Qt.

- In step 6 of the Windows install steps, the "assoc .leo=LeoFile"
  is on a line by itself.

- Updated home page to indicate that Leo requires Python and PyQt.
  I also revised and simplified the introduction in other ways.
  Ditto for description of Leo on SourceForge.

- Changed "%1" to "%*" throughout the installation instructions.

- Made batch files given in Installing Leo and Running Leo the same.

- The dialogs that ask for the Leo ID now tells why Leo needs it.

- Just before raising the dialog that asks for the Leo ID, Leo attempts
  to create the Qt Gui first, and then the Tk Gui if Qt does not exist.
  This should make it much less likely that a prompt for the id
  will be sent to the console.


2. The readme.txt file for 4.7.1-final does not mention that Python and PyQt is
   required.

readme.txt does say it has a new Windows installer. This
led me to believe -- erroneously -- that the Windows installer is all
I would need to download and install, since it's typical for most open
source programs I've used to have everything needed for the install
(for example. .NET) in the single Windows download.

2b. And perhaps the readme.txt file as well?

Can the [install] page be updated to make this clearer?

4. When I first went to the Install page, I clicked on the link for
"Installing Leo on Windows", got to the end of the steps and saw the
next section was "Tracking the development version" which I wasn't
interested in doing so I didn't read any further.

Clicking on the installer-created Windows link for Leo on the Start
Menu did nothing. Eventually I found the Windows section under
"Running Leo" and learned it was required to run Leo the first time
from a console window and not by launching it from Windows.
#@+node:ekr.20101124102457.5196: *7* DnD outline nodes
DnD creates @file or @auto nodes if appropriate
#@+node:ekr.20101124102457.5197: *7* write @edit nodes like @nosent nodes
#@+node:ekr.20101124102457.5198: *7* Leo now uses PyEnchant to check spelling
http://groups.google.com/group/leo-editor/browse_thread/thread/62ac1977b3704590#

#@+node:ekr.20101124102457.5199: *7* Improved @url nodes
Having to type the url after @url in headline is annoying.

The @url handler should look into the first line of body for url, if the text in
the headline is not an url. This way, the headline could actually be
descriptive.

I know some plugin does this, but there is no reason why this couldn't be the
default behavior.
#@+node:ekr.20101124102457.5200: *7* Made sure that all @auto nodes end with a newline
The fix was to the "if not trailingNewlineFlag:" code at the end of at.putBody.
#@+node:ekr.20101124102457.5201: *7* Improved language support
- improved support for elisp.

    - Use @language lisp instead of @language elisp.

- added importer for .ini files.
#@+node:ekr.20101124102457.5202: *6* Settings
#@+node:ekr.20101124102457.5203: *7* Allow multiple files on the command line
Refactored g.app.config.readSettingsFiles.

Settings now honored in workbook.

* Window size not honored when opened from menu.
#@+node:ekr.20101124102457.5204: *7* Allow proportional fonts in plain text
http://groups.google.com/group/leo-editor/browse_thread/thread/e6075a699909db53

You can now set a proportional font to use in all "@language plain" nodes

Specify fonts in @font nodes:

@font plain null font

plain_null_font_family = Times New Roman
plain_null_font_size = 16
plain_null_font_slant = roman
plain_null_font_weight = bold

That is, the actual font specs are in the body text.  Everything
except @font is ignored in the headline.

Specify colors in @color nodes:

@color plain null color = black
#@+node:ekr.20101124102457.5205: *7* Allow changing minibuffer colors
Added the following options with the indicated defaults.

\@color minibuffer_background_color = lightblue
\@color minibuffer_warning_color = lightgrey
#@+node:ekr.20101124102457.5206: *7* Added support for @string qt-toolbar-location
Valid values are top,bottom,left,right
#@+node:ekr.20101124102457.5207: *7* Support @bool write_expansion_bits_in_leo_files
#@+node:ekr.20101124102457.5208: *7* Added support for slideshow plugin
Command-line args
#@+node:ekr.20101124102457.5209: *7* New settings for abbreviations
@bool enable-abbreviations (default: False)

  When true, enables substitution of abbreviations.

@data global-abbreviations
@data abbreviations

  In both cases, body text contains lines of
  the form::

   name=value

  name is the abbreviation name, value is the substituted text. Whitespace is
  ignore around the name, but is significant in the value. Abbreviation names
  may contain only alphabetic characters, but may start with the '@' sign.

  By *convention* @data global-abbreviations setting should be defined in
  myLeoSettings.leo, while @data abbreviations should be defined in other .leo
  files. Regardless of where they are defined, abbreviations in @data
  abbreviation nodes will override settings (with the same name) in @data
  global-abbreviations nodes.
#@+node:ekr.20101124102457.5210: *5* New in 4.8 b1
#@+node:ekr.20101124102457.5211: *6* Bugs
#@+node:ekr.20101124102457.5212: *7* Fixed bug 603720: @auto parsing error on dedented triple quote string
The code that calculates the end of a block of indented Python code now takes
take more care with backslashes.
#@+node:ekr.20101124102457.5213: *7* Fixed bug 597757: c.frame.body.getSelectedText() doesn't work in added editors
#@+node:ekr.20101124102457.5214: *7* Fixed bug 604115: chapter-{clone,copy}-node-to broken
- Added better prompts for move/copy/clone commands.

- Undo/redo of these commands select the main chapter.
#@+node:ekr.20101124102457.5215: *7* Made sure proper install.txt appears
@nocolor-node

http://groups.google.com/group/leo-editor/browse_thread/thread/dea95cd8ab976cac


> > * The file 'INSTALL.TXT' contains the outline text with sentinels from
> > 'Chapter 1: Installing Leo'

There are *two* files called install.txt: the one that should
contain installation instructions and the one that contains the
"Installing Leo" chapter.

The solution was to change install.txt to installing.txt in the users guide.
#@+node:ekr.20101124102457.5216: *6* Completed cascade-windows and minimize-all-windows commands
#@+node:ekr.20101124102457.5217: *6* Improved present autocompleter
Allow "always on" operation:

- Ctrl-space is now bound to force-auto-completion

- Remove Alt-1 and Alt-2 default bindings.
#@+node:ekr.20101124102457.5218: *6* Created head-to-prev-node and tail-to-next-node commands
http://bugs.launchpad.net/leo-editor/+bug/611413

These work around the lack of AI in Python's importer.

The head-to-prev-node command moves non-empty text preceding a class, method or
function definition to the end of the previous sibling node.

The tail-to-next-node command moves non-empty text following a class, method or
function definition to the start of the next sibling node.
#@+node:ekr.20101124102457.5219: *6* Put non-def code in their own node
Fixed wishlist bug 670744: add a setting to put inter-def code in its own node

Added support for @bool at_auto_separate_non_def_nodes option.
The default (legacy mode) is False.
#@+node:ekr.20101124102457.5220: *5* New in 4.8 rc1
#@+node:ekr.20101124102457.5221: *6* Revised many plugins
@nocolor-node

Removed the keybindings.py plugin.  The print-bindings command should suffice.

The plugins_menu.py has been renamed old_plugin_menu.py to indicate that it
needs a lot of work to become functional.

The following plugins are now gui-independent (the used to be Tk only):

at_produce.py
chapter_hoist.py
import_cisco_config.py
macros.py
mod_read_dir_outline.py
multifile.py
read_only_nodes.py
word_count.py
xsltWithNodes.py

I also registered the menu2 event instead of the open2 event in all plugins that
use this event to create menus. This is required because a relatively recent
change creates menus *after* the open2 event happens.
#@+node:ekr.20101124102457.5222: *6* Fixed crasher in UNL.py: recursiveUNLSearch
#@+node:ekr.20101124102457.5223: *6* Big improvement to execute-script command
execute-script now calls execfile (or its equivalent when using Python 3k)
when @bool write_script_file = True.

This allows pdb to show the text of scripts!
#@+node:ekr.20101124102457.5224: *6* Added extract-python-method command
This should have been done *ages* ago. The command makes it easy to put python
methods in separate nodes.

Select a range of text, the first line of which starts with 'def foo (...)'

Do alt-x extract-python-method (or ctrl-p if you are repeating the command).

What happens:

- Creates a new child node whose headline is 'foo'.

- The body of foo contains all the selected text, properly indented.

The command is undoable.
#@+node:ekr.20101124102457.5225: *6* Open the default leo file if possible
Leo opens the file specified by the default_leo_file setting if it exists.

New in 4.8 rc1: if default (workbook) file does not exist Leo will
open an empty file and name is to be the default file.
#@+node:ekr.20101124102457.5226: *6* Fixed problems with installer
The installer now makes proper entries in the Windows start menu.
#@+node:ekr.20101124102457.5227: *5* New in 4.8 final
- Fixed key redefinition message.
#@+node:ekr.20110531155858.19246: *3* 4.9 Qt only, autocompleter, vr pane
Leo 4.9 final              June 21, 2011

Leo 4.9 final is now available at:
http://sourceforge.net/projects/leo/files/

Leo is a text editor, data organizer, project manager and much more.
See: http://leoeditor.com/tutorial.html

The highlights of Leo 4.9:
--------------------------

- The Qt gui completely replaces the Tk gui--Qt gui now has all essential
  features of Tk, including plugins.

- Completed Leo's autocompleter.

- The rendering pane can now display movies, html, svg images, etc.

- Nodes may contain multiple @language directives.

- Leo highlights URL's everywhere. Ctrl-click URL's opens them in your web
  browser. 

- Leo uses an @file node's extension by default if there is no @language
  directive in effect.
  
- Unified extract and import commands.

- Leo can now colorize multiple @language directives in a single node.

- Plain up/down arrow keys in headline-editing mode select a new node.

- New commands to insert, delete, change or print uA's.

- Added namespace directive to .leo files.

- Fixed many bugs, some important, most quite minor.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/projects/leo/files/
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20110601105631.19359: *4* Deprecated/removed features
- Leo no longer supports the Tk gui. The Qt gui now does everything
  the Tk gui did, and more, and better.

- Removed show/hide/toggle minibuffer commands. The minibuffer is an essential
  part of Leo.
  
- These settings are no longer used::
    
    @string selected-background-color
    @string selected-command-background-color
    
- The import-at-root command is no longer supported.
#@+node:ekr.20110531155858.19830: *4* Bugs fixed in b1
#@+node:ekr.20110604043410.17811: *5* Numbered bugs
- Fixed bug 682561: pyenchant install problem.

  https://bugs.launchpad.net/leo-editor/+bug/682561

- Fix bug 690260: g.es sends to wrong tabbed pane.

  https://bugs.launchpad.net/leo-editor/+bug/690260

- Fixed bug 783617: Can't enter text directly in the Find panel

  https://bugs.launchpad.net/leo-editor/+bug/783617

- Fixed bug 681797: Shift-Delete not working in Qt

  https://bugs.launchpad.net/leo-editor/+bug/681797

- Fixed bug 622819: Ctrl-Shift movement is incorrect

  https://bugs.launchpad.net/leo-editor/+bug/622819

  Ctrl-Shift movement (back-word-extend-selection, forward-word-extend-selection)
  was incorrect when there is an existing selection, which was created by some
  method other than Ctrl-Shift movement.

- Resolved bug 323967: leo overrides minibuffer background color.

  https://bugs.launchpad.net/leo-editor/+bug/323967

- Fixed actionscript colors for parens.

  http://groups.google.com/group/leo-editor/browse_thread/thread/ee09fb2c2a5316f2/490fa7cddab36fab

- Fixed Bug 760531:Spurious overwrite warnings.

  https://bugs.launchpad.net/leo-editor/+bug/760531

- Fixed important bug involving orphan nodes

  http://groups.google.com/group/leo-editor/browse_thread/thread/861a0d156b16090f

  This was an important bug. It's been around for a very long time. What I did:
        
    - putVnode no longer clears the orphan bit.
    
    - at.read issues a warning and does not read the external file if the orphan bit is set.

- Fixed bug: show-invisibles now correctly shows blank lines.

- Fixed bug 766747: fill-paragraph doesn't respect setting from set-fill-column.

  https://bugs.launchpad.net/leo-editor/+bug/766747

  The fill-paragraph, center-line and center-region now all use the fill column
  if it has been explicitly set (and greater than zero). Otherwise, these
  commands use the @pagewidth value. Previously, the fill-paragraph command used
  the page width set by the @pagewidth directive, or an initial value from a
  @setting if no @pagewidth directive was in effect.

- Fixed bug 583878: Leo should warn about @comment/@delims clashes.

  https://bugs.launchpad.net/leo-editor/+bug/583878

  Leo now warns when a node contains both @comment and @delims directives.

- Fixed bug 778204: @verbatim not forbidden in body text.

  https://bugs.launchpad.net/leo-editor/+bug/778204

  Leo now generates an error for sentinels that look like @verbatim.

- Fixed bug 784920: @raw mode does not ignore directives.

  https://bugs.launchpad.net/leo-editor/+bug/784920

- Fixed bug 527717: Qt gui should enable/disable menu items.

  https://bugs.launchpad.net/leo-editor/+bug/527717

- Fixed bug 580328: c.frame.toggleSplitDirection() doesn't preserve existing ratio.

  https://bugs.launchpad.net/leo-editor/+bug/580328

- Fixed bug 581031: Scrollbar position is not preserved when
  c.frame.toggleSplitDirection() is executed.

  https://bugs.launchpad.net/leo-editor/+bug/581031

  toggleSplitDirection new ensures that both the selected outline node *and* the
  cursor in the body pane are visible.


- Fixed bug 525004: bash code not colored properly.

    https://bugs.launchpad.net/leo-editor/+bug/525004

    1. Fixed an off-by-one error in getNextToken. This was causing the havoc in
       the shell coloring.
    
    2. match_mark_following now does *nothing* (fails) if there is no next token.
       This is a major change, and it allows more rules to match in the shell
       colorer.
       
- Fixed bug 626587: Menus & dialogs now say "Flatten Selected Outline".

  https://bugs.launchpad.net/leo-editor/+bug/626587
#@+node:ekr.20110604043410.17812: *5* Other bugs
** Changing @language directives now forces a recoloring.

  This fixed the most annoying hangnail remaining in Leo.

** Removed remaining tk-isms from Leo's core.

  These were real bugs: they prevent emacs commands from working.

  Completely rewrote transposeWords.
  
** mod_autosave plugin no longer registers redundant idle-time handlers.

** Fixed mod_http plugin.

** Mark external file dirty when dragging node.

- Disabled the rst button in the contextmenu.

- Fixed horizontal scroll glitch in log pane (Python 2.x).
  qtLog.put sets horizontal scrolling to zero.
  This is a workaround to a glitch (Python 2.x only),
  but in fact it's generally useful.

- Fixed bug: auto-rst gives spurious overwrite message.

- Added bindings to all text widgets in the tab frame.

- Fixed goto-global-line problems.

- Restore positions of non-tabbed windows.

- Fixed Python 3.2 ua problems.

- Fixed bug in p._adjustPostionBeforeUnlink and simplified code.

- Fixed crash in archivedPositionToPosition.

- Fixed top-level uA's. There was a misspelling of 'unknownAttributes' in
  putVnode. This caused the uA for the first top level node in the outline to be
  cleared on save and by some copy paste ops.

- Fixed bug: Leo now ignores f-keys in find/replace patterns.

- c.bringToFront now activates the window.

- Fixed nav_qt plugin.

- Fixed completer focus problems.

- Fixed MacOS Command-C bug.

- Fixed major problem with multiple body editors
#@+node:ekr.20110602091552.16903: *4* Major improvements
- Leo highlights URL's everywhere. Ctrl-click URL's opens them in your web
  browser.
  
- Nodes may contain multiple @language directives.

- Use @file extension by default if there is no @language directive in effect.
  This is oh so useful.

- Unified extract commands.  This command creates a child node from the selected
  body text as follows:
    
    1. If the selection starts with a section reference, the section name become the
       child's headline. All following lines become the child's body text. The
       section reference line remains in the original body text.
       
    2. If the selection looks like a Python class or definition line, the
       class/function/method name becomes child's headline and all selected lines
       become the child's body text.
       
    3. Otherwise, the first line becomes the child's headline, and all selected
       lines become the child's body text.

    Note that the extract-section-names command remains.
    The extract-section and extract-python-method commands are gone.

- The import-file commands replaces all the following commands::
    
    import-at-file                    
    import-cweb-files         
    import-derived-file       
    import-flattened-outline      
    import-noweb-files
    
  Leo chooses one of the above commands as follows.  First, if the file looks
  like an external file that Leo wrote, the command works like
  import-derived-file command.  Otherwise, the file's extension determines the
  importer::
        
        .cw, .cweb:     import-cweb-files
        .nw, .noweb:    import-noweb-files
        .txt:           import-flattened-outline
        all others:     import-at-file
    
  The import-at-root command is no longer supported.
#@+node:ekr.20110602091552.16904: *5* Completed Leo's autocompleter
Terminology: the *legacy* (aka tabbed) autocompleter shows completions in Leo's
tabbed pane. The *new* (aka qcompleter) autocompleter shows completions in or
near the body pane.

Appearance
==========

There is little change to the legacy completer, except that no text is
highlighted in the body pane during completion. This is calmer than before.
Furthermore, there is no longer any need for highlighting, because when the user
types a backspace the legacy completer now simply deletes a single character
instead of the highlighted text.

One minor change: the legacy completer now *does* insert characters that do
not match the start of any possible completion. This is an experimental feature,
but it might play well with using codewise completions as a fallback to
Leo-related completions.

Function and design
===================

Both the legacy and new completer now work *exactly* the same way, because they
both use the AutoCompleterClass to compute the list of completions.

The strict "stateless" requirement means that the "intermediate" completions
must be entered into the body pane while completion is active. It works well as
a visual cue when using the tabbed completer: indeed, the tabbed completer would
be difficult to use without this cue.

The situation is slightly different with the qcompleter. Adding code before the
user accepts the completion might be considered an "advanced" feature. However,
it does have two important advantages, especially when "chaining" across
periods: it indicates the status of the chaining and it limits what must appear
in the qcompleter window.

Codewise completions
====================

The codewise-oriented completions appear to work well. In large part,
this is due to adding the global "self." completions to all class-related
completions (kind == 'class' in ac.get_codewise_completions). This looks like a
really good hack, and it eliminates the need for the ContextSniffer class.

Performance
===========

Performance of Leo-related completions is *much* better than before. The old
code used Python's inspect module and was horribly complex. The new code uses
eval and is perfectly straightforward.

The present codewise-related code caches completions for all previously-seen
prefixes. This dramatically speeds up backspacing. Global caching is possible
because completions depend *only* on the present prefix, *not* on the presently
selected node. If ContextSniffer were used, completions would depend on the
selected node and caching would likely be impractical. Despite these
improvements, the performance of codewise-oriented completions is noticeably
slower than Leo-related completions.

Performance notes
=================

The ac.get_cached_options cuts back the prefix until it finds a cached prefix.
ac.compute_completion_list then uses this (perhaps-way-too-long-list) as a
starting point, and computes the final completion list by calling
g.itemsMatchingPrefixInList.

This may not be absolutely the fastest way, but it is much simpler and more
robust than attempting to do "prefix AI" based on comparing old and new
prefixes. Furthermore, this scheme is completely independent of the how
completions are actually computed. The autocompleter now caches options lists,
regardless of whether using eval or codewise.

In most cases the scheme is extremely fast: calls to get_completions replace
calls to g.itemsMatchingPrefixInList. However, for short prefixes, the list that
g.g.itemsMatchingPrefixInList scans can have thousands of items. Scanning large
lists can't be helped in any case for short prefixes.

Happily, the new scheme is still *completely* stateless: the completionDict does
*not* define state (it is valid everywhere) and no state variables had to be
added. In short, the new caching scheme is much better than before, and it
probably is close to optimal in most situations.

#@+node:ekr.20110602091552.16905: *5* Greatly improved the viewrendered plugin
#@+node:ekr.20110531155858.20246: *4* New and improved features
#@+node:ekr.20110602091552.16907: *5* Colorizing improvements
- Support multiple @language directives in a single node
  As with @color directives, only unambiguous @language directives affect the
  default coloring of descendant nodes.

- Colorize url's in the body text. You can open url's by control-clicking on
  them, or by using the open-url command.

- Added support for cython colorizing.

- Leo ignores (and does not color) @language directive for unknown languages.

- Leo completely recolors nodes when you change @language directives by typing.
#@+node:ekr.20110602091552.16909: *5* New command-line arguments & settings
- The --no-splash command-line option suppresses the splash screen.
  Leo puts up no splash screen when the --silent
  or --script command-line options are given.

- Added @bool view-rendered-auto-create setting.
    
- Added @bool use_qcompleter setting.

- Added @bool auto_tab_complete setting.

- Added @bool single_click_auto_edits_headline setting.

- Removed @bool use_codewise setting.

- You now may set icon button colors in the Qt stylesheet.
#@+node:ekr.20110602091552.16913: *5* Gui improvements
- If you type a *plain* up/down arrow key while editing a headline, Leo will act
  as if you had typed the corresponding *alt*- arrow key. That is, Leo will end
  editing of the headline and go to the next previous node. Leo will end editing
  even if there is no next/ previous node, which is convenient.

- A single click on an already-selected tree node edits the headline
  Enabled only if @bool single_click_auto_edits_headline = True.

- Added a splash screen

  The --no-splash command-line option suppresses the splash screen. In addition,
  Leo puts up no splash screen when the --silent or --script command-line
  options are given. To change the splash screen, replace
  leo\Icons\SplashScreen.jpg with another image.

- The apropos commands now print in a separate area if possible. The commands
  use the viewrendered plugin by default. This makes the apropos messages much
  more visible.

- Handle click events like alt-x or ctrl-g Clicking in the minibuffer now is
  equivalent to alt-x, provided that the minibuffer is not in use. Clicking most
  places outside the minibuffer is equivalent to ctrl-g. Catching clicks is much
  safer than catching focus events.

- The first loaded file sets tabbed gui size

- Enter insert mode after ctrl-h.  This is a vim-related improvement.

- Disabled find/change text areas in find panel.  This is less confusing.
#@+node:ekr.20110602091552.16915: *5* Improved commands
- Improved the clone-find-all command. The descendants of previously found
  (cloned) nodes don't get added again. The clone-find-all pattern now defaults
  to find text.

- Improved the forward and backward by sentences commands Leo's sentence related
  functions now stop at empty lines, skip periods within words, stop at
  sentences ending in non-periods and stop at the end or beginning of the
  buffer.

- Improved the print-bindings command; it now shows were bindings came from.

- Improved the reformat-paragraph command. The command detects paragraphs more
  reliably. The next line is now visible, which is a big improvement.

- Added patch to g.wrap_lines from José Rojas Echenique
  It regularizes the number of spaces after periods.

- Improved expansion of abbreviations. Abbreviations are checked any time a
  non-word character is typed. In particular, newlines trigger abbreviations,
  which I find very helpful, although I did then have to remove newlines from my
  abbreviations. Control sequences do not trigger expansions.

- Improved handling of @url nodes. The new rule is simple: if the body text
  contains any text the first line of the body text is taken to be the url.
  There is no longer any need to put '--' in the headline. More importantly, you
  can put anything you like in the body text following the first line. Other
  url's, notes, even .. graphics:: directives for the viewrendered plugin.

- Improved the clean-all-lines command. It is now much faster and has better
  feedback.
#@+node:ekr.20110602091552.16911: *5* File handling improvements
- Added namespace and Leo comment lines to .leo files

- Leo opens leoSettings.leo only once

- Fixed Bug 745824: @doc duplicates comment delims in html files
  https://bugs.launchpad.net/leo-editor/+bug/745824e
  
- Leo no longer wraps @doc lines. This ensures that Leo does not change files
  unnecessarily.
#@+node:ekr.20110602091552.16917: *5* Scripting improvements
.. _`Runwith class`: http://groups.google.com/group/leo-editor/browse_thread/thread/b8e8fbf6d97fa9f2/a4537fafaf2442ba

- Added namespace arg in c.executeScript

- Put Kent Tenney's `Runwith class`_ in scripts.leo and contrib.

  Kent writes, "I've had endless problems with interpreter versioning, leading
  me create the Runwith class. It writes a file to disk, makes it executable,
  runs it, captures exitcode, err and output, removes the files, provides
  reports. This provides complete decoupling from Leo."

- Call os.chdir when executing scripts.
#@+node:ekr.20110604043410.17808: *4* New in 4.9 b2
- Double-clicking a headline now colorizers the headline exactly the same way as
  when editing the headline with ctrl-H. This was a serious problem for those
  with dark window-color schemes.
  
- The distribution script now ensures that leo\plugins\spellpyx.txt contains
  Linux-style newlines. This prevents crashes in the PyEnchant spell checker.
  
- Leo imports .cfg files just like .ini files.

- Fixed crasher in graphcanvas plugin caused by a bug in CommandChainDispatcher.add.
#@+node:ekr.20110611055444.16617: *4* New in 4.9 b3
#@+node:ekr.20110611055444.16618: *5* Bugs fixed
- Fixed ancient, major bug: F3 now makes sure to save headline changes

- Fixed old bug: set-find-x commands no longer abort find commands

  The commands that switch find scope, set-find-xxx, no longer terminate the
  find command, if one is active.  This is an old bug, and it's good to fix it. 

- Fixed recent bugs in the viewrendered plugin.

  An earlier rev fixed a bug that effectively destroyed the viewrendered plugin.
  It was caused by the new convention that alleviates the need for many
  \@language directives. The fix was simply to enable the update_rst method if
  the massaged p.b is not empty.

- Fixed chapters problems

    http://groups.google.com/group/leo-editor/browse_thread/thread/3f15a855ca38b26e
    
    The new code is more relaxed about where @chapter nodes may reside.  They
    are always *created* as the last child of the first @chapters node in the
    outline (the @chapters, plural, node is created as needed).  However, you may
    move them while in the "main" chapter, with no ill effects.  In fact, you could
    swap @chapter nodes with the same name: when you select a chapter, Leo will use
    (show) the first node it finds. 
    
    The new code is now both more careful and more tolerant of @chapter nodes
    deleted by hand.  The chapter will still appear in the dropdown list: if you
    select it you will give a polite warning.  That's all.  In particular, the
    deleted chapter will *remain* in the dropdown list until you use the proper
    chapter-remove command.  That's about the only sane alternative: it allows you
    to resurrect the chapter, by hand or with an undo. 
    
    This is all made possible because the new code is almost completely stateless.
    The only exception is the saved position used to select a node when selecting a
    chapter. The old position-based findPositionInChapter method has been simplified
    to make it work more reliably. It first looks for a "perfect" match using
    positions, and then degrades to looking for a vnode match. In practice, most
    matches are, in fact, perfect. The "imperfect" case typically happens when the
    user alters nodes in @chapter trees by hand in the "main" chapters.
    
    Technical highlights:
        
    - The check for c.positionExists(p) in c.setCurrentPosition continues to fail
      when deleting @chapter nodes. However, the code now simply falls back to
      c.rootPosition, without any apparent harm.
      
    - The chapterController and chapter classes are now completely stateless, except
      for chapter.p.
      
        A. chapter.findPositionInChapter has been simplified and generalized. It now
           falls back to a reasonable value, based on p.v, if chapter.p does not
           exist.
           
        B. All chapterController code now recomputes the location of @chapters and
           @chapter nodes whenever those locations are needed.
           
        C. All chapter commands are unchanged in their actual workings, but all contain
           a care "preamble" of checking code.
           
- Added unit test for all chapter commands.  All interactive commands now have
  an xByName helper for use by unit tests.
  
- Added lockout to leoQtTreeTab.  This prevents flash during the rename chapter command.

- Rewrote chapter.chapterSelectHelper.  This reduces, but does not eliminate, the
  number of warnings given by c.setCurrentPosition.


- Fixed recent bug: handle 'Escape' character properly

  The fix was a last-minute adjustment in leoQtEventFilter.create_key_event.


- Fixed caps-lock problem

  The fix was yet another last-minute fix leoQtEventFiler.create_key_event.

- Made sure all keys contribute to lossage
#@+node:ekr.20110611055444.16654: *5* Simplified Leo's key handling
This was a major simplification of Leo's core.

- Eliminated event.keysym from Leo's core: test only ev.char and ev.stroke.

- Replaced all dummy (g.bunch) events in Leo's core and in unitTest.leo.
    
- Replaced w.event_generate by g.app.gui.event_generate everywhere.
    
- Rewrote leoGui.leoKeyEvent.

- Created leoGui.create_key_event and leoQtEventFilter.create_key_event.

- Removed some ugly last-minute hacks in leoQtEventFilter.create_key_event.
#@+node:ekr.20110611055444.16726: *5* Features
- Changed names of commands so they have common prefixes

    Any custom key bindings (none are bound by default) will have to change.
    
    The new prefixes are::
    
        abbrev-     abbreviation commands
        buffer-     buffer command
        directory-  director commands
        file-       file commands
        gc-         garbage collection
        macro-      macro expansion
        rectangle-  rectangle commands
        register    register commands
        
    The already existing prefixes are::
    
        apropos-    help
        ddabrev-    dynamic abbreviations
        find-       find commands
        isearch-    incremental search
        print-      print information
        run-        run unit tests
        toggle-     toggle settings
        yank-       yank
        

- Finished macros

    The macro-load and macro-save are as simple as possible.

    No further work will be done on macros unless somebody really wants these commands.


- Added support for word-only option for regular expressions

When the word-only option is in effect, Leo ensures that the search pattern
begins and ends with the '\b' anchor.

- Leo's startup code now forces the qt gui: it changes qttabs to qt.

- Added support for expanded sections in plugin.  Added three new options:

    expand_noweb_references
    
       True: Replace references by definitions.
       Definitions must be descendants of the referencing node.
    
    ignore_noweb_definitions
    
        True: ignore section definition nodes.
    
    expand_noweb_recursively
    
        True: recursively expand definitions by expanding any
        references found in definitions.
        
Notes:

- This is an experimental feature: all aspects might changed.

- The code ensures that unbounded expansions can not happen. While expanding any
  section, the rst3 will not expand again any sections that have already
  occurred in the expansion.

- All rst3 options apply to the entire node in which they appear (and all
  descendant nodes until over-ridden), but by splitting nodes one can change the
  settings on an expansion-by-expansion basis. It is easy to split nodes without
  creating new sections using @rst-no-head in the headline.
#@+node:ekr.20110611092035.16493: *5* Removed settings
The following Tk settings have been removed from leoSettings.leo::

    @bool center_selected_tree_node
    @bool expanded_click_area
    @bool idle_redraw
    @bool initialClickExpandsOrContractsNode
    @bool invisible_outline_navigation
    @bool look_for_control_drag_on_mouse_down
    @bool outline_pane_scrolls_horizontally
    @bool use_minibuffer
    
The following setting was not active, and has also been removed::

    @bool ignore_caps_lock
#@+node:ekr.20110613172008.14775: *4* New in 4.9 b4
Old bugs fixed
--------------

- Fixed an ancient bug: everything after @all was put in the wrong node!

- Fixed an ancient bug: wrap-around search now restarts when find pattern changes

- Fixed an ancient bug: F-keys end incremental searches.

Recent bugs fixed
-----------------

- Fixed a recent problem with commands dispatched from menus The Shift modifier
  was deleted from all commands executed by selecting an item in menus! A new
  unit test checks that menus behave as expected.

- Dismiss splash screen before putting up the dialog that asks for an ID.

Other changes
-------------

- Running all unit tests leaves all files unchanged. This was a major annoyance.

- Leo now does a keyboard-quit when deactivating a window.
#@+node:ekr.20110616100929.14794: *4* New in 4.9 rc1
- When running on MacOS, Leo uses the qt gui when the qttabs gui is requested.

- Leo now looks in home/.leo/Icons directory for icons before looking in the
  leo/Icons directory.
  http://groups.google.com/group/leo-editor/browse_thread/thread/80163aec96b8ea45/4f58418924172252

- Fixed bug 797470: File data sometimes silently erased when the tangler fails.
  https://bugs.launchpad.net/leo-editor/+bug/797470 This was a serious bug, but
  it could happen only when saving an errorneous file twice.

- Fixed bug 798194: --maximized has no effect
  https://bugs.launchpad.net/leo-editor/+bug/798194
  
- Added the @bool forbid_invalid_completions setting.

- Non-plain keys, such as Ctrl-s, abort auto-completion and are interpreted as
  usual.

- Don't mark the .leo file as changed when setting orphan bit. There is no need:
  the orphan bits will ensure errors get reported if the file is saved.

- Disabled the open-compare-window command. It is/was a Tk only command.

- The open-python-window command fails more gracefully It issues a message
  instead of crashing if idlelib does not exist.
#@+node:ekr.20110620083705.14902: *4* New in 4.9 final
Fixed crash on mouse clicks in minibuffer.
#@+node:ekr.20120229094652.14053: *3* 4.10 Incremental improvements
Leo 4.10 final                                         March 29, 2012

Leo 4.10 final is now available at: http://sourceforge.net/projects/leo/files/Leo/4.10%20final/

Leo is a text editor, data organizer, project manager and much more.
See http://leoeditor.com/tutorial.html

Leo 4.10 contains 9 months of intense work on Leo. Several very important
features are subtle; you could almost call them Easter Eggs, so please read
the following notes carefully.

The highlights of Leo 4.10:
--------------------------

* Dozens of new and improved features and commands, including...
  - Tab completion now shows all @command & @button nodes.
  - Leo tabs may be detached from the main window.
  - The Open With menu now works.
  - The leoInspect module answers questions about Python code.
  - Leo can highlight the pane containing the focus.
  - The bigdash plugin searches across multiple files.
  - Improved abbreviation capabilities.
  - Improved handling of URL's.
  - Improved editing of non-Leo files.
  - Improvements create "weightless" unit testing.
  - Improved Leo's home page.
* Easier installation on MacOS.
* Fixed almost 70 bugs.

The Easter Eggs
---------------

1. Tab completion now shows all @command & @button nodes.

Put all your common scripts in @command nodes in myLeoSettings.leo.
Typing <Alt-X>@c<Tab> will remind you of the names of these scripts.
You can execute the scripts by name without the "@command-" prefix.

2. Improved abbreviation capabilities.

Virtually any kind of abbreviation is possible. For example, ~a to ã.

3. Improved handling of URL's.

URL's can be used as links to other Leo outlines.

4 Weightless unit testing.

The mantra is edit, alt-4 (run-marked-unit-tests-externally), edit,
alt-4,... Several seemingly innocuous changes made this work without
"friction". The result is a remarkable increase in productivity.

Links:
------
Leo:      http://leoeditor.com
Forum:    http://groups.google.com/group/leo-editor
Download: http://sourceforge.net/projects/leo/files/
Bzr:      http://code.launchpad.net/leo-editor/
Quotes:   http://leoeditor.com/testimonials.html
#@+node:ekr.20120229094652.14757: *4* Bugs
#@+node:ekr.20120318075211.6163: *5* Significant bugs
#@+node:ekr.20120229094652.14758: *6* Fixed ancient hanger in paste-retaining-clones
https://bugs.launchpad.net/leo-editor/+bug/800157

Fixed at rev 5077.
#@+node:ekr.20120229094652.14780: *6* Fixed serious atFile read bug
Changed at.readEndOthers and at.readEndRef so that they
always set at.inCode = True
#@+node:ekr.20120229094652.14934: *6* Fixed bug: @button @key=x does not override x
Created k.kill_one_shortcut, called from k.remove_conflicting_definitions.
#@+node:ekr.20120229094652.14973: *6* Fixed the wretched scrolling bug
The fix was to save/restore YScroll position in body.setSelectionAreas.

Failure case 1:
    - Search for something.
    - Manually scroll the pane.
    - Click scrolls the pane again.
    
Failure case 2:
    - reformat-paragraph.
#@+node:ekr.20120318075211.6165: *6* Fixed several node-selection bugs related to hoists & chaptesr
#@+node:ekr.20120313074006.14657: *7* Fixed bug 823267: when a tab is closed focus may go to a tab other than the visible one
https://bugs.launchpad.net/leo-editor/+bug/823267

When tabs are closed with the close tab 'X' on the tab, focus
should go to whichever tab becomes visible, but it does not,
it goes to an arbitrary tab which may not be visible. If you
then hit Alt-X expecting to cut the highlighted node in the
visible tab, you cut a node you can not see in a different
commander.

What I did:
    
- Refactored part of g.app.closeLeoWindow into g.app.selectLeoWindow.
- Added the new_c argument to g.app.closeLeoWindow and c.close.
- Changed several event handlers in TabbedFrameFactor so that they
  call g.app.selectLeoWindow as appropriate.
#@+node:ekr.20120313074006.14771: *7* Fixed bug 875327: Positioning outside of hoisted outline" usually causes problems
https://bugs.launchpad.net/leo-editor/+bug/875327
#@+node:ekr.20120313074006.14663: *7* Fixed bug 917814: Switching Log Pane tabs is done incompletely
https://bugs.launchpad.net/leo-editor/+bug/917814
#@+node:ekr.20120313074006.14740: *7* Fixed bug 875323: Hoist an @chapter node leaves a non-visible node selected
https://bugs.launchpad.net/leo-editor/+bug/875323
#@+node:ekr.20120313074006.14765: *7* Fixed bug 831658: @url doesn't leave Chapter
https://bugs.launchpad.net/leo-editor/+bug/831658
#@+node:ekr.20120318075211.6164: *5* Minor bugs
#@+node:ekr.20120229094652.14759: *6* Fixed bug in p.setAllAncestorAtFileNodesDirty
The code that marks descendant @<file> nodes dirty now tests
p2.isAnyAtFileNode().  The old code tested p2.isAtThinFileNode().
#@+node:ekr.20120229094652.14761: *6* Fixed double-click problem
CAUTION: new double click handling code

http://groups.google.com/group/leo-editor/browse_thread/thread/dbd63b9b38911906

The problem isn't single/double, but double click not stopping the
event processing.  It has the correct form:

if g.doHook('doubleClick1') is None:
   do-normal-double-click-stuff
g.doHook('doubleClick2')

but I think some other route through the code, or additional processing
of the event means that even thought the handler registered on
doubleClick1 returns non-None, the node goes into headline edit mode,
with focus.

This is bad, because the doubleClick1 on an @url node attempts to
select and raise a different commander (tab), so now you're looking at
one commander but focus is in another, so what you type trashes the
headline in the original commander.

The timer shouldn't be needed - a 'doubleClick1' hook which returns
non-None should stop the headline going into edit mode.  If you can
make that be the case, all is well.
#@+node:ekr.20120229094652.14762: *6* Fixed url focus issues
#@+node:ekr.20120229094652.14763: *6* Fixed p1 > p2
#@+node:ekr.20120229094652.14764: *6* Fixed cacher problem
- leoCommands.__init__ now sets self.db = {}
- initGlobalDB now returns {} instead of None if there is no cacher.
#@+node:ekr.20120229094652.14765: *6* Fixed encoding problem with @shadow
readOpenFile reads the private shadow file, detecting the encoding.
#@+node:ekr.20120229094652.14767: *6* Fixed a major DnD bug
#@+node:ekr.20120229094652.14769: *6* Regularized slashes in @edit/@file
Examples:
    
    @edit C:/leo.repo/ipython-0.12/IPython/frontend/qt/console/pygments_highlighter.py
        # The filename comes from g.app.gui.runOpenFileDialog
    
    @file C:\leo.repo\ipython-0.12\IPython\frontend\qt\console\pygments_highlighter.py
        # Created by import.
        
The problem was the call to g.os_path_normpath in importDerived files:
it converts slashes to backslashes on windows (!!)
#@+node:ekr.20120229094652.14770: *6* Made sure Leo's write code auto-detects file extension
- Added getLanguageFromAncestorAtFileNode.

- Revised code in at.scanAllDirectives & leoQtColorizer.scanColorDirectives.
#@+node:ekr.20120229094652.14772: *6* Fixed cycle-editor-focus bug
qtBody can use the leoBody code.
#@+node:ekr.20120229094652.14775: *6* Fixed Py3k crash in quicksearch.py
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\plugins\quicksearch.py", line 187, in returnPressed
    self.scon.doSearch(t)
  File "c:\leo.repo\trunk\leo\plugins\quicksearch.py", line 289, in doSearch
    self.addBodyMatches(bm)
  File "c:\leo.repo\trunk\leo\plugins\quicksearch.py", line 257, in addBodyMatches
    self.its[it] = (p, None)
TypeError: unhashable type: 'QListWidgetItem'
#@+node:ekr.20120229094652.14779: *6* Macro expansion now forces a full recolor
#@+node:ekr.20120229094652.14781: *6* Fixed unicode bugs with @shadow
Fixed several encoding problems related to this thread: @shadow - @encoding windows-1250 - problem
http://groups.google.com/group/leo-editor/browse_thread/thread/a4ba80559447218a/9a37a4ed6c44d452

There were several real problems fixed.  The summary: @encoding directives were always required.

In detail:

1. at.initWriteIvars now checks for a Python # -*- coding: line.
   If present, it must be the very first line.
   If present, it will override any @encoding directives.

2. g.getPythonEncodingFromString now can deal with either of the following lines:

    @first # -*- coding: utf-8 -*-
    # -*- coding: utf-8 -*-

That is, g.getPythonEncodingFromString can strip the leading @first.

3. g.readlineForceUnixNewline and x.propagate_changes now catch UnicodeDecodeError.
   This is very important: previously decoding errors crashed Leo!.

All unit tests pass with both Python 2.x and 3.x.

#@+node:ekr.20120229094652.14782: *6* Recompute width of hard tabs depending on @tabwidth
Added configure_hard_tab_width method.
#@+node:ekr.20120229094652.14783: *6* Applied patch for Bug 800311: Undo: Word granularity should recognize cursor movements
https://bugs.launchpad.net/leo-editor/+bug/800311

Having set undo to word granularity, I often change something, move to a
different line and continue editing there. When I want to undo my last change,
Leo also undoes the change in the other place, as word granularity currently
only recognizes a new undo step when a new word is started, no matter if we
moved to a completely different position first.

The attached patch fixes the issue by remembering the previous cursor position.

Something else about the undo code:

- oldSel and newSel are never set to None in the constructor -> it's quite hard
  to know they are there without reading the whole code

- It would be cool if there could be some more comments in that section; e.g. to
  tell that oldSel and newSel from which old_row, old_col, new_row and new_col
  actually mean: old = "the position right before doing the change" and new =
  "the position right after doing the change" and that old != "the position
  after the change before" (which I added as prevSel) - it took me ages to
  discover this

- There are duplicate "The new and old characters are not contiguous." checks.
  Are they different/necessary?

- The "We have just inserted a line." section is not only entered on a new line
  (see other attached patch)
#@+node:ekr.20120229094652.14784: *6* Applied patch for Bug 800312: Collapsing node moves should be optional
https://bugs.launchpad.net/leo-editor/+bug/800312
#@+node:ekr.20120229094652.14785: *6* Fixed Bug 880975: Binding Meta and print-bindings
https://bugs.launchpad.net/leo-editor/+bug/880975

Bug: The Meta+Ctrl section [of print-bindings] is always empty and this makes it
misleading.

Fix: the prefix list in k.printBindings must be sure that if two prefixes have a
common leading part the longer prefix appears first in the lists.
#@+node:ekr.20120229094652.14786: *6* Fixed bug 823601: cascade-windows fails
https://bugs.launchpad.net/leo-editor/+bug/823601
#@+node:ekr.20120229094652.14817: *6* Fixed html colorizing by fixing a bad bug in g.importFromPath
g.importFromPath ('html','C:/leo.repo/trunk/leo/modes/html.py')
returned the standard Python html module!

#@+node:ekr.20120229094652.14818: *6* Allow lower case keywords in colorizer
The fix was to use lowercase versions of docPart,leoKeyword,nameBrackets.
#@+node:ekr.20120229094652.14820: *6* Fixed rst3 pdf problem
Worked around docutils problem in writeToDocutils.
#@+node:ekr.20120229094652.14822: *6* Removed traceback when cancelling a write
not written: c:\recent\data3.html
exception removing: 
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoAtFile.py", line 5280, in remove
    os.remove(fileName)
WindowsError: [Error 3] The system cannot find the path specified: ''
#@+node:ekr.20120229094652.14823: *6* Fixed removeBlankLinesTokens
There were two bugs:
    
- baseScannerClass.skipWsToken must not skip newlines!
- tokenize must add any remaining whitespace at the end of the loop.
#@+node:ekr.20120229094652.14824: *6* Fixed crasher in config.set
The code didn't work for c == None.
#@+node:ekr.20120229094652.14825: *6* Fixed resize-to-screen and minimize-all
#@+node:ekr.20120229094652.14826: *6* Fixed html import problems
http://groups.google.com/group/leo-editor/browse_thread/thread/3c319daba37cd0ef

- Created a separate html importer, a very simple subclass of the xml scanner
  whose only difference is that it uses @data import_html_tags instead of @data
  import_xml_tags.

- The case of tags in @data import_html_tags and @data import_xml_tags no longer matters.

- checkTrialWrite now writes a file *with* sentinels, to handle @others correctly.
  It then removes the sentinels.
  
  This means that the import tests must use the correct @language directives.
  
- The import check now uses a token-based comparison.  
#@+node:ekr.20120229094652.14827: *6* Removed extra newlines in g.trace
The fix was in g.pr:
    
Restored the call to sys.stdout.write(s2) (instead of print)

sys.stdout.write(s2) writes no additional newline at the end of s2.

Aha!  At last I know how to unit test g.pr, g.trace, etc.: redirect stdout!
#@+node:ekr.20120229094652.14828: *6* Fixed crash in compareTokens
 File "/usr/fetching/leo-editor/leo/core/leoImport.py", line 2074, in
scanAndCompare
   n1,n2,ok = self.compareTokens(tokens1,tokens2)
 File "/usr/fetching/leo-editor/leo/core/leoImport.py", line 2094, in
compareTokens
   else:      kind1,val1 = 'eof','',n1
ValueError: too many values to unpack
#@+node:ekr.20120229094652.14829: *6* Finished import work
- Created stand-alone unit tests from @test import dataN.html.
- All leoImport unit tests may now be run externally.
    The Python unit tests were failing because of intermixed tabs and blanks.
    This was fixed by putting @tabwidth -4 in all @test nodes for Python.
- Made sure lines are printed when unit tests fail unexpectedly.
- Added .js & javascript entries to global data structures for javascript unit tests.
- Completed xmlScanner.filterTokens.
- Don't create declaration nodes for html.
- Make sure html tags are as expected.
- Ignore case of html/xml tags.

Rev 4774.1.1:

Fixed all known html-import problems in a clean way. Unit tests exists, but they
use external files. They will be converted soon.

Important changes:

1. Added hasNestedClasses ivar in the baseScannerClass, True only for xml/html scanners.

When True, scanHelper and skipDecls allocate a substring to be used for all further scanning.
This is the *only* way to limit Leo's scanners properly.

This was, in essence, the fix for duplicate code generation arising from unbalanced tags:
skipToEndOfTag and skipToMatchingTag can't match outside the present tag because
the 's' argument passed to those methods has already been truncated.

This is a simple, elegant solution, and in essence the *only* proper solution.
For example, it would not work to past an 'end' argument to skipToEndOfTag and skipToMatchingTag
because the scanners inside those methods do not understand an 'end' argument.

Thus, the simplest, most efficient solution is for scanHelper and skipDecls to truncate the
string to be scanned. That way, the truncation happens at most once per "class".

2. Added hasDecls in the baseScannerClass, False only for xml/html scanners.

Various methods call skipDecls only if this ivar is True.

Rev 4773:

Fixed recent botch: both single and double quotes are allowed in html. 

Rev 4772:

Solved "between element" problem by extending classes up to the next class.
data.html imports "correctly", but not perfectly due to tag mismatches in
skipToMatchingTag.
#@+node:ekr.20120229094652.14831: *6* Fixed hard crash when deleting body editor 3 times
http://groups.google.com/group/leo-editor/browse_thread/thread/421ebf4c3f2d5f59

Adding/deleting body editor 3 times hard-crashed Python

The changes were straightforward:
    
- set w.leo_label to None when calling unpackWidget.

- Test for w.leo_label before using it.

Added a minitest.  To test by hand, add the following @button nodes:
    
    @button add-ed
    w = c.frame.body.addEditor()
    
    @button del-ed
    w = c.frame.body.deleteEditor()
    
Click away in any order...
#@+node:ekr.20120229094652.14832: *6* Fixed add/delete html comments
The new add-comments command adds the comment character at the leftmost column.

The new delete-comments command will remove the comment characters inserted by
either the old or new version of the add-comments command.
#@+node:ekr.20120229094652.14833: *6* Fixed bug that prevented text bindings from working in log tabs
Example: ctrl-shift-home.

The fix was to set self.widget = contents in leoQtLog.selectTab.
#@+node:ekr.20120229094652.14835: *6* Fixed crashers involving calls to w.setSelectionRange
#@+node:ekr.20120229094652.14836: *6* Fixed hang in cycleAllFocus
The safe default pane is the body pane.  It's also the simplest code.
#@+node:ekr.20120229094652.14837: *6* Fixed crasher in k.handleDefaultChar
The code must be careful that the log widget supports the HighLevelInterface.
#@+node:ekr.20120229094652.14838: *6* Fixed bug: Focus lost after opening or closing tab
#@+node:ekr.20120229094652.14839: *6* Ignore unbound Alt/Ctrl keys, especially Alt/Ctrl-N
The bug was in k.handleDefaultChar.  No substantial change made to eventFilter.
#@+node:ekr.20120229094652.14840: *6* Fixed bug: ensure global @buttons work
What I did:
    
1. Fixed major bug in settingsTreeParser.visitNode.
   It now does p.copy() to protect the callers traverals.
   This could have significant impacts on people's settings.
   
2. Added g.app.unitTestDict for unit testing.

3. Leo now extends the list of @buttons and @commands, rather than replacing them.
   This is reasonable only because leoSettings.leo should never define *active*
   buttons or commands.
#@+node:ekr.20120229094652.14841: *6* Fixed bug in p.moveToFirstChild
#@+node:ekr.20120229094652.14842: *6* Fixed bug 804960: Refreshing unlinks clones, just reopening connects them again
https://bugs.launchpad.net/leo-editor/+bug/804960

When we clone a node inside an @shadow (containing @others) node and then
refresh the @shadow node from file, the clone is unlinked and marked as changed.
If we now save, close the .leo file and open it again, the nodes are linked
again! (showing "cloned" symbol) User's thought: "How the heck can the file
change _between save and re-open_ when I changed nothing?"

I think what should be done about this is the check that Leo does when it opens
the file again, and that check should be done immediately after the "refresh
node from file" operation. Also, at this point, the "Recovered nodes" node
should appear (if file and node have both changed), not only after the next .leo
file close/reopen (as that happens quite infrequently, I guess, e.g. once a day
for me). Otherwise, the user can easily lose data.
#@+node:ekr.20120229094652.14848: *6* Fixed crasher in reportMismatch
>  File "/path/to/leo/core/leoImport.py", line 2070, in reportMismatch
>    line = repr(lines2[i])
> IndexError: list index out of range
#@+node:ekr.20120229094652.14850: *6* Fix bug: Allow @all only in top-level @<file> nodes (test2.leo)
The fix was to at.putBody.
#@+node:ekr.20120229094652.14855: *6* Fixed erroneous "file changed" message
http://groups.google.com/group/leo-editor/browse_thread/thread/daf581ace0de871e

"has been modified outside of Leo. Overwrite this file?"

Steps to reproduce:

- Create a node "@edit ~/aaa.txt" assuming aaa.txt does not exist
- Ctrl-S save outline, log reports creating ~/aaa.txt
- Edit text in body
- Ctrl-S save outline, pop-up pops-up erroneously.

The problem was that replaceTargetFileIfDifferent should set root.v.at_read.
Now it does.

Note: both replaceFileWithString methods are part of the @shadow logic,
so there is no need to set any at_read bit in those methods.
#@+node:ekr.20120229094652.14856: *6* Fixed bug 889175: Changing @auto paths overwrites files without warning
https://bugs.launchpad.net/leo-editor/+bug/889175

I loaded an outline with @auto nodes pointing to an out of date path. So body
texts were empty. I updated the paths in the node headlines and saved the file,
expecting to be prompted for overwriting the existing files (now the paths were
correct again), but they were over-written with the blank content without
warning. Damn.

Steps to reproduce in a simpler way below, but don't write the
below of as contrived, because the above is the real problem.

Create @auto /home/tbrown/text.txt

enter text, save file

Edit headline to @auto /home/tbrown/Desktop/text.txt

enter text, save file

Edit headline back to /home/tbrown/text.txt

-----

I now see this happens also if the path change is in a @path node ancestor of the @auto node.
#@+node:ekr.20120229094652.14891: *6* Fixed bug in DynamicWindow.setGeometry
DynamicWindow.setGeometry now does *not* change the window size when using the qttabs gui.

Added a comment to this effect in leoSettings.leo.
#@+node:ekr.20120229094652.14892: *6* Fixed bug 87933: Redefining a key binding breaks menu items with same binding
https://bugs.launchpad.net/leo-editor/+bug/87933
    
- Fixed the Shift-Tab buglet by adding lower-case entries in app.tkNamesList
    This matches what is done in k.settingsNameDict.
- Created << define global key dicts >> in leoApp.py.
- Changed si.val to si.stroke.
- Replaced g.bunch by GeneralSetting & ShortcutInfo.
- Replaced bunchList by aList.
- Removed dynamic_menus "compile-time" constant.
- onAboutToShow now recomputes the contents of menus whenever menus are invoked.
- leo_update_shortcut now shows all shortcuts for a command.
- Wrote and tested merge_settings_dict.
#@+node:ekr.20120229094652.14893: *7*  Report
Bug 879331: Redefining a key binding breaks menu items with same binding

https://bugs.launchpad.net/leo-editor/+bug/879331

> Now I understand.  If I override the shortcut associated with the menu
> item, in this case Alt-A, the menu breaks.

This is a serious bug!  The menu item now executes the command bound
to Alt-A!  Very bad.

=========

http://groups.google.com/group/leo-editor/browse_thread/thread/762e832909c3c530/d99d48eed45d1061

http://mail.google.com/mail/#inbox/1331909dd653f3c9

Redefining a binding, say for Alt-a, in x.leo will cause the sort-siblings menu
(bound to alt-a) to execute the command specified by the command bound to Alt-a!

https://bugs.launchpad.net/leo-editor/+bug/815564

This anomaly only occurs when all of the following conditions are true:

1) There is a global command name X that is the "same" as the root name of the
file containing a plugin Y. Here, "same" means equal after the command name is
converted to lower case and all underlines in the root name are replaced by
dashes.

2) A shortcut (a.k.a. keystroke) is bound to command name X.

When these conditions are true, then the Plugins dropdown menu shows the key
binding next to the plugin name and left-clicking the plugin name executes the
global command--and, there is no way to display the plugin's help.

Plugin Help Rendering: Plugin help is rendered by the viewrendered plugin, not
by the old scrolledmessage.py plugin.

Leo-editor revision: 4433
OS: Ubuntu 11.04 (natty)

Startup log pane:
Leo Log Window
Leo 4.9 final, build 4411, June 21, 2011
Python 2.7.1, qt version 4.7.2
linux2
#@+node:ekr.20120229094652.14894: *7* Bug 815564: Plugin Menu-Keystroke binding can prevent plugin help display
https://bugs.launchpad.net/leo-editor/+bug/815564

===== Probably the same as bug 879331 =====

This anomaly only occurs when all of the following conditions are true:

1) There is a global command name X that is the "same" as the root name of the
file containing a plugin Y. Here, "same" means equal after the command name is
converted to lower case and all underlines in the root name are replaced by
dashes.

2) A shortcut (a.k.a. keystroke) is bound to command name X.

When these conditions are true, then the Plugins dropdown menu shows the key
binding next to the plugin name and left-clicking the plugin name executes the
global command--and, there is no way to display the plugin's help.

Plugin Help Rendering: Plugin help is rendered by the viewrendered plugin, not
by the old scrolledmessage.py plugin.

Leo-editor revision: 4433
OS: Ubuntu 11.04 (natty)

Startup log pane:
Leo Log Window
Leo 4.9 final, build 4411, June 21, 2011
Python 2.7.1, qt version 4.7.2
linux2
#@+node:ekr.20120229094652.14925: *7* Updating dependent dicts
k.computeInversBinding() called by print-commands and for auto-completion.

k.bindKey sets k.bindingsDict.

k.bindKeyToDict sets k.masterBindingDict.
#@+node:ekr.20120229094652.14941: *6* Fixed Bug: @mark-for-unit-tests nodes
The new TM.findMarkForUnitTestNodes allows both
TM.FindAllUnitTestsNodes and createOutline to be much simpler.
#@+node:ekr.20120229094652.14942: *6* The recent files commands now work
#@+node:ekr.20120229094652.15012: *6* Fixed bug: @int pagewidth now set c.page_width
Fixing this bug is important: it allows you to set a default
page width in myLeoSettings.leo for use, for example, in the
reformat-paragraph command.

Without a proper default c.page_width setting, you would have
to use @page_width instead, which is much less convenient.

The fix was the following lines in c.initConfigSettings:
    
    c.page_width = getInt('page_width') or 132
        # 2012/02/27: this appears to be a fix of an *ancient* bug.
#@+node:ekr.20120229094652.15013: *6* Fixed bug: goto end line handler is broken
The fix was easy: moveWithinLineHelper does *not* call
leoMoveCursorHelper for the case spot == 'end-line'
#@+node:ekr.20120229094652.14520: *6* Removed unused color tags
The following tabs remain.  They are Leo-specific, not jEdit specific:
blank, docpart, leokeyword, link, name, nameBrackets, tab, url.
#@+node:ekr.20120229094652.15147: *6* Fixed bug: End only goes to physical line
End going to only physical line and not to the logical (wrapped) one)... 
#@+node:ekr.20120229094652.15146: *6* Fixed bug 87933 with major key reorg
http://groups.google.com/group/leo-editor/browse_thread/thread/c933b28c27d3b9a7

Ref 4952 of the trunk fixes bug 87933:
"Redefining a key binding breaks menu items with same binding"

This was a difficult bug to fix--I rewrote significant parts of Leo's
code that deals with settings for key binding.

Besides fixing the bug, Leo computes accelerators in menu items
dynamically when the user activates a menu.  The accelerator shows
*all* keys bound to the command associated with the menu item.

From the checkin log:

A major reorganization of the configuration code that fixes bug 87933
Redefining a key binding breaks menu items with same binding

- Replaced g.bunches with ShortcutInfo objects...

- Wrote and tested make_settings_dict and its helpers,
  merge_settings_dicts, invert and uninvert.

- Leo computes menu texts dynamically in onAboutToShow.

- leo_update_shortcut now shows all shortcuts for a command.

- leoMenu.define_enable_dict encapsulates data used to enable/disable
  commands regardless of where those commands appear in Leo's menu. The old
  code assumed that a fixed menu location for all commands that could be
  enabled or disabled.
#@+node:ekr.20120313074006.14648: *6* Fixed Bug 930726 re expandNodeAndGoToFirstChild
https://bugs.launchpad.net/leo-editor/+bug/930726

Bug: If the node is not expanded already, then the position
is left on the parent, not the first child.

Function expandNodeAndGoToFirstChild() is referenced only
once in LeoPyRef.leo. This reference is in table of public
Leo commands.

The node in which expandNodeAndGoToFirstChild() is defined
also contains the definition of function
expandNodeOrGoToFirstChild(). At present these two functions
are equivalent. The comments including the header for the
node imply that they should not be equivalent and that
expandNodeAndGoToFirstChild() is not correctly implemented.
#@+node:ekr.20120313074006.14650: *6* Fixed Bug 869429 (undo & redo when deleting nodes from contextmenu)
https://bugs.launchpad.net/leo-editor/+bug/869429
Undo and Redo delete from context menu does not redo properly

The fix was to deletenodes_rclick in contextmenu.py.
The fallback position should be c.rootPosition()
#@+node:ekr.20120313074006.14697: *6* Fixed bug 924123: Some SyntaxError's thrown when compiling the whole source with Python 3
https://bugs.launchpad.net/leo-editor/+bug/924123

These syntax errors were minor in the sense that they had no
effect on Leo's users, but they were a significant
distribution issue because Linux packages are not to have
such errors.

I removed the following files. Apparently, they are used nowhere in Leo. 
    
    leo/core/leo_Debugger.py
    leo/core/leo_FileList.py"
    leo/core/leo_RemoteDebugger.py
    leo/core/leo_Shell.py
    leo/core/leo_run.py

This files no longer exists:

    leosax.py
#@+node:ekr.20120313074006.14702: *6* Fixed bug 501636: Leo's import code should support non-ascii xml tags
https://bugs.launchpad.net/leo-editor/+bug/501636
#@+node:ekr.20120313074006.14713: *6* Fixed bug 799695: colorizer bug after move-lines-up into a docstring
https://bugs.launchpad.net/leo-editor/+bug/799695

The fix was simply to call c.recolor_now(incremental=False)
#@+node:ekr.20120313074006.14714: *6* Fixed bug 824087: Alt+F4 is not the same as Alt+F, c
https://bugs.launchpad.net/leo-editor/+bug/824087

The fix was to bind Ctrl-F4 to close-window, instead of Alt-F4.

I instantly like this new binding.
#@+node:ekr.20120313074006.14715: *6* Fixed bug 923301: Unicode error when executing 'rst3' command
https://bugs.launchpad.net/leo-editor/+bug/923301
#@+node:ekr.20120313074006.14738: *6* Fixed g.os_startfile on Linux
#@+node:ekr.20120313074006.14800: *6* Fixed Bug: multiple @language directive not colored correctly
Example: typing in this rest section recolors as *Python*.
The correct coloring is restored when the entire text is recolored.

In this case, a workaround, and a performance improvement, would be to put
the ``@language python`` directive before the ``language rest``.
#@+node:ekr.20120313074006.14906: *6* Fixed Bug: multiple @language directives mess up add-comments command
- Added scanToCursor argument to c.scanAllDirectives in c.insert/removedComments.

- Added scanToCursor argument to get_directives_dict_list in c.scanAllDirectives.

- get_directives_dict_list sets scanToCursor only for the initial (root) node.

- g.get_directives_dict scans to cursor for @language directives is scanToCursor is True.
#@+node:ekr.20120313074006.15120: *6* Fixed bug 952365: Leo-Editor can't write a file created from the command line
https://bugs.launchpad.net/leo-editor/+bug/952365

Improved error reporting and checking, but the file won't be created if
createActualFile takes an IOError.
#@+node:ekr.20120313074006.15125: *6* Fixed bug 951921: Opening myLeoSettings.leo can clutter the console unworthwhile messages
https://bugs.launchpad.net/leo-editor/+bug/951921
#@+node:ekr.20120328102352.5897: *6* Fixed crasher in flattenOutline
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 553, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 2120, in flattenOutline
    c.importCommands.flattenOutline(fileName)
  File "c:\leo.repo\trunk\leo\core\leoImport.py", line 479, in flattenOutline
    theFile.write(s)
TypeError: must be str, not bytes
#@+node:ekr.20120328102352.5899: *6* Fix viewrendered crash
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoPlugins.py", line 337, in callTagHandler
    result = handler(tag,keywords)
  File "c:\leo.repo\trunk\leo\plugins\viewrendered.py", line 560, in update
    f(s,keywords)
  File "c:\leo.repo\trunk\leo\plugins\viewrendered.py", line 655, in update_graphics_script
    pc.gs = QtGui.QGraphicsScene(pc.splitter)
AttributeError: 'ViewRenderedController' object has no attribute 'splitter'
#@+node:ekr.20120328102352.5900: *6* Fixed most scrolling problem with multiple editors
Selecting body editor with clicks doesn't save/restore visual ivars.
The solution would be to create a new onClick event handler...
#@+node:ekr.20120328102352.5936: *6* Ensure selected @test node is run
In earlier version of Leo if one runs test externally with the selected
position under @test node, that @test was executed with (run-marked-unit-tests-externally)

The fix was to the "important special case" in TM.findAllUnitTestNodes.
#@+node:ekr.20120328102352.5938: *6* fixed problem with file:/// url's on Windows
http://groups.google.com/group/leo-editor/browse_thread/thread/bb063866875a81c3#

The fix is simply to special-case file:/// on Windows in g.computeFileUrl.
#@+node:ekr.20120318075211.6166: *5* Unfixed bugs
#@+node:ekr.20120313074006.14698: *6* Failed to fix bug 844953: copy-clone-pasted node appears in other tab
https://bugs.launchpad.net/leo-editor/+bug/844953

1. Open two empty files with the Leo revision 4451/trunk using the qttabs GUI and save them both.
2. Create a new node and write "Abc" in its head.
3. Select "Copy Node" from the outline menu.
4. Select "Paste Node As Clone" from the outline menu:
   Node is not inserted as clone, but inserted as a copy in the second file/tab.

Sometimes even a standard Copy-Paste action results in the node being inserted in the other file.

EKR: This a unity menu problem, not a problem with the paste commands per se.

http://qt-project.org/forums/viewthread/15366/

#@+node:ekr.20120229094652.14518: *4* Code improvements
#@+node:ekr.20120229094652.15142: *5* Leo's new classes
http://groups.google.com/group/leo-editor/browse_thread/thread/808ba29fec64e590

For almost 15 years Leo has been written using a limited set of classes.
These were "big" classes, implementing major modules of Leo. There is
nothing wrong with these classes, and they will remain unchanged, except
insofar as they will be simplified by the classes I am about to discuss.

Recently, I have become aware that Leo's code could be considerably
simplified by adding "smallish" classes. Indeed, I now think the
distinction between big and small classes is unhelpful. The most important
part of the design of a class is simply whether a class implements an
understandable concept.

With this introduction, here is a short summary of Leo's new classes. Some
have not been fully implemented. Getting them all to work is a big part of
the rewrite of Leo's config, loading and key-handling code.

#@+node:ekr.20120318075211.6168: *6* LoadManager
This class handles all the messy details of loading .leo files at startup.
This class encapsulates almost all the code in runLeo.py, as well as some
methods in leoGlobals.py that really belong somewhere else.

Creating a class simplifies the code to a surprising degree: 5 or 6 ivars
of the class represent command-line options. These ivars are always
available: there is no need to pass them around as arguments.
#@+node:ekr.20120318075211.6169: *6* ModeController & ModeInfo (not used yet)
The ModeController class represents a collection of modes. The ModeInfo
class represents a single mode.

Without these classes, the code in leoKeys.py is extremely hard to
understand. In fact, the old code was a perfect example of the problems
with procedural programming: client code was burdened with knowing way too
many details about matters that it shouldn't have to know about.
Furthermore, that data itself is hard to understand: it's too "raw". These
classes provide "identity" for data. repr(aModeInfo) is surprisingly
useful.
#@+node:ekr.20120318075211.6170: *6* LogManager (not used yet)
This class represents the global log.  It hides the details of the log
from the g.app class and several other pieces of code.

At present, the interface to this class is procedural.  That is, the
present g.app methods that will be moved into this class have a
procedural rather than descriptive nature.  I'm not sure how much this
will change, but creating this class may create opportunities that
were not apparently previously.

#@+node:ekr.20120318075211.6172: *6* KeyStroke & ShortcutInfo
The KeyStroke class is a wrapper for plain strings. It's most important
attribute is its *identity*. It announces that its contents is a
canonicalized value, not a raw user settings string or any other kind of
data associated with key handling.

Similar remarks apply to ShortcutInfo objects. Their identity clarifies the
code. The former code used g.bunches. In complex code such as leoKeys.py,
such anonymous objects really obfuscate matters.

#@+node:ekr.20120318075211.6173: *6* EditCommandsManager
This class solves a problem that has been annoying me ever since I created
leoEditCommands.py. The problem is this: without this class the classesList
has to be defined at the end of the module, after all classes have been
imported. Worse, several module-level methods were needed to manage the
classesList.

In the new scheme, each Commander creates an EditCommandsManager, and the
code that previously had to call the module-level method
leoEditCommands.x(c) now simply calls c.editCommandManager.x(). This is
much cleaner and avoids several very ugly imports. Which brings me to...
#@+node:ekr.20120318075211.6174: *5* Most files now import just leo.core.leoGlobals
Now, most modules import only leo.core.leoGlobals. This simplifies Leo's
startup process considerably. This is something that I've wanted to do for
a long time. To make this work, it is *essential* that leoGlobals.py import
*no* other Leo modules.

However, Leo's core still imports leo.core.leoNodes in order to create
positions, vnodes, etc. It would be straightforward to eliminate these by
creating g.app factory methods, but there is no urgent reason to do so.

The ctor for the Commands class imports many modules. This is essential to
break what would otherwise be circular dependencies among Python imports.
We can extend this pattern by creating more classes, as was done with the
EditCommandsManager class.
#@+node:ekr.20120318075211.6175: *5* Global switches are now all in leoGlobals.py
leoGlobals.py now contains a section called ``<< global switches >>``

This contains global tracing switches. Experience shows that leoGlobals.py
is the most convenient place for such switches. This section also contains
switches that enable new code bases. Recent examples were::

   new_load = False # True: .leo files are loaded at most once.
   if new_load: print('***** new_load')

   new_modes = False # True: use ModeController and ModeInfo classes.
   if new_modes: print('***** new_modes')
#@+node:ekr.20120229094652.15138: *5* version.py now uses bzr_version.py
http://groups.google.com/group/leo-editor/browse_thread/thread/5fdadfba113e12d9/fa329534654ecfec

Leo now reports bzr version numbers and dates automatically.  Very important.
#@+node:ekr.20120229094652.15176: *5* Minor
#@+node:ekr.20120229094652.14522: *6* Eliminated the low-level interface
Only the high-level interface (baseTextWidget) used the low-level interface.
#@+node:ekr.20120229094652.14523: *6* Removed unused cruft from high-level interface
Removed the following unused methods::
    
    bind                c.bind also removed.
    configure
    cget
    event_generate      g.app.gui.event_generate does exist.
    getWidth
    indexIsVisible      Also removed for leoEditCommands: scrollHelper and measure.
    mark_set
    onChar              Fortunately, never used anywhere
    pack                Used only in Tk code
    scrollLines
    set_width           Removed do-nothing calls in Leo's core.
    tag_add             Removed do-nothing calls in qt colorizer.
    tag_bind            Removed do-nothing calls in qt colorizer.
    tag_delete          Removed do-nothing calls in qt colorizer.
    tag_names
    tag_ranges
    tag_remove
    update
    update_idletasks
    xyToPythonIndex
    yview
#@+node:ekr.20120229094652.14525: *6* Unified the high-level interface
leoQTextEditWidget overrides base toPythonIndex toPythonIndexRowCol.

The versions that call g.toPythonIndex are much slower than
leoQTextEditWidget.toPythonIndex.

The following classes have a toPythonIndex method:

leoQTextEditWidget (fast)

HighLevelInterface: calls g.toPythonIndex.
baseTextWidget: calls g.toPythonIndex.
leoFind: calls g.toPytonIndex.
leoQtBaseTextWidget: calls g.toPythonIndex.
#@+node:ekr.20120229094652.14526: *6* Create properties for logCtrl & bodyCtrl
This is an important addition to reliability.

It ensures that body/log.widget and body.bodyCtrl/log.logCtrl are always in synch.
#@+node:ekr.20120229094652.14527: *6* Added eventFilters to top-level frames
Added eventFilter in createFrame in SDI/TabbedFrameFactory classes
#@+node:ekr.20120229094652.14528: *6* Added log.orderedTabNames
#@+node:ekr.20120229094652.14532: *6* Created the TestManager class
All top-level code in leoTest.py now resides in the
TestManager class.

The c.testManager object eliminates the need for imports of
leo.core.leoTest within unitTest.leo, an excellent
simplification.

Furthermore, there is no need to access the testUtils class:
everything is in c.testManager.

The TestManager class substantially clarifies *all* the code
in leoTest.leo. This is surprisingly important because the
testing code is hardly straightforward.
#@+node:ekr.20120229094652.14533: *6* Created the LoadManager class (docs)
This is a major restructuring of Leo's code:
    
Initing settings files and local files is now as simple as possible.

g.openWithFileName now simply calls lm.loadLocalFile.

Commands.__init__ now calls c.finshCreate.

g.app.newCommander now simply calls Commands.__init__,
a *huge* collapse in complexity.

===== Details

The g.app.config class is now substantially simpler:
complex methods have moved to the LoadManager.

The new LoadManager class handles all aspects of Leo's
complex startup process, including most importantly the very
complex process by which Leo reads user settings.

As a side effect, c.config.get is now *much* simpler than
before: it search one, and *only* one dictionary to discover
settings.

Reading local files must be done *twice*. The first read
discovers settings, the second read uses those settings to
open the file. The first read always uses a null gui; the
second read uses g.app.gui, whatever that happens to be.

LM.openLocalFile embodies all aspects of the complex
strategy necessary for opening a local file twice. The first
read creates a PreviousSetting object, which is then passed
to LM.openFileByName, which in turn passes the
PreviousSetting object to the ctor for the Commander.
Finally, the PreviousSetting object inits c.config.

Because of the previousSettings object, the call to
LM.openFileByName does *not* need to "synthesize" a link to
c1 using c.hash. This stamps out bug 568452 at its source.

The crucial point is the previous settings get passed along
to the Commander ctor, *before* LM.openFileByName calls
c.fileCommands.openLeoFile to create the outline.

#@+node:ekr.20120229094652.14534: *6* Removed c argument from g.app.config getters
- Moved findSettingsPosition to LocalConfigManager.

- Moved printSettings to LocalConfigManager.
#@+node:ekr.20120229094652.14535: *6* Delay "reading settings" message until after signon
#@+node:ekr.20120229094652.14538: *6* Use at.readOneAtAutoNode instead of ic.readOneAtAutoNode
It's important to use only one version of the code.
#@+node:ekr.20120229094652.14578: *6* Added p.positionAfterDeletedTree
This important new method allows scripts to traverse an outline, deleting nodes
during the traversal. The pattern is::

    p = c.rootPosition()
    while p:
    if <delete p?>:
        next = p.positionAfterDeletedTree()
        p.doDelete()
        p = next
    else:
        p.moveToThreadNext()
        
This method also allows scripts to *move* nodes during a traversal, **provided**
that nodes are moved to a "safe" spot so that moving a node does not change the
position of any other nodes.

For example, the move-marked-nodes command first creates a **move node**, called
'Clones of marked nodes'. All moved nodes become children of this node.
**Inserting** these nodes as children of the "move node" does not change the
positions of other nodes. **Deleting** these nodes *may* change the position of
nodes, but the pattern above handles this complication cleanly.
#@+node:ekr.20120229094652.14577: *6* Removed Leo's old syntax coloring code
This was Tk code, and so can not possibly be useful now.

Also removed the settings specific to the Tk colorizer.
#@+node:ekr.20120229094652.14583: *6* Rewrote shell-command commands
Rewrote the shellCommand, shellCommandOnRegion and executeSubprocess methods.
#@+node:ekr.20120229094652.14608: *6* Added g.app.isExternalUnitTest
Unit tests can test this ivar.
#@+node:ekr.20120229094652.14611: *6* Added c.config.set
An useful convenience method now that external unit tests can use config settings.
#@+node:ekr.20120229094652.14595: *6* help-for-command now uses g.getDocStringFromFunction
#@+node:ekr.20120229094652.15157: *5* Investigations
#@+node:ekr.20120229094652.15158: *6* Investigated unicode problems with print
After so many years of confusion the problem is now apparent:
the Windows console uses code page 437: which is just extended ascii.

chcp 65001 is equivalent to utf-8, and it would be good to use,
but at present bzr goes nuts and changes to another code page!

So for the moment I'll have to live with what is, in effect, plain ascii.
#@+node:ekr.20120229094652.15159: *6* Investigated autocomplete popup bug
On Ubuntu only, the auto complete popup is system-wide modal, it should only be modal over Leo windows.

However, there does not seem to be any fix:
http://groups.google.com/group/leo-editor/browse_thread/thread/171aaf79e0bea256

All works well on Windows 7.  I do see the "system-wide" model
behavior on Ubuntu.

This appears to be a Ubuntu-specific bug.  Indeed, the popup is a
QListWidget.  Such widgets have a setWindowModality method::

    setWindowModality ( Qt::WindowModality windowModality )

The valid modalities are at: http://doc.qt.nokia.com/4.7-snapshot/qt.html#WindowModality-enum

NonModal: The window is not modal and does not block input to other
windows.

WindowModal: The window is modal to a single window hierarchy and
blocks input to its parent window, all grandparent windows, and all
siblings of its parent and grandparent windows.

ApplicationModal: The window is modal to the application and blocks
input to all windows.

None of these would appear to be a system-wide modality, and
furthermore, the default is supposed to be NonModal.

Anyway, calling setWindowModality(QtCore.Qt.NonModal) does not seem to
have much effect on Ubuntu, so I think I can safely say there is
nothing more I can do. 
#@+node:ekr.20120229094652.15162: *4* Major new features
#@+node:ekr.20120318075211.6167: *5* Improved handling of URL's
Leo's core now supports opening URL's in several ways:

1. By Control-Clicking the headline of a node containing a URL in its
   headline or the *first* line of its body text.
   
2. The open-url command opens a URL in a nodes headline or the first
   line of its body text.
   
3. By Control-Clicking any URL in the body text.

Notes::

- URL's may optionally start with ``@url``.  Leo removes this prefix
  before trying to open the URL.

- Names of existing files are considered valid URL's. In that case, Leo
  prepends ``file://`` to the file name.
  
- Relative file names are resolved to c.openDirectory, the directory of the
  .leo file.
  
- You may use the {{expression}} syntax in any ``file://`` URL, including
  ``file://`` URL's created from file names.
  
- The bookmarks.py plugin supports all of the features listed above.
#@+node:ekr.20120229094652.14593: *5* Tab completion shows all @command/@button commands
Wouldn't it be great if we all could remember what we, and others, have
already done? Now there is an easy way to do so: just put your
commonly-used scripts in global @command nodes. You do this by placing each
@command node as a child of an @commands node in your @settings tree in
myLeoSettings.leo.

Leo's tab completion now shows you all @command nodes, all @button nodes
and all the commands associated with those nodes.  To see the list of
all your @command nodes, simply type::

    <Alt-X>@c<Tab>
    
When I do that, I see::

    @command-align-eq-signs
    @command-c-to-python-clean-docs
    @command-clean-all-blank-lines
    @command-clean-body
    @command-clean-diff
    @command-clean-spellpyx
    @command-cls
    @command-count-pages
    @command-create-@auto-nodes
    @command-create-def-list
    @command-flatten-script
    @command-join-node-above
    @command-join-node-below
    @command-load-all-leo-files
    @command-preview-node
    @command-preview-tree
    @command-print-cmd-docstrings
    @command-promote-bodies
    @command-remove-newlines
    @command-split-defs
    
For each @command (and @button node) Leo creates the correspond commands
without the leading "@command-", so you can use typing completion on the
shorter command name. For example, when writing documentation, I often use
the promote-bodies script. After the reminder above, I can execute the
script with::

    <Alt-X>prom<Tab>-<Tab><Return>
    
Of course, to rexecute the command later, I can use repeat-complex-command
(Ctrl-P).

Summary
=======

If you put all your commonly-used scripts in @command nodes, you can use
<Alt-X>@c<Tab> to remind yourself of their names. That is, Leo's typing
completion eliminates the need for memory-intensive retrieval. I'm not
likely ever to forget typing completion.

This scheme takes full advantage of Leo's organization strengths and
*concentrates* those strengths by putting all the to-be-organized material
in one place. This allows for easy reorganization: changing command-name
prefixes, for instance, would be straightforward.
#@+node:ekr.20120229094652.15093: *5* Weightless unit testsing
Small improvements the unit testing framework created big results. They
completely eliminate the overhead in running unit tests:

    - The run-marked-unit-tests-externally (Alt-4) command runs all marked
      @test nodes. To choose tests, just mark them.
    - Alt-4 now saves the .leo file first.
    - Almost all unit tests may now be run externally:
        - External unit tests always read config settings.
        - The nullGui now uses a fully capable string-based body widget.
        - The nullGui now uses the regular undoer.
    - Unit tests now always have the sources available.
    - Disabled messages on external unit tests.
    - The unit test commands always run a selected @test node.

These improvements mean that almost all unit tests may be run externally.
In turn, this creates a remarkable work flow::

    Edit
    Alt-4
    Edit
    Alt-4
    ...

The energy difference between weightless and heavy is astounding. Try the
new way: you will surely like it.

**Notes**:

Experience shows that being able to run the desired unit tests *without*
selecting any particular node makes an amazingly large difference. Being
able to run all and only marked unit tests is a big step forward.

If a marked node is neither an @test node nor an @suite node, all nodes in
the tree are considered to be marked.
#@+node:ekr.20120313134250.14232: *5* Leo's File:Open With command now works with Qt
Support for the open-with command is now part of Leo's core.
#@+node:ekr.20120229094652.14585: *5* Added quick edit/save mode
Leo can act like a drop-in replacement for SciTe. Suppose you do::
    
    leo x.y
    
where y is not "leo". Leo now opens an unnamed .leo file consisting of
@edit x.y. if x.y exists, the @edit node contains the entire file;
otherwise the node is empty.

When you save the .leo files or close the Leo window Leo saves x.y if it
has been changed, but Leo does *not* prompt you to save the "temporary"
.leo file.

https://bugs.launchpad.net/leo-editor/+bug/381527
#@+node:ekr.20120229094652.15153: *5* Detached windows
http://groups.google.com/group/leo-editor/browse_thread/thread/3666397da2a0d05f/758071d6d9516ab9

The right-click context menu on the tabs in the tabbed window mode (the
default) has a 'Detach' option, if there's more than one outline/tab, and a
Re-attach all option, if there's a detached outline window out there.

Now there's also 'Horizontal tile', and 'Vertical tile', which detach the
tab and then tile its window with the window from which it was detached.

This is very helpful for moving nodes between outlines, I was rearranging
the windows by hand and setting one to 'always on top' with the window
manager before. Note: there's a @setting to determine whether dragging
nodes between outlines copies or moves them.

Depending on your OS / window manager, tiling / placement may be somewhat
off, and may work better with or without the window being maximized before
tiling, you'll have to experiment.

When you close an outline window created by detaching a tab the outline is
just re-attached as a tab. This means it's now possible to reattach just
one outline, rather than having to use the 'reattach all' option.
#@+node:ekr.20120229094652.15135: *5* The leoInspect module
The leoInspect module provides answers to questions about Python source
code. leoInspect is an elegant and easy-to-use front end for Python's AST
(Abstract Syntax Tree) trees *and* a window into a richly connected set of
semantic data built *from* AST trees.

For details, see http://leoeditor.com/leoInspect.html
#@+node:ekr.20120313074006.14640: *5* Instant abbreviations (~a)
Leo's abbreviation code is now simpler and more general than before. The
downside is that you will likely have to revise your abbreviations. I
believe the extra work will be well worthwhile.

Here are the changes:

1. Abbreviations may consist of *any* sequence of characters, including
whitespace or "special" characters. You may include whitespace characters
in definitions using the '\t' and '\n' escapes. However, whitespace may
only appear at the *end* of definitions.

2. You must take care to disambiguate abbreviations if one is a prefix of
   another.

Here is an example of both points.  As always, you define
abbreviations in the body of an @global-abbreviation node or
@abbreviation node::

    nc =@nocolor\n
    nc\n=@nocolor\n
    nc\t=@nocolor\n

    ncn=@nocolor-node\n

As you can see, the definitions uses whitespace at the end
of the definition of "nc" to prevent it from being expanded
when typing "ncn".

3. The reason I call these abbreviations "instant" is that they can be
triggered on *any* keystroke, not just the end of a "word".  This
allows you to define::

    teh=the

Hurray!

4. Two rules limit scans.  They are useful and shouldn't cause
hardships.

A.  The backspace and delete characters *never* trigger substitutions.

B. The scan for definitions ends at the first newline
character. Therefore, whitespace will have effect only at
the *end* of a definition.

**Important**: these rules can cause problems when *defining*
abbreviations:  it's easy to trigger an unwanted definition.  The
solution is to use rule 4B:

I want to type::

    ncn=@nocolor-node\n

But I **cant** type this directly if nc is already defined!  The trick
is to type::

   nxcn=@nocolor-node\n

and then delete the leading x with a backspace character.

Of course, you could also turn abbrevions off while defining abbreviations...

Instant abbreviations solve the problems with Brazilian
keyboards. Just define::

    ~a=ã
    ~A=Ã
    etc.

This works regardless of keyboard, regardless of OS, etc.
You might want to define::

    ~\a=~a
    ~\A=~A

in the somewhat unlikely event that you want to type ~a rather than,
say, ~+a.  Of course, you don't need these, provided you remember to
type ~xa <Right><Delete> :-)
#@+node:ekr.20120229094652.15163: *4* Minor new features
#@+node:ekr.20120328102352.5946: *5* Improved Leo's home page
http://leoeditor.com

- Added link to home page from the TOC.

- Removed online-tutorial link.

- Added search box to Leo's home page.

- Added link to glossary from Leo's home page.

- Added scaled screen shot to Leo's home page.

- Brought screen shots up to date.
#@+node:ekr.20120229094652.14787: *5* Generalized stylesheet handling
Code that wants to set a particular part of a widget's style sheet calls::

   g.app.gui.update_style_sheet(w,key,value)

where w is the widget whose stylesheet is to be changed, key is unique
to the method (or group of methods), and value is the new version of
the stylesheet **for the particular key** to be added.  Examples::

   # In setEditorColors.
   sheet = 'background-color: %s; color: %s' % (bg,fg)
   g.app.gui.update_style_sheet(obj,'colors',sheet)

   # In add_border.
   sheet = "border: %spx solid %s" % (
       c.focus_border_width,c.focus_border_color)
   self.update_style_sheet(w,'border',sheet)

   # In remove_border.
   sheet = "border: %spx solid white" % (c.focus_border_width)
   self.update_style_sheet(w,'border',sheet)

So add_border and remove_border work together because they use the
same 'border' key.

g.app.gui.update_style_sheet is straightforward: it injects a Python
dict called leo_stylesheet_dict into the widget, and computes the
total stylesheet as follows::

   # Step one: update the dict.
   d = hasattr(w,'leo_styles_dict') and w.leo_styles_dict or {}
   d[key] = value
   w.leo_styles_dict = d

   # Step two: update the stylesheet.
   aList = [d.get(key) for key in list(d.keys())]
   s = ';'.join(aList)
   w.setStyleSheet(s)
#@+node:ekr.20120229094652.15151: *5* Leo now raises a dialog on @ignore @<file> nodes
http://groups.google.com/group/leo-editor/browse_thread/thread/b49d23010703aa61/32e1271d25ba2cfb
#@+node:ekr.20120229094652.14596: *5* @ignore now prevents local @button/@command node definitions
There is no longer any need for @@button, etc.: just put under an @ignore node.
#@+node:ekr.20120229094652.14592: *5* Added support for tags in @button nodes
The mod_scripting plugin so that the name of the command created by an @button
nodes does not include any [<tag>] that immediately follows @button. Examples::

    @button [ekr] x
    @button [edit] y
    @button [important] z

These buttons create commands named x, y and z, and the name of the buttons are
x, y and z.

Note that the '[' must be the first non-blank after @button to be recognized and
removed.

The code is a straightforward addition to cleanButtonText in mod_scripting.py:
it is unlikely to have any impact whatsoever to existing @button nodes.

The intended use is for searches of the form @button [some tag].
#@+node:ekr.20120229094652.14610: *5* bridgeController.initLeo now kills events if plugins not loaded
The new code monkey-patches g.doHook to a do-nothing::
    
    if not self.loadPlugins:
        def dummyDoHook(tag,*args,**keys):
            pass
        g.doHook = dummyDoHook
#@+node:ekr.20120229094652.14607: *5* Call unselect1 hook only once
http://groups.google.com/group/leo-editor/browse_thread/thread/e2980a2b86af913e

I see the following
- when a file is opened
  - one message listing the root node
  - 7 repeats of the message for the current node

- when the file is saved in a session with several tabs
  - a message is generated for each current node in each tab

- shifting focus from body to headline doesn't generate the message,
  shifting focus with <Ctrl-H> does

- switching from one tab to another doesn't generate the message 
#@+node:ekr.20120229094652.14613: *5* Improved scannerUnitTest
The error message is now part of the failed assert.  Very helpful.
#@+node:ekr.20120314095341.14216: *5* Leo supports @ignore when scanning for @command and @button nodes.
There no need to disable buttons and commands with \@@button or \@@command.
#@+node:ekr.20120229094652.14777: *5* Support @ignore when installing @command/@button nodes
Changed doButtons and doCommands kind handlers.

This allows us to put example nodes in leoSettings.leo.
#@+node:ekr.20120229094652.14541: *5* set g.app.execute_script during script execution
This allows the following pattern to appear in Leo source files::

    class myClass:
        @others
        
    if g.app.testing:
        myClass(c).test()
        
This is better than enabling the test with "if 1:" because c is not defined
while importing the module, so the import will fail if I forget to change
"if 1:" to "if 0" when saving the .leo file.
#@+node:ekr.20120229094652.14600: *5* Support single-line nodes like <node/> xml import code
The single-line nodes should end in a newline. Otherwise the created node
will add a newline, and the checkers will complain.

The new class is xmlScanner and htmlScanner in leoImport.py.
#@+node:ekr.20120229094652.14576: *5* The Find tab now scrolls
The change was to DynamicWindow.createLogPane.
#@+node:ekr.20120229094652.14621: *5* Warn when importing/reading/writing @ignored nodes
What I did:
    
1. Created c.init_error_dialogs & c.raise_error_dialogs.

These are called from the following methods:
    
c.importAnyFile
c.open
c.readAtAutoNodes
c.readAtFileNodes
at.readAll
c.save
c.saveAs
c.saveTo
fc.writeAtFileNodes
fc.writeAtShadowNodes
fc.writeDirtyAtFileNodes

2. Disabled log messages in several of the above methods during unit testing.

3. Disabled runOpenFileDialog and runSaveFileDialog during unit testing.
#@+node:ekr.20120229094652.14849: *5* Disabled section-reference handling in @auto files
#@+node:ekr.20120313074006.14772: *5* Dragging a binary file to Leo creates an @url node
https://bugs.launchpad.net/leo-editor/+bug/807561

The isBinaryFile helper returns True if the file's extension is not known.
This isn't great, but it's safe. The list of known text types includes:
    
1. '.css','.html','.leo','.txt'
2. All extensions in g.app.extension_dict.keys().
#@+node:ekr.20120229094652.14612: *5* Alt-left-arrow collapses all children when selecting the parent
Under control of @bool collapse_on_lt_arrow option, default *True*.
#@+node:ekr.20120313074006.14643: *5* Reinstated warnings for conflicting definitions
k.remove_conflicting_definitions always gives the warning, not just when tracing.

The warning isn't the best, and it is usually duplicated, but it is much better than nothing.
#@+node:ekr.20120229094652.14589: *5* Searches from Leo's web pages now work
Updating Sphinx and using new .js files did the trick.
#@+node:ekr.20120229094652.14601: *5* Leo's home page now shows the latest postings from leo-editor.
Leo's home page now shows the latest postings on the leo-editor group.
#@+node:ekr.20120328102352.5942: *5* Alt-Home & Alt-End collapse all possible nodes
#@+node:ekr.20120229094652.15164: *4* New & improved commands
#@+node:ekr.20120229094652.14590: *5* Added @button split-defs
#@+node:ekr.20120229094652.14544: *5* Added beautify-c command
Added class CPrettyPrinter & beatifyCCode
#@+node:ekr.20120229094652.14545: *5* Added c-to-python command
This command is a rewrapping of the first Python script I ever wrote. It
takes much of the scut work away from the task of converting C code to
Python code.
#@+node:ekr.20120229094652.14625: *5* Added clone-find-all-flattened command
The clone-find-all command includes nodes only once: if a node's ancestor
appears in the list, the node is not include again in the top-level list.
The new clone-find-all-flattened command includes every found node in the
top-level list of nodes. I find this less confusing.
#@+node:ekr.20120229094652.15090: *5* Added clone/move/delete-marked-nodes commands
http://groups.google.com/group/leo-editor/browse_thread/thread/4686ebad81bb1ea1
#@+node:ekr.20120229094652.14602: *5* Added run-marked-unit-tests-locally/externally
The new command names and default bindings are::

    run-all-unit-tests-externally       = None
    run-all-unit-tests-locally          = None
    run-marked-unit-tests-externally    = Alt-4 # The new standard
    run-marked-unit-tests-locally       = None
    run-selected-unit-tests-externally  = Alt-5 # The new standard
    run-selected-unit-tests-locally     = None
#@+node:ekr.20120229094652.14542: *5* Added select-to-matching-bracket command
#@+node:ekr.20120229094652.14616: *5* Improved add/delete-comments
add-comments preserves trailing whitespace.

delete-comments now works whether or not blanks surround comments delims.
#@+node:ekr.20120229094652.14581: *5* Improved open command
Leo creates @file nodes (not @thin nodes) when opening an external file.

Changed g.openWrapperLeoFile to create @file instead of @edit when possible.

Open now shows all files. This is a cue that *any* file may be opened:
non-Leo files are opened in @edit nodes.
#@+node:ekr.20120229094652.15169: *5* Improved page-up & page-down commands
#@+node:ekr.20120229094652.14622: *5* Improved presentation of autocompletion list
- don't print 'all' in bindings.

- pad bindings properly, as is done in print-commands/bindings.
#@+node:ekr.20120229094652.14618: *5* Improved print-bindings & print-commands
- print-bindings: Alt/Ctrl+Key+N now printed with plain Alt/Ctrl keys and shown as Alt/Ctrl+N.

- print-commands: Alt/Ctrl+Key+N now printed as Alt/Ctrl+N.

- print-commands & print-bindings do not print 'all'.
#@+node:ekr.20120313134250.14294: *5* Improved rst3 command
**Important**: This was all done in Leo 4.9, but not properly documented.

Allow section references in rst3 command.

http://groups.google.com/group/leo-editor/browse_thread/thread/3cd5cb06d32264d

- Added support for the following options:
    - expand_noweb_references:  default False for compatibility.
    - ignore_noweb definitions: default False for compatibility.

- When expand_noweb_references is True, definitions (typically clones)
  must be descendants of the referencing node (in the @rst tree)
#@+node:ekr.20120229094652.14599: *5* Improved word jumps/deletes
Many editors allow you to jump over, select and delete words, especially
those containing or surrounded by special characters, in a smarter way than
just "going to the beginning of the word before" (back-word) or "going to
the end of the next word" (forward-word).

Patches add "-smart" equivalents of the jump, select and delete commands.
Users wanting to use these commands can set in their myLeoSettings.leo::

  back-word-smart                  = Ctrl-LtArrow
  back-word-smart-extend-selection = Ctrl-Shift-LtArrow

  forward-word-smart                  = Ctrl-RtArrow
  forward-word-smart-extend-selection = Ctrl-Shift-RtArrow

  delete-word-smart          = Ctrl-Delete
  backward-delete-word-smart = Ctrl-BackSpace
#@+node:ekr.20120229094652.15165: *4* Plugins
#@+node:ekr.20120229094652.15091: *5* Improved quicksearch plugin
- Selecting any node using arrow keys shows the node in the outline immediately.

- Clicking a node or hitting <return> puts focus in body pane.
#@+node:ekr.20120313074006.16135: *5* New bigdash plugin
http://groups.google.com/group/leo-editor/browse_thread/thread/f7eaf4dd4e84a535

Screenshot here:

https://plus.google.com/103097156557482112329/posts/6qSngscG38Y

Instructions (with current trunk):

- enable bigdash.py plugin
- alt-x global-search
- Enter "s somesearch" in the line editor and press enter
- Browse the hits. Click on link to navigate to the node.

Caveat:

If the document is not in currently active tab, the navigation is
done "in the background". Correct implementation would be to activate
the tab in order to bring attention to it. 
#@+node:ekr.20120229094652.14776: *5* Removed scrolledmessage plugin
The scrolledmessage plugin no longer exists. The runScrolledMessageDialog
*does* still exist, but it now uses the viewrendered plugin.
#@+node:ekr.20120313074006.14655: *5* vim and xemacs plugins now work smoothly with contextmenu plugin.
#@+node:ekr.20120229094652.14540: *5* Supported auto-hide in viewrendered plugin
#@+node:ekr.20120229094652.15166: *4* Scripts
#@+node:ekr.20120229094652.14582: *5* Improved create @auto nodes script
#@+node:ekr.20120229094652.14567: *5* Added import-org-mode script
#@+node:ekr.20120229094652.15131: *5* Code for displaying a function call hierarchy in Leo
From Brian Theado

The other day I stumbled across Ville's code in scripts.leo which displays the
output of python's trace module in a leo outline. The output of the trace module
is not very friendly and I didn't find the result very usable. I was inspired to
write some code to translate the output so the tree of function calls is
displayed via Leo headlines. Thanks to Ville for sharing that code. I never
would have figure this out without that starting point.

Just copy (Ctrl-Shift-V) the child outline into a leo outline and hit ctrl-b on
the "call tree" node. The execution tree of the 'scroll-outline-up-line'
minibuffer command will be displayed to stdout and also as a tree of leo
headlines.
#@+node:ekr.20120229094652.15132: *6* call tree
import trace

@language python
@others

# http://docs.python.org/library/trace.html for documentation
# on the trace module
tracer = trace.Trace(countcallers=1)

# Trace a minibuffer command.

# Any function call will work. Leo's minibuffer commands are easily discoverable
# via tab completion and the 'print-commands' command.

#tracer.runfunc(c.executeMinibufferCommand, 'goto-prev-node')
tracer.runfunc(c.executeMinibufferCommand, 'scroll-outline-up-line')

top = p.insertAsLastChild().copy()
top.h = 'trace session'
displayCalltree(top, tracer.results().callers.keys())
c.redraw()
#@+node:ekr.20120229094652.15133: *7* displayCalltree
def displayCalltree(p, callinfo):
   '''
   Converts the function call hierarchy in 'callinfo' into a tree of function
   calls.  The function call tree is displayed to stdout as indented text
   and is inserted as a tree of leo nodes rooted at the given position 'p'
   '''
   callers = [k[0] for k in callinfo]
   callees = [k[1] for k in callinfo]

   # The first set of children will be those that don't have any callers
   # listed in callinfo
   toplevels = list(set(callers) - set(callees))
   positions = {}
   path = []

   # Depth-first traversal of the call hierarchy represented by 'callinfo'
   # 'levels' is a stack which grows during descend and shrinks
   # during ascend.  Each element of 'levels' is a list of unprocessed
   # siblings of each other
   levels = [toplevels]
   while len(levels) > 0:
       while len(levels[-1]) > 0:
           # Process the first element in the 'deepest' (i.e. last) list of siblings
           cur = levels[-1][0]
           levels[-1] = levels[-1][1:]
           indent = " " * 4 * (len(levels)-1)
           if cur not in path:
               if cur in positions.keys():
                   # Function already seen, so make a clone
                   clone = positions[cur].clone()
                   clone.moveToLastChildOf(p)
                   print (indent + "%s %s ..." % cur[1:])
               else:
                   # Haven't seen this function, so insert a new headline
                   p = p.insertAsLastChild().copy()
                   p.h = "%s %s" % cur[1:]
                   print (indent + p.h)

                   # Remember the position so it can be cloned if seen again
                   positions[cur] = p

                   # Find all callees of this function and descend
                   levels.append([c[1] for c in callinfo if c[0] == cur])
                   path.append(cur)
           else:
               r = p.insertAsLastChild().copy()
               r.h = "(recursive call) %s %s" % (cur[1], cur[2])
               print(indent + r.h + "...")

       # Ascend back up one level
       path = path[0:-1]
       p = p.parent()
       levels = levels[0:-1]
#@+node:ekr.20120229094652.15134: *7* trace session
#@+node:ekr.20120229094652.14543: *5* Improved recursive import script
- Generates only @auto, does not do an actual import.

- Creates @path nodes so actual @auto nodes are short.
#@+node:ekr.20120229094652.15149: *5* Replacing Qt stylesheets on the fly
http://groups.google.com/group/leo-editor/browse_thread/thread/ba9eb63337467d42/a3f3750d0ce6e847

> Here's a one line @button node you can add to myLeoSettings.leo
>
> @button set-style
>    c.frame.top.leo_ui.setStyleSheet(p.b)

Cool.  I've added this to my "pre-writing" pile of things to be
included in the next set of docs.

Important:  setStyleSheet *replaces* the previous stylesheet with the
new stylesheet, so you had best set all the attributes of Leo's
default stylesheet.

As an alternative, if w is any Qt widget, w.setStyleSheet(p.b) will
set the stylesheet for that widget only: the top-level stylesheet (the
stylesheet for c.frame.top.leo_ui) remains unchanged.
#@+node:ekr.20120229094652.15089: *5* Terry added bookmark scripts
http://groups.google.com/group/leo-editor/browse_thread/thread/b17d140b7ceb8fc9

I've added web page bookmarking from your browser to Leo.

Docs., appended to the mod_http plugin, where this functionality lives,
are pasted below.

Screen shot of the form which pops up when you click the Bookmark
button in your browser attached.  The body text of the corresponding
bookmark node created in Leo is:

    Leo's Home Page
        http://leoeditor.com

        Tags: leo, python

        Leo's Home Page

        Collected: Sun 02 Oct 2011 02:52:51 PM CDT

        Keep this under your pillow.

If you had some text selected on the page in your browser that would
also appear in the above, and repeatedly bookmarking the same page with
different selections incrementally adds such quotes to the bookmark
node.

Here are the docs.:

Can also be used for bookmarking directly from the browser to Leo.  To
do this, add a bookmark to the browser with the following URL / Location:

    javascript:w=window;if(w.content){w=w.content}; d=w.document; w.open('http://localhost:8130/_/add/bkmk/?&name=' + escape(d.title) + '&selection=' + escape(window.getSelection()) + '&url=' + escape(w.location.href),%22_blank%22,%22toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=800, height=300, status=no%22);void(0)

and edit the port (8130 in the example above) to match the port you're using
for mod_http.

Bookmarks are created as the first node in the outline which has been opened longest.
You can set the ``@string`` ``http_bookmark_unl`` to specify an alternative location,
e.g.::

    @string http_bookmark_unl = /home/tbrown/.bookmarks.leo#@bookmarks-->Incoming

to place them in the `Incoming` node in the `@bookmarks` node in the `.bookmarks.leo` outline.

The headline is preceeded with '@url ' *unless* the ``bookmarks`` plugin is loaded.
If the ``bookmarks`` plugin is loaded the bookmark will have to be moved to a ``@bookmarks`` tree to be useful.

The browser may or may not be able to close the bookmark form window for you, depending on settings - set ``dom.allow_scripts_to_close_windows`` to true
in ``about:config`` in Firefox. 
#@+node:ekr.20120229173025.20633: *5* Document Terry's magic refactor button
http://groups.google.com/group/leo-editor/browse_thread/thread/d21349c52dabd066

Ever find that you have a whole lot of:

.. sourcecode:: py

  rec[f['analyte']] ... rec[f['sample_type']] ...

expressions in your code, and now things have changed and you want them
all to be:

.. sourcecode:: py

  row.Analyte ... row.Sample_Type ...

basically if str variable s was::

  rec[f['analyte']]

then you want to perform:

.. sourcecode:: py

  s = "row."+s.split("'")[1].title()

on each one.  In general it would be nice to be able to use a python
expression when search and replace doesn't cut it.

The button code below creates a button, ``fac``, which, when pressed,
creates another button, with some name you choose, which, when pressed,
executes some python code to fix the selected text in the body.

You can define the code to be executed in two ways, either in its own
node:

 - insert a new node with a headline which describes the refactor
 - enter code in the node which modifies the string variable ``s``,
   which is initially set to the selected text in the body
 - press the ``fac`` button, which creates a new button named
   after this code node
 - select each offending piece of text and press the button created
   in the previous step to fix

or

 - type some code modifying ``s`` right in the body you're working on
 - press the ``fac`` button, which creates a new button named "fix"
 - select each offending piece of text and press the button created
   in the previous step to fix

Note:

 - unlike regular button nodes, changing the code after the
   button's created (first option above) doesn't change the code
   executed by the button
 - replacing selection text makes Leo reposition the insert point at
   the top of the window, this is annoying but unrelated to this code

Here's the button code:

.. sourcecode:: py

  @button fac
    from leo.plugins.mod_scripting import scriptingController

    sc = scriptingController(c)

    if c.frame.body.hasSelection():
        code = c.frame.body.getSelectedText()
        heading = 'fix'
    else:
        code = p.b
        heading = p.h

    def transform(c=c, code=code):
        s = c.frame.body.getSelectedText()
        g.es(s)
        exec code
        g.es(s)
        c.frame.body.deleteTextSelection()
        i = c.frame.body.getInsertPoint()
        c.frame.body.insert(i, s)
        p.b = c.frame.body.getAllText()
        c.frame.body.setInsertPoint(i)

    b = sc.createIconButton(
        heading,
        command = transform,
        shortcut = None,
        statusLine = 'Make filter button',
        bg = "LightBlue"
    ) 
#@+node:ekr.20120229173025.20635: *6* @@button fac
@language python

from leo.plugins.mod_scripting import scriptingController

sc = scriptingController(c)

if c.frame.body.hasSelection():
    code = c.frame.body.getSelectedText()
    heading = 'fix'
else:
    code,heading = p.b,p.h

def transform(c=c,code=code):
    w = c.frame.body
    s = w.getSelectedText()
    g.es(s)
    exec(code)
    g.es(s)
    w.deleteTextSelection()
    i = w.getInsertPoint()
    w.insert(i,s)
    p.b = w.getAllText()
    w.setInsertPoint(i)

sc.createIconButton(
    heading,
    command = transform,
    shortcut = None,
    statusLine = 'Make filter button',
    bg = "LightBlue"
)
#@+node:ekr.20120229094652.15139: *5* Changed calling signatures of g.openWithFileName and g.app.newCommander
Note: in rev 4990, the g.app.newCommander method (formerly called
g.app.newLeoCommanderAndFrame) also returns a single value (a
Commander) rather than the tuple (c,c.frame). 
#@+node:ekr.20120229094652.19777: *5* The open-with event now has a new format
- open-with hook has changed: it now uses a "d" arg.
#@+node:ekr.20120229094652.15168: *4* Settings
#@+node:ekr.20120229094652.14615: *5* Added @bool indent_added_comments setting
The default, True, is the legacy operation, which I recommend.

#@+node:ekr.20120229094652.14606: *5* Added @bool use_body_focus_border
#@+node:ekr.20120229094652.14598: *5* Added border around selected pane
Configurable and optional::

    @color focus_border_color = red
    @int focus_border_width = 1
    @bool use_body_focus_border  = True
    @bool use_focus_border = True
#@+node:ekr.20120229094652.14584: *5* Added shell commands to Cmds menu
#@+node:ekr.20120229094652.14619: *5* Added show-decoration-selected: 1 to stylesheet
Added show-decoration-selected: 1 to QTreeWidget stylesheet.

This causes the entire headline row to be shown when select, a big improvement, imo.
#@+node:ekr.20120229094652.14620: *5* Added stylesheets for Log & Find tabs
#@+node:ekr.20120229094652.15143: *5* Eliminated the -c option
#@+node:ekr.20120318075211.7524: *5* New default settings for run unit tests commands
The new command names and default bindings are::

    run-all-unit-tests-externally       = None
    run-all-unit-tests-locally          = None
    run-marked-unit-tests-externally    = Alt-4 # The new standard
    run-marked-unit-tests-locally       = None
    run-selected-unit-tests-externally  = Alt-5 # The new standard
    run-selected-unit-tests-locally     = None
#@+node:ekr.20120229094652.15140: *5* New format for @openwith settings nodes
http://groups.google.com/group/leo-editor/browse_thread/thread/dd5907529208ee98

The body of @openwith nodes contains one or more lines of the following
form::

   tag: value

The possible tags are::

    kind: <a string>

The value specifies the **opener logic**, that is, the method used to
launch the external editor, one of 'subprocess.Popen', 'os.startfile',
'os.spawnl', 'os.spawnv', 'exec'.

    arg: <a string>

There may be many such arg lines. Each line will be a string to be passed
as an argument to the opener logic, in a format that is compatible with the
specified opener logic.

Quotes in <a string> will be *retained*, allowing the user to specify
exactly the arguments to be passed to opener logic.

..  custom: <a string>
..  Here, <a string> *will* be eval'd, yielding an object to be used as
..  the opener logic.
#@+node:ekr.20120229094652.15144: *5* New search order for leoSettings.leo & myLeoSettings.leo
leoSettings.leo:

table = (
        # First, leoSettings.leo in the home directories.
        join(g.app.homeDir,     settings_fn),
        join(g.app.homeLeoDir,  settings_fn),

        # Next, <machine-name>leoSettings.leo in the home directories.
        # join(g.app.homeDir,     machine_fn),
        # join(g.app.homeLeoDir,  machine_fn),

        # Last, leoSettings.leo in leo/config directory.
        join(g.app.globalConfigDir, settings_fn)
    )

myLeoSettings.leo:

    table = (
        # First, myLeoSettings.leo in the local directory
        join(localDir,          settings_fn),

        # Next, myLeoSettings.leo in the home directories.
        join(g.app.homeDir,     settings_fn),
        join(g.app.homeLeoDir,  settings_fn),
    
        # Next, <machine-name>myLeoSettings.leo in the home directories.
        join(g.app.homeDir,     machine_fn),
        join(g.app.homeLeoDir,  machine_fn),

        # Last, leoSettings.leo in leo/config directory.
        join(g.app.globalConfigDir, settings_fn),
    )
#@+node:ekr.20130926053913.15855: *3* 4.11 Better abbreviations, many bug fixes
#@+node:ekr.20131105110107.16836: *4* Leo 4.11 final Release notes
Leo 4.11 final                                     November 6, 2013

Leo 4.11 final is now available at: http://sourceforge.net/projects/leo/files/Leo/
Leo 4.11 contains over a year's work on Leo.

Leo is a PIM, an IDE and an outliner for programmers, authors and web
designers. Leo's unique features organize data in a revolutionary way.
Python scripts can easily access all parts of Leo outlines.
See http://leoeditor.com/tutorial.html

The highlights of Leo 4.11:
---------------------------

- Leo's tutorials have been rewritten and simplified.
- Greatly improved abbreviations, including templates.
- Clones are now valid anywhere in @file nodes.
- Leo now warns if a .leo file is open elsewhere.
- Leo's IPython bridge now works with IPython 1.x.
- Added support for @testsetup and @testclass.
- Added support for sessions.
- Added colorizing themes.
- A colored border highlights the pane with focus.
- Added support for the clojure, markdown and TypeScript languages.
- Added importers for .ipynb, .otl and vimoutliner files.
- Many new and improved commands, plugins and scripts.
- Dozens of bug fixes and code-level improvements.

Links:
------
Leo:       http://leoeditor.com
Docs:      http://leoeditor.com/leo_toc.html
Tutorials: http://leoeditor.com/tutorial.html
Forum:     http://groups.google.com/group/leo-editor
Download:  http://sourceforge.net/projects/leo/files/
Bzr:       http://code.launchpad.net/leo-editor/
Quotes:    http://leoeditor.com/testimonials.html
#@+node:ekr.20131105110107.16837: *5* a1 and a2 releases
#@+node:ekr.20131105110107.16838: *6* Bugs
#@+node:ekr.20131105110107.16839: *7* Bugs: minor
#@+node:ekr.20131105110107.16840: *8* Clear previous focus-border after alt-tab
This was a recent problem.  Normally setInputState should *not* set the border.

Added code to eventFilter to call remove_border on focus out.

set-xxx-state commands call setInputState with set_border = True.
#@+node:ekr.20131105110107.16841: *8* Don't horizontally scroll body pane if word wrapping
The fix was in qtBody.setWrap.
#@+node:ekr.20131105110107.16842: *8* Execute selected script now works again
# The change was to g.getScript.
#@+node:ekr.20131105110107.16843: *8* Fixed activateMenu
The trick is to find the wrapper first: it is *also* a QMenu.
We can then call menuBar.setActiveAction on its action!!
#@+node:ekr.20131105110107.16844: *8* Fixed bug 1021849: typo in path for icon of desktop shortcut
https://bugs.launchpad.net/leo-editor/+bug/1021849

Rev 5789 fixes this bug, using some hints from the NSIS support forum.

The fix was to CreateShortCut in the Desktop Shortcut section:
  - remove single quotes.
  - remove the "0" trailing arg.

The installer passes all my tests on my Windows 7 machine, which is all the testing I have ever done.


Here is the checkin log::

QQQ
Fixed the icon problem and improved and simplified the install/uninstall 
process in several ways.

1. Fixed https://bugs.launchpad.net/leo-editor/+bug/1021849

The fix was to CreateShortCut in the Desktop Shortcut section:
  - remove single quotes.
  - remove the "0" trailing arg.

2. Changed the make-leo button to simplify the uninstall manifest.

Rather than computing the files to be deleted, the uninstall script now 
just does RMDir /r "$INSTDIR\\leo".
This *is* safe, and ensures that all files & directories get deleted, 
including $INSTDIR itself.
QQQ

The only possible drawback to using the /r option is that it will delete 
any files that the user has created in the leo directory.  Imo, there is no 
perfect solution to this.  Warning prompts never do any good, and if we 
retain files, for whatever reason, there will be bug reports saying that 
Leo didn't properly uninstall itself.  This has already happened :-)

I am happy to live with the present situation, unless somebody a) objects 
loudly and b) shows how the problem can be solved cleanly.
#@+node:ekr.20131105110107.16845: *8* Fixed bug 1194209: Inconsistent Window Titles
https://bugs.launchpad.net/leo-editor/+bug/1194209

save-as doesn't update the window title.  Changing tabs does.

The main fixes were to qtFrame.get/setTitle. When using tabs, the
LeoTabbedTopLevel widget is the top-level window, *not* the DynamicWindow
(a QMainWindow).

Another fix was setting c.frame.title in saveAs to::
    
    c.computeWindowTitle(c.mFileName)
    
This ensures that all all window titles have the same format.

I chose to do the bare minimum fix, confined to g.computeWindowTitle::

    if os.sep in '/\\':
        title = title.replace('/',os.sep).replace('\\',os.sep)

I didn't have the nerve to put similar code in, say, g.os_path_join. The
Python docs for os.path.join state, "In all cases, join(head, tail) returns
a path to the same location as path (but the strings may differ)."

#@+node:ekr.20131105110107.16846: *8* Fixed bug 879338: Global tables in leoApp.py should describe all languages known to the colorizer
https://bugs.launchpad.net/leo-editor/+bug/879338

Having the colorizer colorize a language properly gives the false illusion
that Leo "understands" the language.

Supporting the language in the global tables in leoApp.py makes the
illusion a reality.

Rev 5334 is a first draft of a fix of bug 879338:
Global tables in leoApp.py should describe all languages known to the colorizer
https://bugs.launchpad.net/leo-editor/+bug/879338

The essence of the bug fix is that Leo's language-description tables should
contain entries for all .py files in the leo/modes folder. These files
control the colorizer. If Leo's colorizer knows about a language, then Leo
should know as much as possible about the language.

In concept, this is a fairly straightforward process, but there were *many*
details to handle. If you aren't a Leo developer, you might want to stop
reading now...

===== Tables

Fixing this bug required non-trivial changes to the following tables::

    g.app.language_delims_dict
    # Keys are languages, values are 1,2 or 3-tuples of delims.

    g.app.language_extension_dict
    # Keys are language names, values are extensions.

    g.app.self.extension_dict
    # Keys are extensions, values are language names

I used scripts to generate new entries for these tables, but these scripts
can not possibly deal with the all the complications...

Leo uses these tables as follows:

1.  To generate the comment delimiters in sentinels for each language.

Happily, getting the comment delimiters correct was probably the easiest
part, so Leo should continue to write sentinels properly for
previously-know languages. However, I had to take care to preserve the REM,
CWEB, forth and perlpod hacks, so that comment delims would include the
necessary spaces.

2. To associate file extensions with importers.

Knowing about new file extensions doesn't actually allow Leo to import any
new languages. For all languages without an official importer Leo will
simply copy the entire text of the file into a single node, as it always
has.

3. To colorize code.

Leo's colorizer mostly doesn't use these tables: to colorize language x,
the colorizer looks for the file leo/modes/x.py. Thus, these changes
probably do not affect the colorizer at all.

===== Special cases

I did a lot of googling in order to determine the proper file extensions to
use for various language. In the process, I learned that *almost* all
languages described in the leo/modes folder are real, interesting and
useful languages.

However, there at least 5 categories of special cases that affect the
tables:

1. Languages that are really just colorizer modes:

These include embperl, pseudoplain and phpsection. We need entries in
leo/modes for these, but they aren't real languages and thus they should
not appear in the language-description tables.

2. Things that might be colorized but aren't real languages.

Afaik, the following are not real languages, and Leo would never have to
generate files in these languages: cvs_commit,dsssl,relax_ng_compatc and svn_commit.

Notes:

- relax_ng_compact is an xml schema.

- The rtf colorizer is *not* a colorizer for binary .rtf file format, is a
  colorizer for .rtf sources. It probably won't do too much harm to retain
  the colorizer data for these languages, but I wouldn't mind eliminating
  them either.

3.  Unknown languages.

A few languages seem not really to exist: freemarker, hex, jcl, progress, props.

4. Languages without real comment delimiters.

Patch annotations are *not* real comment delimiters, so Leo could not
generate patch (.fix or .patch) files from an outline. Happily, there is no
need to do so.

5. Conflicting file extensions.

There are two separate kinds of problems:

A. Leo contains colorizers for several assembly languages. Typically,
assembly languages have .asm or .a file extensions. However, a particular
extension can only be associated with a single language name. Thus, Leo has
no way of knowing what language to associate with .asm or .a files. So I
just punted and didn't make any association at all.

B. Both the rebol and r languages use the .r file extension. One of Leo's
users previously created an entry for rebol, so that's the language that
takes precedence.
#@+node:ekr.20131105110107.16847: *8* Fixed bug 971171: re .leoRecentFiles
https://bugs.launchpad.net/leo-editor/+bug/971171

If If $(HOME)/.leo/.leoRecentFiles.txt does not exist,
the only recent file ever is the current file

The fix: rf.writeRecentFilesFile creates $(HOME)/.leo/.leoRecentFiles.txt if it does not exist.
#@+node:ekr.20131105110107.16848: *8* Fixed bug 981849: incorrect body content shown
https://bugs.launchpad.net/leo-editor/+bug/981849

The original fix was misguided. It attempted to use more careful code in
setSelectionRangeHelper & lengthHelper.
    
The new fix avoids messing with the viewport in both setEditorColors methods:

leo-editor thread: opening new top level windows
http://groups.google.com/group/leo-editor/browse_thread/thread/8f5f6c72d8716b33

The key is to use a descriptor in LeoQTextBrowser stylesheets.  Example::

'LeoQTextBrowser { << the actual stylesheet >> }

See http://stackoverflow.com/questions/9554435/qtextedit-background-color-change-also-the-color-of-scrollbar
#@+node:ekr.20131105110107.16849: *8* Fixed bug 998090: save file as doesn't remove entry from open file list
https://bugs.launchpad.net/leo-editor/+bug/998090
save file as doesn't remove entry from open file list

Save file as leaves the file's previous path in g.app.db.openFiles, so
that next time the original file's opened you get a "already open"
message.
#@+node:ekr.20131105110107.16850: *8* Fixed bug: selected node was not always restored properly
The bug was in chapter.findPositionInChapter.
#@+node:ekr.20131105110107.16851: *8* Fixed bugs 971166 & 979142 re copy/paste
These bugs are really the same bug

Node body contents displayed is unpredictably incorrect
https://bugs.launchpad.net/leo-editor/+bug/979142

Prints to tabs in the Log Pane are UTF-8 encoded
https://bugs.launchpad.net/leo-editor/+bug/971166

The fix was:

1. Use the "slow" code in leoQTextEditWidget.get.
2. Use w.get/setAllText in leoFrame.pasteText.
#@+node:ekr.20131105110107.16852: *8* Fixed crash after viewrendered-hide
#@+node:ekr.20131105110107.16853: *8* Fixed crasher in active_path.py
#@+node:ekr.20131105110107.16854: *8* Fixed crasher in flattenOutline
Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 553, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 2120, in flattenOutline
    c.importCommands.flattenOutline(fileName)
  File "c:\leo.repo\trunk\leo\core\leoImport.py", line 479, in flattenOutline
    theFile.write(s)
TypeError: must be str, not bytes
#@+node:ekr.20131105110107.16855: *8* Fixed crasher in leoBridge
The crash happens only when the new readSettings argument to leoBridge.bridgeController is False.
In that case, the global dicts were not inited properly.

What I did:
    
- Created lm.createDefaultSettingsDicts, called by lm.readGlobalSettingsFiles.
- leoBridge.initLeo calls lm.createDefaultSettingsDicts to set the global dicts.

Bug description:

--- Begin Python script to run from a console ------
import leo.core.leoBridge as b
bridge = b.controller(gui='nullGui',verbose=False,loadPlugins=False,readSettings=False)
c = bridge.openLeoFile(r'c:\users\edreamleo\test\minimal.leo')
--- End Python Script -----

The above script and minimal.leo are attached to this bug report.  Put
them in the same directory, open a console, set the current working
directory to the directory containing the script, and run the script.
You will see the this exception on the console:

2012-11-16 11:28:51 /home/ldi/tmp
$ python readSettingsFile.py
Traceback (most recent call last):
File "readSettingsFalse.py", line 5, in <module>
  cmdrUnl = bridge.openLeoFile('minimal.leo')
File "/home/ldi/bzr/LeoLatest/leo/core/leoBridge.py", line 330, in openLeoFile
  c = self.createFrame(fileName)
File "/home/ldi/bzr/LeoLatest/leo/core/leoBridge.py", line 367, in createFrame
  c = g.openWithFileName(fileName)
File "/home/ldi/bzr/LeoLatest/leo/core/leoGlobals.py", line 1875, in openWithFileName
  return g.app.loadManager.loadLocalFile(fileName,gui,old_c)
File "/home/ldi/bzr/LeoLatest/leo/core/leoApp.py", line 2539, in loadLocalFile
  previousSettings = lm.getPreviousSettings(fn)
File "/home/ldi/bzr/LeoLatest/leo/core/leoApp.py", line 1668, in getPreviousSettings
  lm.globalSettingsDict,lm.globalShortcutsDict,localFlag=True)
File "/home/ldi/bzr/LeoLatest/leo/core/leoApp.py", line 1626, in computeLocalSettings
  settings_d = settings_d.copy()
AttributeError: 'NoneType' object has no attribute 'copy'
2012-11-16 11:28:55 /home/ldi/tmp
$
#@+node:ekr.20131105110107.16856: *8* fixed crasher involving g.importFromPath
Note: happens only with Python 3.3.0.

Here is a minor traceback when opening quickstart.leo

Leo 4.11 devel, build 5468, 2012-09-30 13:02:59
Python 3.3.0, qt version 4.8.3
Windows 6, 1, 7601, 2, Service Pack 1
reading: C:\Python33\Lib\site-packages\leo-editor\leo\doc\quickstart.leo
unexpected exception in g.importFromPath(rest)
Traceback (most recent call last):
  File "C:\Python33\Lib\site-packages\leo-editor\leo\core\leoGlobals.py", line 5689, in importFromPath
    data = imp.find_module(moduleName,[path]) # This can open the file.
  File "C:\Python33\lib\imp.py", line 203, in find_module
    package_directory = os.path.join(entry, name)
  File "C:\Python33\lib\ntpath.py", line 171, in join
    if b[:1] in seps:
TypeError: Type str doesn't support the buffer API
Can not import rest
#@+node:ekr.20131105110107.16857: *8* Fixed failing unit tests in distro
The @test at.readOneAtShadowNode retains @shadow links node
give fail1: test not set up properly.
The outline is then corrupted, causing other unit tests to fail.
The partial solution is not to call the undo command in the finally clause.
#@+node:ekr.20131105110107.16858: *8* fixed get_fn in viewrendered plugin
https://groups.google.com/group/leo-editor/browse_thread/thread/bb063866875a81c3/6162e6108b09428e

The new code is much like g.computeFileUrl.
#@+node:ekr.20131105110107.16859: *8* Fixed import problems discovered by importing 2to3
** Not all import problems can be fixed automatically! **

- Added perfectImportFlag. (There was already an importing flag).

- Fixed bug in Fixed underindent convention:

    undentBy adds a period; parseUnderindentTag removes the period.
    
- @file read code must *regenerate* the \\- convention.

    This is done by readNormalLine.
    
    - Fixed an unrelated bug in g.computeWidth.  All unit tests pass.

    - Created g.computeLeadingWhitespaceWidth.
    
- some docstrings are not imported properly in py2_test_grammar.py

    The must be fixed by hand, using @raw and @end_raw.

- escapeFalseSectionReferences now is a do-nothing:
    
    It never generates @verbatim sentinels during import.
    
===== Notes

Rev 5378: cleanup-imported-nodes script in scripts.leo & an Aha
http://groups.google.com/group/leo-editor/browse_thread/thread/77b9df4f4ed6dba0

> The third (and I think last) import fail involves not generating
> @verbatim sentinels when importing files.

Fixed in the trunk at rev 5386.

This is (to me) a really interesting dark corner of Leo's import code.

By searching for @verbatim, I discovered a method called
escapeFalseSectionReferences.  This method inserts an @verbatim
"directive" before lines that look like section references.

This is wrong for multiple reasons.  It confuses the importer, there
is no such thing as an @verbatim directive, and worst, it fails to
solve the essential problem, which is that before the imported file is
saved, the **user** must fix the problem!

For example, when importing a line like::

  a = x << y >> z

The user, and *only* the user, should change this to something like::

   a = x << y \
   >> z # EKR

I suppose each importer could figure out a language-specific
workaround, but imo this isn't particularly important, for reasons
which will become clearer below.

So now escapeFalseSectionReferences is a do-nothing.

With this explanation, perhaps the checkin log will make sense::

QQQQQ
Fixed another import fail in an "interesting" way: the import code no
longer inserts @verbatim. This means a later write of the imported
will fail. This is correct!

Indeed, the failed write is the only way to alert the user that the
code must be revised by hand.

Note that another import fail, involving a leading '@' on a line in a
docstring, must also be fixed by hand. In lib2to3/pgen/grammar.py the
*only* possible fix is to enclose the entire docstring at the end of
the file by @raw and @end_raw.

All unit tests pass, but no new tests have been added so far.
QQQQQ

The other import fail mentioned in the checkin log is a truly
fascinating case, one that no amount of AI could possibly discover the
correct fix.

At the very end of lib2to3/pgen/grammar.py the following code
(shortened a bit) appears at the top level::

   opmap_raw = """
   ( LPAR
   ) RPAR
   [snip]
   @ AT
   [snip]
   == EQEQUAL
   != NOTEQUAL
   """
   opmap = {}
   for line in opmap_raw.splitlines():
       if line:
           op, name = line.split()
           opmap[op] = getattr(token, name)

There are several things to notice about this code:

1. It contains a line starting with '@'.  Sooner or later, this is
going to cause problems for either Leo's import code or Leo's write
code.

2. It's overly clever, but it's overly clever for a reason: it's
testing tokenizing logic.

3. The code at the end of the file assumes that all lines of the
docstring are 2-tuples.

For these reasons, the one and *only* possible way to make Leo write
this code correctly is to enclose the *entire* docstring in @raw and
@end_raw directives.  Like this::

   @raw
   opmap_raw = """
   ( LPAR
   ) RPAR
   [snip]
   @ AT
   [snip]
   == EQEQUAL
   != NOTEQUAL
   """
  @end_raw

In particular, surrounding the line "@ AT" with @raw/@end_raw
directives will cause 2to3 to fail on startup:  the Leo sentinel lines
will not be 2-tuples!

===== Important Conclusions

All this picky detail illustrates a crucial fact.  No matter how good
Leo's importers are, (and they are now quite good), there will
*always* be cases where thoughtful human intervention will be
required.

Furthermore, the simplest thing that could possibly work is for the
importers to allow some constructions that are guaranteed to cause
problems later, when the user attempts to write the file.  We hope
that Leo will complain about certain constructions, but Leo may not be
able to complain about all constructions.

Thus, some import mistakes can *only* be found by running tests.  For
complex programs like 2to3, the only truly safe way to check imports
is by running the 2to3 test suite.
#@+node:ekr.20131105110107.16860: *8* Fixed missing search text bug
The fix was to always call c.selectPosition in leoFind.showSuccess.
This ensures that leoTree.setBodyTextAfterSelect always does w.setAllText,
which is essential to init the syntax colorer properly.

The happy side effect of this change is that a lot of duplicate selection
code in showSuccess disappears.

Also converted two section references in leoTree.selectHelper to selectNewNode.
#@+node:ekr.20131105110107.16861: *8* fixed problem with file:/// url's on Windows
http://groups.google.com/group/leo-editor/browse_thread/thread/bb063866875a81c3#

In my installation, now on the latest revision ( r5195) I'm still
experiencing an issue with the '@url command' using 'File-URL' in a Windows
environment.

I'm able to create the Leo User documentation locally. - However, when I
try to read the documentation using the 'File-URL'

file:///D:/Branches/leo-editor/leo/doc/html/_build/html/leo_toc.html

I get the following message in the Leo-Log.

<log>

File 'D:\D:\Branches\leo-editor\leo\doc\html\_build\html\leo_toc.html' does not exist

</log>

However if I enter this URL directly into FF it is found and displayed properly.

EKR: Obviously, the 'D:\D:\' is the problem.

The fix is simply to special-case file:/// on Windows in g.computeFileUrl.
#@+node:ekr.20131105110107.16862: *8* Fixed problems with scrolling when saving
LeoQTextBrowser.onSliderChanged must set v.scrollBarSpot only if "self" is actually the body pane.

Otherwise scrolling the log pane will scroll the body pane!
#@+node:ekr.20131105110107.16863: *8* Fixed scrolling problem with scrollwheel
The maintain_scroll option is *evil*.
#@+node:ekr.20131105110107.16864: *8* Fixed several problems with c-to-py command
An assert failed during scanning in mungeAllFunctions.

Added defensive code to mungeAllFunctions, dedentBlocks and
replaceComments. The new code simply increments a pointer if a "progress"
assert would fail. (The progress assert still exists, as a double-check.)

Fixed bug: the call to u.afterChangeGroup in the go() method is called only once.

Suppress warning messages given by CPrettyPrinter.indent.
#@+node:ekr.20131105110107.16865: *8* Fixed special cases of auto-completion of commands
If the user has not typed anything in the minibuffer, <alt-x><tab> returns *all* completions.

Otherwise, if there are no completions, the "Completions" tab is empty, *not* all completions.

This behavior is much more intuitive than the old behavior.

The fix was a new special case in k.computeCompletionList.
#@+node:ekr.20131105110107.16866: *8* Fixed undo problems in headlines
# The fix was simply to call c.endEdiing in undo and redo *before* getting the undo params.
# This allows c.endEditing to properly set the undo stack.
#@+node:ekr.20131105110107.16867: *8* Increased the width of find/change text
dw.createFindTab now creates a third column with a minimum width.
The find/change text widgets span the second and third columns.
#@+node:ekr.20131105110107.16868: *8* Made sure tab completion only happens on explicit tab
Don't show full completion list when the minibuffer becomes empty.
#@+node:ekr.20131105110107.16869: *8* Made sure the new load code loads plugins at most once
http://groups.google.com/group/leo-editor/browse_thread/thread/dd16ac6dc1832eb2

bookmarks.py was the culprit. The code in onCreate must test to see if c.free_layout already exists.
#@+node:ekr.20131105110107.16870: *8* Minimize scrolling during paste-text
#@+node:ekr.20131105110107.16871: *8* Restore focus on window activation
# Changed: onActivateEvent (qtGui), onDeactivateEvent (qtGui)
#@+node:ekr.20131105110107.16872: *8* Restored special case for run-selected-unit-tests
Added code to findAllUnitTestNodes to look up the tree for @test & @suite nodes
if none have been found so far.  Only for the run-unit-tests-externally/locally.
#@+node:ekr.20131105110107.16873: *8* Rewrote and tested at.deleteUnvisitedNodes
#@+node:ekr.20131105110107.16874: *8* Rewrote and tested p.deletePositionsInList
A shock: p.deletePositionsInList must be rethought and rewritten
https://groups.google.com/forum/#!topic/leo-editor/IWMWhUlkos0
#@+node:ekr.20131105110107.16875: *8* Running unit tests no longer change the selected tab
The fix was to set new_c=self.c in the call to c.close in createFileFromOutline.
#@+node:ekr.20131105110107.16876: *8* The @auto read code now catches failed asserts in import code.
If an assert fails, the entire file is read into a single node.
#@+node:ekr.20131105110107.16877: *8* Wont Fix bug 903640: Import of Python files containing the strings "<<" and ">>" does not work
https://bugs.launchpad.net/leo-editor/+bug/903640
Import of Python files containing the strings "<<" and ">>" does not work

At present @auto can import .py files containing self.cprint("<<" + ret +
">>\n")

Furthermore, it's possible to write such files properly after changing
them.

Thus, this bug seems to have been completely fixed, as far as @auto goes.

However, *importing* the file with Leo's import-file command does fail (an
@ignore is inserted). This is expected: unlike @auto, the import command
creates an @file node, so the "perfect import" check will complain that the
section called << ret >> is undefined.

I am going to close this item. I see no real need to support other section
delimiters in external files. If there ever becomes a real need to do so, a
separate wishlist item will be appropriate.
#@+node:ekr.20131105110107.16878: *7* Bugs: serious
#@+node:ekr.20131105110107.16879: *8* Added ubuntu only menu kludge
Rev 5840 adds support for hack that is active only on Ubuntu systems.

When Leo starts up, it creates a commander (tab) called "loading..." before
loading all tabs. This ensures that the first "real" .leo file loaded (into
a tab) will have a menu area. This tab exists only until the first real
.leo file is loaded.

Yes, this is a pretty horrible hack, but it seems necessary on Ubuntu
Unity. Presumably this is a Qt or Unity problem, but there has been
response to previous bug reports, so it seems that best that can be done.

#@+node:ekr.20131105110107.16880: *8* Created a dummy tab when only one tab would otherwise be opened
This was a horrible kludge in LM.doPostPluginsInit
#@+node:ekr.20131105110107.16881: *8* Fixed another scrolling bug
Changes in rev 4163 caused the bug.

The problem is the call to w.setStyleSheet in g.app.gui.update_style_sheet.
Apparently, this causes a layout-request event that spoils the scroll position.

The fixes:
    
1. update_style_sheet does nothing if the new stylesheet is the same as the old.

2. Added lockout to mouseReleaseEvent. update_style_sheet does nothing if
   the lockout is set.
   
3. mouseReleaseEvent sets c.p.v.insertPoint if appropriate.

Hitting Ctrl-H can still cause a small unwanted scroll, but the insert point remains visible.
#@+node:ekr.20131105110107.16882: *8* Fixed bug 1184855: data loss with command line 'leo somefile.ext'
https://bugs.launchpad.net/leo-editor/+bug/1184855

The fix was to set the name of the .leo file to foobar.pyxxx.leo in LM.initWrapperLeoFile.
#@+node:ekr.20131105110107.16883: *8* Fixed scrolling problem with multiple editors
Selecting body editor with clicks doesn't save/restore visual ivars.
The solution would be to create a new onClick event handler...

- Removed insert=None,new_p=None args from all versions of setAllText.
  These are entirely misguided, and may have contributed to scrolling problems.
  
  setAllText now *only* sets text, nothing else!

- All calls to leoMoveCursorHelper are followed by code that updates
  v.insertSpot, v.selectionStart and v.selectionLength.
  
- v.restoreCursorAndScroll now *carefully* restores selection
  based on v.insertSpot, v.selectionStart and v.selectionLength.
  It also restores the scrollbar using v.scrollBarSpot.
  
- < < unselect the old node > > (selectHelper) now *only*
  sets v.scrollBarSpot.
#@+node:ekr.20131105110107.16884: *6* Code
#@+node:ekr.20131105110107.16885: *7* Added c.deletePositionsInList
https://groups.google.com/forum/#!topic/leo-editor/IWMWhUlkos0

There has been much discussion recently about deleting lists of positions.
I now see that all previous strategies are fatally flawed. This is quite
shocking.

Here is the Aha: the positions passed to p.deletePositionsInList only
*specify* the desired changes; the only way to *make* those changes is to
operate on vnodes!

The new view of the problem is relatively straightforward. Consider this
very simple outline, containing no clones::

    + ROOT
      - A
      - B

The fundamental problem is simple. If we delete node A, the index of node B
in ROOT.children will change. This problem has (almost) nothing to do with
clones or positions.

To make this concrete, let's look at the *vnodes* that represent this tree.
It is the vnodes, and *not* the positions, that represent all of Leo's
data. Let ROOT, A and B be the vnodes corresponding to the nodes ROOT, A
and B. ROOT.children will look like this at first::

    ROOT.children = [A,B]

That is, the children array contains references (links) to both A and B.
After deleting A, we will have::

    ROOT.children = [B]

As you can see, the reference to B is at index 1 of ROOT.children before
deleting A, and at index 0 of ROOT.children after deleting A. Thus, *any*
position referring to B will become invalid after deleting A.

Several people, including myself, have proposed an unsound solution--just
delete positions in reverse order, so that B will be deleted before A. This
idea has appeal, but it truly *is* unsound. Here is an outline that at last
explodes the notion that there is *any* correct order for deleting
positions. All A' nodes are clones of each other::

    + ROOT
      + A'
        - B # at position p1
      + A'
        - B # at position p2

**Important**: B is *not* a clone. Also note that there is only *one* node
called A and *one* node called B. The children arrays will look like::

    ROOT.children = [A,A]
    A.children = [B]
    B.children = []

It surely must be reasonable to pass either *or both* positions p1 and p2
to p.deletePositionsInList. But after deleting the B corresponding to p1,
the children arrays will look like:

    ROOT.children = [A,A]
    A.children = []
    B.children = [] # B is no longer referenced anywhere!

So if p.deletePositionsInList attempts to delete position p2 (from A), B
will no longer appear in A.children!

There are many other cases that we could discuss, but the conclusion in all
cases is that we must use the positions passed to p.deletePositionsInList
only as *hints* about what to do.

Happily, there is a simple strategy that sidesteps all the difficulties:

Step 1. Verify, *before* making any changes to the outline, that all the
positions passed to p.deletePositionsInList *initially* make sense.

Step 2. Treat each position as a "request" to delete *some* vnode from the
children array in the *position's* parent vnode.

This is just a bit subtle. Let me explain it in detail.

First, recall that vnodes do not have unique parent vnodes. Because of
clones, a vnode may may have *many* parents. Happily, every position *does*
specify a unique parent (vnode) at that position.

Second, as shown above, there is no way to order positions such that all
later positions remain valid. As the example above shows, deleting (the
vnode corresponding to) a position P may cause *all* later positions
referring to P.v to refer to *already deleted* vnodes.

In other words, we simply *must* ignore the child indices in positions.
Given a position P, P.parent is well defined. So Step 2 above will simply
delete the *first* element in P.parent.children containing P.v.

As we have seen, there may not even *be* any such element of
P.parent.children: a previous delete may have already deleted the last item
of P.parent.children equal to P.v. That should *not* be considered an
error--Step 1 has ensured that all positions *originally* did make sense.

Summary

Positions passed to p.deletePositionsInList specify *vnodes* to be deleted
from specific parents, but they do *not* specify at what index in the
parent.children array (if any!) those vnodes are to be found. The algorithm
will delete the *first* item in the children array that references the
vnode to be deleted.

This will almost always be good enough. In the unlikely event that more
control is desired, p.deletePositionsInList can not possibly be used.

The new emphasis on vnodes at last puts the problem an a completely solid
foundation. Moreover, the new algorithm should be considerably faster than
the old: there is no need to sort positions.
#@+node:ekr.20131105110107.16886: *7* Added c2 keyword arg to c.bringToFront
#@+node:ekr.20131105110107.16887: *7* Added default button to dialog methods
#@+node:ekr.20131105110107.16888: *7* Added external/leosax.py to leoPyRef.leo
http://groups.google.com/group/leo-editor/browse_thread/thread/93f2cc88ebbf9893
#@+node:ekr.20131105110107.16889: *7* Added g.getActualColor
#@+node:ekr.20131105110107.16890: *7* Added g.restore_selection_range
If off, only the insert point is restored.

It's kinda pointless to make this a user option.
#@+node:ekr.20131105110107.16891: *7* Added leo/extensions/sh.py
Extensions is a convenient place: code can use g.importExtension to import it.

Alas, sh.py can not be used in Leo's core.
#@+node:ekr.20131105110107.16892: *7* Added local pylint suppressions
The format of such local suppressions is::

    # pylint: disable=<message-number>
#@+node:ekr.20131105110107.16893: *7* baseNativeTree.onHeadChanged now truncates headlines
The new code works like leoTree.onHeadChanged.

The code can be called twice, so it is a bit tricky
to only issue warnings once.
#@+node:ekr.20131105110107.16894: *7* Cached syntax coloring
#@+node:ekr.20131105110107.16895: *7* g.pdb now does qtGui stuff
#@+node:ekr.20131105110107.16896: *7* Improved g.trace
A few changes that should have been done long ago:

- Added support for 'before' keyword.  Prints something before the function name.
- Use g.shortFileName(__file__) instead of "<module>"
#@+node:ekr.20131105110107.16897: *7* Integrated free_layout into Leo's core
#@+node:ekr.20131105110107.16898: *7* Removed unused files from leo/modes directory
Remove all .xml files in the leo/modes directory.

Imo, this should have been done long ago, for at least the following
reasons:

- These files are part of the jEdit project.
- They are used only by the jedit2py script in scripts.leo.
- The colorizer doesn't use them.
- Bug fixes to the colorizer are made to the .py files, not to the .xml files.
- We can always get updated versions of the .xml files from the jEdit
  project in the unlikely event that we ever need them again.

2. Remove the following .py files from the leo/modes directory:
cvs_commit.py, dsssl.py, freemarker.py, hex.py, jcl.py, progress.py,
props.py and svn_commit.py.

Notes:

- embperl.py, phpsection.py and pseudoplain.py will *not* be removed;
they are internal colorizer states.

- relax_ng_compact.py will be removed if it is not used by any other
colorizer.

- patch.py and rtf.py colorizers will be retained, even though Leo can
never generate such files. 
#@+node:ekr.20131105110107.16899: *7* SherlockTracer now shows returned values
#@+node:ekr.20131105110107.16900: *6* Contrib branch
You can get this branch here: https://code.launchpad.net/~leo-editor-team/leo-editor/contrib
#@+node:ekr.20131105110107.16901: *7* Dumping leo docs to excel
By Ville M. Vainio.

I created a proof of concept for dumping leo trees to excel.

Demo outline is in collab branch,

/Projects/excel_integration

Screenshot attached.

My usage is that I collect and organize findings (of technology studies) in
leo, and then dump the report to excel, to be read and actioned upon by
other people.

I haven't yet polished this workflow in that there is a bunch of manual
work in formatting the report...
 
#@+node:ekr.20131105110107.16902: *7* Full text searches
Apart from the full text search indexing script I just added, I've made
a bunch of basically cosmetic changes to Ville's multi outline full text
search tool.  There's a new @setting, @int fts_max_hits, which controls
the max hits returned, instead of the hardwired default of 30.

With any sensible value for fts_max_hits, searches for terms which
generate many hits in many outlines won't return the full list of
outlines containing hits, because the search stops when fts_max_hits is
reached.  I set fts_max_hits to a non-sensible 1200 to get around this,
it seems to work fine.  Obviously terms which generate that many hits
are bad search terms anyway, but it's helpful to get as close to the
full list of outlines containing hits as possible.

Also most of my changes apply only to the "f target" find command, not
the simpler "s target" search command.
#@+node:ekr.20131105110107.16903: *7* LeoReader: Leo as web app
From Ville:

aaaaand we are live :).

Test it out at:

http://koti.kapsi.fi/vivainio/t/LeoReader/main.html

Sources here:

https://github.com/vivainio/LeoReader

Pretty much all the relevant stuff is in these files:

https://github.com/vivainio/LeoReader/blob/master/leoaccess.coffee

https://github.com/vivainio/LeoReader/blob/master/main.html

Works ok in Firefox and Chrome.
#@+node:ekr.20131105110107.16904: *7* QML notebook
By Ville M. Vainio

Ok, I now created a toy UI demo for how "cell" based leo (like ipython
notebook) could operate.

qmlnotebook.leo (ctrl+b script + test outline) is now at contrib branch. If
you want to try it, open the .leo file, ensure you are running latest Leo
from trunk, and press ctrl+b on the first node.

It's probably the first stab at using QML to solve a problem in Leo. It
doesn't run from leo yet (it's not a plugin, more protoing needed before
it's worthwhile to make it a plugin.

When you add and delete text, the cells resize naturally.

What it currently does is putting every node wrapper in a list of QObjects,
and use that as the model in QML side (model is just a container that has
the list of stuff to show in Repeater).

So you can edit every node in a leo document in this "notebook". Future
version will probably only allow editing a subtree.

Note how headlines are "toned down" with small, grey font. Intention is
that e.g. with ipython notebook, the headline will just be a running,
uneditable sequence number basically.

BTW, forgot to mention that I put the NodeWrapper stuff under leo.core. We
can move it out eventually, but right now it seemed like a natural place
for this kind of cross-plugin utility.

And on related note: remember that with QML, sky is the limit as far as the
styling goes :). So if you have wild ideas about adding customizable
images, animated checkboxes, or other weird stuff next to the nodes, fire
away.

===== Kent Tenney

Interesting ...

Am I correct: this is POC, edits in your serialized pane don't reflect in
the Leo file?

===== Ville

Yes, modifications are not saved yet. Also, modifications in normal body
editors are not copied over to the notebook yet.  This is probably going to
end up like tabula and stickynotes in this regard.

===== Kent

This is a hint of something I've long wanted, what I have called 'slurped'
vs 'chunked' Something I miss with Leo is the capability get an overview of
a file, I find myself needing to 'open file with gvim' to grok at file
level.

The pane you are generating offers both at once, I can see the linear view
of the file, retaining the 'chunk' metadata (node headlines).

===== Ville

Getting an overview of a file could be an interesting extra use case, my
main interest is still in using it for interactive programming/computation
(like ipython notebook) .

===== Terry Brown

Played with it. I guess the next step would be demo of python handling
events from the QML UI elements, and of python finding and manipulating the
QML UI elements.

I'm wondering about the advantages of this approach over the "regular"
QWidget approach. QML is perhaps a more terse and elegant language for
defining a UI, and it has scripting of UI behavior in javascript. And
perhaps it has a more tablet friendly widget set?

But I wonder what it lets you do that you can't do with the QWidget stack,
given that mixing the two seems to mean that Leo is using two GUI systems -
they may be very tightly integrated, but mind-space wise it's two complex
systems instead of one.

Which isn't a reason not to use QML, just wondering if it has advantages
I'm missing.

===== Terry

Here's a demo to run Ville's QML thing in a free_layout pane. Requires rev.
5284 so the .qml file in leo/plugins/qmlnb/ is available.

Paste this into a node, run-script on the node, right click a splitter
handle, Insert, click the Action button, select "Add QML shower".

Note that you can flick the text boxes it shows up and down with the mouse,
in a tablet / phone ui kind of way.

---cut here---
from PyQt4.QtCore import QUrl
from PyQt4.QtDeclarative import QDeclarativeView
class QMLShower:
    def __init__(self, c):
        self.c = c
        c._qml_shower = self
        self.w = None
        c.free_layout.get_top_splitter().register_provider(self)
    def ns_provider_id(self):  # allow for re-registering, mainly for dev.
        return '__qml_shower'
    def ns_provides(self):  # what we can provide
        return [("Add QML shower", '__add_qml_shower')]
    def ns_provide(self, id_):  # provide it
        if id_ == '__add_qml_shower':
            g.unregisterHandler('select2', self.update)
            g.registerHandler('select2', self.update)
            if not self.w:
                self.w = self.make_widget()
            return self.w
    def make_widget(self):
        view = QDeclarativeView()
        path = g.os_path_join(g.computeLeoDir(), 'plugins', 'qmlnb', 'qml', 'leonbmain.qml')
        view.setSource(QUrl(path))
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        # Display the user interface and allow the user to interact with it.
        view.setGeometry(100, 100, 400, 240)
        view.show()
        # rootObject = view.rootObject()
        return view   
    def update(self, tag, kwords):
        pass
    def closed(self, event):
        g.unregisterHandler('select2', self.update)

QMLShower(c)
---cut here---
#@+node:ekr.20131105110107.16905: *7* Templates with macro expansions
From: Jacob Peck

One of the ways I use Leo is as an information management/database for when
I'm running tabletop RPGs. Such games involve a fair amount of similarly
structure data. I set out to make a way of defining a template, and
providing macro expansions within the template, so that the user could
click a script button, be prompted for data, and be rewarded with a
fully-populated copy of the template. I've managed to accomplish this with
the code below:

https://gist.github.com/gatesphere/2be5030506a364ee6ec1

How it works is like this:

- Create a `@template` node.  This is the parent node for your template.

- Create a `@destination` node as a child of the @template node. This 
node's headline is the name of a top level node where your completed 
template will be placed.  `@destination Sessions` will place the 
finished product under the top-level "Sessions" node.

- Populate the @template node with various `@item` nodes - these keep 
their structure in the filled template.  Anything that needs to be a 
part of the final product has to be an @item node.

All of that is fine and dandy if you just want to copy and paste... but 
that's already baked into Leo.  So I added macro expansion.  The script 
gathers up all instances of anything that fits the regex "<\\$\\w+>" is a 
macro variable name.  Something like `<$name>` or `<$date>`.  The script 
gathers up all of these variable names, and prompts the user (ala 
todo.py's "Redistribute Priorities" function) for values for each of 
them. They are global with respect to the template, so using the same 
macro variable in multiple places in the same template will result in 
all of them being filled in with the same value.

In addition, there is one more type of node that can go under @template 
nodes - @default.  @default nodes provide a default value for a macro 
variable.  The node with a headline of `@default <$name>` and a body of 
"This is my body" gives the `<$name>` macro a value of "This is my body" 
everywhere within the template, and that macro will not be prompted for 
a value.  This is handy if you're copying templates between Leo 
worksheets, and want them flexible, but don't want them to fill in the 
same value for every single invocation of copy-template.

Here's an example template:

@template <$campaign> Session #<$num> ($date)
       @destination Sessions
       @default <$campaign>
       @item Who's Coming?
       @item In-World Start Date
       @item Log
       @item Threads
             @item High Priority
             @item Low Priority
       @item News
             @item Out of Character
             @item In Character

The body of `@default <$campaign>` is "World of Ka'rim".  The body of 
`@item Who's Coming?` is "John, Jane, Jack, Jenny, Jeremy".

Running copy-template on this template, and filling the values prompted 
for (<$num> and <$date>) gives the following under the top-level node 
Sessions:

World of Ka'rim Session #1 (01 May 2013)
       Who's Coming?
       In-World Start Date
       Log
       Threads
             High Priority
             Low Priority
       News
             Out of Character
             In Character

The headlines bodies are correctly filled in with macro expansions, and 
other text is verbatim copied from the respective headlines and bodies.

So... two questions:

1.) Did I re-implement something Leo already does?
2.) Anyone have any suggestions on reducing the amount of code/any fixes?

Also, hope someone else finds this useful.  Once it's cleaned up, I 
might do a leo-editor blog post about it.
#@+node:ekr.20131105110107.16906: *6* Commands: new and improved
#@+node:ekr.20131105110107.16907: *7* Added docstrings for all commands
Help-for command translate !<command-name>! in the docstring to the binding for command-name.
#@+node:ekr.20131105110107.16908: *7* All viewrended commands now start with vr
#@+node:ekr.20131105110107.16909: *7* Allow periods before section names in headlines
Skip '.' before section names in v.matchHeadline.

2013/08/01: bug fix: allow leading periods in at.isSectionName.
#@+node:ekr.20131105110107.16910: *7* Alt-Home & Alt-End collapse all possible nodes
#@+node:ekr.20131105110107.16911: *7* Ensure selected @test node is run
In earlier version of Leo if one runs test externally with the selected
position under @test node, that @test was executed with
(run-marked-unit-tests-externally)

The fix was to the "important special case" in TM.findAllUnitTestNodes.
#@+node:ekr.20131105110107.16912: *7* Fixed dabbrev commands
The commands now work, and Alt-slash and Alt-Ctrl-slash are bound as in Emacs.
#@+node:ekr.20131105110107.16913: *7* go-anywhere command (quicksearch plugin)
The quicksearch plugin now supports the go-anywhere command. It works "sort
of" like Nav bar. Also Nav bar now does live search on headline (you have
to press enter to force search of bodies as well)

Once the hits are shows, you can navigate them by pressing up/down while
focus is still in line editor & you can keep on typing (sort of like
sublime text).

This has a very clever hack (even if I say so myself)--spaces in search
string are replaced with * wild card. So if you search for, say "file txt",
it will search for "file*txt", matching e.g. @file readme.txt
#@+node:ekr.20131105110107.16914: *7* Help commands now use <pre> formatting if docutils is not available
#@+node:ekr.20131105110107.16915: *7* help-for-command executes apropos commands
Instead of just printing their docstrings.
#@+node:ekr.20131105110107.16916: *7* help-for-python now uses vr window
#@+node:ekr.20131105110107.16917: *7* help-for-regular-expressions command
#@+node:ekr.20131105110107.16918: *7* Improved incremental search commands
- Documented that return ends the search.
- Documented that deleting the entire search pattern aborts the search.
- Removed annoying status messages printed to log.

- (Can't do) If text is already highlighted, Alt-S or Alt-R should use that text.

#@+node:ekr.20131105110107.16919: *7* leoscreen-jump-to-error command
By Terry Brown

I assume all *nix shell users use the screen shell multiplexer, and
hopefully *nix shell users who use Leo know about the leoscreen plugin
which passes text back and forth between Leo and the shell (provided you're
running screen), which is very handy for build scripts and SQL hacking etc.
etc.

Anyway, if you're in that sliver on the Venn diagram :-) there's a new
command leoscreen-jump-to-error which scans the output in the shell for the
offending line in the last python traceback, handy if you're coding python
in Leo and running/debugging in the shell.

leoscreen-jump-to-error
    Jump to the python error reported in the shell window, if the
    file's loaded in the current Leo session. Just looks for a line:

        File "somefile.py", line NNN, in xxx

    and looks for a node starting with "@" and ending with "somefile.py",
    then jumps to line NNN in that file.
#@+node:ekr.20131105110107.16920: *7* normalize-whitespace
https://bugs.launchpad.net/bugs/994985
Wishlist: normalize-whitespace

When using @auto, the logic often complains about "abnormal" whitespace and
refuses to write/read node normally.

What I did:
    
1. The clean-lines command (and thus the clean-all-lines command)
   now remove trailing whitespace while preserving newlines.
   
2. reportMismatch suggests using the clean-all-lines command.
   Note: a good unit test for reportMismatch already exists.
   
3. Added a unit test for clean-lines.
#@+node:ekr.20131105110107.16921: *7* parse-body command
Useful for re-parsing text that was not originally parsed properly.
#@+node:ekr.20131105110107.16922: *7* print-buttons command
Created print-buttons command, showing source of all @command and @button nodes.

Changed ParserBaseClass.doButtons/doCommands so they return
lists of (p.copy(),script) rather than (p.h,script)

Added g.app.config.atLocalButtonsList & g.app.config.atLocalCommandsList
for use by print-buttons command.
#@+node:ekr.20131105110107.16923: *7* Refresh from disk menu command now refreshes all selected nodes
"refresh from disk" is now done for all selected nodes. You can either

ctrl-click each @<file> node you want refreshed, then "refresh from
disk" to refresh all of them, or

shift-click the first and last @<file> node you want refreshed, to
select the entries in between, then "refresh from
disk" to refresh all of them.

(i.e. standard UI list multi item selection)

But be aware of this bug:
https://bugs.launchpad.net/leo-editor/+bug/1090950

using refresh from disk immediately after cutting nodes from the
outline has odd effects.
#@+node:ekr.20131105110107.16924: *7* Show all commands after <alt-x><tab>
A simple change to k.computeCompletionList was all that was needed.

#@+node:ekr.20131105110107.16925: *7* vr-expand/contract commands
#@+node:ekr.20131105110107.16926: *7* zoom-in/out commands
From: Terry Brown <terry_n_brown@yahoo.com>

I just pushed two new commands, zoom-in and zoom-out, which increase
or decrease the body text font size by one point size.  They probably
deserve default bindings, but to what?  I have them on Ctrl-; and Ctrl-'

They leverage the new theme "engine" by manipulating a constant
"@font-size-body".  I've set it up in the default theme, anyone using
the new dark theme will need to add

   @font-size-body = 18px

in the config node for that theme, 

@settings-->solarized_dark theme settings-->stylesheet & source-->config

and replace the literal "18px" with "@font-size-body" in the node

@settings-->solarized_dark theme settings-->stylesheet & source-->Non-color styles (fonts etc.)-->body editor

commit log:

  zoom-in / zoom-out commands
  ctrl-mouse wheel scrolling for same
  
  replace old focused pane border highlight with pure stylesheet
  version
  
  rename solarized_dark theme leo_dark_0
#@+node:ekr.20131105110107.16927: *6* Gui improvements
#@+node:ekr.20131105110107.16928: *7* @wrap now suppresses horizontal scrolling
This is a significant improvement, and makes Leo suitable for authoring
text. It should have been done ages ago. Please let me know immediately if
this new behavior causes problems for you.

There is one glitch.  If you add @wrap, the directive won't be in effect 
until you leave the node and revisit it.

===== redla

There is one problem which is caused by this change: I have @wrap active
and see my "plain" text wrapped properly. But if there is any "long enough"
URL on the page (i.e. longer than the screen width), this is not wrapped
(as there is no space in the string) nor I can see the end of it (as there
is no horizontal scrollbar either)

#@+node:ekr.20131105110107.16929: *7* All @button nodes now show call tips
These are generated from the @button node's docstring, if it exists.
#@+node:ekr.20131105110107.16930: *7* Change focus-border color depending on input state
Leo now supports having border colors that show which pane has focus.

To enable such borders, modify (in your myLeoSettings.leo)::

    @data qt-gui-plugin-style-sheet

Change::

  @focused-border-style = none

to::

  @focused-border-style = solid

**Important**: The following settings are no longer used::

    @int focus_border_width = 1
    @bool use_focus_border = False 
#@+node:ekr.20131105110107.16931: *7* Dark colorizing theme
by Terry Brown

I just pushed the solarized dark theme to trunk. There were some changes to
core code, but nothing too major, and I've been using it for some time.

In leoSettings.leo there's a new top-level node called 'Themes', which
contains a single theme node at the moment, you can copy that to you
myLeoSettings.leo file under @settings. Read the README node of the theme
node for more instructions.

The theme is far from perfect - it's relatively easy to get it looking ok
if you're already running a dark desktop theme, which is what I'm doing,
but much harder if you want Leo dark in a light desktop theme, as you need
to theme everything.

 - See the README. If you're already running a dark theme there's a `base`
   node which can be switched to `@ignore base` to take more advantage of
   your desktop theme.

 - The new theme system includes a stylesheet authoring tool with macro
   substitutions :-) you no longer edit @data qt-gui-plugin-style-sheet
   directly but edit a more comfortable Leo tree version and then
   run-script on the appropriate node to "compile" to @data
   qt-gui-plugin-style-sheet
   
**Note**: The docs in the theme node do mention moving other @data
qt-gui-plugin-style-sheet and @color nodes out of the way, but I've added a
couple of notes about putting it at the bottom of the @setting list to
ensure it overrides other settings. The problem is when the default theme's
@data qt-gui-plugin-style-sheet node comes after the dark theme's.

===== Ville.

If you prefer the bigger contrast that e.g. Sublime Text 2 has, try this
"config": https://gist.github.com/vivainio/5261207

===== Terry

From: Terry Brown <terry_n_brown@yahoo.com>

Along these lines someone wanted a dark body only, you can get that by just
adding @ignore to all the color related nodes other than body, or moving
all of them under an @ignore node.

===== Ville 

I'm slightly bothered by the fact that color variable names have
"solarized" in them. You are supposed to create new themes by changing
their values in the "config" node, after which the theme is not "solarized"
any more. How about "@leotheme-c-0" (for color 0) etc.

===== Terry

The variable replacement runs up to ten levels deep, after which it bails
assuming you've created a loop :-)

So there's nothing wrong with::

  @solarized-yellow = #abcdef

The issue is that `@solarized-yellow` is used in the guts of the stylesheet
definition. Instead, ideally, but I didn't get to it, in the config node
you'd have::

  @solarized-yellow = #abcdef
  ...
  @highlight-hot = @solarized-yellow

and then use `@highlight-hot` in the guts of the stylesheet definition.

**Note**: you can't create new themes simply by editing the config node,
it's not possible to create enough constants for every style element that
can be addressed by a stylesheet.

But it would be nice to move all the color and numeric constants out of the
stylesheet and into the config node as I've described above, just a find
and replace operation.
#@+node:ekr.20131105110107.16932: *7* Sublime Text 2 (A dark colorizing theme)
By Ville M. Vainio

https://plus.google.com/103097156557482112329/posts/6D9GPRCdXVh
#@+node:ekr.20131105110107.16933: *7* Use ctrl-click to open url's
- Added the following commands:
    
    - ctrl-click-icon
    - ctrl-click-at-cursor
    - open-url
    - open-url-under-cursor
    
- Double-click *only* edits headline.
- Only look at first line of the body in @url nodes.
- Ctrl-click in body allows spaces in url's.
#@+node:ekr.20131105110107.16934: *6* New features
#@+node:ekr.20131105110107.16935: *7* About @testsetup
Leo now contains support for \@testsetup nodes. At present, they work only
when running unit tests locally.

In effect, \@testsetup nodes provide common setup code for all following
\@test and \@suite nodes. Such common setup code is the real reason for
having custom subclasses of unittest.TestCase. This Leonine solution is
much than either:

a) @testclass nodes (which I never use) or

b) "injecting" common test code using::

    exec(g.findTestScript(c,\'@common name-of-common-test-code\'))

Leo's test-execution code prepends the body text of an \@testsetup node to
all following @test and @suite nodes. Multiple \@testsetup nodes may appear
in an outline. The range of an @testsetup node extends over all following
\@test and \@suite nodes until the next \@testsetup node is seen (in
outline order).

#@+node:ekr.20131105110107.16936: *7* Added support for @testclass
\@testclass nodes should set either the suite or testclass vars.

\@suite nodes should set the suite var.
#@+node:ekr.20131105110107.16937: *7* Added support for sessions
- Changed es so it always queues messages when g.app.log is None.
- Completed the command-line args: --session-save and --session-restore.
- Wrote session info in leoTabbedTopLevel.closeEvent and g.app.onQuit.

Rev 5324 finishes some session-related work. The existing
session commands are unchanged, but Leo now fully supports
two new command-line arguments::

    --session-restore     restore previously saved session tabs at startup
    --session-save        save session tabs on exit

If you use both arguments, everything is automatic: Leo
saves the tabs when you quit Leo, and restores tabs when you
start Leo. Note that you can still specify file names on the
command line in addition to whatever files --session-restore
will open for you.

If you use only --session-restore, it is up to you to save
sessions "by hand" with one of the session commands, for
instance, session-snapshot-save.
#@+node:ekr.20131105110107.16938: *7* Allow cloned siblings
A major change in Leo's read/write code.  The first "live" rev was 5584.
At present, controlled by the allow_cloned_sibs switch in leoAtFile.py.

Fixes the following bugs:

clones sometimes not saved
https://bugs.launchpad.net/leo-editor/+bug/882243

When all clones of a node are in an @file subtree, they disappear on exit
https://bugs.launchpad.net/leo-editor/+bug/1084661
#@+node:ekr.20131105110107.16939: *7* Allow clones anywhere in @file nodes
http://groups.google.com/group/leo-editor/browse_thread/thread/67a28984616d09c9
About bug 882243: clones sometimes not saved

What I did:

- Added allow_cloned_sibs switch at the start of leoAtFile.py.
  All new code enabled by this switch.

- Refactored at.createNewThinNode:
    - Renamed createThinChild4 to old_createThinChild4.
    - Added new_createThinChild4.
    - Added createV5ThinNode.
    
The key invariant in createV5ThinNode:
    On exit from at.changeLevel, top of at.thinNodeStack is the parent.
#@+node:ekr.20131105110107.16940: *7* Major additions to abbreviations
From: Terry Brown <terry_n_brown@yahoo.com>

Abbreviations can now include computed values and place holders which you
can step through, filling in a template.

Here's a quick screencast of the template expansions:
http://www.greygreen.org/tmp/leoabbrev.ogv

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.


===== EKR

The same exec statement appears to allow the execution of arbitrary
Python code.

===== Terry

That's why enabling requires @bool scripting-at-script-nodes = True as
well as the abbreviation specific stuff.  The risk seems equivalent to
the scripting-at-script-nodes = True risk.
#@+node:ekr.20131105110107.16941: *7* Major improvements made to abbreviations
Leo's abbreviations have been significantly improved by adding scripted
abbreviations and templates. This is the work of Terry Brown,
<terry_n_brown@yahoo.com>

Terry describes the new features in a screencast: http://www.greygreen.org/tmp/leoabbrev.ogv

The highlights::

1. The @data abbreviations-subst-env node contains a script defining the
   environment in which all abbreviations execute. This allows helper
   functions to be defined. Very handy.
   
2. Scripts may span multiple lines. Line starting with "\:" (2 characters)
   continue a script. This allows abbreviations to define multi-line
   templates.  Helpers defined in @data abbreviations-subst-env can
   fill in templates with *calculated* (not predefined) data.
   
3. Templates may contain placeholders that the user can fill in.  By default,
   the double comma binding selects the next placeholder.

4. Added 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. Added a new example node: @@data abbreviations examples.  This contains
   several extremely useful scripts.
#@+node:ekr.20131105110107.16942: *7* Warn if same .leo file open in another Leo instance
https://bugs.launchpad.net/leo-editor/+bug/711158

- The PickleShareDB object is created even if caching (of files) is disabled.
  This allows us to used g.app.db even when --no-cache is in effect.
  
- Added the three methods in app.Detecting already-open files.
#@+node:ekr.20131105110107.16943: *6* New languages and importers
#@+node:ekr.20131105110107.16944: *7* Added importer for .otl files
Leo now supports @auto-otl, along with imports of .otl files.

There are two ways to create @auto-otl nodes:

1.  Use Leo's import-file command to create and populate an @auto-otl
node. Save the .leo file.

2. Create an @auto-otl <path to the .otl file>.  Use the refresh-from-disk command
to populate the node *before* saving the .leo file.

Either way, you should now have an @auto-otl node whose **children**
represent the contents of the external .otl file.  (The actual @auto-
otl node is *not* written to the external file.  This allows you to
put Leo directives in the node.) Changing the children in Leo will
change the external file.  Changing the external file outside of Leo
will update the outline the next time you restart the .leo file
containing the @auto-otl node.
#@+node:ekr.20131105110107.16945: *7* Added importer for .ipynb importer
Rev 5488 contains a prototype for importing IPython notebook (.ipynb) files 
into Leo.  In theory, this would allow two-way interchanges between Leo 
outlines and the outlines in IPython notebooks.

At present, the prototype simply converts a string containing the contents 
of a .ipynb file to a Leo outline.  A few details remain, but it shows that 
such conversion is straightforward.  Otoh, this is just a first step: we 
would like the Leo outline to support most of the features of IPython 
notebooks, including embedded images, etc.

===== From: Alia K

May a suggest a radical thought exercise that only occurred to me after 
seeing what can be achieved in terms of in-browser editing with 
http://codemirror.net/: 

Why not create an ipython notebook "plugin" version of leo which would only 
provide core leo functionality: outlines, literate programming, and clones, 
but would not be burdened by having to support legacy leo plugins. 

You could leverage all the mad goodness and momentum that is happening with 
ipython right now (interactivity, parallelism, networking and 
collaboration, interactive access to javascript libs like d3.js, etc.., 
inline images, and movies, and cell magic, etc..). Since ipython is pretty 
much pervasively used ... it could be a good thing for leo (-:
#@+node:ekr.20131105110107.16946: *7* Added importer for TypeScript files
Added TypeScriptScanner class and related code.
#@+node:ekr.20131105110107.16947: *7* Added importer for vimoutliner imports and @auto-otl
Created vimoutlinerScanner.

Created at.writeAtAutoOtlFile.
#@+node:ekr.20131105110107.16948: *7* Added support for clojure syntax coloring
#@+node:ekr.20131105110107.16949: *6* Plugins
#@+node:ekr.20131105110107.16950: *7* New plugins
Added printing.py.
#@+node:ekr.20131105110107.16951: *8* leomylyn.py
From: Ville M. Vainio
See: http://en.wikipedia.org/wiki/Mylyn

I went on to start a "leo mylyn" plugin to exercise using the
childrenModified and contentModified signals.

If you want to play with it, pull, enable leomylyn.py, modify stuff
around the tree and do alt-x mylyn-scores.

Of course as it is useless in this state, but becomes useful when it
has a proper gui (maybe in Nav pane), where you would then have a list
of "most interesting" nodes.

In the future, this could be able to remember the scores through the
sessions, degrade the old scores by time, etc. Also, a scoreset would
be associated with a "project" (e.g."own research", "work project
foo"), each of them having their own typical node working set.

Mylyn was a nice boost back in the eclipse days, it could work for Leo
too. My main motivation right now was to demonstrate the signals with
something that is much simpler than using them in qmlnotebook.
#@+node:ekr.20131105110107.16952: *8* printing.py
The printing.py plugin fixes this bug:
https://bugs.launchpad.net/leo-editor/+bug/1132804

Here's the docstring:

'''Supports printing from the Qt GUI.

Jacob M. Peck, 2013

Commands
========
This plugin supports the following twelve commands:

print-selected-node
-------------------

Opens up the print dialog to print the selected headline and node.

print-preview-selected-node
---------------------------

Opens up the print preview dialog to preview the selected headline
and node.

print-selected-node-body
------------------------

Opens up the print dialog to print the selected node body.

print-preview-selected-node-body
--------------------------------

Opens up the print preview dialog to preview the selected node body.

print-expanded-node
-------------------

Opens up the print dialog to print the expanded contents of the
selected node, with top-level headline.

print-preview-expanded-node
---------------------------

Opens up the print preview dialog to preview the expanded contents
of the selected node, with top-level headline.

print-expanded-node-body
------------------------

Opens up the print dialog to print the expanded node body.

print-preview-expanded-node-body
--------------------------------

Opens up the print preview dialog to preview the expanded node
body.

print-marked-nodes
------------------

Opens up the print dialog to print all marked nodes in the current
outline, with headlines.

print-preview-marked-nodes
--------------------------

Opens up the print preview dialog to preview all marked nodes in \\
the current outline, with headlines.

print-marked-node-bodies
------------------------

Opens up the print dialog to print the bodies of all marked nodes
in the current outline.

print-preview-marked-node-bodies
--------------------------------

Opens up the print preview dialog to preview the bodies of all
marked nodes in the current outline.

Settings
========
- ``@string printing-font-family = DejaVu Sans Mono``
   The font family for printing.  A monospaced font is recommended.

- ``@string printing-font-size = 12``
   The font size for printing bodies, in px.  Due to limitations
   of PyQt, the size of headlines cannot be changed.
   
'''
#@+node:ekr.20131105110107.16953: *8* screen_capture.py
By Terry Brown.

See http://leo-editor.github.io/screen_capture.html

screen_capture_now captures an image immediately, screen_capture_5sec waits
five seconds, so you can position the pointer, open menus etc. The only
feedback is in the console, as messages in the log would be distracting in
the captured image.
#@+node:ekr.20131105110107.16954: *8* screencast.py
By Edward K. Ream

Screencasts promise to be easy to be *much* easier to create than 
slideshows, while also being more interesting, informative and flashy.  It 
is *so* much easier to write a screencast script than it is to lay out a 
slide, take a screenshot, and then manage resulting slide.

In particular, there are few continuity problems with screencasts.  
Continuity is a *huge* problem with slideshows!  If I change one slide, I 
am likely to want to change all following slides.  Which means I have to 
retake all the slides, and file the new versions in the proper places.  In 
contrast, any changes to screencasts naturally propagate forward.  There 
might be an effect on following screencasts scenes, but this will happen 
rarely with a reasonable scene design, and any problems should be easy to 
fix.

With screencasts, the *movie* script is also the *python* script!  There is 
no "translation" from one to the other.  Furthermore, all the work to 
produce a screencast is done (naturally!) within Leo.  No need to create 
and manage external data.  This is another huge advantage and it make 
producing screencasts much faster than producing slideshows.

Screencasts may be the long-awaited tools that will allow me to show Leo in
action so that other will finally be able to understand it easily.
#@+node:ekr.20131105110107.16955: *8* timestamp.py
By Kent Tenney

The timestamp plugin manages the following node attributes:

- str_ctime: creation time
- str_mtime: time node was last modified
- str_atime: time node contents were last viewed
#@+node:ekr.20131105110107.16956: *7* Improved plugins
#@+node:ekr.20131105110107.16957: *8* bookmarks.py
By Terry Brown

The bookmarks.py plugin provides a pane with colored links to nodes.
Bookmarks can now be added and removed with mouse clicks, making navigation
back and forward between related nodes quick and easy.

The free_layout Action button context menu will also allow you to add one
of these bookmark panes, and they will be saved and loaded again if the
layout is saved and loaded.

=====

Can also be used for bookmarking directly from the browser to Leo.  To
do this, add a bookmark to the browser with the following URL / Location:

    javascript:w=window;if(w.content){w=w.content}; d=w.document; w.open('http://localhost:8130/_/add/bkmk/?&name=' + escape(d.title) + '&selection=' + escape(window.getSelection()) + '&url=' + escape(w.location.href),%22_blank%22,%22toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=800, height=300, status=no%22);void(0)

and edit the port (8130 in the example above) to match the port you're using
for mod_http.

Bookmarks are created as the first node in the outline which has been opened longest.
You can set the ``@string`` ``http_bookmark_unl`` to specify an alternative location,
e.g.::

    @string http_bookmark_unl = /home/tbrown/.bookmarks.leo#@bookmarks-->Incoming

to place them in the `Incoming` node in the `@bookmarks` node in the `.bookmarks.leo` outline.

The headline is preceded with '@url ' *unless* the ``bookmarks`` plugin is loaded.
If the ``bookmarks`` plugin is loaded the bookmark will have to be moved to a ``@bookmarks`` tree to be useful.

The browser may or may not be able to close the bookmark form window for you, depending on settings - set ``dom.allow_scripts_to_close_windows`` to true
in ``about:config`` in Firefox.
#@+node:ekr.20131105110107.16958: *8* ipython.py
IPython plugin now works with all versions of IPython.

- Import logic looks for legacy IPython first (0.11 and prev),
  then looks for new-style IPython (0.12 and above).

- Created GlobalIPythonManager class, assigned to leoIPython.gipm and g.app.gipm.

- Added self.c ivar to LeoNode class.  This is the same as p.v.context.

- Changed:
    - init (qtGui.py top level) (qtPdb)
    - runMainLoop (qtGui)
    - start_new_api
#@+node:ekr.20131105110107.16959: *8* valuespace.py
**Important** Ville M. Vainio has made many nifty additions to this plugin.

Here is a summary: http://leo-editor.github.io/valuespace-intro.html

Some details:

1. valuespace now support yaml in named anchors (i.e. "@a foo.yaml" now parses
parent as yaml and assigns the result to variable "foo"). It also has a
dependency on pyyaml now.

2. I'm doing some research now, that requires storing inputs in json, I use
   those inputs to calculate some outputs and store them in .json files. I
   added a few directives to valuespace.py plugin to bring native json data
   support.

**@vsi foo.json**

reads in file foo.json, and stores the parsed data structure to vs /
ipython variable "foo"

**@vso bar.json**

serializes content of variable "bar" to json file. \@vsi gets executed
during pass 1 of vs-update, \@vso gets executed in phase 2.

Body text gets assigned with json content in both cases.

Some further notes:

- Yes, the .json extension is explicitly special cased in the code. The
  idea is that e.g. @vso foo.csv would serialize the contents of variable
  "foo" as csv, .yml would use yaml etc.

- vsi and vso stand for value space input and value space output,
  respectively

For now, the best way to study it is valuespage_example.py in contrib
branch.

I'm being very successful in using it + new ipython support as "ipython
notebook" workalike.

Ipython notebook is better for quick experiments, but I'm doing long term
(multi-week) research, where Leo + IPython + valuespace is doing a great
job so far.

===== Terry Brown

I've added ``vs-eval``, ``vs-last``, and ``vs-last-pretty`` commands to
the ``valuespace.py`` plug-in.  Update docs below.

===== Ville

If you don't want them in there, let me know and I'll move them. I put them
in there to avoid creating yet another plug-in, they're sort of a light
weight local calculation tool, vs. ``valuespace.py``'s outline wide calcs.

valuespace.py
=============

vs-eval
-------

Execute the selected text, if any.  Select next line of text.
    
Tries hard to capture the result of from the last expression in the
selected text::
    
    import datetime
    today = datetime.date.today()
    
will capture the value of ``today`` even though the last line is a
statement, not an expression.
    
Stores results in ``c.vs['_last']`` for insertion
into body by ``vs-last`` or ``vs-last-pretty``.

Removes common indentation (``textwrap.dedent()``) before executing,
allowing execution of indented code.

``g``, ``c``, and ``p`` are available to executing code, assignments
are made in the ``c.vs`` namespace and persist for the life of ``c``.
    
vs-last
-------

Insert the last result from ``vs-eval``.  Inserted as a string,
so ``"1\\n2\\n3\\n4"`` will cover four lines and insert no quotes,
for ``repr()`` style insertion use ``vs-last-pretty``.
    
vs-last-pretty
--------------

Insert the last result from ``vs-eval``.  Formatted by
``pprint.pformat()``,  so ``"1\\n2\\n3\\n4"`` will appear as
'``"1\\n2\\n3\\n4"``', see all ``vs-last``.
#@+node:ekr.20131105110107.16960: *8* viewrendered.py
Supported ctrl-clicks in viewrendered panes.

Jacob Peck added support for markdown
http://packages.python.org/Markdown/
markup in viewrendered panes.
#@+node:ekr.20131105110107.16961: *6* Revised IPython Bridge
The highlights of the changes:

1. leo.core.leoIPython.py now contains *all* of Leo's IPython-related code.
   The setup code comes mainly from leo.plugins.internal_ipkernel.py.

2. internal_ipkernel.py still exists (it will go away soon), but it has has
   been completely disabled as follows::

    if 0:
        @others

3. When the --ipython command-line argument is in effect, g.app.ipk is a
   *singleton* IPython shell, shared by any and all IPython consoles.

4. The startup code injects only a single object, _leo, into the IPython
   namespace. This is an instance of the bulked-up LeoNameSpace class. This
   interface class now contains features that make it easier to deal with
   multiple open Leo commanders.

- _leo.g is set to leoGlobals only once. Not exactly correct, perhaps, but
  nobody will notice.

- _leo.commanders is a (read-only) property returning the list of open
  commanders. This list is always kept up-to-date: it scans
  g.app.windowList before returning its result.

- _leo.c is a (read/write) property returning g.app.windowList[0].c if the
  windowList has only one element, or the "designated commander" if it
  exists. Otherwise, it returns None. In that case, the expectation is that
  the user will "designate" a commander with: _leo.c = aCommander.

- _leo.find_c(path) returns the commander c such that c.fileName() or
  g.shortFileName(c) matches path.

5. Perhaps most importantly, that's *all* there is. In particular, Ville's
   magic functions and LeoWorkbook class are gone.

Imo, the deleted code might better exist as IPython startup code, but I
could be wrong. Furthermore, Leo's p.h and p.b properties are new since
Ville first created the code, and so this kind of support code is less
urgently needed.

If there is a great demand to restore these features, it can always be done
later. For now, though, I wanted to do the simplest thing that could
possibly work.
#@+node:ekr.20131105110107.16962: *6* Scripts
The following scripts have been added to scripts.leo:

By Terry Brown::

    Add @script node
    Cross-outline node editing
    Export full contents
    Full tree view (See the discussion in the child)
    Indexing files for full text search
    Persistent state with json as a leo abbreviation
    Tool for diffing Leo files
    
By Edward K. Ream::

    Cleanup imported nodes
    Create global data structures from in modes/*.py files
    Get all comments from modes (slow)
    Import org mode
    jinja2 templating
    Recursive import script (with cleanups)
    
By Brian Theado::

    Display function call hierarchy in Leo
#@+node:ekr.20131105110107.16963: *7* Full tree preview
From: wgw <wgwinder@gmail.com>

I would like to see a fuller outline view of Leo trees. So instead of 
seeing one body only and the tree of headlines, I want to display all the 
parts of the tree (all bodies and subheadings) as continuous text, much 
like a word processor outline. 

===== From: Terry Brown <terry_n_brown@yahoo.com>

Ville did something possibly similar:
https://groups.google.com/forum/?fromgroups=#!topic/leo-editor/Zs-5jKjPAB0

===== From: wgw <wgwinder@gmail.com>

Thanks! That plugin does both more and less than I want: more, because I
get a full and nicely formatted window with editable text boxes; less,
since it doesn't write any edited text back to the tree.

My fumbling tinkering would go towards not editing in the preview
window/pane at all, and just having a keystroke or click scroll the editing=

pane to the right node in Leo. But that would mean that the preview panel=

would have have to be properly indexed so that from the cursor position in=

the panel the plugin could find the proper node back in the Leo panel.
 (Kludgey way: put the node id in the text!)

Thanks for the suggestion.

===== wgw

Is there a  way to delete an inserted pane?

===== Terry

Yes, although a bit putzy.  Right click on the panel divider adjacent
to the pane, it may be above or below or left or right of it.  The panes
either side of the divider will be highlighted blue and orange.  There
will be an option to "Delete 1 left" or "Delete 1 below" or similar, if
that seems to refer to the panel you want to delete, that's your option.

If the target panel seems to be joined with another (i.e. 2 not 1
above) try right clicking a different divider to start with.

===== Matt Wilkie

I use *"r-click > Edit in ..."* for this purpose. It's a poor man's
workaround. Something integrated would be much nicer. Just thought I'd
mention it for anyone looking for something they might be able to use right
away.

===== Terry

When I try that it only edits the one node, none of its children.
Which is what I thought it did.

===== Matt Wilkie

Are the links in the overview supposed to open up a browser window? The
alt-tip text gives an in-Leo hierarchy, e.g. "B:\code\dropbox-code.leo#leo
stuff-->Overview of selected nodes" but clicking goes to
http://www.google.ca/, and in Internet Explorer even though Firefox is my
default browser.

===== Terry

No, that's not right, they're supposed to just select the node they
belong to.

===== Matt

And, more generally, can these hover-over-pane-divider-then-right-click
actions be made available any other way? Like a drop down menu from a
button or alt-x command or something.

===== Terry

What, you mean instead of being completely hidden where no one will
ever find them?  :-)  Most of them (not the Open Window variants of
course) rely on the context provided by your selection of a particular
divider, insert-where, delete-which etc.

Probably the most friendly would be a button which pops up an overlay
over the UI where you can select which pane to delete, or where to
insert, etc.  But that would be hard.

But it occurs to me that it might be the open window variants you want,
specifically the code to make a button / command to open a window with
a particular panel in it.  That would be this:

if hasattr(c, 'free_layout'):
    splitter = c.free_layout.get_top_splitter()
    if splitter:
        splitter.open_window(action='_add_overview_pane')

===== wgw

Excellent! This is really a great help for me. I'm still experimenting, but 
one thing I will find useful is that I can open several of these panes and 
navigate through each of the "views". Plus (and this has been a longtime 
wishlist item for those with fading sight), I can increase the text size 
for reading big chunks of text. 

(Another plus, and this is a big one, I can actually read your code well 
enough that I start to have some inkling about how to do this kind of 
addition to Leo. I could never begin to write it myself, but Leo makes it 
accessible even for shambling hackers.)

One question: is there a  way to delete an inserted pane?  It  looks useful 
to have an inserted pane, but refreshing will require killing the pane and 
reinserting.... 


#@+node:ekr.20131105110107.16964: *6* Settings & options
- Added @color minibuffer-foreground-color setting.
- Added @color log_warning_color setting.
- Fully supported :: convention in @mode nodes.
- Added --no-plugins command-line option.
#@+node:ekr.20131105110107.16965: *6* Web site improvements
The new home page is http://leoeditor.com/

- Added link to home page from the TOC.
- Removed online-tutorial link.
- Added search box.
- Added link to glossary from Leo's home page.
- Added scaled screen shot to Leo's home page.
- Brought screen shots up to date.
#@+node:ekr.20131105110107.16966: *5* b1 release
#@+node:ekr.20131105110107.16967: *6* Greatly improved tutorials
See http://leoeditor.com/tutorial.html
#@+node:ekr.20131105110107.16968: *6* Code improvements
#@+node:ekr.20131105110107.16969: *7* Added c.recursiveImport and ic.recursiveImportController
This will reduce duplicate scripts.
#@+node:ekr.20131105110107.16970: *7* Added c.user_dict and g.user_dict
There are non-persistent Python dicts, for free use by plugins and scripts.
#@+node:ekr.20131105110107.16971: *7* Added strip_data argument to config.getData
#@+node:ekr.20131105110107.16972: *7* Improved abbreviations
Made the following changes:

- Refactored the code in abbrevClass.finishCreate into three parts, mostly
  so each may have its own docstring.

- Added try/finally protection in the exec statement, so that errors in
  \@data abbreviations-subst-env do not cause problems during startup.

- Added 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.

- finishCreate always reports either::

        Abbreviations on
        Abbreviations 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"

- Changed @data abbreviations-subst-env node to handle missing os.environ['LOGNAME'].

- To make this work, the doData parser in leoConfig.py no longer strips
  lines.
#@+node:ekr.20131105110107.16973: *7* Removed unused binding & gui code
Found empty methods using: ^[ ]*def.*$(\n[ ]*)*pass
    
Removed all calls to unused methods in qtGui.
    
Rev 6016:
- Removed all definitions and calls to createBindings.
  All definitions were empty.
  
Rev 6017:
- Removed all definitions and calls of createFindPanel.
  All definitions were empty.
- Removed call to createFrame in findTab ctor in leoFind.py.
  The gui code creates the frame.
- Removed all calls to createRootWindow and recreateRootWindow
- Removed do-nothing leoQtFindTab.createFindTab and leoQtFindTab.createFrame.
- Removed all definitions and calls of setBindings.
  All definitions were empty.
  
Rev 6017:
- Removed all definitions of killGui, createRootWindow and recreateRootWindow.
  All definitions were empty and they were never called.
- Removed all definitions of interrupt.  All were do-nothings.
  Removed a single call to .interrupt in 
- Removed do-nothing def of colorizer.kill.  Never called.

Rev 6018:
- Removed do-nothing def of setCanvasBindings.  Never called.
- Removed LeoQTreeWidget.dragEvent.  Never called.
- Removed all definitions of isSameColorState.  It always returned True.
  Removed the single usage of isSameColorState.
- Removed all definitions of killPopupMenu.
  Removed the only call to killPopupMenu in backlink.py.
- Removed all definitions of gui.color.  Never called.
- Removed qtFrame.enable, qtFrame.disable and qtFrame.isEnabled. Never called.
- Removed all calls to getFrame.  They were never called and they always returned None.
- Removed all calls to onActivate.  They were never called and did nothing.

Rev 6019:
* Removed leoQtLog do:nothings, and any calls in Leo's core.
    No calls: configureBorder,configureFont,getFontConfig.
    Commented out calls to setColorFromConfig and setFontFromConfig.
- Removed leoQtLog: saveAllState, restoreAllState, SetWidgetFontFromConfig, forceLogUpdate.
- Removed HighLevelInterface: onActivateLog, disable, enable.
- Removed *all* defs of setFocus.  They are never called!
- Removed all defs of setTabBindings and one call.  All defs were do-nothings.
- Ditto for setMinibufferBindings and createBindings.  All defs were do-nothings.
* Removed tree methods: headWidth,widthInPixels,
    setEditLabelState,setUnselectedLabelState,
    setDisabledHeadlineColors,setEditHeadlineColors,setUnselectedHeadlineColors,
    setFont,getFont.
#@+node:ekr.20131105110107.16974: *7* Simplified creation of event filters in qtGui.py
Added qtGui.setFilter and used it to simplify the code.

The new code is only enabled if the newFilter is set at the start of qtGui.py.
#@+node:ekr.20131105110107.16975: *6* Fixed bugs
#@+node:ekr.20131105110107.16977: *7* Fixed annoying reformat-paragraph bug
The cursor was positioned one character from the end when there was no
newline at the end of the paragraph.  

The fix was to adjust ins in rp_reformat as follows::

    if not tail and ins < len(s): ins += 1

Example::

A file that is both source controlled and customized by the user is
inconvenient for both novices and experts.
#@+node:ekr.20131105110107.16978: *7* Fixed autocompletion crasher
Typed tab while autocompleting: The fix was adding a better guard in
tab_callback.

#@+node:ekr.20131105110107.16979: *7* Fixed bug  869385: Chapters make the nav_qt.py plugin useless
https://bugs.launchpad.net/leo-editor/+bug/869385

The Nav pane and the "prev" and "next" buttons can't position
from one chapter to another.

What I did:
    
- c.goToNext/PrevHistory now just call nodeHistory.goNext/Prev.
  This encapsulates complications properly.
- Added "chapter" keyword arg to cc.selectChapterForPosition.
  When present, this forces a match in the given chapter if possible.
- Rewrote the select and update methods in class nodeHistory.
  Most importantly, update removes duplicates.
  A kludge: update ignores @chapter nodes, which are "selected" behind the scenes.
#@+node:ekr.20131105110107.16980: *7* Fixed bug  879338: Global tables in leoApp.py should describe all languages known
@language rest

# https://bugs.launchpad.net/leo-editor/+bug/879338

Only the clojure language needed entries in the tables.

The following script finds all language keys lacking a mode file::

@language python

    import glob
    files = glob.glob(g.os_path_finalize_join(g.app.loadDir,'..','modes','*.py'))
    files = [g.shortFileName(z)[:-3] for z in files]
    print('\n'.join(sorted(files)))
    keys = sorted(g.app.language_delims_dict.keys())
    for fn in files:
        if fn not in keys:
            print(fn)
            
@language rest
            
The result is::
        
    clojure
    embperl     # A helper mode
    patch       # No comment lines
    phpsection  # A helper mode.
    pseudoplain # No comment lines.
    rtf         # Annotations not exactly a comment.
#@+node:ekr.20131105110107.16981: *7* Fixed bug 1019794: p.copyTreeFromSelfTo, chould deepcopy p.v.u
https://bugs.launchpad.net/leo-editor/+bug/1019794

Added the following to copyTreeFromSelfTo:

    p2.v.u = copy.deepcopy(p.v.u)
#@+node:ekr.20131105110107.16982: *7* Fixed bug 1028986: create relative urls when dragging binary files to Leo
https://bugs.launchpad.net/leo-editor/+bug/1028986

The fix was to createUrlForBinaryFile.
#@+node:ekr.20131105110107.16983: *7* Fixed bug 1046195: character encoding changes when dragging outline between leo files
https://bugs.launchpad.net/leo-editor/+bug/1046195

If I drag part of an outline from one leo file to another and the source
outline contain special characters (ä, ö, ü, ß, ...), then they are
misrepresented in the target file.

The fix was to use g.toUnicode rather than g.u in parseText.
#@+node:ekr.20131105110107.16984: *7* Fixed bug 1046728: quickstart.leo 'auto nodes' example is not working
https://bugs.launchpad.net/leo-editor/+bug/1046728

The @auto example now works.
#@+node:ekr.20131105110107.16985: *7* Fixed bug 1074812: certain .leo file causes "IndexError: list index out of range"
https://bugs.launchpad.net/leo-editor/+bug/1074812

The problem are the marks created by a svn conflict. Leo can not recover
from this kind of error in such a way as to recover data. The workaround is
to report a corrupted file in at.scanText4.
#@+node:ekr.20131105110107.16986: *7* Fixed bug 1099035: Leo yank and kill behaviour not quite the same as emacs
https://bugs.launchpad.net/leo-editor/+bug/1099035

The new kill-to-end-of-line command is supposed to work just
like the emacs kill-line command. That is, it kill from the
insert point to the end of the line. If there are no
non-blank characters to the right of the insert point, it
kills everything up to and including the newline.
#@+node:ekr.20131105110107.16987: *7* Fixed bug 1132821: Leo replaces a soft link with a real file
https://bugs.launchpad.net/leo-editor/+bug/1132821

When opening a file with @auto via a soft link (on Linux) Leo reads in the
file correctly, but after modifying the content leo replaces the link with
an actual file, which means the original file, is not modified and you end
up with two different versions on disk.

os.path.realpath follows symbolic links.

The only safe place for the fix is in at.replaceTargetFileIfDifferent.
#@+node:ekr.20131105110107.16988: *7* Fixed bug 1160660: File-Compare-Leo-Files creates "other file" clones
https://bugs.launchpad.net/leo-editor/+bug/1160660

The primary fix was to createCompareClones.

The created nodes are also a bit clearer about what the changes are.
#@+node:ekr.20131105110107.16989: *7* Fixed bug 1162307: Undoing a headline change does not change focus to the headline
Undoing a headline change does not change focus to the headline
https://bugs.launchpad.net/leo-editor/+bug/1162307
#@+node:ekr.20131105110107.16990: *7* Fixed bug 1175013: leo/plugins/spellpyx.txt is both source controlled and customized
https://bugs.launchpad.net/leo-editor/+bug/1175013

A file that is both source controlled and customized by the user is
inconvenient for both novices and experts.

What I did:
    
- leo\plugins\spellpyx.txt is no longer part of the distribution.
- EnchantClass.__init__ creates an empty leo/plugins/spellpyx.txt if necessary.

Rev 5992: eliminate redraw flash when selecting the Chapters: combo box.
#@+node:ekr.20131105110107.16991: *7* Fixed bug 1182695: the tricky string that leo can not handle
the tricky string that leo can not handle 
https://bugs.launchpad.net/leo-editor/+bug/1182695
#@+node:ekr.20131105110107.16992: *7* Fixed bug 1182864: goto-global-line cmd bug
https://bugs.launchpad.net/leo-editor/+bug/1182864

The fix was to countLinesHelper.
#@+node:ekr.20131105110107.16993: *7* Fixed bug 1185409: importing binary files puts binary content in body editor
https://bugs.launchpad.net/leo-editor/+bug/1185409

Added g.is_binary_external_file and is_binary_string.
Modified ic.createOutline to create @url file:// node.
#@+node:ekr.20131105110107.16994: *7* Fixed bug 1193819: Script buttons cant "go to script" after outline changes
https://bugs.launchpad.net/leo-editor/+bug/1193819

Changed mod_scripting.py and setCommandForButton in qtGui.py.
#@+node:ekr.20131105110107.16995: *7* Fixed bug 1193870 Delete Menu doesn't work in Qt
https://bugs.launchpad.net/leo-editor/+bug/1193870

The fix was to leoQtMenu.destroy.  Previously, it did nothing.
#@+node:ekr.20131105110107.16996: *7* Fixed bug 1208659 leo parsed the wrong line number of html file
https://bugs.launchpad.net/leo-editor/+bug/1208659

The compare failure was the result of using baseScannerClass.startsString.
This is wrong: single quotes do *not* start strings in xml or html.

Added better traces when the comparison fails.

Another change: if the @auto import fails, the file is imported as usual
(with an @ignore node). That is, no @edit node is created. This disables a
dubious feature.

Alas, reportMismatch can't possibly detect tokenizing errors: reportMismatch
only has the imported lists of *lines* for the error report, not the
tokens.
#@+node:ekr.20131105110107.16997: *7* Fixed bug 1208942: Leo holding directory/file handles after file close?
https://bugs.launchpad.net/leo-editor/+bug/1208942
Leo holding directory/file handles after file close?

Open Leo
2. Create a new directory "test"
3. Create a new Leo file, save as "test/test.leo"
4. Create @file node in test.leo, save file.
5. Close test.leo, but keep Leo open (with another .leo open in a different tab)
6. Attempt to delete "test" directory <<-- FAILS, "open in another application"
7. Close Leo completely
8. Delete "test" directory <<-- Succeeds, now that Leo's closed

Actually, only just opening a .leo file without any @file nodes was enough to keep a file open.

The fix was to close theFile in fc.getLeoFile.
#@+node:ekr.20131105110107.16998: *7* Fixed bug 1223383: Garbled text with BOM-marked files
This bug was fixed by the new_read (and new_write) logic
first committed at Rev. 5960.

#@+node:ekr.20131105110107.16999: *8*  report
https://bugs.launchpad.net/leo-editor/+bug/1223383

https://groups.google.com/forum/#!searchin/leo-editor/garbled$20text/leo-editor/tq1HdMFuyVg/fbpK2M6K1tIJ

**Note**: Python does not support utf-16 encoding:
http://www.python.org/dev/peps/pep-0263/

converting utf-16 -> utf-8 AND remove BOM
http://stackoverflow.com/questions/8827419/converting-utf-16-utf-8-and-remove-bom

    # str.decode will get rid of the BOM for you (and deduce the endianness).
    with open(ff_name, 'rb') as source_file:
        with open(target_file_name, 'w+b') as dest_file:
            contents = source_file.read()
            dest_file.write(contents.decode('utf-16').encode('utf-8'))
        
Note:  my favorite way to see BOM bytes is to open the file in xemacs and use <alt-x>hexl-mode.
For example, the following body text::
    
    @first # -*- coding: utf-16 -*-
    @encoding utf-16

    This is a test
    
Will be rendered as::
    
    00000000: fffe 2300 2000 2d00 2a00 2d00 2000 6300  ..#. .-.*.-. .c.
    00000010: 6f00 6400 6900 6e00 6700 3a00 2000 7500  o.d.i.n.g.:. .u.
    00000020: 7400 6600 2d00 3100 3600 2000 2d00 2a00  t.f.-.1.6. .-.*.
    00000030: 2d00 0a23 fffe 4000 2b00 6c00 6500 6f00  -..#..@.+.l.e.o.
    00000040: 2d00 7600 6500 7200 3d00 3500 2d00 7400  -.v.e.r.=.5.-.t.
    00000050: 6800 6900 6e00 2d00 6500 6e00 6300 6f00  h.i.n.-.e.n.c.o.
    00000060: 6400 6900 6e00 6700 3d00 7500 7400 6600  d.i.n.g.=.u.t.f.
    00000070: 2d00 3100 3600 2c00 2e00 0a23 fffe 4000  -.1.6.,....#..@.
    00000080: 2b00 6e00 6f00 6400 6500 3a00 6500 6b00  +.n.o.d.e.:.e.k.
    00000090: 7200 2e00 3200 3000 3100 3300 3000 3900  r...2.0.1.3.0.9.
    000000a0: 3000 3900 3100 3900 3300 3700 3000 3200  0.9.1.9.3.7.0.2.
    000000b0: 2e00 3900 3100 3700 3000 3a00 2000 2a00  ..9.1.7.0.:. .*.
    000000c0: 2000 4000 6600 6900 6c00 6500 2000 6300   .@.f.i.l.e. .c.
    000000d0: 3a00 2f00 7400 6500 7300 7400 2f00 7500  :./.t.e.s.t./.u.
    000000e0: 7400 6600 2d00 3100 3600 2d00 7400 6500  t.f.-.1.6.-.t.e.
    000000f0: 7300 7400 2e00 7400 7800 7400 0a23 4040  s.t...t.x.t..#@@
    00000100: 6669 7273 740a 23ff fe40 0040 0065 006e  first.#..@.@.e.n
    00000110: 0063 006f 0064 0069 006e 0067 0020 0075  .c.o.d.i.n.g. .u
    00000120: 0074 0066 002d 0031 0036 000a 0aff fe54  .t.f.-.1.6.....T
    00000130: 0068 0069 0073 0020 0069 0073 0020 0061  .h.i.s. .i.s. .a
    00000140: 0020 0074 0065 0073 0074 000a 2340 2d6c  . .t.e.s.t..#@-l
    00000150: 656f 0a                                  eo.

From: Chema Cortes <pych3m4@gmail.com>

I have some external files encoded with utf8 and utf16-le with BOM marks.
Leo ignores these marks, and these files become garbled. I cannot fix this
problem with @encoding directives.

Reading the code, I can see the problem when leo opens files as
binary, followed by a unicode encoding. Why not use, instead, the
'codecs.open' for this job, more friendly with BOM-marks?

Testing with system:
Leo 4.11 devel, build 5418, 2012-07-09 09:10:17
Python 2.7.3, qt version 4.8.0
Windows 5, 1, 2600, 2, Service Pack 3
#@+node:ekr.20131105110107.17000: *8*  what I did
Added new_write master switch in leoAtFile.py.
When new_write is True:
- Leo no longer writes a temporary output file.
- at.replaceTargetFileIfDifferent calls the new at.create method to write the target file.
- onl simply writes '\n'.  Conversion to the desired newline happens only in at.create.

Important: writing utf-16 files appears to work, but reading utf-16 files
does not. There are problems decoding utf-16 string in at.readline.
Possibly reading the entire file and converting to unicode might work.

Added new_read master switch in leoAtFile.py.
When new_read is True:
- at.readFileToUnicode converts the entire input file to unicode
  with a single call to g.toUnicode.
- at.getLine uses ivars to retrieve the next line.
  (the theFile and fileName arguments to at.getLine are not used).
  
I am quite happy with the new code. It is considerably
simpler than the old, and handles unicode in a much more
reasonable fashion. In particular:

1. at.readFileToUnicode at last handles the problem of
   discovering encodings properly, without reading files
   twice. It uses a trial encoding (ascii) in order order to
   scan @+leo headers. This is an unexpected simple
   fundamental method. at.readFileToUnicode converts the
   entire file unicode.

2. When new_read is True, at.readLines now is very simple
   because the conversion to unicode has already happened.

3. When new_write is True, the conversion of newlines and
   the conversion to an encoded string each happens exactly
   once, in at.create. This is an important simplification.
#@+node:ekr.20131105110107.17001: *7* Fixed bug 1224586: Reorganizing @chapter nodes breaks chapter menu
https://bugs.launchpad.net/leo-editor/+bug/1224586

Reorganizing @chapter nodes under an outline's @chapters node breaks the
Chapter dropdown navigation box until the outline is reloaded.

Summary:

- Recompute drop-down list every time it is activated.
- Eliminated chapter.hoist ivar.
- Recompute chapter data every time a chapter is selected.

Details:
    
- Eliminate chapter.root ivar.
- recompute root of @chapter node every time it is needed
  using chapter.findChapterNode(chapter.name).
- Eliminated chapter.hoistStack.
  Append one entry to c.hoistStack when selection a non-main chapter.
  Pop one entry when unselecting a non-main chapter.
- Created LeoQComboBox in tt.createControl in order to be able to subclass focusInEvent.
- Created cc.setAllChapterNames, called from LeoQComboBox.focusInEvent.
- Added "create" keyword argument to selectChapterByName.
  This avoid a compile-time choice: it is True except when the user
  types the name from the minibuffer. 
#@+node:ekr.20131105110107.17002: *7* Fixed bug 1226358 File URL's are broken on MacOS
@language rest

https://bugs.launchpad.net/leo-editor/+bug/1226358

First reported at URLs seem to be broken on Mac OS 10.7 Lion
https://groups.google.com/forum/#!searchin/leo-editor/URLs$20seem$20to$20be$20broken/leo-editor/vM8qn66aNi0/4oTIu_UIDUwJ

I think I know the cause of the problem with file URLs on Mac OS 10.7
Lion. In leoGlobals.py, in g.os_startfile(fname), we have::

@language python

    elif sys.platform == 'darwin':
        # From Marc-Antoine Parent.
        try:
            subprocess.call(['open', quoted_fname])
        except OSError:
            pass # There may be a spurious "Interrupted system call"
        except ImportError:
            os.system('open %s' % (quoted_fname))
            
@language rest

The problem is that the quoted file path is being passed to
subprocess.call, instead of the raw file path. I verified this by
experimenting with subprocess.call() in a Python interactive mode
window -- it doesn't want the path to be quoted. I also modified the
os_startfile method to use the unquoted pathname, and verified that
this fixed the problem.
#@+node:ekr.20131105110107.17003: *7* Fixed bug 1226816: Command line "leo xxx.leo" creates file xxx.leo.leo
https://bugs.launchpad.net/leo-editor/+bug/1226816

The fix was to LM.initWrapperLeoFile.
#@+node:ekr.20131105110107.17004: *7* Fixed bug 1229896: nav_qt traceback when node deleted
https://bugs.launchpad.net/leo-editor/+bug/1229896

The fix was to nodeHistory.select at rev 6042
#@+node:ekr.20131105110107.17005: *7* Fixed bug in at.putCodeLine
https://plus.google.com/_/notifications/emlink?emr=02870587547267324596&emid=CJCDv9Ppo7QCFcQbTAodl2MAAA&path=%2F103097156557482112329%2Fposts%2FTL3HQegbK3T&dt=1355829277202&ub=63

\@auto did not write the following .json file properly(!)::

    {
        'name' : "Test app 1"
    }

The last } was missing from the generated file.

The fix was to at.putCodeLine(!!).  It is amazing that this bug could exist.
#@+node:ekr.20131105110107.17006: *7* Fixed bugs 1183855 & 1212332 involving missing select hooks
1183855 (un)select hooks not fired when node selection changed by find command
https://bugs.launchpad.net/leo-editor/+bug/1183855

1212332 Insert doesn't fire unselect / select events
https://bugs.launchpad.net/leo-editor/+bug/1212332


Select and unselect hooks were not being called when a command (including
the find command) left focus in the headline.

The fix was to c.redraw(!) It now calls c.frame.tree.select before calling
c.frame.tree.redraw.
#@+node:ekr.20131105110107.17007: *7* Fixed docs re bug 1159302: Correcting and improving the "Open with" documentation
https://bugs.launchpad.net/leo-editor/+bug/1159302
#@+node:ekr.20131105110107.17008: *7* Investigated bug  971171: re .leo/.leoRecentFiles.txt
If $(HOME)/.leo/.leoRecentFiles.txt does not exist, the only recent file ever is the current file

https://bugs.launchpad.net/leo-editor/+bug/971171

It works for me.  I did make minor changes to rf.writeRecentFileFileHelper.
#@+node:ekr.20131105110107.17009: *7* Investigated bug 1178249: url: file relative path does not work same way
https://bugs.launchpad.net/leo-editor/+bug/1178249

I am going to mark this report as invalid. Please reopen if necessary.

There were recent changes to the @url handling::
- rev 5171 Refactored URL handling, and revised bookmarks plugin to use the new code.
- rev 5208 Fixed g.computeFileUrl so that it converts (Windows only) file:/// to file://

However, file url's seem to be working as expected.

Note that @url file:filename.leo is *not* a valid url, it should be @url file://filename.leo.

Any of the following work in a headline::

    < a relative path >
    file://< a relative path >
    @url < a relative path >
    @url file://< a relative path>

In particular, note this code in g.computeFileUrl::

    path = g.os_path_finalize_join(c.openDirectory,base,path)

#@+node:ekr.20131105110107.17010: *7* Investigated bug 1182694: not display unique in leo and other editor
https://bugs.launchpad.net/leo-editor/+bug/1182694

A string-formatting bug.

https://groups.google.com/forum/?fromgroups#!topic/leo-editor/uy_7dP1uY8w

https://leo-editor.googlegroups.com/attach/4b330006a649027d/SC-2013_5_21_14_12_31.png?view=1&part=5

https://leo-editor.googlegroups.com/attach/4b330006a649027d/SC-2013_5_21_14_12_19.png?view=1&part=4

This is a consequence of an underindented comment.  Like this::

        def test(self):
            string = "abc,\n\
    xyz"

http://leoeditor.com/directives.html#index-7

An underindented line is a line of body text that is indented less then the
starting line of the class, method or function in which it appears. Leo
outlines can not represent such lines exactly: every line in an external
file will have at least the indentation of any unindented line of the
corresponding node in the outline. Leo will issue a warning (not an error)
for underindented Python comment lines. Such lines can not change the
meaning of Python programs.
#@+node:ekr.20131105110107.17011: *7* Investigated bug 1190778: ScriptFile.py not generating correctly (ignores text after @others)
Already fixed.
#@+node:ekr.20131105110107.17012: *7* Investigated spell crash (already fixed)
From: "Ville M. Vainio" <vivainio@gmail.com>
Leo 4.10 deb for Ubuntu Precise available

The open_dict now protects again crashes with try/except.
It's not clear when this new code happened.

When launched from command line, it causes this error that should
probably be hidden with try-except:

/home/ville/.leo/workbook.leo
Traceback (most recent call last):

  File "/usr/lib/pymodules/python2.7/leo/core/leoEditCommands.py",
line 10372, in __init__
    self.d = enchant.DictWithPWL(language,fn)

  File "/usr/lib/python2.7/dist-packages/enchant/__init__.py", line
735, in __init__
    self.pwl = self._broker.request_pwl_dict(pwl)

  File "/usr/lib/python2.7/dist-packages/enchant/__init__.py", line
280, in request_pwl_dict
    self._raise_error(eStr % (pwl,))

  File "/usr/lib/python2.7/dist-packages/enchant/__init__.py", line
219, in _raise_error
    raise eclass(err)

Error: Couldn't open personal wordlist
'/usr/share/pyshared/leo/plugins/spellpyx.txt'

not a valid dictionary file /usr/share/pyshared/leo/plugins/spellpyx.txt
wrote recent file: /home/ville/.leo/.leoRecentFiles.txt
ville@ville-tp:~$ leo

** isPython3: False
Leo 4.10 final, build 5020, 2012-02-26 13:18:08 -0600
Python 2.7.3, qt version 4.8.1
linux2
reading settings in /usr/share/pyshared/leo/config/leoSettings.leo
Using default leo file name:
/home/ville/.leo/workbook.leo
Traceback (most recent call last):

  File "/usr/lib/pymodules/python2.7/leo/core/leoEditCommands.py",
line 10372, in __init__
    self.d = enchant.DictWithPWL(language,fn)

  File "/usr/lib/python2.7/dist-packages/enchant/__init__.py", line
735, in __init__
    self.pwl = self._broker.request_pwl_dict(pwl)

  File "/usr/lib/python2.7/dist-packages/enchant/__init__.py", line
280, in request_pwl_dict
    self._raise_error(eStr % (pwl,))

  File "/usr/lib/python2.7/dist-packages/enchant/__init__.py", line
219, in _raise_error
    raise eclass(err)

Error: Couldn't open personal wordlist
'/usr/share/pyshared/leo/plugins/spellpyx.txt'

not a valid dictionary file /usr/share/pyshared/leo/plugins/spellpyx.txt
wrote recent file: /home/ville/.leo/.leoRecentFiles.txt

#@+node:ekr.20131105110107.17013: *7* Fixed import problem in leoRst.py
https://groups.google.com/forum/#!topic/leo-editor/Mbn3VzY-jr0
#@+node:ekr.20131105110107.17014: *7* Fixed major bug in rst3 command
Rev 6119 fixes a major bug involving the rst3 command.
Previously, rst3-related settings, which start with "rst3_"
where not, in fact, initializing the internal rst3 settings!

I never noticed this because all the documentation in
LeoDocs.leo used to use @ @rst-options parts to specify
settings.

But using @ @rst-options this way is *very* bad style: it
hides any variations in settings in the blah-blah-blah of
specifying defaults.

Now, the defaults are given in settings in the "Startup"
node. This is correct: defaults are given *one*, in an
out-of-the way place.

BTW, now that almost all @ @rst-options parts are gone,
there is even less reason for the @file nodes in
LeoDocs.leo. I'm going to remove them, thereby removing all
the not-really-needed .txt files they generate. Naturally,
this makes LeoDocs.leo bigger, but I think the clarity of
expression is worthwhile. LeoDocs.leo really should be a
model of good practice.
#@+node:ekr.20131105110107.17015: *7* Fixed Alt-Gr keys
At rev 6107.
    
- Restored @bool ignore_unbound_non_ascii_keys setting to leoSettings.leo.
- Made self-insert-char an official command, but it will do nothing if
  executed from the minibuffer.
- ec.selfInsertCommand now calls g.app.gui.insertKeyEvent for non-plain keys.
- qtGui.insertKeyEvent uses QKeyEvent.text() to insert Alt-Ctrl keys as follows:
  qw.insertPlainText(qevent.text()).
  Viktor verifies that this strategy works.
- Added event ivar (a QKeyEvent) to leoKeyEvent class.
- Added event positional arg to leoGui.create_key_event.
#@+node:ekr.20131105110107.17016: *7* Alt-0 (vr-toggle) now puts focus in the body pane
#@+node:ekr.20131105110107.17017: *7* Fixed crasher in k.auto_completer_state_hander
Happened when user typed tab.
#@+node:ekr.20131105110107.17018: *7* Fixed problems with c.save commands in the leoBridge
@language rest

To emphasize what is said below in the checkin log, there is a systemic
problem with the leoBridge module: it uses a nullGui in which all dialogs
are do-nothings. This will affect all commands, such as c.save, etc., that
may (or may not) ask the user for input.

The workaround I used for c.save, c.saveAs and c.saveTo was to add a
"fileName" keyword arg, so that code using a commander returned by
leoBridge can just demand that a certain fileName be used. This is as far
as I am willing to go for the 4.11 release.

The following test, call it leo-bridge-test.py, passes::

@language python

# Do *not* execute this from inside Leo!
if __name__ == '__main__':
    import os
    import sys
    sys.path.insert(0,'c:/leo.repo/trunk/leo')
    import leo.core.leoBridge as leoBridge
    print(leoBridge)
    cc = leoBridge.controller(gui='nullGui',verbose=False)
    g = cc.globals()
    print(g)
    path = 'c:/Users/edreamleo/does-not-exist.leo'
    assert not os.path.exists(path),path
    assert not g.os_path_exists(path),path
    c = cc.openLeoFile(path)
    root = c.rootPosition()
    assert root
    root.h = 'root'
    p = root.insertAsLastChild()
    p.h = 'A'
    assert p and p.h
    if 0:
        for p in c.all_positions():
            print(p.h)
    path = 'c:/Test/leo-bridge-test.leo'
    c.save(fileName=path)
    assert os.path.exists(path),path
    assert g.os_path_exists(path),path
    os.remove(path)
    assert not os.path.exists(path),path
    assert not g.os_path_exists(path),path
    c.saveAs(fileName=path)
    assert os.path.exists(path),path
    assert g.os_path_exists(path),path
    c.saveTo(fileName=path)
    assert os.path.exists(path),path
    assert g.os_path_exists(path),path
#@+node:ekr.20131105110107.17019: *7* Fixed bug 1168689 re ipython
1168689 outdated documentation about ipython
https://bugs.launchpad.net/leo-editor/+bug/1168689

Changed runWithIpythonKernel, LM.initApp, app.finishQuit.
Added commanders property.

Injects only _leo into the IPython namespace
_leo.c is a property
The getter returns the single element of _leo.commanders_list
or a commander set previously by the setter.
    
_leo.commanders is a read-only property returning _leo.commanders_list
after first doing an update.

The highlights of the changes:

1. leo.core.leoIPython.py now contains *all* of Leo's IPython-related code.
   The setup code comes mainly from leo.plugins.internal_ipkernel.py.

2. internal_ipkernel.py still exists (it will go away soon), but it has has
   been completely disabled as follows::

    if 0:
        @others

3. When the --ipython command-line argument is in effect, g.app.ipk is a
   *singleton* IPython shell, shared by any and all IPython consoles.

4. The startup code injects only a single object, _leo, into the IPython
   namespace. This is an instance of the bulked-up LeoNameSpace class. This
   interface class now contains features that make it easier to deal with
   multiple open Leo commanders.

- _leo.g is set to leoGlobals only once. Not exactly correct, perhaps, but
  nobody will notice.

- _leo.commanders is a (read-only) property returning the list of open
  commanders. This list is always kept up-to-date: it scans
  g.app.windowList before returning its result.

- _leo.c is a (read/write) property returning g.app.windowList[0].c if the
  windowList has only one element, or the "designated commander" if it
  exists. Otherwise, it returns None. In that case, the expectation is that
  the user will "designate" a commander with: _leo.c = aCommander.

- _leo.find_c(path) returns the commander c such that c.fileName() or
  g.shortFileName(c) matches path.

5. Perhaps most importantly, that's *all* there is. In particular, Ville's
   magic functions and LeoWorkbook class are gone.

Imo, the deleted code might better exist as IPython startup code, but I
could be wrong. Furthermore, Leo's p.h and p.b properties are new since
Ville first created the code, and so this kind of support code is less
urgently needed.

If there is a great demand to restore these features, it can always be done
later. For now, though, I wanted to do the simplest thing that could
possibly work.
#@+node:ekr.20131105110107.17020: *7* Fixed several window-sizing bugs
Bug: Window size was not set when --minimized is in effect.

LM.scanOptions now sets LM.options['windowSize'] to (h,w), both ints.

getWindowPositionAttributes now checks LM.options.get('windowSize')

startVnodes now properly sets top geometry when --minimized is in effect.
#@+node:ekr.20131105110107.17021: *7* Fixed bug 1243847: unicode error when saving @shadow nodes
https://bugs.launchpad.net/leo-editor/+bug/1243847

The fix: at.replaceFileWithString now *always* calls g.toEncodedString.
#@+node:ekr.20131105110107.17022: *7* Fixed bug #1243855: @auto-rst doesn't save text
https://bugs.launchpad.net/leo-editor/+bug/1243855

The fix was to not make assumptions about type in compareFiles and create.

#@+node:ekr.20131105110107.17023: *7* --minimized now disables splash screen

#@+node:ekr.20131105110107.17024: *7* Fixed bug: 1168689 outdated documentation about ipython
https://bugs.launchpad.net/leo-editor/+bug/1168689

You must use "python launchLeo.py --ipython" instead of the ipython.py plugin

The old ipython.py plugin is deprecated: it exists in leo/plugins/obsolete.

The docs of ipython and leo should be updated

https://groups.google.com/forum/?fromgroups#!topic/leo-editor/n5IVGe6fh2k
#@+node:ekr.20131105110107.17025: *7* Fixed bug 1180186: debian install not documented well enough
https://bugs.launchpad.net/leo-editor/+bug/1180186
#@+node:ekr.20131105110107.17026: *6* New commands, features & settings
#@+node:ekr.20131105110107.17027: *7* Added @bool enable-tree-dragging to leoSettings.leo
#@+node:ekr.20131105110107.17028: *7* Added help text to the find panel
Changed DynamicWindow.createFindTab.

Added a help line at the bottom.
#@+node:ekr.20131105110107.17029: *7* Added yes-to-all button when prompting for dangerous writes
importing a medium sized java project ~ 400 files
https://groups.google.com/forum/#!searchin/leo-editor/importing$20a$20medium$20sized$20java$20project/leo-editor/PiuFXtAHG0s/o6vwu19PsMEJ

For example, when warning about existing files.

Fixed at rev 5935. What I did:
    
1. Added yesToAllMessage keyword arg to all runAskYesNoCancelDialog methods.

2. **only** at.writeAll manages at.canCancelFlag, at.cancelFlag and at.yesToAll.

3. Path changed logic in at.writeAllHelper now calls at.promptForDangerousWrite.

4. at.promptForDangerousWrite sets cancelFlag and yesToAll *only* if canCancelFlag is True.
   This ensures that these flags are not changed outside the code managed by at.writeAll.
#@+node:ekr.20131105110107.17030: *7* Bound Alt-Ctrl-M for macro-call-last
Bound Alt-Ctrl-M for macro-call-last (c-x e in emacs).
#@+node:ekr.20131105110107.17031: *7* Copy cheatsheet.leo when creating workbook
Added c.openCheatSheet.
Added LM.openEmptyWorkBook.
Added open-cheat-sheet-leo command.
Added "Open CheatSheet.leo" menu item.
Changed LM.doPostPluginsInit.
#@+node:ekr.20131105110107.17032: *7* Created insert-node-before command & p.insertBefore
Added c.insertHeadlineBefore and unit tests for same.
#@+node:ekr.20131105110107.17033: *7* Revised help-for commands
help-for-dynamic-abbreviations
help-for-abbreviations
help-for-find-commands
#@+node:ekr.20131105110107.17034: *6* New plugins
markup_inline.py,richtext.py, rss.py.
#@+node:ekr.20131105110107.17041: *5* final release
@language rest
#@+node:ekr.20131105110107.17042: *6* Improved reformat-paragraph
1. The following are always single-line paragraphs::
    
    @anything
    '''         # on a line all by itself. 
    """         # on a line all by itself.

2. The following always start a paragraph, terminating the previous
   paragraph::

    - Whatever
    1. Whatever
    22) Whatever
    a. Whatever # single character only.
    Z. Whatever # single character only.

3. The leading indentation in lists will be at least the the number of
   characters preceding "Whatever".

Not yet: support for non-breaking space (unicode code point U+00A0).

What I did:
    
- Rewrote c.findBoundParagraph & added helpers:
    - c.starts/endParagraph
    - c.singleLineParagraph.
- Add space adjustments to rp_wrap_all_lines.
#@+node:ekr.20131105110107.17043: *6* Fixed bug: add/remove comments now handle ambiguous @language directives
- g.set_language doesn't handle ambiguous @language directives!!
- Eliminated scanToCursor logic
- Added c.hasAmbiguousLanguage and c.getLanguageAtCursor helpers.
- Changed c.insertComments and c.removeComments.
#@+node:ekr.20131105110107.17044: *6* Fixed Haskell coloring problem
https://bugs.launchpad.net/leo-editor/+bug/1247672

In Haskell it is common to end certain functions with the single quote character. i.e.

sum = foldl' (+) 0

foldl' is a variety of the function foldl with modified characteristics. In
this case, it is strict.

The haskell syntax highlighter on Leo treats that single quote as the
beginning of a string.

As a note that may matter -- I don't know Leo so below may be non-important
I see this:

def haskell_rule4(colorer, s, i):
    return colorer.match_seq(s, i, kind="literal1", seq="' '",
        at_line_start=False, at_whitespace_end=False, at_word_start=False, delegate="")

In the leo/modes/haskell.py file.

Haskell does have strings that are surrounded by single quotes. Single
quotes are either (somewhat) regular characters or surround a single (
non-string ) character.

Gatesphere on the #Leo was helpful today and asked that I include the link
to this jedit xml syntax def for haskell:

http://jedit.git.sourceforge.net/git/gitweb.cgi?p=jedit/jEdit.bak;a=blob_plain;f=modes/haskell.xml;hb=HEAD

Feel free to contact me if you need additional info.

====



Oh -- I should add that it is not uncommon to end function names with
multiple single quotes as well.

i.e.

sqrt
sqrt'
sqrt''
sqrt'''

for 4 different methods of determining square root.

The fix was a hack to match_keywords, and an alteration to rule28.
#@+node:ekr.20131105110107.17045: *6* Fixed text in Find Panel
Changed defaults in leoSettings.leo from 14px to 12px.
#@+node:ekr.20131105110107.17046: *6* Investigated install problem
@language rest

https://groups.google.com/forum/#!topic/leo-editor/qglPWiqnyog

Using the LeoSetup-4.11-b1.exe installer with Python27 works fine.

However using Python33 it's not so happy. Selecting Start Menu>Leo does not launch Leo, I just see a flash of the splashscreen and it dies.
Same result using the desktop shortcut icon.

The target properties of the desktop icon are:
C:\Python33\pythonw.exe "C:\Program Files (x86)\Leo-4.11-b1\launchLeo.py"

I can run Leo from a console though. Here is the log:
C:\Program Files (x86)\Leo-4.11-b1>launchleo.py

** isPython3: True
Leo 4.11b1, build 5020, 2012-02-26 13:18:08 -0600
Python 3.3.3, qt version 4.8.5
Windows 6, 1, 7601, 2, Service Pack 1
...

Running from a command shell works fine with no errors.

===== EKR

    Using the LeoSetup-4.11-b1.exe installer with Python27 works fine.

    However using Python33 it's not so happy. Selecting Start Menu>Leo does not launch Leo, I just see a flash of the splashscreen and it dies.
    Same result using the desktop shortcut icon.


Thanks for this report.

> The target properties of the desktop icon are:
> C:\Python33\pythonw.exe "C:\Program Files (x86)\Leo-4.11-b1\launchLeo.py"

These look correct. And they work for me after a clean install. Note: the
initial load of Leo can take quite awhile: all .py files must be compiled.

For trouble shooting, please do the following:

- Change pythonw.exe to python.exe
- Add an -i option to the target properties.

The effect of this will be to run Leo in a console window, holding the
console window open.

This should tell you exactly what is happening.

> Selecting Start Menu>Leo does not launch Leo, I just see a flash of the
  splashscreen and it dies.

I did find an issue related to the start menu. If I chose "All Programs"
then Leo, there was an old copy of the leo shortcut lying around that
didn't work. And even after deleting the Leo install, there was an old,
out-out-date Leo folder accessible from the start menu. And furthermore,
there were differences (from the start menu) between opening Leo and
opening Leo for all users.

This is surely confusing, but it may be the result of old installs.

My suggestion:

1. Uninstall b1.
2. Delete everything related to Leo from your start menu, both accessible
   via "search programs and files" and the "all programs list". Make sure
   to delete everything for all users as well as yourself.
3. Reinstall b1.
4. Test. If problems remain, make the changes above (-i, python.exe), and
   report the results.
#@+node:ekr.20131220065609.16614: *3* 4.11.1 Release notes
Leo 4.11.1 final                                December 20, 2013

Leo 4.11.1 is now available at:
http://sourceforge.net/projects/leo/files/Leo/

This version makes Leo easier to learn.

Leo is a PIM, an IDE and an outliner.
Video tutorials: http://leoeditor.com/screencasts.html
Text tutorials: http://leoeditor.com/tutorial.html

The highlights of Leo 4.11.1:
-----------------------------

- New video tutorials: http://leoeditor.com/screencasts.html
- Added join-leo-irc command: a good way to get help.
- The Find Tab is easier to understand and use.
- Simplified and reorganized global settings in leoSetting.leo.
- Reorganized menus, including a new Settings menu.
- Added @data qt-gui-user-style-sheet
- More untuitive bindings for Return, Insert and Delete keys.
- Per-node expansions of cloned nodes.

Links:
------
Leo:       http://leoeditor.com
Docs:      http://leoeditor.com/leo_toc.html
Tutorials: http://leoeditor.com/tutorial.html
Videos:    http://leoeditor.com/screencasts.html
Forum:     http://groups.google.com/group/leo-editor
Download:  http://sourceforge.net/projects/leo/files/
Bzr:       http://code.launchpad.net/leo-editor/
Quotes:    http://leoeditor.com/testimonials.html
#@+node:ekr.20131220065609.16634: *4* Leo is now easier to use
#@+node:ekr.20131221065129.16525: *5* Added more intuitive key bindings
- When editing a headline, the Return key leaves focus in the tree.
- When focus is in the outline pane, the Insert key inserts a node.
- When focus is in the outline pane, the Delete and BackSpace keys deletes node.
#@+node:ekr.20131220065609.16619: *5* Improved the Find tab
#@+node:ekr.20131220065609.16638: *5* Improved & reorganized menus
Help menu:
- Contains only help-related items.
- Contains more items that link to Leo's web site.

Settings menu (a new menu):
- Open Global Settings opens leoSettings.leo.
- Open Personal Settings opens myLeoSettings.leo.
- Open Local settings selects the @settings node in the local .leo file, if it exists.

Plugins menu:
- Changed plugins_menu.py plugin so it honors items in @menu Plugins.

Cmds menu:
- Improved Settings submenu and added & Help submenu.
- Open Python Shell (was in Windows menu) now part of Cmds:Debug menu.

File menu:
- Now contains items that open various .leo files.
#@+node:ekr.20131220065609.16628: *5* Simplified leoSettings.leo
Eliminated clones from this file: all settings are defined in exactly one
place.
#@+node:ekr.20131220065609.16621: *5* Added join-leo-irc command
#@+node:ekr.20131220065609.17422: *5* Added @data qt-gui-user-style-sheet
The entries here override the entries in @data qt-gui-plugin-style-sheet

This is a *major* improvement: you don't have to copy/paste @data
qt-gui-plugin-style-sheet. Just put your particular overrides in
@data qt-gui-user-style-sheet. At long last, you can see just what you
changed.
#@+node:ekr.20131221065129.16526: *5* Improved the print-bindigs command
All menu shortcuts are shown as bound to the menu-shortcut command.
#@+node:ekr.20131222112420.16374: *5* Added per-node expansions of cloned nodes
This should be more intuitive for newcomers.
#@+node:ekr.20131220065609.16635: *4* Fixed bugs
#@+node:ekr.20131220065609.16622: *5* Allow comments after @data setting-name
Changed ParserBaseClass.parseHeadline so it ignores everything after @data
name.
#@+node:ekr.20131220065609.16620: *5* Got focus border working again
Changed add_border and remove_border in qtGui.py
#@+node:ekr.20131220065609.16623: *5* Allow comment lines in @item nodes
The first line is significant.  All others are comments.

The fix was to ParserBaseClass.doItems.
#@+node:ekr.20131220065609.16624: *5* Improved debugging capabilities
Disambiguated various debug switches.

The master debug switches are now::
    
    g.app.debug_app
    g.app.debug_widgets

Added leoQtEventFilter.traceWidget.

Added toggle-debug button in my copy of leoPy.leo.
#@+node:ekr.20131220065609.16625: *5* Improved tab pane
@language rest

What I did:
    
- Created LeoBaseTabWidget, containing most of the code of LeoTabbedTopLevel.
- LeoTabbedTopLevel derives from this new class.
    
- leoQtLog.__init__ now calls tw.setMovable(True).
  This allows Log pane tabs to be rearranged.
  
- Changed dw.createTabWidget. The changes have as yet no effect:

    def createTabWidget (self,parent,name,hPolicy=None,vPolicy=None):
    
        # w = LeoBaseTabWidget(parent)
        w = QtGui.QTabWidget(parent)
        tb = w.tabBar()
        # tb.setTabsClosable(True)
        self.setSizePolicy(w,kind1=hPolicy,kind2=vPolicy)
        self.setName(w,name)
        return w
#@+node:ekr.20131220065609.16626: *5* Fixed greedy checkbox bug
@language rest

When the Find pane is active, Alt-x toggles the regex check box, etc.

There is no obvious way to disable the widget when the pane is deactivated.
It must be possible, but perhaps it is not worth it.

The solution was simply to remove the keyboard hints from the Find pane!

#@+node:ekr.20131220065609.16631: *5* Fixed bug re Ctrl-A in minibuffer
It used to select the minibuffer label, which messed up following logic.
#@+node:ekr.20131220065609.16633: *5* Changed frame.endEditLabelCommand
It now always stays in the tree pane when you hit return to
end editing.

This will be more natural to newbies, and allows plain arrow
keys to traverse the tree more easily.

Also, c.treeEditFocusHelper no longer exists, and the @bool
stayInTreeAfterEditHeadline setting no longer exists.
#@+node:ekr.20131220065609.16616: *5* fixed documentation of ctrl-tab
http://mail.google.com/mail/u/0/#inbox/1423c5445471eeb2

The Command reference was wrong.
#@+node:ekr.20131220065609.16636: *4* Settings
#@+node:ekr.20131220065609.16615: *5* Added @bool force_execute_entire_body
@language rest

Added support for @bool force_execute_entire_body, default False.
When True, the execute_script command forces whole text to be the text.

The c.forceExecuteEntireBody ivar can be toggled by scripts.
#@+node:ekr.20131220065609.16617: *5* Added support for @outline-data
- Restored c.config.getData.
- Added gcm.getOutlineData, c.config.getOutlineData.
- Added parser.doOutlineData and getOutlineDataHelper.
#@+node:ekr.20131220065609.16618: *5* Added support for @outline-data tree-abbreviations
@language rest

https://groups.google.com/forum/#!topic/leo-editor/OSe0_D5tmJQ

What I did:
    
- Added (complex) code to support scanning after tree substitutions.
- Added support for @data tree-abbreviations.
    - The body contains a list of the abbreviation names.
    - The children should contain nodes matching each abbreviation name.
        The children of *those* nodes are pasted as the last children
        of the present node when the tree abbreviation fires.
- Added ParserBaseClass.doTreeAbbreviationData, called from PBC.doData.
- Added abbrevClass.init_tree_abbrev and helpers.
- Refactored and changed expandAbbrev: added ac.expand_text and ac.expand_tree.
- Added some flags to c.pasteOutline and c.promote,
  These flags disable unwanted actions when expanding tree abbreviations.

@language python
#@+node:ekr.20131220065609.16637: *4* Plugins
- The new nodewatch.py plugin creates a scriptable jump-list of nodes with a UI pane.
  It is an alternative to clones/bookmarks/backlinks/UNLs.
  
- Fixed bug in viewrendered.py: '@string view-rendered-default-kind' is now
  functional. Setting it to 'md' makes vr default to trying markdown
  rendering without the need for the ugly '@md' in the headline. vr is
  still smart enough to default to rst for Leo's various help-for commands,
  as well as anything that uses c.putHelpFor.
  
- The booksmarks.py plugin (rev 6420) now supports cross-file bookmarks.
  
- Improved quickfind.py plugin (rev 6390).
  
- Improved quickmove.py plugin (rev 6446).

- Improved todo.py plugin (rev 6433).

- The scripting.py now creates commands from @rclick nodes, but only if
  @bool scripting-at-rclick-nodes is True.
#@+node:ekr.20131220065609.16629: *5* Added web-oriented bookmarks to mod_http plugin
Can also be used for bookmarking directly from the browser to Leo.  To
do this, add a bookmark to the browser with the following URL / Location:

    javascript:w=window;if(w.content){w=w.content}; d=w.document; w.open('http://localhost:8130/_/add/bkmk/?&name=' + escape(d.title) + '&selection=' + escape(window.getSelection()) + '&url=' + escape(w.location.href),%22_blank%22,%22toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=800, height=300, status=no%22);void(0)

and edit the port (8130 in the example above) to match the port you're using
for mod_http.

Bookmarks are created as the first node in the outline which has been opened longest.
You can set the ``@string`` ``http_bookmark_unl`` to specify an alternative location,
e.g.::

    @string http_bookmark_unl = /home/tbrown/.bookmarks.leo#@bookmarks-->Incoming

to place them in the `Incoming` node in the `@bookmarks` node in the `.bookmarks.leo` outline.

The headline is preceeded with '@url ' *unless* the ``bookmarks`` plugin is loaded.
If the ``bookmarks`` plugin is loaded the bookmark will have to be moved to a ``@bookmarks`` tree to be useful.

The browser may or may not be able to close the bookmark form window for you, depending on settings - set ``dom.allow_scripts_to_close_windows`` to true
in ``about:config`` in Firefox.
#@+node:ekr.20141113102829.6: *3* 5.0 Plays well with others
* Better compatibility with vim, Emacs, pylint and PyQt:
    - Optional native emulation of vim commands.
    - Full support for Emacs org-mode outlines.
    - Better support for pylint.
    - Support for both PyQt4 and PyQt5.
* Better handling of nodes containing large text:
    - Idle time syntax coloring eliminates delay.
    - Optional delayed loading of large text.
* Power features:
    - Leo available via github repository.
    - File name completion.
    - Cloned nodes expand and contract independently.
    - @data nodes can be composed from descendant nodes.
    - No need to change Leo's main style sheet:
      it can be customized with @color and @font settings.
    - @persistence nodes save data in @auto trees.
    - A pluggable architecture for @auto nodes.
    - The style-reload command changes Leo's appearance instantly.
* Important new plugins for tagging, display and node evaluation.
#@+node:ekr.20141120113801.6: *4* Leo 5.0-final release notes
Leo 5.0 final                       November 24, 2014

Leo 5.0-final is now available at:
http://sourceforge.net/projects/leo/files/Leo/

This release fixes several installation issues
and updates installation instructions for Linux/Ubuntu.

Leo is a PIM, an IDE and an outliner.
Video tutorials: http://leoeditor.com/screencasts.html
Text tutorials: http://leoeditor.com/tutorial.html

The highlights of Leo 5.0
--------------------------

* Better compatibility with vim, Emacs, pylint and PyQt:
    - Optional native emulation of vim commands.
    - Full support for Emacs org-mode outlines.
    - Full support for Vim .otl outlines.
    - Better support for pylint.
    - Support for both PyQt4 and PyQt5.
* Smoother installation:
    - Support for brew install leo on MacOS.
    - 'python setup.py install' now works.
    - pip install leo now works.
    - Leo is now a debian package.
* Better handling of nodes containing large text:
    - Idle time syntax coloring eliminates delay.
    - Optional delayed loading of large text.
* Power features:
    - Command history for minibuffer commands.
    - Leo available via github repository.
    - File name completion.
    - Cloned nodes expand and contract independently.
    - @data nodes can be composed from descendant nodes.
    - No need to change Leo's main style sheet:
      it can be customized with @color and @font settings.
    - @persistence nodes save data in @auto trees.
    - A pluggable architecture for @auto nodes.
    - The style-reload command changes Leo's appearance instantly.
* Important new plugins for tagging, display and node evaluation.
* For beginners:
    - Leo's default workbook files contains Leo's quickstart guide.
* Hundreds of new/improved features and bug fixes.

Links:
------
Leo:       http://leoeditor.com
Docs:      http://leoeditor.com/leo_toc.html
Tutorials: http://leoeditor.com/tutorial.html
Videos:    http://leoeditor.com/screencasts.html
Forum:     http://groups.google.com/group/leo-editor
Download:  http://sourceforge.net/projects/leo/files/
Github:    https://github.com/leo-editor/leo-editor
Quotes:    http://leoeditor.com/testimonials.html
#@+node:ekr.20141120113801.7: *5* Highlights
#@+node:ekr.20141120113801.8: *6* Better integration with Vim, Emacs & pylint
#@+node:ekr.20141120113801.9: *7* vim mode
See: http://leoeditor.com/vimBindings.html#using-leo-s-native-vim-mode

do_visual_mode will extend the selection if visual_line_mode is True.

Affected methods: vc.vim_V and vc>do_visual_mode.

It would be good if LeoQTextEditWidget.setSelectionRangeHelper could handle
insert points in the middle of a text selection, but at present it can't.
#@+node:ekr.20141120113801.10: *7* Better support for pylint
Created g.run_pylint so pylint can run unmodified. This runs pylint (with
optional Sherlock tracing) in a separate process, thereby allowing Leo to
run pylint unchanged.

What I did:

1. pylint-leo.py: run now runs the following command in a separate process::

    <python> -c "import leo.core.leoGlobals as g; g.run_pylint(<args>)"
    
2. g.run_pylint uses Sherlock tracing if requested.

    
#@+node:ekr.20141120113801.11: *7* Full support for org-mode (.org) and vimoutline (.otl) files
Note: persistence applies to @auto-vimoutline-mode and @auto-org-mode

- Supported @auto-org-mode and @auto-vimoutline-mode
- Created importers and writers for .org and .otl files.
#@+node:ekr.20141120113801.12: *6* Power features
#@+node:ekr.20141120113801.13: *7* Added command history
After Alt-x puts you in the minibuffer, you can now use UpArrow and
DownArrow keys to cycle through previous "complex" commands, that is,
commands entered via Alt-x<command-name><return>.

For example, Alt-x UpArrow is roughly equivalent to Ctrl-p.

This completes one of the top four wishlist items at:
https://github.com/leo-editor/leo-editor/issues/93
#@+node:ekr.20141120113801.14: *7* @data nodes can now be composed from a tree of nodes
How did we ever live without this?

@data nodes, like @data qt-gui-plugin-style-sheet may now be composed of
the body text of the @data node itself, concatenated to the body text of
all its descendants, in outline order.

For example, @data qt-gui-plugin-style-sheet node consists of some general
comments, with descendant nodes for the body pane, tree pane, etc. etc.
There is no limit of nesting: the Plugins node has a child for each plugin
that uses style sheets.

Not only does this new arrangement make it far easier to find the style
sheet of interest, it makes debugging style sheets easier. Typically, an
error in any part of the style sheet invalidates the whole style sheet.
With the new organization, one can swap nodes into or out of the @data node
to find the invalid node or nodes.

Two fine points about the concatenation of data:

1. Descendant nodes whose headlines start with '@' do not become part of
   the data. At present, no @data nodes have descendants, but this
   convention does something reasonable if nodes like @int or @string were
   descendants of an @data node.

2. The @data parser adds a newline to every "fragment" if necessary. This
   doesn't seem to matter for style sheets, but it could matter for other
   kinds of @data data.
#@+node:ekr.20141120113801.15: *7* Clones expand and contract independently
https://groups.google.com/forum/#!topic/leo-editor/Wd0NtBLEZZk

Leo now stores "ephemeral" or position-related data **in vnodes*. This is a
completely new idea in Leo's history!
#@+node:ekr.20141120113801.16: *7* File name completion
The :r, :tabnew, insert-file-name and  file-open-by-name commands now have file-name completion

I bind Ctrl-O to file-open-by-name to bypass the Windows open file dialog.
#@+node:ekr.20141120113801.17: *7* Better support for nodes containing large text
The user can lose text if they start typing before the body text completely loads!

- Added c.max_pre_loaded_body_chars = c.config.getInt('max-pre-loaded-body-chars')

- The "dummy" body text now contains a warning to wait until the text fully loads.
#@+node:ekr.20141120113801.18: *7* Leo now colors text at idle time
Leo now uses an all-Python replacement for the QSyntaxHighlighter class.

This fixes git bug 28: https://github.com/leo-editor/leo-editor/issues/28
Leo hangs when a node with too large body is selected

To see the effect of the new code:

1  Create a node with *lots* of colored text.
2. Move the cursor to the last line of the text.
3. Select another node, and then move back to the "big" node.

You should see the end of the text all in black at first, and then become
colored later.

In the meantime, Leo is responsive to all commands, mouse clicks, etc.
#@+node:ekr.20141120113801.205: *7* Fully parameterized style sheet
Almost all settings in @data qt-gui-plugin-style-sheet in leoSettings.leo
are now defined in terms of @values. Traditional Leo settings nodes
(@strings, @color, @font, etc.) define these @values.

Most users, and certainly all newbies, will never have to touch, or even
look at, @data qt-gui-plugin-style-sheet. This is a really good thing,
because the slightest syntax error silently messes up everything that
follows.

Notes:

1. There is now a node called "Basic Fonts (change these first)"
   This node contains the basic font definitions. Changing only the
   settings in this tree (in myLeoSettings.leo, of course) should be enough
   to get Leo looking pretty much as it was.

2. Don't even *think* about changing @data qt-gui-plugin-style-sheet.
   Really, the whole point of this exercise is to be able to change all
   aspects of Leo's appearance without touching this stylesheet. As Terry
   points out, there will always be a place for @data qt-gui-user-style-sheet

3. In an emergency, there is at present a node called "OLD
   qt-gui-plugin-style-sheet" that you could use to revert to the old
   settings. Just rename it and copy it to your myLeoSettings.leo.

4. The new settings scheme will moot the need for leo10pt.leo, leo12pt.leo
   and all the rest. Instead, all font sizes are now defined in terms of
   three intermediate settings: @string font-size, @string medium-font-size
   and @string small-font-size. Changing just these three settings will
   suffice to change *all* the font sizes used in Leo.

5. When things don't look right, I execute this script::

    c.styleSheetManager.print_style_sheet()

This prints the complete stylesheet to the console. What I mainly look for
are lines like::

    background-color: @some-setting

An @value as the value of a setting indicates that no substitution took
place, that is, that there is no node::

    @string some-setting = aValue

Any user that wants to roll their own @data node will want to be aware of
this technique.

5. The @data qt-gui-**user**-style-sheet setting is deprecated. Indeed,
   @data qt-gui-**plugin**-style-sheet now takes care to define almost
   everything that any user would want to define. myLeoSettings.leo should
   contain overrides of only the @color and @string nodes in
   leoSettings.leo.
#@+node:ekr.20141120113801.20: *7* The style-reload command changes Leo's appearance instantly
The style-reload reloads all visual settings.

Suppose you have the following @button node:

    @button reload-styles
    c.k.simulateCommand('style-reload')

And suppose you have the following setting in your local @setting tree::

    @string font-size = 12pt

Change the setting to 10pt (or 14pt), click the button, and see what happens :-)

The present code doesn't deal with themes, although there is some commented
out that hints about what might be done.
#@+node:ekr.20141120113801.21: *7* A plugable architecture for @auto nodes
The leo/plugins/importers folders now contains importer plugins.

The leo/plugins/writers folders now contain writer plugins.

Both importer and writer plugins can defined new kinds of @auto nodes.

Importers and writers can register either @auto-names or file extensions.
For example, @auto x.xyzzy will use both the importer and the writer for
the .xyzzy extension, that is, importers/test.py and writers/test.py. So,
for *unique* extensions, there is no need to use a separate @auto name, you
can just use @auto.
#@+node:ekr.20141120113801.22: *6* Leo's default workbook contains Leo's quickstart guide
The default workbook contains both the cheat sheet and an example from the
rst3 tutorial.

#@+node:ekr.20141120113801.23: *5* Bugs fixed
Over 70 bugs have been fixed.
#@+node:ekr.20141124033239.2: *6* Bugs fixed in 5.0rc1
#@+node:ekr.20141124033239.3: *7* Fixed scrolling problem when expanding abbreviations
When editing at the end of a large block of text where all of the body text
does not fit in the edit window, if I enter an abbreviation, the scroll
position resets to the top of the page even though the text cursor position
remains with the replaced text.
#@+node:ekr.20141120113801.24: *6* Bugs fixed in 5.0b2
#@+node:ekr.20141120113801.25: *7* Fixed bug  38: autocompleter gives a strange traceback
https://github.com/leo-editor/leo-editor/issues/38

Fixed by Terry Brown at e8c0e27.
#@+node:ekr.20141120113801.26: *7* Fixed bug  78?: find-next target not always scrolled into view
https://github.com/leo-editor/leo-editor/issues/78

It's hard to know whether the change did anything.  It does not appear to have hurt.

find.showSuccess now sets p.v.scrollBarSpot = None, which prevents v.restoreCursorAndScroll
from altering the vertical scrollbars.
#@+node:ekr.20141120113801.27: *7* Fixed bug  80: Find-previous fails at last node with mouse click
https://github.com/leo-editor/leo-editor/issues/80

Fixed at 614817a, October 26, 2014.
#@+node:ekr.20141120113801.28: *7* Fixed bug 101: IPython issues
https://github.com/leo-editor/leo-editor/issues/101

https://bugs.launchpad.net/leo-editor/+bug/1228099
Cancelling save of dirty untitled commander doesn't work with --ipython
Works for me.

https://bugs.launchpad.net/leo-editor/+bug/1258512
_leo.c not working from IPython
Improved the documentation of the "c" property.
#@+node:ekr.20141120113801.29: *7* Fixed bug 102: Loading @file node with embedded code broken
https://github.com/leo-editor/leo-editor/issues/102

The fix was to call c.os_path_finalize/_join instead of
g.os_path_finalize_join in two places in the read logic.
#@+node:ekr.20141120113801.30: *7* Fixed bug 103: Installation Issues on Linux
https://github.com/leo-editor/leo-editor/issues/103

Where are we?
#@+node:ekr.20141120113801.31: *7* Installer window now shows version
#@+node:ekr.20141120113801.32: *7* Investigated bug 66: support @path with md importer/writer/rclick
https://github.com/leo-editor/leo-editor/issues/66

Works for me.
#@+node:ekr.20141120113801.33: *7* Made sure the .json file is part of the .zip file.
https://github.com/leo-editor/leo-editor/issues/104
https://github.com/leo-editor/leo-editor/issues/103
#@+node:ekr.20141120113801.34: *6* Bugs fixed in 5.0b1
#@+node:ekr.20141120113801.35: *7* Fixed
#@+node:ekr.20141120113801.36: *8* The spell checker handles apostrophes correctly
Previously, when checking "didn't" the spell checker would complain that
"didn" wasn't in the dictionary. Now it checks (and accepts) "didn't".

We have all been putting up with this annoyance for *far* to long. Changing
just two lines of code was all that was required.
#@+node:ekr.20141120113801.37: *8* fixed bug 1159490: "Open with" fails to copy changes by external editor back to Leo-Editor node
https://bugs.launchpad.net/leo-editor/+bug/1159490

The solution is to change the following setting in leoSettings.leo::
    
    @bool open_with_save_on_update = True
#@+node:ekr.20141120113801.38: *8* Fixed bug 1338773: Autocompleter error
https://bugs.launchpad.net/leo-editor/+bug/1338773
Autocompleter error

Added the following defensive code::

    try:
        self.deleteLater()
    except RuntimeError:
        # Avoid bug 1338773: Autocompleter error
        pass
#@+node:ekr.20141120113801.39: *8* Fixed bug 1338172: ReplaceAll will not replace newlines indicated as \n in target string
https://bugs.launchpad.net/leo-editor/+bug/1338172
ReplaceAll will not replace newlines indicated as \n in target string

Using regX , I can search on a pattern and replace it with a string that
includes "\n" as a newline in the transformed string.

If I do a simple search and replace-search from the Find pane that works
(I'm searching within the body of a single node).

However, if I do a Replace All, the "\n" is not translated into a newline;
it remains as is and appears as "\n" in the transformed string.

Also, I can't seem to get the replace-all command to work from the
minibuffer line; it only does a single replace.
#@+node:ekr.20141120113801.40: *8* Fixed bug 92: Tab loses focus when executing a button defined in an unopened settings file
https://github.com/leo-editor/leo-editor/issues/92
#@+node:ekr.20141120113801.41: *8* Fixed bug 66: errors inhibited read @auto foo.md
https://github.com/leo-editor/leo-editor/issues/66
errors inhibited read @auto foo.md

The markdown code is now similar to the @auto-rst code.

Added some kludgey code to handle underlining.
#@+node:ekr.20141120113801.42: *8* Disable activate/deactivate logic
LeoQtGui.onActivate/DeactiveEvent

This fixed several focus problems.
#@+node:ekr.20141120113801.43: *8* fixed pythonw bug
The fix was to define out in the ctor of SaxContentHandler.
#@+node:ekr.20141120113801.44: *6* Bugs fixed in 5.0a2
- Leo's desktop button now works properly with Python 3.x.
  The underlying cause was that Leo did not work with python34\pythonw.exe.

- Fixed name of a Qt class in richtext.py plugin.
#@+node:ekr.20141120113801.45: *6* Bugs fixed in 5.0a1
#@+node:ekr.20141120113801.46: *7* Fixed 14 github bugs
#@+node:ekr.20141120113801.47: *8* Fixed bug 12: when hoisted, the (alt-)arrow keys can't navigate to the top node
https://github.com/leo-editor/leo-editor/issues/12

The fix was to p.isVisible.
#@+node:ekr.20141120113801.48: *8* Fixed bug 28: Leo hangs when a node with too large body is selected
https://github.com/leo-editor/leo-editor/issues/28

Summary post:
https://groups.google.com/d/msg/leo-editor/b6TszFS_6NQ/gJrlRkqH9_oJ
#@+node:ekr.20141120113801.49: *8* Fixed bug 31: 'undo' on a freshly-loaded outline
https://github.com/leo-editor/leo-editor/issues/31
'undo' on a freshly-loaded outline containing chapters removes chapters

Chapter.afterCreateChapter does not push undo data when cc.initing is True.
#@+node:ekr.20141120113801.50: *8* Fixed bug 35: leoBridge sometimes assigns the same GNX to two distinct vnodes
https://github.com/leo-editor/leo-editor/issues/35
leoBridge sometimes assigns the same GNX to two distinct vnodes

c.initObjects sets c.hiddenRootNode.fileIndex to 'hidden-root-vnode-gnx'

fc.getLeoFile calls the new fc.setMaxNodeIndex after reading all nodes.
#@+node:ekr.20141120113801.51: *8* Fixed bug 36: @auto file not found produces a script error
https://github.com/leo-editor/leo-editor/issues/36

The report seems misleading: it says this happens when Leo tries to load an
@auto file that is in the outline but which was erased outside Leo,
but it worked for me.

I did add a guard in g.recureiveUNLFind to ensure that the IndexError shown
in the bug report can never happen.
#@+node:ekr.20141120113801.52: *8* Fixed bug 50: Important body text lost switching @file to @auto-rst
https://github.com/leo-editor/leo-editor/issues/50
Important: body text lost switching @file to @auto-rst

This case is so dangerous that Leo refuses to create the file and instead
reverts to the previous @file node.

Changes:
    
- v.at_read is now a dict: keys are full file names; values are lists of headlines.
- at.shouldPromptForDangerousWrite returns True if p.h is not in v.at_read.
- at.promptForDangerousWrite issues a warning and reverts the headline
#@+node:ekr.20141120113801.53: *8* Fixed bug 59: drag and drop: target too small
https://github.com/leo-editor/leo-editor/issues/59

When a file is dropped into any part of the Leo window, if the cursor is
not on a node it goes to the top or bottom of the tree as a root node.
#@+node:ekr.20141120113801.54: *8* Fixed bug 60: create relative paths & urls when dragging files to Leo
https://github.com/leo-editor/leo-editor/issues/60

It would be nice for Drag and drop files to have relative paths,taking into
account the @path settings of the part of the tree they're dropped into
(currently it is relative to the .leo file).
#@+node:ekr.20141120113801.55: *8* Fixed bug 63: refresh-from-disk does not clear big text load delay UI
https://github.com/leo-editor/leo-editor/issues/63
#@+node:ekr.20141120113801.56: *8* Fixed bug 64: https://github.com/leo-editor/leo-editor/issues/64
https://github.com/leo-editor/leo-editor/issues/64
#@+node:ekr.20141120113801.57: *8* Fixed bug 74: problems with @button if defined in myLeoSettings.leo
https://github.com/leo-editor/leo-editor/issues/74

What I did:

- ScriptingController now uses *gnxs* (not vnodes!) to detect duplicate buttons.
- Use AtButtonCallback for *all* buttons.
- QtIconBarClass.setCommandForButton always calls
  ScriptingController.build_rclick_tree.
- build_rclick_tree no longer assumes that command_p exists.

Rev 8413e2d fixes an important bug in the new code: "remote"
buttons (buttons defined in settings files) now work if the
settings file is not open.

There are some tricky details that must be handled. As an
example, consider a button defined as follows in
myLeoSettings.leo:

    @button print p.h
    print(p.h)

Detail 1: Leo must open myLeoSettings.leo to find the
@button node. Unlike the Goto Script rclick item, the search
does *not* leave myLeoSettings.leo open. That would be too
great a side effect of clicking the @button node!

Detail 2: We don't want to open myLeoSettings.leo every time
the user clicks the buttons, so the first time the user does
so the script is saved (cached). If the user clicks the
button later the cached value is used.

Detail 3: Caching is used "forever" (while Leo remains
open), even if the user opens myLeoSettings.leo and changes
the script. Sorry, this can't be helped. Don't ask me to
change this.

Detail 4: The new code is careful to execute the script in
the commander in which the button is *located*, not in the
commander in which the button is defined.

Report:

Putting @button definitions in myLeoSettings.leo (in an @buttons tree)
makes them available in all Leo files, a nice feature. Two problems:

- The buttons lack the 'Goto Script' rclick feature in all .leo files.
- There are duplicate buttons in myLeoSettings.leo

#@+node:ekr.20141120113801.58: *8* Fixed bug 75: write-opml-file always produces an empty file
https://github.com/leo-editor/leo-editor/issues/75
write-opml-file always produces an empty file

leoOPML.py's docstring needs updating.

Improved the packaging as follows:

- The leoOPML plugin no longer monkey patches any part of the FileCommands
  class. Instead the plugin sets the c.opmlController ivar.

- fc.writeToFileHelper calls c.opmlController.putToOPML(owner=self).
    
- OpmlController.putToOPML is just PutToOPML(owner) where PutToOPML is a
  class that creates the opml using the owner's put method.
#@+node:ekr.20141120113801.59: *8* Fixed bug 76: erroneous clone markers in @auto trees
https://github.com/leo-editor/leo-editor/issues/76
erroneous clone markers in @auto trees

The fixes were to several methods of the PersistenceDataController class.
#@+node:ekr.20141120113801.60: *8* Fixed bug 78: F3 find-next target not always highlighted
https://github.com/leo-editor/leo-editor/issues/78

This is a scrolling problem, not a failure to select text.

Changed the call to w.see in find.showSuccess.
#@+node:ekr.20141120113801.61: *7* Fixed 20+ Launchpad bugs
#@+node:ekr.20141120113801.62: *8* Fixed bug 1028986: create relative urls when dragging binary files to Leo
https://bugs.launchpad.net/leo-editor/+bug/1028986
create relative urls when dragging binary files to Leo

This bug was fixed by #60: 
https://github.com/leo-editor/leo-editor/issues/60
create relative paths & urls when dragging files to Leo

Modified dropEvent and its helpers.

Added createLeoFileTree and isLeoFile.

Regular drag of .leo files from a file folder works like the open-outline
command.

Ctrl-drag of .leo files from a file folder copies all nodes of the .leo
file to the receiving outline.

#@+node:ekr.20141120113801.63: *8* Fixed bug 1041906: underlying C/C++ object has been deleted
https://bugs.launchpad.net/leo-editor/+bug/1041906

Changed LeoQtTree.closeEditorHelper as follows:
    
- Call w.setItemWidget(item,0,None) to make sure e is never referenced again.
    
- Catch RuntimeError exceptions.
#@+node:ekr.20141120113801.64: *8* Fixed bug 1090950: refresh from disk - cut node resurrection
Fixed bug 1090950: refresh from disk - cut node resurrection.
https://bugs.launchpad.net/leo-editor/+bug/1090950

refresh_rclick_cb in contextmenu.py now just calls c.refreshFromDisk,
which calls c.recreateGnxDict() before reading any file.

Also created the new refresh-from-disk command and the corresponding item in the File menu.
#@+node:ekr.20141120113801.65: *8* Fixed bug 1185933: insert-headline-time should insert at cursor
https://bugs.launchpad.net/leo-editor/+bug/1185933

Note: the insert-headline-time command must be bound to a shortcut in order for this to work.
#@+node:ekr.20141120113801.66: *8* Fixed bug 1228312: Find tab selected in log pane disables Minibuffer
https://bugs.launchpad.net/leo-editor/+bug/1228312

This was the so-called "greedy checkbox bug".
#@+node:ekr.20141120113801.67: *8* Fixed bug 1228452: related to the radio buttons in the Find pane
https://bugs.launchpad.net/leo-editor/+bug/1228452

#@+node:ekr.20141120113801.68: *8* Fixed bug 1228458: Inconsistency between Find-forward and Find-backward
https://bugs.launchpad.net/leo-editor/+bug/1228458
#@+node:ekr.20141120113801.69: *8* Fixed bug 1231656: File-Compare-Leo-Files leaves other file open-count incremented
https://bugs.launchpad.net/leo-editor/+bug/1231656

This bug may already have been fixed, but just to make sure compareLeoFiles
now calls g.app.forgetOpenFile
#@+node:ekr.20141120113801.70: *8* Fixed bug 1244461: Numpad 'Enter' key does not work in minibuffer
https://bugs.launchpad.net/leo-editor/+bug/1244461

LeoQtEventFilter.qtKey now changes a toString value of 'Enter' to 'Return'
#@+node:ekr.20141120113801.71: *8* Fixed bug 1245535: API allows headlines to contain newlines
https://bugs.launchpad.net/leo-editor/+bug/1245535
#@+node:ekr.20141120113801.72: *8* Fixed bug 1245616: Autocomplete ? function...does not work
https://bugs.launchpad.net/leo-editor/+bug/1245616
#@+node:ekr.20141120113801.73: *8* Fixed bug 1251252: Minibuffer commands created by mod_scripting.py have no docstrings
https://bugs.launchpad.net/leo-editor/+bug/1251252

F11 (help-for-command) now works for @button & @command nodes.
#@+node:ekr.20141120113801.74: *8* Fixed bug 1254861: Ctrl-f doesn't ensure find input field visible
https://bugs.launchpad.net/leo-editor/+bug/1254861
#@+node:ekr.20141120113801.75: *8* Fixed bug 1258373: failed find focus fails
https://bugs.launchpad.net/leo-editor/+bug/1258373
#@+node:ekr.20141120113801.76: *8* Fixed bug 1260415: exception writing external files" is insufficient
https://bugs.launchpad.net/leo-editor/+bug/1260415
Added more informative error messages
#@+node:ekr.20141120113801.77: *8* Fixed bug 1264350: Up-arrow on the first node in a chapter switches to another chapter 
https://bugs.launchpad.net/leo-editor/+bug/1264350
#@+node:ekr.20141120113801.78: *8* Fixed bug 1267921: isearch-forward accepts non-alphanumeric keys as input
https://bugs.launchpad.net/leo-editor/+bug/1267921
#@+node:ekr.20141120113801.79: *8* Fixed bug 1276236: unicode problem in the log pane
https://bugs.launchpad.net/leo-editor/+bug/1276236

g.insertCodingLine adds coding line to start of all python scripts, except when unit testing.
#@+node:ekr.20141120113801.80: *8* Fixed bug 613153: unable to describe root directory on thumb drive
https://bugs.launchpad.net/leo-editor/+bug/613153

Use the %~dp0 syntax. Example::

  %~dp0\Python27\python.exe %~dp0\Leo-editor\launchLeo.py

http://ss64.com/nt/syntax-args.html
http://stackoverflow.com/questions/5034076/what-does-dp0-mean-and-how-does-it-work

I have just created a FAQ entry for this, so at last this issue is closed.
#@+node:ekr.20141120113801.81: *8* Fixed bug 735938: file association crash
https://bugs.launchpad.net/leo-editor/+bug/735938
#@+node:ekr.20141120113801.82: *8* Fixed bug 969391: setup.py confuses newbies
https://bugs.launchpad.net/leo-editor/+bug/969391
#@+node:ekr.20141120113801.83: *7* Fixed 30+ other bugs
#@+node:ekr.20141120113801.84: *8* eliminated "can not exedute commands from headlines"
Removed the odious "'Can not execute commands from headlines" message.

Leo now ends editing, replaces the event.widget and event.w fields with
c.frame.body.wrapper.widget and carries on.
#@+node:ekr.20141120113801.85: *8* find-all now uses exising find pattern
#@+node:ekr.20141120113801.86: *8* Fixed a startup error involving --ipython
Fixed a bug that caused Leo to exit during startup when
--python given on the command line but IPython is not installed.
#@+node:ekr.20141120113801.87: *8* Fixed annoyance: shift-ctrl-w leaves .leo file as dirty
- pd.update_before_write_foreign_file tells when an @data node has been
  changed. This explains why the .leo file is now dirty.
- at.saveOutlineIfPossible automatically saves the .leo file if only
  unchanged persistence nodes remain.
  
at.saveOutlineIfPossible makes the following hacks unnecessary:
    
- at.writeAllHelper writes an unchanged @auto file only if it is
  selected explicitly.
- Changed at.writeAll so that the no @<file> node written message now says
  that you must selected an unchanged @auto node directly in order to write
  it with the write-at-files-nodes command.
#@+node:ekr.20141120113801.88: *8* Fixed autocompleter bug
https://groups.google.com/d/msg/leo-editor/NGbogCgVmx4/nsJGngrS8BgJ
#@+node:ekr.20141120113801.89: *8* Fixed bug re the factor language
Fixed the entry in g.app.language_extension_dict
#@+node:ekr.20141120113801.90: *8* Fixed bug: activate events now properly restore focus
Previously, Ctrl-F Alt-tab Alt-tab would put focus in an inactive minibuffer.

The fix involved rewriting onActivate/DeactivateEvent.
#@+node:ekr.20141120113801.91: *8* Fixed bug: Find-previous fails at last node
https://groups.google.com/d/msg/leo-editor/RAzVPihqmkI/-tgTQw0-LtwJ

This only affected searches that were initiated using the buttons in the Find tab.

What I did:
    
- Init buttonFlag ivar in setup_button & setup_command.
- showSuccess sets was_in_headline ivar.
- focusInTree returns was_in_headline when buttonFlag is True.
- editLabelHelper now properly sets selection range for backward searches.
- Removed a selection hack in initNextText.
#@+node:ekr.20141120113801.92: *8* Fixed clone-find-all command
Changed find.findAll and helpers as follows:
    
- findAll inits onlyPosition for the clone-find-all commands.
    
- createCloneFindAllNode does not link the node into the outline.
  To do this, leoFind.py imports leo.core.leoNodes.

- linkCloneFindAllNode does this *after* the command completes. This keeps
  all positions unchanged while they are being scanned.
   
- The code now tests for either clone_find_all or clone_find_all_flattened
  in various places.
#@+node:ekr.20141120113801.93: *8* Fixed Crash deleting body editor
# Trying to delete a second body editor.

Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 560, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\plugins\qtGui.py", line 2980, in deleteEditor
    name = w.leo_name
AttributeError: 'LeoQTextBrowser' object has no attribute 'leo_name'
#@+node:ekr.20141120113801.94: *8* Fixed find bug
https://groups.google.com/forum/#!topic/leo-editor/yR8eL5cZpi4

Another example of the wretched newline problem. @edit nodes preserve '\r'
characters, and that messes up the counts in the find command.

The fix was a hack to find.search: it removes '\r' characters.

#@+node:ekr.20141120113801.95: *8* Fixed important security hole in mod_scripting plugin
The ctor of the scriptingController does not allow::

    @bool scripting-at-script-nodes = True
    
in local .leo files. 
#@+node:ekr.20141120113801.96: *8* Fixed leoGlobals bug (per Reinhard Engle)
@language rest

Reinhard Engel reinhard.engel.de@googlemail.com

There seems to be a subtle bug in leoGlobals.py:

In the 'globalDirectiveList', the directive 'command' is missing. This
seems not to cause problems, because of the way 'aList' in
'compute_directives_re' is constructed. Then in 'get_directives_dict' the
directive is silently skipped.

The following pattern in 'compute_directives_re' solves this problem:

@language python

    aList = [x for x in globalDirectiveList if z != 'others']
    aList.sort(lambda a,b: len(b)-len(a))
        # Sort by length, longest first
    pat = "^@(%s)(?=( |\t|\n)+)" % "|".join(aList)
#@+node:ekr.20141120113801.97: *8* Fixed modes/md.py
@language python

import glob
pattern = g.os_path_finalize_join(g.app.loadDir,'..','modes','*.py')
for fn in glob.glob(pattern):
    sfn = g.shortFileName(fn)
    f = open(fn)
    s = f.read()
    f.close()
    if s.find(r'regexp="\\') > -1:
        g.es(sfn)

@language text

Possible automatic computation of First sets:
http://stackoverflow.com/questions/787134/can-i-determine-the-set-of-first-chars-matched-by-regex-pattern
http://www.cs.uky.edu/~lewis/texts/theory/automata/reg-sets.pdf

found: Rules indicated are dubious or broken

md.py:
    disabled: 6,7,
    changed: 8,12,20,21,23,24,25,47
    [ \t]   leadins: 8,20,24,25,50,51
    space   leadins: 23,46,49
    [=-]    leadins: 21,47
    [\\_]   leadins: 54,55
    other   leadins: 12,19,53

moin.py:
    [ \t]           rule 3.
    single-quote    rule 6.

erlang.py:  no obvious problem.
lilypond.py:no obvious problem.
perl.py:    no obvious problem.
pl1.py:     no obvious problm.
rest.py:    no obvious problem.
rtf.py:     no obvious problem.
scala.py:   no obvious problem.
yaml.py:    fixed
#@+node:ekr.20141120113801.98: *8* Fixed problem with 1-character reverse searches!
The problem was an off-by-one test in regexHelper.
#@+node:ekr.20141120113801.99: *8* Fixed problems with clone-expansion
Alt-End when the last top-level node was a clone caused all clones to expand.

The fix was in p.isAncestorOf.

Also, changed p.all_unique_positions() to p.all_positions() in places where p.contract was called.

I started this project by doing a clone-find-all for isExpanded.
#@+node:ekr.20141120113801.100: *8* Fixed QCompleter bug
http://i.imgur.com/1ZV45oB.png

There was a problem with hitting tab, and possibly with using the mouse in the QListWidget.

The fix was to define w as follows in lqlw.select_callback and lqlw.tab_callback:
    
    w = c.k.autoCompleter.w or c.frame.body.wrapper

In addition, I changed assert in lqlw.set_position to calls to g.trace.
#@+node:ekr.20141120113801.101: *8* Fixed recent bug in change command
The change pattern doesn't always get set properly.

The fix was in find.addChangeStringToLabel. It must never protect the
change string!
#@+node:ekr.20141120113801.102: *8* Fixed recursive import bug
https://github.com/leo-editor/leo-editor/issues/49

The file import code as found in scripts fails on reaching
Word backup files (file names prefixed with a ~)

The problem was that g.os_path_join automatically called
os.path.expanduser, which converts ~ to the users home directory.

The fix was to disable the call to os.pathexpanduser in g.os_path_join &
g.os_path_finalize if the new expanduser keyword argument is False.
#@+node:ekr.20141120113801.103: *8* Fixed serious bug in c.deletePositionsInList
https://groups.google.com/forum/#!topic/leo-editor/Uoa7ifVV_Aw
#@+node:ekr.20141120113801.104: *8* Fixed several crashers re no-to-all during startup
The present code just exists Leo, which imo is the reasonable thing to do. 
#@+node:ekr.20141120113801.105: *8* Fixed suboutline only find bug
https://groups.google.com/d/msg/leo-editor/ujDqUI68Sx4/EwTYCw7O38cJ

qtree.onItemClicked now calls c.findCommands.reset_state_ivars()
#@+node:ekr.20141120113801.106: *8* Fixed tab cycling
Tab cycling now works as expected in all my tests.

- Reset tab cycling if the user types backspace or any plain character.
- Start cycling *only* if len(label) == len(common_prefix)

These restriction appear to be essential.
#@+node:ekr.20141120113801.107: *8* Fixed tab-completion problems
It sometimes picked a shorter completion that is not a prefix of the present label!

Examples:
    print-se **sometimes** shows print-uas or print-bindings or...
    print-stat<tab>-h<tab> shows print-statusbar-hide
    print-st<tab> shows print-style-sheet.
    print-pr<tab> show print-plugin-handlers.
    
The fix was a single extra check in ga.do_tab.
#@+node:ekr.20141120113801.108: *8* Fixed unwanted scrolling in abbreviations
Saved and restored the y-scroll position in find_place_holder.
#@+node:ekr.20141120113801.109: *8* Gave the Find Tab the intended amount of border
dw.createGrid now honors the margin argument.
#@+node:ekr.20141120113801.110: *8* Improved ctrl-o code
- Non-plain keys are now ignored.
- Backspace and other characters now do something fairly reasonable when text is selected.
  This is an edge case, unless everything to the end of the text is selected.
#@+node:ekr.20141120113801.111: *8* Investigated bug: fill-region & format-body can hang
This was probably fixed earlier by the addition of progress guards
in ec.fillRegion and c.reformatBody.

Added one line for fillRegion.
#@+node:ekr.20141120113801.112: *8* Made beautify commands compatible with pep8
http://legacy.python.org/dev/peps/pep-0008/

https://github.com/leo-editor/leo-editor/issues/68

    (fixed) puts whitespace between function name and opening '('
    (fixed) puts whitespace between dictionary name and '['
    (fixed) removes whitespace between function arguments after ','
    (partially fixed) removes whitespace around operator inside parentheses
        (this is not so clear, depends on situation, can be correct or can be wrong)
    (fixed) puts whitespace between print and opening '('

print(obj) is correct and PEP8 style in Python 3, in Python 2.7 runs
correctly but print(obj) is not correct traditionally
#@+node:ekr.20141120113801.113: *8* Re-enabled command completion for @button commands
This had been disabled when completion for vim : commands was added.

Changed ga.get_command and ga.is_command.
#@+node:ekr.20141120113801.114: *8* Reported QTextEdit bug
https://bugreports.qt-project.org/browse/QTBUG-41153
#@+node:ekr.20141120113801.115: *8* Set the default syntax color for operators to black
This is required so that, for example, python coloring is correct after
selecting a node that sets another color for operators.
#@+node:ekr.20141120113801.116: *8* Suppressed duplicate console messages
g.es does nothing when g.app.gui.consoleOnly is True
#@+node:ekr.20141120113801.117: *8* Worked around a strange PyQt5 bug in LeoQtGui.runSaveFileDialog
For some strange reason, the PyQt5 version of LeoQtGui.runSaveFileDialog
returns a tuple instead of a string!
#@+node:ekr.20141120113801.118: *6* Invalid/won't fix
#@+node:ekr.20141120113801.119: *7* 5.0b1
#@+node:ekr.20141120113801.120: *8* Invalid bug 1286909: Settings in file A propagate to file B when editing A and B is opened
https://bugs.launchpad.net/leo-editor/+bug/1286909
Settings in file A propagate to file B when editing A and B is opened

#@+node:ekr.20141120113801.121: *8* Investigated bug 1240786: Corner case bug in tab-cycle-next and tab-cycle-previous
https://bugs.launchpad.net/leo-editor/+bug/1240786
Corner case bug in tab-cycle-next and tab-cycle-previous

This bug appears to have been fixed.

Open any already existing Leo-Editor file. Call this File 1. Ctrl-O and
open any already existing Leo-Editor file. We will refer to this file as
"File 2." At this point the File 2 tab has focus.

Now execute tab-cycle-next or tab-cycle-previous. I do this using shortcuts
Ctrl+Next and Ctrl+Prior respectively, but your shortcuts may be different.
Now the File 1 tab has the focus. Now type any printable key.

Note that the printable key character is put into File 2 and File 2 is now
dirty, but the focus is still on File 1.

In every other case that I've tried tab-cycle-next and tab-cycle-previous
perform correctly and the tab with the focus is the tab into which
characters are inserted.
#@+node:ekr.20141120113801.122: *8* Investigated bug 1249684: "add body editor" adds editor pane in wrong tab
https://bugs.launchpad.net/leo-editor/+bug/1249684
"add body editor" adds editor pane in wrong tab

This seems to have been fixed.
#@+node:ekr.20141120113801.123: *8* Investigated bug 1258302: Window, Toggle Split Direction Error
https://bugs.launchpad.net/leo-editor/+bug/1258302
Window, Toggle Split Direction Error

This works for me.  Don't know when it was fixed.
#@+node:ekr.20141120113801.124: *8* Investigated bug 1269540: File importing problems: Path doesn't properly appear as node header
https://bugs.launchpad.net/leo-editor/+bug/1269540
File importing problems: Path doesn't properly appear as node header

This bug was fixed by #60 or at some earlier time.

I am aware of no problems with drag and drop at present.
Please create a github bug report if any new issues appear.

#@+node:ekr.20141120113801.125: *8* Investigated bug 1286914: A custom menu that seems correct, but does nothing
https://bugs.launchpad.net/leo-editor/+bug/1286914
A custom menu that seems correct, but does nothing

This problem is demonstrated by the file settingsCreep01.leo attached to bug 1286909.

The fix is to remove the amperstand from the @item headlines.
#@+node:ekr.20141120113801.126: *8* Won't fix bug 1286913: After the "menu already exists"...
https://bugs.launchpad.net/leo-editor/+bug/1286913
After the "menu already exists: ampersand menu name" warning,
the menu entries are added to the existing menu.

This is a minor wishlist item.
#@+node:ekr.20141120113801.127: *8* Won't fix bug 1292207: Disabling Plugins disables menu actions
https://bugs.launchpad.net/leo-editor/+bug/1292207
Disabling Plugins disables menu actions

This bug is invalid.

Disabling plugins disable the mod_scripting plugin, so the @command nodes
given in the example do nothing.
#@+node:ekr.20141120113801.128: *8* Won't fix bug 815564: Plugin Menu-Keystroke binding can prevent plugin help display
https://bugs.launchpad.net/leo-editor/+bug/815564
Plugin Menu - Keystroke binding can prevent plugin help display

Obvious workaround: avoid name clashes.
#@+node:ekr.20141120113801.129: *7* 5.0a1
#@+node:ekr.20141120113801.130: *8* Cleared bug 1228457: Beginning find at the current node's body cursor when that cursor is not displayed
https://bugs.launchpad.net/leo-editor/+bug/1228457

This appears to have been fixed.
#@+node:ekr.20141120113801.131: *8* Cleared bug 1228713: Find-backward skips headlines under some conditions
https://bugs.launchpad.net/leo-editor/+bug/1228713

This appears to have been fixed at some time in the past, possibly as the result of fixing another bug.
#@+node:ekr.20141120113801.132: *8* Cleared bug 1254864: Can't search from current cursor position downward in body text
https://bugs.launchpad.net/leo-editor/+bug/1254864
#@+node:ekr.20141120113801.133: *8* Investigated bug  524890: Incomplete derived file
https://bugs.launchpad.net/leo-editor/+bug/524890
Incomplete derived file

This bug was fixed by the allow_cloned_sibs logic in leoAtFile.py 2013/01/20.
#@+node:ekr.20141120113801.134: *8* Investigated bug 1177355: node-only wrapped search does not work in long nodes
https://bugs.launchpad.net/leo-editor/+bug/1177355
node-only wrapped search does not work in long nodes

This works for me.
#@+node:ekr.20141120113801.135: *8* Investigated bug 1193820: Focus change on tree pane after saving current Leo file
From https://github.com/leo-editor/leo-editor/issues/73

https://bugs.launchpad.net/leo-editor/+bug/1193820
Focus change on tree pane after saving current Leo file
    
Using Qt. First reported here:
https://groups.google.com/forum/#!topic/leo-editor/hPwPG9OTC3U

This no longer seems to be a problem.
#@+node:ekr.20141120113801.136: *8* Investigated bug 1266269: Mac: alt-x does not work in body pane
https://bugs.launchpad.net/leo-editor/+bug/1266269
Mac: alt-x does not work in body pane

No problem with a clean homebrew install on MacOS 10.9 Mavericks.
#@+node:ekr.20141120113801.137: *8* Investigated bug 1268970: Leo does not remember window maximized state
https://bugs.launchpad.net/leo-editor/+bug/1268970

This works for me (Windows 7 and Ubuntu) with Python 2.7.8, PyQt version 4.8.6.
#@+node:ekr.20141120113801.138: *8* Investigated bug 1282362: shadow file name collisions cause spontaneous clone creation
[Fixed?] https://bugs.launchpad.net/leo-editor/+bug/1282362
shadow file name collisions cause spontaneous clone creation

Works for me. Furthermore, the scenario is bizarre enough not to be important.

- Create a new leo file.
- Create @shadow foo.txt
- Set body to @others, add two children, with different body texts.
- Copy / paste the @shadow node, change the path to x/foo.txt

(In shell, create x folder, saving shadow doesn't create path, which is
maybe another bug) save and close file

open file again, children of shadow nodes are clones of each other. I think
it's the name collision, not the copy pasting etc.

#@+node:ekr.20141120113801.139: *8* Investigated bug 869098: Context menu settings lost if save as used
https://bugs.launchpad.net/leo-editor/+bug/869098
Context menu settings lost if save as used

This report appears invalid.

The renamed file uses the @data contextmenu_commands node in that files.

Note that @data contextmenu_commands node in the file *replaces* any other
@data contextmenu_commands node in leoSettings.leo or myLeoSettings.leo.

#@+node:ekr.20141120113801.140: *5* Code
#@+node:ekr.20141120113801.141: *6* A beautiful and general design pattern
In an earlier post I said:

QQQ

Strictly speaking, tab cycling doesn't have to be disabled for all colon
commands. One could imaging a list of commands that use tab to complete
file names. Otoh, maintaining that list would be clumsy, and it would add
still more special cases to ga.do_tab.

QQQ

This post describes a much better way, done at rev 3994eca.

The new code is gorgeous, if I do say so myself. Even better, the solution
is a design pattern with many applications.

The trick is to replace functions implementing commands by classes having
`__call__` methods. See the P.P.S for details.

Yes, this has all been done before. Several of Leo's commands are
implemented this way. But read on...

What's new is that classes can "advertise" their ability to do various
things. Here, the classes implementing vim commands advertise, by having a
tab_callback method, that they want to handle a tab that follows their
name. ga.do_tab then defers to the vim command.

There are several really cool things about this code.

1. ga.do_tab, and its helper, ga.do_tab_callback, no longer know *anything*
    about colon commands, or what any command intends to do with the
    tab(!!). If the command handler has a tab_callback attribute,
    ga.do_tab_callback just does::

     ga.reset_tab_cycling()
     k.functionTail = tail # For k.getFileName.
     handler.tab_callback()

Nothing could be simpler, or more general.

2. The code in the command classes is simplified as well. No need for a
   kludgy test event.get_arg_value. See the P.S. for the full
   implementation of the :tabnew command.

The overall result is a spectacular collapse in complexity, which the
attendant increase in power and generality.

Edward

P.S. Here is the flattened form of the class that handles the :tabnew
command (does not require vim-mode). In particular, note that the __call__
and tab_callback methods are trivial. This is the way it is written in The
Book.

class Tabnew:
    '''
    A class to handle Vim's :tabnew command.
    This class supports the do_tab callback.
    '''
    def __init__(self,vc):
        '''Ctor for VimCommands.tabnew class.'''
        self.vc = vc
    __name__ = ':tabnew'
        # Required.

    def __call__(self,event=None):
        '''Prompt for a file name, the open a new Leo tab.'''
        self.vc.c.k.getFileName(event,callback=self.open_file_by_name)
       
    def tab_callback(self):
        '''Called when the user types :tabnew<tab>'''
        self.vc.c.k.getFileName(event=None,callback=self.open_file_by_name)
       
    def open_file_by_name(self,fn):
        c = self.vc.c
        if fn and not g.os_path_isdir(fn):
            c2 = g.openWithFileName(fn,old_c=c)
            try:
                g.app.gui.runAtIdle(c2.treeWantsFocusNow)
            except Exception:
                pass
        else:
            c.new()

P.P.S. This pattern is particularly well suited to Leo, because the various
getPublicCommands methods reference those functions when create command
dictionaries. Here, we replace just two entries in the dict::

    ':r':   vc.LoadFileAtCursor(vc),
    ':tabnew': vc.Tabnew(vc),

This creates instances of the LoadFileAtCursor and Tabnew classes. In other
words, we replace a function by an instance of a class. All such classes
must have __call__ methods, so that Leo can "call" the instance as if it
were a function.
#@+node:ekr.20141120113801.142: *6* A major reorg of Leo's code
One change is required to all plugins and scripts:

    body.bodyCtrl.x -> body.wrapper.x
    
There is a script that does this automatically.

What I did
- Created "@test interfaces using API classes" based on the checking script.
- The various isTextWidget methods now check for the existence of a supportsHighLevelInterface ivar.
- StringTextWrapper is now a stand-alone class.
- Removed BaseTextWrapper.
- LeoLog is no longer a subclass of the HighLevelInterface class.
  This required a hack to handle keystrokes in the log pane:
  k.masterKeyHandler sends strokes to c.frame.log.logWidget (a QTextEditWrapper)
  by changing event.widget.
  QTextMixin sets supportsHighLevelInterface = True as a signal to k.handleDefaultChar.
- Eliminated redirection code from LeoQtBody class.
- LeoBody is no longer a subclass of the HighLevelInterface class.
    - The only changes, one or two new guards.
- Create WrapperAPI class whose text indicates expected type of the result.
- Removed wrapper.getFocus method.
- Removed all references to HighLevelInterface class in the core.
- Removed the evil set_focus synonym in the HighLevelInterface class.
#@+node:ekr.20141120113801.143: *6* Added support for qt5
It is not possible to use both the PyQt4 and PyQt5 installers at the same
time. But this is no big deal on Windows: just install PyQt5 for Python 3.4
only.
#@+node:ekr.20141120113801.144: *6* added the IdleTime class
@language rest

Rev 060c33a contains a spectacular collapse in complexity in idle-time
handling.

Instantly, registering idle-time event handlers can be considered
deprecated, though I have no plans to remove the horrendous older code.

The new pattern allows multiple, independent (or cooperating) idle-time
handlers, created at will as needed.

The new code is based on the IdleTime class in qtGui.py. Rather than access
this directly, code should use the g.IdleTime proxy::

@language python

    def IdleTime(c,handler,delay=500):
        '''A proxy for the g.app.gui.IdleTime class.'''
        if g.app and g.app.gui and hasattr(g.app.gui,'idleTimeClass'):
            return g.app.gui.idleTimeClass(c,handler,delay)
        else:
            return None
            
@language rest

g.IdleTime ensures that all is well when using gui's that don't have an IdleTime class.

Here is how to use the new code::

@language python

    def handler(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace(it.count,it.c.shortFileName(),'%2.4f' % (delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    it = g.IdleTime(c,handler,delay=500)
    if it: it.start()
    
@language rest

The code creates an instance of the IdleTime class that calls the given
handler at idle time, and no more than once every 500 msec. Here is the
output::

    handler 1 ekr.leo 0.5100
    handler 2 ekr.leo 1.0300
    handler 3 ekr.leo 1.5400
    handler 4 ekr.leo 2.0500
    handler 5 ekr.leo 2.5610
    handler done

Timer instances are completely independent.  For example:

@language python

    def handler1(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    def handler2(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 10:
            g.trace('done')
            it.stop()

    it1 = g.IdleTime(c,handler1,delay=500)
    it2 = g.IdleTime(c,handler2,delay=1000)
    if it1 and it2:
        it1.start()
        it2.start()
        
@language rest

Here is the output::

    handler1  1 ekr.leo 0.5200
    handler2  1 ekr.leo 1.0100
    handler1  2 ekr.leo 1.0300
    handler1  3 ekr.leo 1.5400
    handler2  2 ekr.leo 2.0300
    handler1  4 ekr.leo 2.0600
    handler1  5 ekr.leo 2.5600
    handler1 done
    handler2  3 ekr.leo 3.0400
    handler2  4 ekr.leo 4.0600
    handler2  5 ekr.leo 5.0700
    handler2  6 ekr.leo 6.0800
    handler2  7 ekr.leo 7.1000
    handler2  8 ekr.leo 8.1100
    handler2  9 ekr.leo 9.1300
    handler2 10 ekr.leo 10.1400
    handler2 done
#@+node:ekr.20141120113801.145: *6* All unit tests now pass when run externally
Fixed an important bug in addNode, a helper of createOutline: There was a
confusion about commanders: p is in the old commander. p2 must be in the
new commander.

Disabled a few unit tests when run externally:
This was due to missing nodes or copies of clones not being cloned.
#@+node:ekr.20141120113801.146: *6* API changes
- Converted all class names to pep8 style
- Removed g.choose from Leo's core & plugins
  This function is deprecated: use Python's ternary operator instead.
#@+node:ekr.20141120113801.147: *6* Changed most calls to k.setLabel to k.setStatusLabel
Leo's core now calls k.setStatusLabel, not k.setLael, to report the status
of a Leo command. This allows an option (does not exist yet) to use g.es
instead of the minibuffer to report status.
#@+node:ekr.20141120113801.148: *6* Cleaned up command-name handling a bit
Changed k.inverseCommandsDict to c.inverseCommandsDict.
Called vc.define commands from c.finishCreate.
Changed ecm.finishCreateEditCommanders to ecm.defineCommandNames.
The new c.createCommandNames copies entries in g.app.global_commands_dict to commander c.
    Note: @g.command makes entries in g.app.global_commands_dict.
#@+node:ekr.20141120113801.149: *6* code: regularized .wrapper and .widget ivars
@language rest

This post will summarize what has already been done and what will be done in the next few days.  Let's start with the basics...

===== About wrappers and widgets

Wrapper and widget classes are at the heart of Leo's design. Clarifying the
relationships between wrappers and widgets started the present avalanche.

Here is what you *must know* to understand Leo's core:

1. A **widget** is an actual Qt widget.

Leo's core seldom accesses widgets directly. Instead...

2. A **wrapper class** defines a standard api that hides the details of the
   underlying gui **text** widgets.

Leo's core uses this api almost exclusively. That is, Leo's core code
treats wrappers *as if* they were only text widgets there are!

There is, however, a back door for (hopefully rare!) special cases. All
wrapper classes define an official "widget" ivar, so core or plugin code
can gain access to the real Qt widget using wrapper.widget. Searching for
wrapper.widget will (or soon will) find all gui-dependent snippets of code
in Leo's core.

3. Wrappers are crucial, even if Leo *always* uses the Qt gui.

This has just become crystal clear to me. Indeed:

- Wrappers allow users to choose different Qt widgets for the body pane,
  without changing *any* of Leo's core code (except the startup code).

- Wrappers allow Leo's text-handling code to remain unchanged regardless of
  whether the body or log panes are a QTextBrowser or a QsciScintilla
  widget.

- Without wrappers, all of Leo's text-editing commands would have to know
  the details of the api of the actual Qt text widget!

==== Summary of the avalanche

Here is what is happening now in Leo's code base, and in my thinking!

1. A collapse in the complexity of relationships between Leo's most
   important classes and between the files containing those classes.

qt_text.py was supposedly a minor reorg. Wrong! It has become the road map
to the reorganization of all of Leo's fundamental classes:

- qt_text.py is *self contained*: it doesn't depend on any other classes!

- qt_text.py defines a QTextMixin class. This is a new kind of class for
  me. As its name suggest, it is not so much a base class as a helper
  class. It provides helper code for all of Leo's Qt wrapper widgets.

- All the classes that use QTextMixin implement the HighLevelInterface
  class in leoFrame.py.

The HighLevelInterface class will soon morph into the WrapperInterface
class. Th WrapperInterface class will contain only the definition of
methods and their docstrings. Unlike the HighLevelInterface class, the
WrapperInterface will contain *no* redirection code!

- If we were (heaven forbid) going to change Leo's gui, we would simply use
  a copy of qt_text.py, say new_gui.text.py, as a starting point.

2. All "redirection" code will soon be gone.

Ville, Terry and I will be much happier. Eliminating this cruft makes Leo's
code both lighter and thicker, to use the go terminology. It's lighter
because there is far less blah, blah, blah. It's thicker because there is
less to check and to fail.

It's easy to eliminate redirection. For example, the LeoBody methods that
just call the corresponding wrapper methods will soon be gone. We'll
change::

    c.frame.body.wrapperMethod

to::

    c.frame.body.wrapper.wrapperMethod

Doh! This should have been done years ago. Yes, it's more verbose, but it's
also more explicit. Furthermore, few such calls actually exist!

3. widget.widget and other type-checking horrors will soon be a thing of
   the past.

New coding conventions will remove all confusion between wrappers and
widgets. Wrappers will *always* be called wrappers, never widgets.

There is/was something both fundamentally wrong and confusing about
widget.widget. The first widget must have a different type than the second,
but there is *no* indication of this fundamental fact. The reorg changes
widget.widget to wrapper.widget everywhere.

4. I have a new approach toward type checking.

It is obvious now, in retrospect, that clarity of design is something much
more important than type checking! Leo's code will soon make the types of
objects *explicit* and this far more important in practice than even
"perfect" static type checking. This is a revolution in my thinking.

pylint, while supremely important for day-to-day programming, is *totally
inadequate* to have produced the design changes I have been discussing.

Now that widgets are always clearly distinct from wrappers, we could
imaging type-checking assertions to verify their apparent types. Imo, such
assertions are seldom pythonic, but in this case assertions might be good
documentation, if nothing else. The assertions would be based on the
following functions:

- g.isWrapper(obj): calls g.app.gui.isWrapper(obj)
- g.isWidget(obj): calls g.app.gui.isWidget(obj)

5. A dead-easy script shows how to enforce the relationships between types
   that really matter.

This is a big Aha. The script merely compares dir(o1) with dir(o2), where
o1 is the "template" HighLevelInterface class in leoFrame.py and o2 is one
of QTextEditWrapper or QScintillaWrapper. You could call this the "back
door" approach to type checking. It's sooo easy! No more messing with
ast's!

As a result of running this script, (given in the P.P.S.) I was able to
removed cruft from both the HighLevelInterface class, and other parts of
Leo's code.

===== Summary

None of these massive changes adds anything directly to Leo :-)

However, they make understanding and changing Leo's code far easier and
more pleasant. Leo's code is now more beautiful.

Imo, these changes are long overdue. They fundamentally improve Leo's code
base.

That's all for now. I'll keep you posted as I change code, but this post
covers all the essentials.

Edward

P.S. git and easier access to pylint contributed to the present avalanche
of energy and ideas.

Git has allowed me to revise Leo's source code radically, with complete
safety. I would never have done what I have done lately with bzr.

Leo's new pylint command allows me to run pylint *easily* on one or more
"recent" files, *without* having to change any list. As a result, I run
pylint much more often.

P.P.S. Here is the script that checks that all text wrapper classes
implement all required methods. This is, to the first approximation, the
only type checking that Leo really needs. It will probably become a unit
test.

@language python

    import leo.core.leoFrame as leoFrame
    import leo.plugins.qt_text as qt_text
    from leo.core.leoQt import Qsci,QtWidgets
    
    h = leoFrame.HighLevelInterface(c)
    w = Qsci.QsciScintilla()
    tw = QtWidgets.QTextBrowser()
    q = qt_text.QScintillaWrapper(widget=w,c=c,name='test')
    t = qt_text.QTextEditWrapper(widget=tw,name='test2')
    
    h_list = [z for z in sorted(dir(h)) if not z.startswith('__')]
    t_list = [z for z in sorted(dir(t)) if not z.startswith('__')]
    q_list = [z for z in sorted(dir(q)) if not z.startswith('__')]
    ignore = [
        'set_focus', # synonym for setFocus
        'mutable_methods', # To be removed.
    ]
    for z in h_list:
        if z not in t_list and z not in ignore:
            print('QTextEditWrapper: not in HighLevelInterface: %s' % z)
    for z in h_list:
        if z not in q_list and z not in ignore:
            print('QScintillaWrapper: not in HighLevelInterface: %s' % z)
    print('done')

@language rest

=====

This project appears to be a complete success. No further work is planned.
I have encountered no problems at all during this reorg, and don't expect
any, but we shall see...

Here are the highlights:

1. *All* of the odious redirection code in Leo is gone.
 
The redirection code appeared in various places, especially in the
HighLevelInterface class.

2. The HighLevelInterface class is gone: the LeoBody and LeoLog classes are
   now subclasses of object.

3. The logCtrl property is gone: the LeoLog class now defines a .logCtrl
   ivar.

This ivar is inherently tricky: depending on which log *tab* is selected,
LeoLog.logCtrl may be either a wrapper or a widget!

Because LeoLog no longer contains redirection code a hack was needed.
k.masterKeyHandler redirects text-related events originally sent to the
c.frame.log to c.frame.log.logWidget, which, confusingly enough, is
actually a text wrapper.

4. leoFrame.py contains several new API classes: ColorizerAPI, IconBarAPI,
   StatusLineAPI and WrapperAPI.

No class is a subclass of these classes: they are for unit testing only.

The new unit test, "@test interfaces using API classes", checks that
classes implement all the methods in the corresponding API class. This is
not a perfect solution and it is no substitute for pylint. Nevertheless,
these API classes are good documentation, and they did result in a few new
methods being added to each tested "Null" class.

That's all! You may not believe it, but I think of all this work as being
related to fixing bugs. I'll now return more directly to bug fixes.
#@+node:ekr.20141120113801.150: *6* Completed generalization of importers
- ic.createOutline and its helper, ic.dispatch, now use tables
  created by ic.createImporterData and its helper.

- Eliminated odious special cases involving self.treeType in
  ic.create_top_node and ic.init_import.
  
- self.treeType is used only in a limited way in the scanner classes:
  The only tests are against '@root' and '@file'.
  
- For now, the unit-tests wrappers are hard-coded.
#@+node:ekr.20141120113801.151: *6* Created g.IdleTime and qtGui.IdleTime
Rev 060c33a...Leo build: 20140825070951 contains a spectacular collapse in
complexity in idle-time handling. Instantly, registering idle-time event
handlers can be considered deprecated, though I have no plans to remove the
horrendous older code.

The new pattern allows multiple, independent (or cooperating) idle-time
handlers, created at will as needed.

The new code is based on the IdleTime class in qtGui.py. Rather than access
this directly, code should use the g.IdleTime proxy:: g.IdleTime ensures
that all is well when using gui's that don't have an IdleTime class.

Here is how to use the new code::

    def handler(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace(it.count,it.c.shortFileName(),'%2.4f' % (delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()
    it = g.IdleTime(c,handler,delay=500)
    if it: it.start()

The code creates an instance of the IdleTime class that calls the given handler at idle time, and no more than once every 500 msec.  Here is the output::

    handler 1 ekr.leo 0.5100
    handler 2 ekr.leo 1.0300
    handler 3 ekr.leo 1.5400
    handler 4 ekr.leo 2.0500
    handler 5 ekr.leo 2.5610
    handler done

Timer instances are completely independent.  For example:

    def handler1(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    def handler2(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 10:
            g.trace('done')
            it.stop()

    it1 = g.IdleTime(c,handler1,delay=500)
    it2 = g.IdleTime(c,handler2,delay=1000)
    if it1 and it2:
        it1.start()
        it2.start()

Here is the output::

    handler1  1 ekr.leo 0.5200
    handler2  1 ekr.leo 1.0100
    handler1  2 ekr.leo 1.0300
    handler1  3 ekr.leo 1.5400
    handler2  2 ekr.leo 2.0300
    handler1  4 ekr.leo 2.0600
    handler1  5 ekr.leo 2.5600
    handler1 done
    handler2  3 ekr.leo 3.0400
    handler2  4 ekr.leo 4.0600
    handler2  5 ekr.leo 5.0700
    handler2  6 ekr.leo 6.0800
    handler2  7 ekr.leo 7.1000
    handler2  8 ekr.leo 8.1100
    handler2  9 ekr.leo 9.1300
    handler2 10 ekr.leo 10.1400
    handler2 done
#@+node:ekr.20141120113801.152: *6* Delayed allocation of gnx's...
- fc.getLeoFile now calls ni.begin/end_holding
- Added gnx keyword arg to VNode ctor.
- Added traces to pd.restore_gnx

What I did:
    
- checked all calls to VNode ctor.
- checked all calls to getNewIndex.
- checked all calls to fileIndex =
#@+node:ekr.20141120113801.153: *6* Delayed allocation of vnodes
https://groups.google.com/d/msg/leo-editor/JWhlmJBiesk/RsC64VZ1gxQJ
#@+node:ekr.20141120113801.154: *6* Improved idle-time handling
@language rest

Simplified and generalized idle-time handling as follows:
    
- Removed g.app.afterHandler: g.app.idleTimeHook does the same thing now.
- The timer callback now calls g.app.idleTimeHook() if it exists.
- g.enableIdleTimeHook now has the following signature::
    
    def enableIdleTimeHook(idleTimeDelay=500,idleTimeHandler=None):
        
  The two args set g.app.idleTimeDelay and g.app.idleTimeHandler respectively.
  g.idleTimeHookHandler is used if idleTimeHandler is None.

The new code has these properties:
    
1. g.app.idleTimeHook() actually gets called only at idle-time,
2. There is no busy waiting, and
3. There is at least g.app.idleTimeDelay msec. between calls to g.app.idleTimeHook()

Here is an script illustrating the possibilities::

@language python

'''
A script illustrating interacting idle-time handlers.
Do Alt-x enable-idle-time-tracing before executing this script
'''
class Handlers:
    def h1(self):
        g.trace()
        g.enableIdleTimeHook(1000,self.h2)
    def h2(self):
        g.trace()
        g.enableIdleTimeHook(500,self.h1)
h = Handlers()
if g.app.idleTimeHook:
    g.disableIdleTimeHook()
else:
    g.enableIdleTimeHook(1000,h.h1)
#@+node:ekr.20141120113801.155: *6* Improved p.isAncestorOf and c.positionExists
- Added test for c.positionExists to p.isAncestorOf.
- Added v.isNthChildOf
- Rewrote c.positionsExists using v.isNthChildOf
#@+node:ekr.20141120113801.156: *6* Improved speed of selection logic
0. Added details timing traces throughout the selectHelper logic.
   These traces showed precisely where the performance bugs were.

1. updateSyntaxColorer now does nothing if the body text starts with @killcolor.

2. w.setSelectionRangeHelper and v.restoreCursorAndScroll had performance bugs
because they called code that computed the length of text slowly.

3. The solution: w.setSelectionRangeHelper and all setInsertPoint methods
now take an 's' keyword arg. In the selection logic, s is set to p.b.
If s is not None, the desired length is simply len(s)

As a result, w.setSelectionRangeHelper no longer calls lengthHelper.
lengthHelper used QTextCursor, which is *much* slower than getAllText.

4. Even though all w.setInsertPoint methods have an s keyword arg,
   v.restoreCursorAndScroll uses the following defensive code::
       
    try:
        w.widget.setInsertPoint(ins,s=v._bodyString)
    except TypeError:
        w.setInsertPoint(ins)
#@+node:ekr.20141120113801.157: *6* Leo imports importers & writers from home/.leo
Leo now imports from ~/.leo/plugins before importing from leo/plugins.

The new code is in at.createWritersData & helper and ic.at.createImportersData & their helpers.
#@+node:ekr.20141120113801.158: *7*  demo script
'''Load each plugins ~/.leo/plugins if possible, then from leo/plugins.'''
import glob
def report(message,kind,folder,name):
    g.trace('%7s: %5s %9s %s' % (message,kind,folder,name))
g.cls()
plugins1 = g.os_path_finalize_join(g.app.homeDir,'.leo','plugins')
plugins2 = g.os_path_finalize_join(g.app.loadDir,'..','plugins')
seen = set() # set of (folder,sfn)
for kind,plugins in (('home',plugins1),('leo',plugins2)):
    if g.os_path_exists(plugins):
        for folder in ('importers','writers'):
            path = g.os_path_finalize_join(plugins,folder)
            pattern = g.os_path_finalize_join(plugins,folder,'*.py')
            for fn in glob.glob(pattern):
                sfn = g.shortFileName(fn)
                if g.os_path_exists(fn) and sfn != '__init__.py':
                    moduleName = sfn[:-3]
                    if moduleName:
                        data = (folder,sfn)
                        if data in seen:
                            report('seen',kind,folder,sfn)
                        else:
                            m = g.importFromPath(moduleName,path) # Uses imp.
                            if m:
                                seen.add(data)
                                report('loaded',kind,folder,m.__name__)
                            else:
                                report('error',kind,folder,sfn)
                # else: report('skipped',kind,folder,sfn)
@language python
#@+node:ekr.20141120113801.159: *6* Leo now uses a new xml namespace
For several years the xml namespace line at the start of .leo files has been::

    <leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" >

The new line is::

    <leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
#@+node:ekr.20141120113801.160: *6* Rewrote & simplified k.getArg
What I did:
- Removed prefix arg to all calls to k.getArg.
  Not needed now that there is better convention for k.setLabelBlue.
- Removed protect argument from k.setLabelBlue.
  Some code now uses k.extendLabel to mix protect and unprotected parts of the label.
  
- k.fnc and k.getArgInstance now created by finishCreate.
  This guarantees that the c,k and log ivars are inited properly.
- Allow <tab> to escape to :r and :tabname code.
  This required several kludges.

#@+node:ekr.20141120113801.161: *6* Simplified gnx scan logic
1. createSaxVnode now does::
    
    v.fileIndex = ni.tupleToString(x.scanGnx(sax_node.tnx))
    
ni.tupleToString is substantially simpler than ni.toString.

This is the only call to tupleToString in Leo.

2. Removed ni.toString.

3. ni.scanGnx no longer converts n to an int.  It's going to become a string again anyway.

4. The new fc.setMaxNodeIndex *does* convert the n field to an int, but
   this very rarely happens.
#@+node:ekr.20141120113801.162: *6* Split qtGui.py into separate files
- qt_big_text.py contains support for the "big text" warning buttons.

- qt_commands.py contains several commands created by @g.commands.
  qt_gui.py now imports this file so the commands are actually defined.

- qt_events.py contains the LeoQtEventFilter class. The LeoKeyEvent class
  remains in leoGui.py: it is independent of gui.

- qt_frame.py contains most of the Qt-related code that creates the Leo
  window and frames.
  
- qt_idle_time.py contains the IdleTime class.

- qt_gui.py contains Qt-specific code that defines g.app.gui. leoGui.py is
  the gui-independent code and was essentially unchanged.

- qt_quickheadlines.py contains the QuickHeadlines class.

- qt_text.py contains most the code for Leo's Leo's text widgets.
  leoFrame.py contains a few gui-independent classes.

- qt_tree.py contains all the Qt tree code. It replaces baseNativeTree.py.

No longer used: baseNativeTree.py, qtGui.py. qtGui.py still exists, but
just prints a warning message when imported.
#@+node:ekr.20141120113801.163: *6* The @auto write code now uses writer plugins
What I did:
- at.createWritersData inits tables using the writers_dict in each plugin.
- at.writeOnAtAutoNode calls at.dispatch to find writers.
  An important escape hatch: at.writeOnAtAutoNode calls the *existing* rst.writer
  if the user deletes plugins/writers/rst.py.

Won't do:
- at.writeAllHelper has lots of special-case code, but that probably can't be helped.
- It would be way too dangerous to refactor the write code for @file, @shadow, etc.
#@+node:ekr.20141120113801.164: *6* Wanted: w.getTextLength and p/v.get_b_length
A head-slapping moment: the so-called high-level interfaced throughout
Leo's core to interact with Leo's text panes lacks a way of getting the
length of text *without* making a copy of the text.

This is more than a slight oversight: I imagine there are several place
were the code does s = w.getAllText() merely so it can use len(s)! This is
a huge strain on the GC for large p.b.

Worse, the absence of w.getTextLength() has lead to the most unfortunate
LeoQTextEditWidget.lengthHelper, which calculated the length of the text
using QTextCursor methods! This is catastrophically slow for large text.
This method was doubling node load times for large nodes.

@language rest

In other words, w.getTextLength() is an essential part of fixing git bug 28:
https://github.com/leo-editor/leo-editor/issues/28

But nooooooo... w.getTextLength() is far from easy to do. There is no
QTextEdit or QTextDocument method that delivers the length of the text!
This is a *huge* hole in the QTextEdit and QTextDocument api's, but there
is nothing we can do about that.

The simplest thing that could possibly work would be::

@language python

    def getTextLength(self):
        w = self.widget
        return len(w.getAllText())
        
@language rest

But this would be a step backwards because it hides the fact that it is
expensive.

It might be possible to cache the value of w.getAllText in an "text
changed" event handler in LeoQTextBrowser:(QTextBrowser). But I would like
to avoid this approach--any bug would lead to data loss or corruption. I
may play around with this, but for now it's not likely to happen. See below
for a workaround.

By analogy with w.getTextLength(), we can imagine a p.b_length method that
would simply return len(p.v._bodyString). This, at least, is worth doing.

===== Summary

w.getTextLength() isn't trivial.

Caching the value returned by w.getAllText() seems too dangerous.

As a work-around, the crucial node-selection logic will attempt to minimize
calls to w.getAllText. There, and *only* there, it should be possible to
create a *single* copy of the text and pass that copy around to all code
that needs it. It would be a complication, but a completely safe one.

Otoh, p/v.b_length are trivial and useful. They will be added asap.

-------------

Two parts to this reply:

===== Part 1: defining w.getTextLength

> w.getTextLength() isn't trivial...Caching the value returned by
w.getAllText() seems too dangerous.

Actually, defining w.getTextLength using a textChanged event handler in
LeoQTextBrowser is straightforward::

@language python

    def onTextChanged(self):
        '''The textChanged event handler.  Cached the text in self.leo_s.'''
        self.leo_s = s = g.u(self.toPlainText())

    def getTextLength(self):
        '''Return the length of all the text.'''
        if 1: # safe.
            s = g.u(self.toPlainText())
            if s != self.leo_s:
                g.trace('can not happen: text mismatch.')
                self.leo_s = s
            return len(self.leo_s)
        else: # fast
            return len(self.leo_s)
            
@language rest

We can use the "safe" version of getTextLength until we are *sure* the can
not happen message never happens ;-)

Otoh, we must be careful: onTextChanged will be called in the middle of the
node-switching logic.

===== Part 2: doing without w.getTextLength

Imo, the simplest thing that could possibly work is to avoid the extra call
to w.getAllText in the node switching logic in selectHelper.

Here are the relevant parts of selectHelper. (w is a LeoQTextEditWidget).

1. setBodyTextAfterSelect *already* calls w.getAllText() to get the
   "before" text. This is unavoidable.

The "after" text will be p.b, where p is the *new* position.

2. restoreCursorAndScroll calls w.setInsertPoint, which just calls
   w.setSelectionRangeHelper.

3. w.setSelectionRangeHelper is the problem It used to call the horribly
   slow lengthHelper. Now it calls w.getAllText()

But w.getAllText must be the new p.b! So the selectHelper logic could
simply pass an optional s argument to w.setInsertPoint and
w.setSelectionRangeHelper. If present, setSelectionRangeHelper will use s
rather than calling w.getAllText.

Imo, this is the safe, if not exactly elegant way.
#@+node:ekr.20141120113801.165: *6* c.executeScript adds '.' to sys.path
https://groups.google.com/forum/#!topic/leo-editor/cYWigOYtjUM

c.executeScript places '.' as the *second* element of
sys.path, following c.frame.openDirectory as before.
#@+node:ekr.20141120113801.166: *5* Features
#@+node:ekr.20141120113801.167: *6* New commands
#@+node:ekr.20141120113801.168: *7* Added focus-to-find/spell commands
The focus-to-spell command just makes the spell tab visible.

It would not be a good idea actually to transfer focus.
#@+node:ekr.20141120113801.169: *7* Added clone-find-parents command
As of rev 1d882d3. Leo supports an undoable clone-find-parents command.
Select a cloned node, then do:

    <alt-x>clone-find-parents<return>

This works somewhat like the clone-find-all command: it creates a node containing
clones of all the parents of the selected node.
#@+node:ekr.20141120113801.170: *7* Added clone-to-last-node
This does *not* change the selected node so it's easy to
clone several nodes.

Added c.cloneToLastNode.  
#@+node:ekr.20141120113801.171: *7* Added flatten-outline-to-node
Very useful when summarizing documentation nodes.
#@+node:ekr.20141120113801.172: *7* Added help-for-drag-and-drop command
#@+node:ekr.20141120113801.173: *7* Added idle-time commands
Added the following commands:
    
disable-idle-time-tracing
enable-idle-time-tracing
toggle-idle-time-tracing
disable-idle-time-events
enable-idle-time-events
toggle-idle-time-events
#@+node:ekr.20141120113801.174: *7* Added insert-file-name command
# The code is in leoEditCommands.py::insertFileName.
#@+node:ekr.20141120113801.175: *7* Added pylint command
When pylint is available on your machine, Leo's pylint
command will execute run pylint on all @<file> nodes in the
selected tree. This command is now available from the popup
menus created by the contextmenu plugin.

This command is a dynamic way of selecting files to check
with pylint. It is *much* easier to use than the old pylint
-r option in pylint-leo.py. There is no longer any need to
update a list of "recent" files. Hooray.

The command has significantly changed my work flow. I use
pylint much more often.

The details of the search process are as follows:

1. The command looks down the tree of the selected node,
   looking for @<file> nodes.
2. If now @<file> nodes are found, it looks up the tree,
   looking for @<file> nodes.
3. If the selected node is a clone, and no @<file> nodes
   have yet been found, it expands the search to all
   ancestors of all positions cloned to the selected node.

This means that you can check a file by selecting any
(possibly clone) node of the file.

**Important**: running pylint-leo.py is still often very
useful. In particular, I often run python pylint-leo.py -a
to check all files. Here is the recently improved docstring
for pylint-leo.py::

    '''
    This file runs pylint on predefined lists of files.
    
    The -r option no longer exists. Instead, use Leo's pylint command to run
    pylint on all Python @<file> nodes in a given tree.
    
    On windows, the following .bat file runs this file::
        python27 pylint-leo.py %*
    
    On Ubuntu, the following alias runs this file::
        pylint="python27 pylint-leo.py"
    '''
#@+node:ekr.20141120113801.176: *7* Added spell-as-you-type commands
Thanks to Terry Brown for these commands::

spell-as-you-type-toggle
  Enable / disable spell as you type mode.  When enabled, word ending
  keystrokes will put a short list of suggestions in the log window, if
  the word is unknown to the speller.  Only shows the first 5
  suggestions, even if there are more.

spell-as-you-type-next
  Cycle the word behind (left of, for ltr languages) the cursor through
  the full list of suggestions.

spell-as-you-type-undo
  Change the word behind (left of, for ltr languages) the cursor to
#@+node:ekr.20141120113801.177: *6* Improved commands
#@+node:ekr.20141120113801.178: *7* Improved find/replace-all commands
These commands now get their arguments from the Find Panel.

Changed the following methods:

generalChangeHelper,
minibufferFind/ReplaceAll,
searchWithPresentOptions,
setReplaceString,

Also fixed the bindings in create_find_buttons so buttons
are bound to the proper button-related methods. As a result,
the find-all and change-all buttons now work as expected.
#@+node:ekr.20141120113801.179: *7* (Optional) beautify command now uses PythonTidy
This is a major upgrade to the beautify command.

PythonTidy (tidy for short) does a full parse of the Python sources:
https://pypi.python.org/pypi/PythonTidy/

What I did today.  See the < < version info > > section for all the details::

1. Leonized tidy's sources: @file ../external/PythonTidy.py in in LeoPyRef.leo.

- Removed all pylint complaints and made other minor mods.
 
2. Suppressed features not appropriate for Leo:

- Adds shebang and encoding lines only for @<file> nodes.
- Suppress extra spacing between classes & functions.

3. Added settings to leoSettings.leo that control tidy operation:

    @bool tidy_add_blank_lines_around_comments =True
    @bool tidy_double_quoted_strings = False
    @bool tidy_keep_blank_lines = True
    @bool tidy_left_adjust_docstrings = False
    @int  tidy_lines_before_split_lit = 2
    @int  tidy_seps_before_split_line = 8

3. Fixed several important bugs:

- The original code deleted all comments because of a botch in Comments__init__.
- Tidy now properly handles the tidy_add_blank_lines_around_comments and
  tidy_double_quoted_strings settings.
#@+node:ekr.20141120113801.180: *7* Improved check outline
It now tests that all gnx's exist and are unique.
#@+node:ekr.20141120113801.181: *7* Added Yes To All and No To All buttons to dialogs
Added YesToAll and NoToAll capability to g.app.gui.runAskYesNoDialog
and uses this in the open file again? questions when opening Leo after a
crash.
#@+node:ekr.20141120113801.182: *7* Added more files to pylint -a & -p
Used glob to discover files, not static lists.
#@+node:ekr.20141120113801.183: *7* The clean-all-lines command strips trailing whitespace
#@+node:ekr.20141120113801.184: *6* Other features
#@+node:ekr.20141120113801.185: *7* Added some support for scintilla
I have been using a Scintilla widget in Leo's body pane today. It has been
the best incentive to improve it.

To enable it, set @bool qt-use-scintilla = True.

Almost everything works. It is certainly seems possible to do real work
safely and pleasantly.

The Scintilla code now honors the settings in @data qt-scintilla-styles,
but *only in leoSettings.leo, not myLeoSettings.leo. This is likely a bug
in the settings system, and I'll fix it soon.

Leo now switches between the native Scintilla colorizer and a custom,
do-nothing, colorizer depending on @language, @killcolor, etc. Creating a
custom Scintilla colorizer was unexpectedly easy. There is no native
Scintilla colorizer for @language rest. That will be the next custom
colorizer that I write.

Scintilla thinks Leo directives are decorators, so Leo directives are, in
effect, colorized.

No section references are ever colored. It *might* be possible to define a
custom colorizer that defers to a native colorizer in everything but
section references.

Most unit tests pass with @bool qt-use-scintilla = True. Something strange
is going on in the failing cases, but it doesn't seem strange enough to
cause real problems ;-) I'll be fixing these tests asap.

No other colorizing is available, but everything is in place to support
Scintilla's other native colorizers. They are:

AVS, Bash, Batch, CMake, CoffeeScript, CPP, CSS, D, Diff, Fortran77, HTML,
Lua, Makefile, Matlab, Pascal, Perl, PO, PostScript, POV, Properties,
Python, Ruby, Spice, SQL, TCL, TeX, Verilog, VHDL, YAML.
#@+node:ekr.20141120113801.186: *7* Added support for dart language
#@+node:ekr.20141120113801.187: *7* Added support for delegate languages
Allow colorizing for languages to be delegated to another language.

- Added g.app.delegate_language_dict, with three entries for David McNab.

- jEditColorizer.nameToRuleSetName now replaces the original language name
  with the delegated name.
  
There are two other changes you must make if you don't want
to use @language, as in your example with @nosent trees.

1. To write the proper delims for .hbs files, add the
   following entry in define_language_delims_dict in
   leoApp.py::

    "hbs" : "<!-- -->", # McNab: delegate to html.

2. To automatically use @language hbs in .hbs files, add the
   following entry in define_extension_dict in leoApp.py:
#@+node:ekr.20141120113801.188: *7* Added warning buttons when selecting large text
#@+node:ekr.20141120113801.189: *7* Eliminated cycle-all-focus command
Replaced by new focus-to-find and focus-to-spell commands.
#@+node:ekr.20141120113801.190: *7* Removed stand-alone globals
#@+node:ekr.20141120113801.191: *5* Plugins & leo/external 
#@+node:ekr.20141120113801.192: *6* Added livecode plugin
Then livecode-show command shows the live code evaluation pane. Hover on
the buttons for helpful tool-tips.

It currently has a dependency on https://pypi.python.org/pypi/meta
which you can install with

    pip install meta

The dependency on `meta` is for recursively turning AST node trees back
into printable identifiers like "m[m[5]]"

i.e.

   a = 7

is easy,

   m[m[5]] = 7

is not.
#@+node:ekr.20141120113801.193: *6* Added nodetags.py plugin
This is only an API for tags, but I feel like it should simplify the
process and allow someone to focus on the important bits, i.e. UI hooks,
rather than low-level details. Also, it's usable now for scripts.

Here is the docstring:

Provides node tagging capabilities to Leo

By Jacob M. Peck

API
----

This plugin registers a controller object to c.theTagController, which
provides the following API::

    tc = c.theTagController
    tc.get_all_tags() # return a list of all tags used in the current
outline, automatically updated to be consistent
    tc.get_tagged_nodes('foo') # return a list of positions tagged 'foo'
    tc.get_tags(p) # return a list of tags applied to the node at
position p; returns [] if node has no tags
    tc.add_tag(p, 'bar') # add the tag 'bar' to the node at position p
    tc.remove_tag(p, 'baz') # remove the tag 'baz' from p if it is in
the tag list

Internally, tags are stored in `p.v.unknownAttributes['__node_tags']` as
a set.

UI
----

The "Tags" tab in the Log pane is the UI for this plugin.  The bar at
the top is a search bar, editable to allow complex search queries.  It
is pre-populated with all existing tags in the outline, and remembers
your custom searches within the given session.  It also acts double duty
as an input box for the add (+) button, which adds the contents of the
search bar as a tag to the currently selected node.

The list box in the middle is a list of headlines of nodes which contain
the tag(s) defined by the current search string.  These are clickable,
and doing so will center the focus in the outline pane on the selected node.

Below the list box is a dynamic display of tags on the currently
selected node.  Left-clicking on any of these will populate the search
bar with that tag, allowing you to explore similarly tagged nodes.
Right-clicking on a tag will remove it from the currently selected node.

The status line at the bottom is purely informational.

The tag browser has set-algebra querying possible.  Users may search for
strings like 'foo&bar', to get nodes with both tags foo and bar, or
'foo|bar' to get nodes with either or both.  Set difference (-) and
symmetric set difference (^) are supported as well.  These queries are
left-associative, meaning they are read from left to right, with no
other precedence.  Parentheses are not supported. See below for more
details.

Searching
---------

Searching on tags in the UI is based on set algebra.  The following
syntax is used::

    <tag>&<tag> - return nodes tagged with both the given tags
    <tag>|<tag> - return nodes tagged with either of the given tags (or
both)
    <tag>-<tag> - return nodes tagged with the first tag, but not the
second tag
    <tag>^<tag> - return nodes tagged with either of the given tags
(but *not* both)

These may be combined, and are applied left-associatively, building the
set from the left, such that the query `foo&bar^baz` will return only
nodes tagged both 'foo' and 'bar', or nodes tagged with 'baz', but *not*
tagged with all three.

Tag Limitations
---------------

The API is unlimited in tagging abilities.  If you do not wish to use
the UI, then the API may be used to tag nodes with any arbitrary
strings.  The UI, however, due to searching capabilities, may *not* be
used to tag (or search for) nodes with tags containing the special
search characters, `&|-^`.  The UI also cannot search for tags of
zero-length, and it automatically removes surrounding whitespace
(calling .strip()).
#@+node:ekr.20141120113801.194: *6* Added viewrendered2 plugin
https://groups.google.com/d/msg/leo-editor/3dH_NSQ4TsQ/ueVewAn50ZcJ

https://groups.google.com/d/msg/leo-editor/BDzmytlSegw/C0IbSz0US54J

As mentioned in my previous post I'll attempt to elaborate on the plugin
I've used to make Leo more useful to me, in case it is useful for others
also. Apologies for the very long post, but I wanted get get all its
features and warts exposed here to get some feedback on whether others see
this as useful or that this is only valuable to me. If it's useful to
others then it may be worth polishing up quite a bit.

Why a better viewrendered plugin?
---------------------------------

I like to use reStructuredText (reST) for all of my note-taking, idea
development, project and task management and automation of desktop
activities (e.g. initiating a backup). You could say it is the control
center of my daily activities, including calculating and showing dashboards
of where I am and where I'm going.

This means I need a tool which seamlessly shows me the full-fidelity
browser-rendered version of what I am writing and be able to print my notes
for meetings, cut and paste nicely formatted output to my office e-mails
and documents, as well as show some of the material as a slideshow.

The existing *viewrendered* plugin couldn't seem to do what I needed
(especially math) and I was almost ready to abandon Leo again. This time I
bit the bullet and created a more capable renderer in viewrendered2 (VR2).
Initially I made a plugin that rendered, on demand, to my normal web
browser. This worked well, but I really thought live rendering like
"viewrendered" would be better, and for that I needed close control over
scroll positions etc. that I couldn't get with an external browser. So the
plugin became much more complex as I merged it with the existing
viewrendered plugin, but was ultimately more powerful and useful to me.

Objectives
-----------

* Show a "full" html representation of any reST node or tree, without an
  @rst root node, including more features than the existing viewrendered
  plugin:

  - proper html layout
  - math (mathjax, etc.)
  - clickable URLs
  - clickable hyperlinks within the page (e.g. TOC)
  - good quality zoom
  - cut and paste html with ctl-C
  - s5 slideshows
  - javascript
  - svg images
  - configurable css

* Allow showing of node tree rather than just the current node. This can
  give a better overview perspective of the tree contents.

* Be able to lock the rendering on the root node of a tree, to view the
  effect editing a sub-node within the larger html document.

* Provide proper rendering of any combination of node types in a tree, so long as
  they have been properly designated by @language directives (i.e. reST, text,
  code, css, ...).

* Allow viewing (and printing) of an entire source file from an @file type
root node.

* Be able to *export* any of these renderings to a full web-browser to take advantage
  of the large rendering window (especially for slideshows, as well as printing, saving output.
  
* Be able to integrate automatically executed code nodes intermingled with
  reST nodes to provide an automatic calculation-based "Notebook" or "Report"
  type output.

* Don't increase the dependencies of Leo.

Implementation
--------------

VR2 is implemented mostly as an ~600 line expansion of the update_rst
method in the viewrendered.py plugin. The text-oriented class used for
rendering in VR1 has been replaced by the QWebView class which provides the
full rendering functionality of a real web-browser. To make this flexible,
a toolbar has been attached to the top with a few controls.

Because I wanted to retain compatibility with VR1, I created the
viewrendered2.py plugin, but retained all the class naming which occurred
within VR1. This means that it remains compatible with the existing
mechanisms (like free_layout) of showing and creating panes for VR1. I
tried this with an expectation that it would fail, but it appears to work
without any unintended side-effects.

Tooltips have been added where Qt allows, with the philosophy that a user
shouldn't need a manual to use this pane.

VR2 has been used a lot under Windows 7 and a little under Ubuntu 13.10.

Issues / Limitations
--------------------

I use VR2 every few minutes every working day. However, VR2 is likely to
still have a lot of rough edges and, in particular, bugs that show up with
different work flows or css folder layouts etc. In fact, VR2 is still a
work in progress and therefore still being fiddled with, so bugs creep in
regularly.

But overall, my perception of its deficiencies are:

* Does not handle reST headings within the node bodies well (sometimes very
  slow render, blocking Leo).

  - VR2 attempts to reconcile reST headings that originate from explicit
    headings within the nodes against reST headings that are automatically
    generated by the node hierarchy. In many cases, this is impossible,
    resulting in many errors which drastically slows down rendering. -
    Recommend not using headings within the nodes themselves, leaving the
    node hierarchy to do this automatically.

* If the node triggers one of the special viewrendered node header types
  (@md, @image, @movie, @html) VR2 simply defaults to the old handlers for
  those types. This means it jumps back to whatever pane type VR1 uses, so
  the features of VR2 disappear. I suspect that VR2 could incorporate these
  types into the new version and retain these new features. I should look
  at that.
    
* Doesn't integrate with rst3 plugin, especially honouring @others etc.
  There are some conflicts in objectives, so this may never be fully
  resolved. It would probably make sense for rst3 settings to get used for
  VR2 as well, along with additional VR2 specific settings. Currently, VR2
  has its own @settings-style settings. The rst3 code is not used.
  
* For slideshow purposes, a patch to docutils s5_writer is required to be
  able to handle an arbitrary hierarchy of nodes (forces all headings to
  start a new slide). Otherwise, only the 2nd level nodes (from the root)
  force a new slide.
  
* The integration of VR2 code into the existing viewrendered plugin code is
  rudimentary. I took the shortcut of not trying to understand this code
  well and confining my integration to the rst rendering only. Better
  integration would be a good future step.

With the plugin being able to execute javascript etc. there may be some
form of security issue, but I can't see it myself (given that Leo can
execute arbitrary python code anyway). Any thoughts?

Future?
-------

* Expand the export button if pandoc is installed, adding optional output
  formats such as docx, odt, plus additional slideshow formats. * Use new
  reST functionality to replace other media viewrendered methods for
  images, svg, movies, etc. * Integrate better with rst3?

Conclusion
----------

* I've attached the source as well as a bunch of screenshots. Feel free to
try out the source by putting viewrendered2 into your @enabled-plugins
instead of the usual viewrendered. I'd be interested in whether it works or
not - expect bugs to show up!

* I'm looking for feedback on whether this appears useful to others and not
just me. If so, it should probably be polished a bit more before being used
widely. Perhaps greater understanding of the existing viewrendered plugin
operation would help me here.
#@+node:ekr.20141120113801.195: *6* Added wikiview plugin
Hides text in the body editor, each time a new node is selected. Makes::

  file://#some-->headlines-->mynode     appear as mynode,
  http://www.google.com/search          appear as search, and
  `Python <https://www.python.org/>`_   appear as Python
  
There is a tiny dot to the left or right of the visible
text. Clicking that area, or clicking and dragging, or
clicking and using shift arrows *through* that area exposes
the hidden text.

full docs:
https://raw.githubusercontent.com/leo-editor/leo-editor/master/leo/plugins/wikiview.py

This plugin only addresses the visual aspects of wiki links.  Leo
already supports internal wikilinks as
file://#headline-->other%20headline-->Setup, which will now appear as
just 'Setup' with this pluing active.

#@+node:ekr.20141120113801.196: *6* Converted 7 plugins so they work with PyQt5
active_path.py, attrib_edit.py, contextmenu.py, graphcanvas.py,
notebook.py, projectwizard.py, stickynotes.py
#@+node:ekr.20141120113801.197: *6* leo/external/leoftsindex.py
From: Terry Brown <terry_n_brown@yahoo.com>

Indexing files for full text search

Just pushed leo/external/leoftsindex.py:

Stand alone GUI free index builder for Leo's full text search system::

  python leoftsindex.py <file1> <file2> <file3>...

If <file> does not contain '#' it's assumed to be a .leo file
to index, and is indexed.

If <file> does contain '#' it's assumed to be a .leo file
containing a list of .leo files to index, with the list in
the node indicated by the UNL after the #, e.g.::

   path/to/myfile.leo#Lists-->List of outlines

In the latter case, if the node identified by the UNL has children,
the list of files to scan is built from the first line of the body
of each child node of the identified node (works well with bookmarks.py).
If the node identified by the UNL does not have children, the
node's body is assumed to be a simple text listing of paths to .leo files).

note::
    
    It may be necessary to quote the "file" on the command line,
    as the '#' may be interpreted as a comment delimiter::
        
        python leoftsindex.py "workbook.leo#Links"
#@+node:ekr.20141120113801.198: *6* Rewrote at_produce plugin
This plugin used ancient coding technology, created menu items instead of
minibuffer commands, did not report progress and was probably not thread
safe.

All these defects have now been remedied. It could be quite useful in some
situations. For example, suppose node P has this body text::

    @produce echo pylint commands
    @produce pylint -v
    @produce pylint -f core\leoAtFile.py
    @produce pylint -g

Selecting node P and running the at-produce-selected command produces these
messages in the log pane::

    @produce pylint -g
    @produce pylint -g
    @produce pylint -g
    @produce pylint -g
    at-produce done

And produces a node whose headline is::

    produce.log from Sun Sep 21 06:35:37 2014

And whose body text is::

    produce: echo pylint commands
    pylint commands
    ===============
    produce: pylint -v
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -v
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -v
    pylint-leo.py 1.1.0,
    astroid 1.0.1, common 0.61.0
    Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
    ===============
    produce: pylint -f core\leoAtFile.py
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -f core\leoAtFile.py
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -f core\leoAtFile.py
    pylint-leo.py: core\leoAtFile.py
    time:  5.000 sec.
    ===============
    produce: pylint -g
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -g
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -g
    pylint-leo.py: plugins\free_layout.py
    pylint-leo.py: plugins\nested_splitter.py
    pylint-leo.py: plugins\qt_commands.py
    pylint-leo.py: plugins\qt_events.py
    pylint-leo.py: plugins\qt_frame.py
    pylint-leo.py: plugins\qt_idle_time.py
    pylint-leo.py: plugins\qt_gui.py
    pylint-leo.py: plugins\qt_text.py
    pylint-leo.py: plugins\qt_tree.py
    time: 40.073 sec.
    ===============
#@+node:ekr.20141120113801.199: *5* Settings & command-line options
#@+node:ekr.20141120113801.200: *6* Added --no-persist command-line option
removed new_auto switch in leoAtFile.py

added g.app.at_auto_persist

c.persistenceController exists only if g.app.auto_persist is True
#@+node:ekr.20141120113801.201: *6* Added --trace-plugins option
#@+node:ekr.20141120113801.202: *6* Added @int max-pre-loaded-body-chars
#@+node:ekr.20141120113801.203: *6* Added @bool auto-scroll-find-tab
The default is True, so as to enable the "fix" to bug
1254861: find - ctrl-f doesn't ensure find input field
visible https://bugs.launchpad.net/leo-editor/+bug/1254861

I found the new behavior extremely unpleasant. For me, it
was the worst fit-and-finish issues with Leo.
#@+node:ekr.20141120113801.204: *6* Added support for html handlebar syntax coloring
These are colored with the previously unused literal3 tag,
so you specify the color with:

    @color html_literal3_color = pink
#@+node:ekr.20141120113801.205: *6* Fully parameterized style sheet
Almost all settings in @data qt-gui-plugin-style-sheet in leoSettings.leo
are now defined in terms of @values. Traditional Leo settings nodes
(@strings, @color, @font, etc.) define these @values.

Most users, and certainly all newbies, will never have to touch, or even
look at, @data qt-gui-plugin-style-sheet. This is a really good thing,
because the slightest syntax error silently messes up everything that
follows.

Notes:

1. There is now a node called "Basic Fonts (change these first)"
   This node contains the basic font definitions. Changing only the
   settings in this tree (in myLeoSettings.leo, of course) should be enough
   to get Leo looking pretty much as it was.

2. Don't even *think* about changing @data qt-gui-plugin-style-sheet.
   Really, the whole point of this exercise is to be able to change all
   aspects of Leo's appearance without touching this stylesheet. As Terry
   points out, there will always be a place for @data qt-gui-user-style-sheet

3. In an emergency, there is at present a node called "OLD
   qt-gui-plugin-style-sheet" that you could use to revert to the old
   settings. Just rename it and copy it to your myLeoSettings.leo.

4. The new settings scheme will moot the need for leo10pt.leo, leo12pt.leo
   and all the rest. Instead, all font sizes are now defined in terms of
   three intermediate settings: @string font-size, @string medium-font-size
   and @string small-font-size. Changing just these three settings will
   suffice to change *all* the font sizes used in Leo.

5. When things don't look right, I execute this script::

    c.styleSheetManager.print_style_sheet()

This prints the complete stylesheet to the console. What I mainly look for
are lines like::

    background-color: @some-setting

An @value as the value of a setting indicates that no substitution took
place, that is, that there is no node::

    @string some-setting = aValue

Any user that wants to roll their own @data node will want to be aware of
this technique.

5. The @data qt-gui-**user**-style-sheet setting is deprecated. Indeed,
   @data qt-gui-**plugin**-style-sheet now takes care to define almost
   everything that any user would want to define. myLeoSettings.leo should
   contain overrides of only the @color and @string nodes in
   leoSettings.leo.
#@+node:ekr.20141120113801.206: *6* Leo stylesheets now support all color names in leoColor.py
For example, this setting works without any explicit definition of mistyrose2.
    
    @color head-bg = @mistyrose2
#@+node:ekr.20141113102829.7: *4* Leo 5.0b2 release notes
Leo 5.0 beta 2                  November 17, 2014

Leo 5.0b2 is now available at:
http://sourceforge.net/projects/leo/files/Leo/

This release fixes several installation issues
and updates installation instructions for Linux/Ubuntu.

Leo is a PIM, an IDE and an outliner.
Video tutorials: http://leoeditor.com/screencasts.html
Text tutorials: http://leoeditor.com/tutorial.html

The highlights of Leo 5.0
--------------------------

* Better compatibility with vim, Emacs, pylint and PyQt:
    - Optional native emulation of vim commands.
    - Full support for Emacs org-mode outlines.
    - Full support for Vim .otl outlines.
    - Better support for pylint.
    - Support for both PyQt4 and PyQt5.
* Better handling of nodes containing large text:
    - Idle time syntax coloring eliminates delay.
    - Optional delayed loading of large text.
* Power features:
    - Command history for minibuffer commands.
    - Leo available via github repository.
    - File name completion.
    - Cloned nodes expand and contract independently.
    - @data nodes can be composed from descendant nodes.
    - No need to change Leo's main style sheet:
      it can be customized with @color and @font settings.
    - @persistence nodes save data in @auto trees.
    - A pluggable architecture for @auto nodes.
    - The style-reload command changes Leo's appearance instantly.
* Important new plugins for tagging, display and node evaluation.
* For beginners:
    - Leo's default workbook files contains Leo's quickstart guide.
* Hundreds of new/improved features and bug fixes.

Links:
------
Leo:       http://leoeditor.com
Docs:      http://leoeditor.com/leo_toc.html
Tutorials: http://leoeditor.com/tutorial.html
Videos:    http://leoeditor.com/screencasts.html
Forum:     http://groups.google.com/group/leo-editor
Download:  http://sourceforge.net/projects/leo/files/
Github:    https://github.com/leo-editor/leo-editor
Quotes:    http://leoeditor.com/testimonials.html
#@+node:ekr.20141113102829.8: *5* Highlights
#@+node:ekr.20141113102829.9: *6* Better integration with Vim, Emacs & pylint
#@+node:ekr.20141113102829.10: *7* vim mode
See: http://leoeditor.com/vimBindings.html#using-leo-s-native-vim-mode

do_visual_mode will extend the selection if visual_line_mode is True.

Affected methods: vc.vim_V and vc>do_visual_mode.

It would be good if LeoQTextEditWidget.setSelectionRangeHelper could handle
insert points in the middle of a text selection, but at present it can't.
#@+node:ekr.20141113102829.11: *7* Better support for pylint
Created g.run_pylint so pylint can run unmodified. This runs pylint (with
optional Sherlock tracing) in a separate process, thereby allowing Leo to
run pylint unchanged.

What I did:

1. pylint-leo.py: run now runs the following command in a separate process::

    <python> -c "import leo.core.leoGlobals as g; g.run_pylint(<args>)"
    
2. g.run_pylint uses Sherlock tracing if requested.

    
#@+node:ekr.20141113102829.12: *7* Full support for org-mode (.org) and vimoutline (.otl) files
Note: persistence applies to @auto-vimoutline-mode and @auto-org-mode

- Supported @auto-org-mode and @auto-vimoutline-mode
- Created importers and writers for .org and .otl files.
#@+node:ekr.20141113102829.13: *6* Power features
#@+node:ekr.20141113102829.174: *7* Added command history
After Alt-x puts you in the minibuffer, you can now use UpArrow and
DownArrow keys to cycle through previous "complex" commands, that is,
commands entered via Alt-x<command-name><return>.

For example, Alt-x UpArrow is roughly equivalent to Ctrl-p.

This completes one of the top four wishlist items at:
https://github.com/leo-editor/leo-editor/issues/93
#@+node:ekr.20141113102829.14: *7* @data nodes can now be composed from a tree of nodes
How did we ever live without this?

@data nodes, like @data qt-gui-plugin-style-sheet may now be composed of
the body text of the @data node itself, concatenated to the body text of
all its descendants, in outline order.

For example, @data qt-gui-plugin-style-sheet node consists of some general
comments, with descendant nodes for the body pane, tree pane, etc. etc.
There is no limit of nesting: the Plugins node has a child for each plugin
that uses style sheets.

Not only does this new arrangement make it far easier to find the style
sheet of interest, it makes debugging style sheets easier. Typically, an
error in any part of the style sheet invalidates the whole style sheet.
With the new organization, one can swap nodes into or out of the @data node
to find the invalid node or nodes.

Two fine points about the concatenation of data:

1. Descendant nodes whose headlines start with '@' do not become part of
   the data. At present, no @data nodes have descendants, but this
   convention does something reasonable if nodes like @int or @string were
   descendants of an @data node.

2. The @data parser adds a newline to every "fragment" if necessary. This
   doesn't seem to matter for style sheets, but it could matter for other
   kinds of @data data.
#@+node:ekr.20141113102829.15: *7* Clones expand and contract independently
https://groups.google.com/forum/#!topic/leo-editor/Wd0NtBLEZZk

Leo now stores "ephemeral" or position-related data **in vnodes*. This is a
completely new idea in Leo's history!
#@+node:ekr.20141113102829.16: *7* File name completion
The :r, :tabnew, insert-file-name and  file-open-by-name commands now have file-name completion

I bind Ctrl-O to file-open-by-name to bypass the Windows open file dialog.
#@+node:ekr.20141113102829.17: *7* Better support for nodes containing large text
The user can lose text if they start typing before the body text completely loads!

- Added c.max_pre_loaded_body_chars = c.config.getInt('max-pre-loaded-body-chars')

- The "dummy" body text now contains a warning to wait until the text fully loads.
#@+node:ekr.20141113102829.18: *7* Leo now colors text at idle time
Leo now uses an all-Python replacement for the QSyntaxHighlighter class.

This fixes git bug 28: https://github.com/leo-editor/leo-editor/issues/28
Leo hangs when a node with too large body is selected

To see the effect of the new code:

1  Create a node with *lots* of colored text.
2. Move the cursor to the last line of the text.
3. Select another node, and then move back to the "big" node.

You should see the end of the text all in black at first, and then become
colored later.

In the meantime, Leo is responsive to all commands, mouse clicks, etc.
#@+node:ekr.20141113102829.167: *7* Fully parameterized style sheet
Almost all settings in @data qt-gui-plugin-style-sheet in leoSettings.leo
are now defined in terms of @values. Traditional Leo settings nodes
(@strings, @color, @font, etc.) define these @values.

Most users, and certainly all newbies, will never have to touch, or even
look at, @data qt-gui-plugin-style-sheet. This is a really good thing,
because the slightest syntax error silently messes up everything that
follows.

Notes:

1. There is now a node called "Basic Fonts (change these first)"
   This node contains the basic font definitions. Changing only the
   settings in this tree (in myLeoSettings.leo, of course) should be enough
   to get Leo looking pretty much as it was.

2. Don't even *think* about changing @data qt-gui-plugin-style-sheet.
   Really, the whole point of this exercise is to be able to change all
   aspects of Leo's appearance without touching this stylesheet. As Terry
   points out, there will always be a place for @data qt-gui-user-style-sheet

3. In an emergency, there is at present a node called "OLD
   qt-gui-plugin-style-sheet" that you could use to revert to the old
   settings. Just rename it and copy it to your myLeoSettings.leo.

4. The new settings scheme will moot the need for leo10pt.leo, leo12pt.leo
   and all the rest. Instead, all font sizes are now defined in terms of
   three intermediate settings: @string font-size, @string medium-font-size
   and @string small-font-size. Changing just these three settings will
   suffice to change *all* the font sizes used in Leo.

5. When things don't look right, I execute this script::

    c.styleSheetManager.print_style_sheet()

This prints the complete stylesheet to the console. What I mainly look for
are lines like::

    background-color: @some-setting

An @value as the value of a setting indicates that no substitution took
place, that is, that there is no node::

    @string some-setting = aValue

Any user that wants to roll their own @data node will want to be aware of
this technique.

5. The @data qt-gui-**user**-style-sheet setting is deprecated. Indeed,
   @data qt-gui-**plugin**-style-sheet now takes care to define almost
   everything that any user would want to define. myLeoSettings.leo should
   contain overrides of only the @color and @string nodes in
   leoSettings.leo.
#@+node:ekr.20141113102829.20: *7* The style-reload command changes Leo's appearance instantly
The style-reload reloads all visual settings.

Suppose you have the following @button node:

    @button reload-styles
    c.k.simulateCommand('style-reload')

And suppose you have the following setting in your local @setting tree::

    @string font-size = 12pt

Change the setting to 10pt (or 14pt), click the button, and see what happens :-)

The present code doesn't deal with themes, although there is some commented
out that hints about what might be done.
#@+node:ekr.20141113102829.21: *7* A plugable architecture for @auto nodes
The leo/plugins/importers folders now contains importer plugins.

The leo/plugins/writers folders now contain writer plugins.

Both importer and writer plugins can defined new kinds of @auto nodes.

Importers and writers can register either @auto-names or file extensions.
For example, @auto x.xyzzy will use both the importer and the writer for
the .xyzzy extension, that is, importers/test.py and writers/test.py. So,
for *unique* extensions, there is no need to use a separate @auto name, you
can just use @auto.
#@+node:ekr.20141113102829.22: *6* Leo's default workbook contains Leo's quickstart guide
The default workbook contains both the cheat sheet and an example from the
rst3 tutorial.

#@+node:ekr.20141113102829.23: *5* Bugs fixed
Over 70 bugs have been fixed.
#@+node:ekr.20141115093034.1: *6* Bugs fixed in 5.0b2
#@+node:ekr.20141117073519.6: *7* Fixed bug  38: autocompleter gives a strange traceback
https://github.com/leo-editor/leo-editor/issues/38

Fixed by Terry Brown at e8c0e27.
#@+node:ekr.20141117073519.8: *7* Fixed bug  78?: find-next target not always scrolled into view
https://github.com/leo-editor/leo-editor/issues/78

It's hard to know whether the change did anything.  It does not appear to have hurt.

find.showSuccess now sets p.v.scrollBarSpot = None, which prevents v.restoreCursorAndScroll
from altering the vertical scrollbars.
#@+node:ekr.20141117073519.7: *7* Fixed bug  80: Find-previous fails at last node with mouse click
https://github.com/leo-editor/leo-editor/issues/80

Fixed at 614817a, October 26, 2014.
#@+node:ekr.20141117073519.5: *7* Fixed bug 101: IPython issues
https://github.com/leo-editor/leo-editor/issues/101

https://bugs.launchpad.net/leo-editor/+bug/1228099
Cancelling save of dirty untitled commander doesn't work with --ipython
Works for me.

https://bugs.launchpad.net/leo-editor/+bug/1258512
_leo.c not working from IPython
Improved the documentation of the "c" property.
#@+node:ekr.20141115093034.4: *7* Fixed bug 102: Loading @file node with embedded code broken
https://github.com/leo-editor/leo-editor/issues/102

The fix was to call c.os_path_finalize/_join instead of
g.os_path_finalize_join in two places in the read logic.
#@+node:ekr.20141117073519.11: *7* Fixed bug 103: Installation Issues on Linux
https://github.com/leo-editor/leo-editor/issues/103

Where are we?
#@+node:ekr.20141115093034.5: *7* Installer window now shows version
#@+node:ekr.20141117073519.4: *7* Investigated bug 66: support @path with md importer/writer/rclick
https://github.com/leo-editor/leo-editor/issues/66

Works for me.
#@+node:ekr.20141117073519.3: *7* Made sure the .json file is part of the .zip file.
https://github.com/leo-editor/leo-editor/issues/104
https://github.com/leo-editor/leo-editor/issues/103
#@+node:ekr.20141113102829.170: *6* Bugs fixed in 5.0b1
#@+node:ekr.20141113102829.234: *7* Fixed
#@+node:ekr.20141113102829.173: *8* The spell checker handles apostrophes correctly
Previously, when checking "didn't" the spell checker would complain that
"didn" wasn't in the dictionary. Now it checks (and accepts) "didn't".

We have all been putting up with this annoyance for *far* to long. Changing
just two lines of code was all that was required.
#@+node:ekr.20141113102829.190: *8* fixed bug 1159490: "Open with" fails to copy changes by external editor back to Leo-Editor node
https://bugs.launchpad.net/leo-editor/+bug/1159490

The solution is to change the following setting in leoSettings.leo::
    
    @bool open_with_save_on_update = True
#@+node:ekr.20141113102829.192: *8* Fixed bug 1338773: Autocompleter error
https://bugs.launchpad.net/leo-editor/+bug/1338773
Autocompleter error

Added the following defensive code::

    try:
        self.deleteLater()
    except RuntimeError:
        # Avoid bug 1338773: Autocompleter error
        pass
#@+node:ekr.20141113102829.199: *8* Fixed bug 1338172: ReplaceAll will not replace newlines indicated as \n in target string
https://bugs.launchpad.net/leo-editor/+bug/1338172
ReplaceAll will not replace newlines indicated as \n in target string

Using regX , I can search on a pattern and replace it with a string that
includes "\n" as a newline in the transformed string.

If I do a simple search and replace-search from the Find pane that works
(I'm searching within the body of a single node).

However, if I do a Replace All, the "\n" is not translated into a newline;
it remains as is and appears as "\n" in the transformed string.

Also, I can't seem to get the replace-all command to work from the
minibuffer line; it only does a single replace.
#@+node:ekr.20141113102829.224: *8* Fixed bug 92: Tab loses focus when executing a button defined in an unopened settings file
https://github.com/leo-editor/leo-editor/issues/92
#@+node:ekr.20141113102829.227: *8* Fixed bug 66: errors inhibited read @auto foo.md
https://github.com/leo-editor/leo-editor/issues/66
errors inhibited read @auto foo.md

The markdown code is now similar to the @auto-rst code.

Added some kludgey code to handle underlining.
#@+node:ekr.20141113102829.228: *8* Disable activate/deactivate logic
LeoQtGui.onActivate/DeactiveEvent

This fixed several focus problems.
#@+node:ekr.20141113102829.229: *8* fixed pythonw bug
The fix was to define out in the ctor of SaxContentHandler.
#@+node:ekr.20141113102829.24: *6* Bugs fixed in 5.0a2
- Leo's desktop button now works properly with Python 3.x.
  The underlying cause was that Leo did not work with python34\pythonw.exe.

- Fixed name of a Qt class in richtext.py plugin.
#@+node:ekr.20141113102829.25: *6* Bugs fixed in 5.0a1
#@+node:ekr.20141113102829.26: *7* Fixed 14 github bugs
#@+node:ekr.20141113102829.27: *8* Fixed bug 12: when hoisted, the (alt-)arrow keys can't navigate to the top node
https://github.com/leo-editor/leo-editor/issues/12

The fix was to p.isVisible.
#@+node:ekr.20141113102829.28: *8* Fixed bug 28: Leo hangs when a node with too large body is selected
https://github.com/leo-editor/leo-editor/issues/28

Summary post:
https://groups.google.com/d/msg/leo-editor/b6TszFS_6NQ/gJrlRkqH9_oJ
#@+node:ekr.20141113102829.29: *8* Fixed bug 31: 'undo' on a freshly-loaded outline
https://github.com/leo-editor/leo-editor/issues/31
'undo' on a freshly-loaded outline containing chapters removes chapters

Chapter.afterCreateChapter does not push undo data when cc.initing is True.
#@+node:ekr.20141113102829.30: *8* Fixed bug 35: leoBridge sometimes assigns the same GNX to two distinct vnodes
https://github.com/leo-editor/leo-editor/issues/35
leoBridge sometimes assigns the same GNX to two distinct vnodes

c.initObjects sets c.hiddenRootNode.fileIndex to 'hidden-root-vnode-gnx'

fc.getLeoFile calls the new fc.setMaxNodeIndex after reading all nodes.
#@+node:ekr.20141113102829.31: *8* Fixed bug 36: @auto file not found produces a script error
https://github.com/leo-editor/leo-editor/issues/36

The report seems misleading: it says this happens when Leo tries to load an
@auto file that is in the outline but which was erased outside Leo,
but it worked for me.

I did add a guard in g.recureiveUNLFind to ensure that the IndexError shown
in the bug report can never happen.
#@+node:ekr.20141113102829.32: *8* Fixed bug 50: Important body text lost switching @file to @auto-rst
https://github.com/leo-editor/leo-editor/issues/50
Important: body text lost switching @file to @auto-rst

This case is so dangerous that Leo refuses to create the file and instead
reverts to the previous @file node.

Changes:
    
- v.at_read is now a dict: keys are full file names; values are lists of headlines.
- at.shouldPromptForDangerousWrite returns True if p.h is not in v.at_read.
- at.promptForDangerousWrite issues a warning and reverts the headline
#@+node:ekr.20141113102829.33: *8* Fixed bug 59: drag and drop: target too small
https://github.com/leo-editor/leo-editor/issues/59

When a file is dropped into any part of the Leo window, if the cursor is
not on a node it goes to the top or bottom of the tree as a root node.
#@+node:ekr.20141113102829.34: *8* Fixed bug 60: create relative paths & urls when dragging files to Leo
https://github.com/leo-editor/leo-editor/issues/60

It would be nice for Drag and drop files to have relative paths,taking into
account the @path settings of the part of the tree they're dropped into
(currently it is relative to the .leo file).
#@+node:ekr.20141113102829.35: *8* Fixed bug 63: refresh-from-disk does not clear big text load delay UI
https://github.com/leo-editor/leo-editor/issues/63
#@+node:ekr.20141113102829.36: *8* Fixed bug 64: https://github.com/leo-editor/leo-editor/issues/64
https://github.com/leo-editor/leo-editor/issues/64
#@+node:ekr.20141113102829.37: *8* Fixed bug 74: problems with @button if defined in myLeoSettings.leo
https://github.com/leo-editor/leo-editor/issues/74

What I did:

- ScriptingController now uses *gnxs* (not vnodes!) to detect duplicate buttons.
- Use AtButtonCallback for *all* buttons.
- QtIconBarClass.setCommandForButton always calls
  ScriptingController.build_rclick_tree.
- build_rclick_tree no longer assumes that command_p exists.

Rev 8413e2d fixes an important bug in the new code: "remote"
buttons (buttons defined in settings files) now work if the
settings file is not open.

There are some tricky details that must be handled. As an
example, consider a button defined as follows in
myLeoSettings.leo:

    @button print p.h
    print(p.h)

Detail 1: Leo must open myLeoSettings.leo to find the
@button node. Unlike the Goto Script rclick item, the search
does *not* leave myLeoSettings.leo open. That would be too
great a side effect of clicking the @button node!

Detail 2: We don't want to open myLeoSettings.leo every time
the user clicks the buttons, so the first time the user does
so the script is saved (cached). If the user clicks the
button later the cached value is used.

Detail 3: Caching is used "forever" (while Leo remains
open), even if the user opens myLeoSettings.leo and changes
the script. Sorry, this can't be helped. Don't ask me to
change this.

Detail 4: The new code is careful to execute the script in
the commander in which the button is *located*, not in the
commander in which the button is defined.

Report:

Putting @button definitions in myLeoSettings.leo (in an @buttons tree)
makes them available in all Leo files, a nice feature. Two problems:

- The buttons lack the 'Goto Script' rclick feature in all .leo files.
- There are duplicate buttons in myLeoSettings.leo

#@+node:ekr.20141113102829.38: *8* Fixed bug 75: write-opml-file always produces an empty file
https://github.com/leo-editor/leo-editor/issues/75
write-opml-file always produces an empty file

leoOPML.py's docstring needs updating.

Improved the packaging as follows:

- The leoOPML plugin no longer monkey patches any part of the FileCommands
  class. Instead the plugin sets the c.opmlController ivar.

- fc.writeToFileHelper calls c.opmlController.putToOPML(owner=self).
    
- OpmlController.putToOPML is just PutToOPML(owner) where PutToOPML is a
  class that creates the opml using the owner's put method.
#@+node:ekr.20141113102829.39: *8* Fixed bug 76: erroneous clone markers in @auto trees
https://github.com/leo-editor/leo-editor/issues/76
erroneous clone markers in @auto trees

The fixes were to several methods of the PersistenceDataController class.
#@+node:ekr.20141113102829.40: *8* Fixed bug 78: F3 find-next target not always highlighted
https://github.com/leo-editor/leo-editor/issues/78

This is a scrolling problem, not a failure to select text.

Changed the call to w.see in find.showSuccess.
#@+node:ekr.20141113102829.41: *7* Fixed 20+ Launchpad bugs
#@+node:ekr.20141113102829.53: *8* Fixed bug 1028986: create relative urls when dragging binary files to Leo
https://bugs.launchpad.net/leo-editor/+bug/1028986
create relative urls when dragging binary files to Leo

This bug was fixed by #60: 
https://github.com/leo-editor/leo-editor/issues/60
create relative paths & urls when dragging files to Leo

Modified dropEvent and its helpers.

Added createLeoFileTree and isLeoFile.

Regular drag of .leo files from a file folder works like the open-outline
command.

Ctrl-drag of .leo files from a file folder copies all nodes of the .leo
file to the receiving outline.

#@+node:ekr.20141113102829.54: *8* Fixed bug 1041906: underlying C/C++ object has been deleted
https://bugs.launchpad.net/leo-editor/+bug/1041906

Changed LeoQtTree.closeEditorHelper as follows:
    
- Call w.setItemWidget(item,0,None) to make sure e is never referenced again.
    
- Catch RuntimeError exceptions.
#@+node:ekr.20141113102829.55: *8* Fixed bug 1090950: refresh from disk - cut node resurrection
Fixed bug 1090950: refresh from disk - cut node resurrection.
https://bugs.launchpad.net/leo-editor/+bug/1090950

refresh_rclick_cb in contextmenu.py now just calls c.refreshFromDisk,
which calls c.recreateGnxDict() before reading any file.

Also created the new refresh-from-disk command and the corresponding item in the File menu.
#@+node:ekr.20141113102829.56: *8* Fixed bug 1185933: insert-headline-time should insert at cursor
https://bugs.launchpad.net/leo-editor/+bug/1185933

Note: the insert-headline-time command must be bound to a shortcut in order for this to work.
#@+node:ekr.20141113102829.57: *8* Fixed bug 1228312: Find tab selected in log pane disables Minibuffer
https://bugs.launchpad.net/leo-editor/+bug/1228312

This was the so-called "greedy checkbox bug".
#@+node:ekr.20141113102829.58: *8* Fixed bug 1228452: related to the radio buttons in the Find pane
https://bugs.launchpad.net/leo-editor/+bug/1228452

#@+node:ekr.20141113102829.59: *8* Fixed bug 1228458: Inconsistency between Find-forward and Find-backward
https://bugs.launchpad.net/leo-editor/+bug/1228458
#@+node:ekr.20141113102829.60: *8* Fixed bug 1231656: File-Compare-Leo-Files leaves other file open-count incremented
https://bugs.launchpad.net/leo-editor/+bug/1231656

This bug may already have been fixed, but just to make sure compareLeoFiles
now calls g.app.forgetOpenFile
#@+node:ekr.20141113102829.61: *8* Fixed bug 1244461: Numpad 'Enter' key does not work in minibuffer
https://bugs.launchpad.net/leo-editor/+bug/1244461

LeoQtEventFilter.qtKey now changes a toString value of 'Enter' to 'Return'
#@+node:ekr.20141113102829.62: *8* Fixed bug 1245535: API allows headlines to contain newlines
https://bugs.launchpad.net/leo-editor/+bug/1245535
#@+node:ekr.20141113102829.63: *8* Fixed bug 1245616: Autocomplete ? function...does not work
https://bugs.launchpad.net/leo-editor/+bug/1245616
#@+node:ekr.20141113102829.64: *8* Fixed bug 1251252: Minibuffer commands created by mod_scripting.py have no docstrings
https://bugs.launchpad.net/leo-editor/+bug/1251252

F11 (help-for-command) now works for @button & @command nodes.
#@+node:ekr.20141113102829.65: *8* Fixed bug 1254861: Ctrl-f doesn't ensure find input field visible
https://bugs.launchpad.net/leo-editor/+bug/1254861
#@+node:ekr.20141113102829.66: *8* Fixed bug 1258373: failed find focus fails
https://bugs.launchpad.net/leo-editor/+bug/1258373
#@+node:ekr.20141113102829.67: *8* Fixed bug 1260415: exception writing external files" is insufficient
https://bugs.launchpad.net/leo-editor/+bug/1260415
Added more informative error messages
#@+node:ekr.20141113102829.68: *8* Fixed bug 1264350: Up-arrow on the first node in a chapter switches to another chapter
https://bugs.launchpad.net/leo-editor/+bug/1264350
#@+node:ekr.20141113102829.69: *8* Fixed bug 1267921: isearch-forward accepts non-alphanumeric keys as input
https://bugs.launchpad.net/leo-editor/+bug/1267921
#@+node:ekr.20141113102829.70: *8* Fixed bug 1276236: unicode problem in the log pane
https://bugs.launchpad.net/leo-editor/+bug/1276236

g.insertCodingLine adds coding line to start of all python scripts, except when unit testing.
#@+node:ekr.20141113102829.71: *8* Fixed bug 613153: unable to describe root directory on thumb drive
https://bugs.launchpad.net/leo-editor/+bug/613153

Use the %~dp0 syntax. Example::

  %~dp0\Python27\python.exe %~dp0\Leo-editor\launchLeo.py

http://ss64.com/nt/syntax-args.html
http://stackoverflow.com/questions/5034076/what-does-dp0-mean-and-how-does-it-work

I have just created a FAQ entry for this, so at last this issue is closed.
#@+node:ekr.20141113102829.72: *8* Fixed bug 735938: file association crash
https://bugs.launchpad.net/leo-editor/+bug/735938
#@+node:ekr.20141113102829.73: *8* Fixed bug 969391: setup.py confuses newbies
https://bugs.launchpad.net/leo-editor/+bug/969391
#@+node:ekr.20141113102829.74: *7* Fixed 30+ other bugs
#@+node:ekr.20141113102829.75: *8* eliminated "can not exedute commands from headlines"
Removed the odious "'Can not execute commands from headlines" message.

Leo now ends editing, replaces the event.widget and event.w fields with
c.frame.body.wrapper.widget and carries on.
#@+node:ekr.20141113102829.76: *8* find-all now uses exising find pattern
#@+node:ekr.20141113102829.77: *8* Fixed a startup error involving --ipython
Fixed a bug that caused Leo to exit during startup when
--python given on the command line but IPython is not installed.
#@+node:ekr.20141113102829.78: *8* Fixed annoyance: shift-ctrl-w leaves .leo file as dirty
- pd.update_before_write_foreign_file tells when an @data node has been
  changed. This explains why the .leo file is now dirty.
- at.saveOutlineIfPossible automatically saves the .leo file if only
  unchanged persistence nodes remain.
  
at.saveOutlineIfPossible makes the following hacks unnecessary:
    
- at.writeAllHelper writes an unchanged @auto file only if it is
  selected explicitly.
- Changed at.writeAll so that the no @<file> node written message now says
  that you must selected an unchanged @auto node directly in order to write
  it with the write-at-files-nodes command.
#@+node:ekr.20141113102829.79: *8* Fixed autocompleter bug
https://groups.google.com/d/msg/leo-editor/NGbogCgVmx4/nsJGngrS8BgJ
#@+node:ekr.20141113102829.80: *8* Fixed bug re the factor language
Fixed the entry in g.app.language_extension_dict
#@+node:ekr.20141113102829.81: *8* Fixed bug: activate events now properly restore focus
Previously, Ctrl-F Alt-tab Alt-tab would put focus in an inactive minibuffer.

The fix involved rewriting onActivate/DeactivateEvent.
#@+node:ekr.20141113102829.82: *8* Fixed bug: Find-previous fails at last node
https://groups.google.com/d/msg/leo-editor/RAzVPihqmkI/-tgTQw0-LtwJ

This only affected searches that were initiated using the buttons in the Find tab.

What I did:
    
- Init buttonFlag ivar in setup_button & setup_command.
- showSuccess sets was_in_headline ivar.
- focusInTree returns was_in_headline when buttonFlag is True.
- editLabelHelper now properly sets selection range for backward searches.
- Removed a selection hack in initNextText.
#@+node:ekr.20141113102829.83: *8* Fixed clone-find-all command
Changed find.findAll and helpers as follows:
    
- findAll inits onlyPosition for the clone-find-all commands.
    
- createCloneFindAllNode does not link the node into the outline.
  To do this, leoFind.py imports leo.core.leoNodes.

- linkCloneFindAllNode does this *after* the command completes. This keeps
  all positions unchanged while they are being scanned.
   
- The code now tests for either clone_find_all or clone_find_all_flattened
  in various places.
#@+node:ekr.20141113102829.84: *8* Fixed Crash deleting body editor
# Trying to delete a second body editor.

Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 560, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\plugins\qtGui.py", line 2980, in deleteEditor
    name = w.leo_name
AttributeError: 'LeoQTextBrowser' object has no attribute 'leo_name'
#@+node:ekr.20141113102829.85: *8* Fixed find bug
https://groups.google.com/forum/#!topic/leo-editor/yR8eL5cZpi4

Another example of the wretched newline problem. @edit nodes preserve '\r'
characters, and that messes up the counts in the find command.

The fix was a hack to find.search: it removes '\r' characters.

#@+node:ekr.20141113102829.86: *8* Fixed important security hole in mod_scripting plugin
The ctor of the scriptingController does not allow::

    @bool scripting-at-script-nodes = True
    
in local .leo files. 
#@+node:ekr.20141113102829.87: *8* Fixed leoGlobals bug (per Reinhard Engle)
@language rest

Reinhard Engel reinhard.engel.de@googlemail.com

There seems to be a subtle bug in leoGlobals.py:

In the 'globalDirectiveList', the directive 'command' is missing. This
seems not to cause problems, because of the way 'aList' in
'compute_directives_re' is constructed. Then in 'get_directives_dict' the
directive is silently skipped.

The following pattern in 'compute_directives_re' solves this problem:

@language python

    aList = [x for x in globalDirectiveList if z != 'others']
    aList.sort(lambda a,b: len(b)-len(a))
        # Sort by length, longest first
    pat = "^@(%s)(?=( |\t|\n)+)" % "|".join(aList)
#@+node:ekr.20141113102829.88: *8* Fixed modes/md.py
@language python

import glob
pattern = g.os_path_finalize_join(g.app.loadDir,'..','modes','*.py')
for fn in glob.glob(pattern):
    sfn = g.shortFileName(fn)
    f = open(fn)
    s = f.read()
    f.close()
    if s.find(r'regexp="\\') > -1:
        g.es(sfn)

@language text

Possible automatic computation of First sets:
http://stackoverflow.com/questions/787134/can-i-determine-the-set-of-first-chars-matched-by-regex-pattern
http://www.cs.uky.edu/~lewis/texts/theory/automata/reg-sets.pdf

found: Rules indicated are dubious or broken

md.py:
    disabled: 6,7,
    changed: 8,12,20,21,23,24,25,47
    [ \t]   leadins: 8,20,24,25,50,51
    space   leadins: 23,46,49
    [=-]    leadins: 21,47
    [\\_]   leadins: 54,55
    other   leadins: 12,19,53

moin.py:
    [ \t]           rule 3.
    single-quote    rule 6.

erlang.py:  no obvious problem.
lilypond.py:no obvious problem.
perl.py:    no obvious problem.
pl1.py:     no obvious problm.
rest.py:    no obvious problem.
rtf.py:     no obvious problem.
scala.py:   no obvious problem.
yaml.py:    fixed
#@+node:ekr.20141113102829.89: *8* Fixed problem with 1-character reverse searches!
The problem was an off-by-one test in regexHelper.
#@+node:ekr.20141113102829.90: *8* Fixed problems with clone-expansion
Alt-End when the last top-level node was a clone caused all clones to expand.

The fix was in p.isAncestorOf.

Also, changed p.all_unique_positions() to p.all_positions() in places where p.contract was called.

I started this project by doing a clone-find-all for isExpanded.
#@+node:ekr.20141113102829.91: *8* Fixed QCompleter bug
http://i.imgur.com/1ZV45oB.png

There was a problem with hitting tab, and possibly with using the mouse in the QListWidget.

The fix was to define w as follows in lqlw.select_callback and lqlw.tab_callback:
    
    w = c.k.autoCompleter.w or c.frame.body.wrapper

In addition, I changed assert in lqlw.set_position to calls to g.trace.
#@+node:ekr.20141113102829.92: *8* Fixed recent bug in change command
The change pattern doesn't always get set properly.

The fix was in find.addChangeStringToLabel. It must never protect the
change string!
#@+node:ekr.20141113102829.93: *8* Fixed recursive import bug
https://github.com/leo-editor/leo-editor/issues/49

The file import code as found in scripts fails on reaching
Word backup files (file names prefixed with a ~)

The problem was that g.os_path_join automatically called
os.path.expanduser, which converts ~ to the users home directory.

The fix was to disable the call to os.pathexpanduser in g.os_path_join &
g.os_path_finalize if the new expanduser keyword argument is False.
#@+node:ekr.20141113102829.94: *8* Fixed serious bug in c.deletePositionsInList
https://groups.google.com/forum/#!topic/leo-editor/Uoa7ifVV_Aw
#@+node:ekr.20141113102829.95: *8* Fixed several crashers re no-to-all during startup
The present code just exists Leo, which imo is the reasonable thing to do. 
#@+node:ekr.20141113102829.96: *8* Fixed suboutline only find bug
https://groups.google.com/d/msg/leo-editor/ujDqUI68Sx4/EwTYCw7O38cJ

qtree.onItemClicked now calls c.findCommands.reset_state_ivars()
#@+node:ekr.20141113102829.97: *8* Fixed tab cycling
Tab cycling now works as expected in all my tests.

- Reset tab cycling if the user types backspace or any plain character.
- Start cycling *only* if len(label) == len(common_prefix)

These restriction appear to be essential.
#@+node:ekr.20141113102829.98: *8* Fixed tab-completion problems
It sometimes picked a shorter completion that is not a prefix of the present label!

Examples:
    print-se **sometimes** shows print-uas or print-bindings or...
    print-stat<tab>-h<tab> shows print-statusbar-hide
    print-st<tab> shows print-style-sheet.
    print-pr<tab> show print-plugin-handlers.
    
The fix was a single extra check in ga.do_tab.
#@+node:ekr.20141113102829.99: *8* Fixed unwanted scrolling in abbreviations
Saved and restored the y-scroll position in find_place_holder.
#@+node:ekr.20141113102829.100: *8* Gave the Find Tab the intended amount of border
dw.createGrid now honors the margin argument.
#@+node:ekr.20141113102829.101: *8* Improved ctrl-o code
- Non-plain keys are now ignored.
- Backspace and other characters now do something fairly reasonable when text is selected.
  This is an edge case, unless everything to the end of the text is selected.
#@+node:ekr.20141113102829.102: *8* Investigated bug: fill-region & format-body can hang
This was probably fixed earlier by the addition of progress guards
in ec.fillRegion and c.reformatBody.

Added one line for fillRegion.
#@+node:ekr.20141113102829.103: *8* Made beautify commands compatible with pep8
http://legacy.python.org/dev/peps/pep-0008/

https://github.com/leo-editor/leo-editor/issues/68

    (fixed) puts whitespace between function name and opening '('
    (fixed) puts whitespace between dictionary name and '['
    (fixed) removes whitespace between function arguments after ','
    (partially fixed) removes whitespace around operator inside parentheses
        (this is not so clear, depends on situation, can be correct or can be wrong)
    (fixed) puts whitespace between print and opening '('

print(obj) is correct and PEP8 style in Python 3, in Python 2.7 runs
correctly but print(obj) is not correct traditionally
#@+node:ekr.20141113102829.104: *8* Re-enabled command completion for @button commands
This had been disabled when completion for vim : commands was added.

Changed ga.get_command and ga.is_command.
#@+node:ekr.20141113102829.105: *8* Reported QTextEdit bug
https://bugreports.qt-project.org/browse/QTBUG-41153
#@+node:ekr.20141113102829.106: *8* Set the default syntax color for operators to black
This is required so that, for example, python coloring is correct after
selecting a node that sets another color for operators.
#@+node:ekr.20141113102829.107: *8* Suppressed duplicate console messages
g.es does nothing when g.app.gui.consoleOnly is True
#@+node:ekr.20141113102829.108: *8* Worked around a strange PyQt5 bug in LeoQtGui.runSaveFileDialog
For some strange reason, the PyQt5 version of LeoQtGui.runSaveFileDialog
returns a tuple instead of a string!
#@+node:ekr.20141113102829.233: *6* Invalid/won't fix
#@+node:ekr.20141113102829.235: *7* 5.0b1
#@+node:ekr.20141113102829.194: *8* Invalid bug 1286909: Settings in file A propagate to file B when editing A and B is opened
https://bugs.launchpad.net/leo-editor/+bug/1286909
Settings in file A propagate to file B when editing A and B is opened

#@+node:ekr.20141113102829.191: *8* Investigated bug 1240786: Corner case bug in tab-cycle-next and tab-cycle-previous
https://bugs.launchpad.net/leo-editor/+bug/1240786
Corner case bug in tab-cycle-next and tab-cycle-previous

This bug appears to have been fixed.

Open any already existing Leo-Editor file. Call this File 1. Ctrl-O and
open any already existing Leo-Editor file. We will refer to this file as
"File 2." At this point the File 2 tab has focus.

Now execute tab-cycle-next or tab-cycle-previous. I do this using shortcuts
Ctrl+Next and Ctrl+Prior respectively, but your shortcuts may be different.
Now the File 1 tab has the focus. Now type any printable key.

Note that the printable key character is put into File 2 and File 2 is now
dirty, but the focus is still on File 1.

In every other case that I've tried tab-cycle-next and tab-cycle-previous
perform correctly and the tab with the focus is the tab into which
characters are inserted.
#@+node:ekr.20141113102829.225: *8* Investigated bug 1249684: "add body editor" adds editor pane in wrong tab
https://bugs.launchpad.net/leo-editor/+bug/1249684
"add body editor" adds editor pane in wrong tab

This seems to have been fixed.
#@+node:ekr.20141113102829.198: *8* Investigated bug 1258302: Window, Toggle Split Direction Error
https://bugs.launchpad.net/leo-editor/+bug/1258302
Window, Toggle Split Direction Error

This works for me.  Don't know when it was fixed.
#@+node:ekr.20141113102829.226: *8* Investigated bug 1269540: File importing problems: Path doesn't properly appear as node header
https://bugs.launchpad.net/leo-editor/+bug/1269540
File importing problems: Path doesn't properly appear as node header

This bug was fixed by #60 or at some earlier time.

I am aware of no problems with drag and drop at present.
Please create a github bug report if any new issues appear.

#@+node:ekr.20141113102829.193: *8* Investigated bug 1286914: A custom menu that seems correct, but does nothing
https://bugs.launchpad.net/leo-editor/+bug/1286914
A custom menu that seems correct, but does nothing

This problem is demonstrated by the file settingsCreep01.leo attached to bug 1286909.

The fix is to remove the amperstand from the @item headlines.
#@+node:ekr.20141113102829.197: *8* Won't fix bug 1286913: After the "menu already exists"...
https://bugs.launchpad.net/leo-editor/+bug/1286913
After the "menu already exists: ampersand menu name" warning,
the menu entries are added to the existing menu.

This is a minor wishlist item.
#@+node:ekr.20141113102829.196: *8* Won't fix bug 1292207: Disabling Plugins disables menu actions
https://bugs.launchpad.net/leo-editor/+bug/1292207
Disabling Plugins disables menu actions

This bug is invalid.

Disabling plugins disable the mod_scripting plugin, so the @command nodes
given in the example do nothing.
#@+node:ekr.20141113102829.195: *8* Won't fix bug 815564: Plugin Menu-Keystroke binding can prevent plugin help display
https://bugs.launchpad.net/leo-editor/+bug/815564
Plugin Menu - Keystroke binding can prevent plugin help display

Obvious workaround: avoid name clashes.
#@+node:ekr.20141113102829.42: *7* 5.0a1
#@+node:ekr.20141113102829.43: *8* Cleared bug 1228457: Beginning find at the current node's body cursor when that cursor is not displayed
https://bugs.launchpad.net/leo-editor/+bug/1228457

This appears to have been fixed.
#@+node:ekr.20141113102829.44: *8* Cleared bug 1228713: Find-backward skips headlines under some conditions
https://bugs.launchpad.net/leo-editor/+bug/1228713

This appears to have been fixed at some time in the past, possibly as the result of fixing another bug.
#@+node:ekr.20141113102829.45: *8* Cleared bug 1254864: Can't search from current cursor position downward in body text
https://bugs.launchpad.net/leo-editor/+bug/1254864
#@+node:ekr.20141113102829.46: *8* Investigated bug  524890: Incomplete derived file
https://bugs.launchpad.net/leo-editor/+bug/524890
Incomplete derived file

This bug was fixed by the allow_cloned_sibs logic in leoAtFile.py 2013/01/20.
#@+node:ekr.20141113102829.47: *8* Investigated bug 1177355: node-only wrapped search does not work in long nodes
https://bugs.launchpad.net/leo-editor/+bug/1177355
node-only wrapped search does not work in long nodes

This works for me.
#@+node:ekr.20141113102829.48: *8* Investigated bug 1193820: Focus change on tree pane after saving current Leo file
From https://github.com/leo-editor/leo-editor/issues/73

https://bugs.launchpad.net/leo-editor/+bug/1193820
Focus change on tree pane after saving current Leo file
    
Using Qt. First reported here:
https://groups.google.com/forum/#!topic/leo-editor/hPwPG9OTC3U

This no longer seems to be a problem.
#@+node:ekr.20141113102829.49: *8* Investigated bug 1266269: Mac: alt-x does not work in body pane
https://bugs.launchpad.net/leo-editor/+bug/1266269
Mac: alt-x does not work in body pane

No problem with a clean homebrew install on MacOS 10.9 Mavericks.
#@+node:ekr.20141113102829.50: *8* Investigated bug 1268970: Leo does not remember window maximized state
https://bugs.launchpad.net/leo-editor/+bug/1268970

This works for me (Windows 7 and Ubuntu) with Python 2.7.8, PyQt version 4.8.6.
#@+node:ekr.20141113102829.51: *8* Investigated bug 1282362: shadow file name collisions cause spontaneous clone creation
[Fixed?] https://bugs.launchpad.net/leo-editor/+bug/1282362
shadow file name collisions cause spontaneous clone creation

Works for me. Furthermore, the scenario is bizarre enough not to be important.

- Create a new leo file.
- Create @shadow foo.txt
- Set body to @others, add two children, with different body texts.
- Copy / paste the @shadow node, change the path to x/foo.txt

(In shell, create x folder, saving shadow doesn't create path, which is
maybe another bug) save and close file

open file again, children of shadow nodes are clones of each other. I think
it's the name collision, not the copy pasting etc.

#@+node:ekr.20141113102829.52: *8* Investigated bug 869098: Context menu settings lost if save as used
https://bugs.launchpad.net/leo-editor/+bug/869098
Context menu settings lost if save as used

This report appears invalid.

The renamed file uses the @data contextmenu_commands node in that files.

Note that @data contextmenu_commands node in the file *replaces* any other
@data contextmenu_commands node in leoSettings.leo or myLeoSettings.leo.

#@+node:ekr.20141113102829.109: *5* Code
#@+node:ekr.20141113102829.110: *6* A beautiful and general design pattern
In an earlier post I said:

QQQ

Strictly speaking, tab cycling doesn't have to be disabled for all colon
commands. One could imaging a list of commands that use tab to complete
file names. Otoh, maintaining that list would be clumsy, and it would add
still more special cases to ga.do_tab.

QQQ

This post describes a much better way, done at rev 3994eca.

The new code is gorgeous, if I do say so myself. Even better, the solution
is a design pattern with many applications.

The trick is to replace functions implementing commands by classes having
`__call__` methods. See the P.P.S for details.

Yes, this has all been done before. Several of Leo's commands are
implemented this way. But read on...

What's new is that classes can "advertise" their ability to do various
things. Here, the classes implementing vim commands advertise, by having a
tab_callback method, that they want to handle a tab that follows their
name. ga.do_tab then defers to the vim command.

There are several really cool things about this code.

1. ga.do_tab, and its helper, ga.do_tab_callback, no longer know *anything*
    about colon commands, or what any command intends to do with the
    tab(!!). If the command handler has a tab_callback attribute,
    ga.do_tab_callback just does::

     ga.reset_tab_cycling()
     k.functionTail = tail # For k.getFileName.
     handler.tab_callback()

Nothing could be simpler, or more general.

2. The code in the command classes is simplified as well. No need for a
   kludgy test event.get_arg_value. See the P.S. for the full
   implementation of the :tabnew command.

The overall result is a spectacular collapse in complexity, which the
attendant increase in power and generality.

Edward

P.S. Here is the flattened form of the class that handles the :tabnew
command (does not require vim-mode). In particular, note that the __call__
and tab_callback methods are trivial. This is the way it is written in The
Book.

class Tabnew:
    '''
    A class to handle Vim's :tabnew command.
    This class supports the do_tab callback.
    '''
    def __init__(self,vc):
        '''Ctor for VimCommands.tabnew class.'''
        self.vc = vc
    __name__ = ':tabnew'
        # Required.

    def __call__(self,event=None):
        '''Prompt for a file name, the open a new Leo tab.'''
        self.vc.c.k.getFileName(event,callback=self.open_file_by_name)
       
    def tab_callback(self):
        '''Called when the user types :tabnew<tab>'''
        self.vc.c.k.getFileName(event=None,callback=self.open_file_by_name)
       
    def open_file_by_name(self,fn):
        c = self.vc.c
        if fn and not g.os_path_isdir(fn):
            c2 = g.openWithFileName(fn,old_c=c)
            try:
                g.app.gui.runAtIdle(c2.treeWantsFocusNow)
            except Exception:
                pass
        else:
            c.new()

P.P.S. This pattern is particularly well suited to Leo, because the various
getPublicCommands methods reference those functions when create command
dictionaries. Here, we replace just two entries in the dict::

    ':r':   vc.LoadFileAtCursor(vc),
    ':tabnew': vc.Tabnew(vc),

This creates instances of the LoadFileAtCursor and Tabnew classes. In other
words, we replace a function by an instance of a class. All such classes
must have __call__ methods, so that Leo can "call" the instance as if it
were a function.
#@+node:ekr.20141113102829.111: *6* A major reorg of Leo's code
One change is required to all plugins and scripts:

    body.bodyCtrl.x -> body.wrapper.x
    
There is a script that does this automatically.

What I did
- Created "@test interfaces using API classes" based on the checking script.
- The various isTextWidget methods now check for the existence of a supportsHighLevelInterface ivar.
- StringTextWrapper is now a stand-alone class.
- Removed BaseTextWrapper.
- LeoLog is no longer a subclass of the HighLevelInterface class.
  This required a hack to handle keystrokes in the log pane:
  k.masterKeyHandler sends strokes to c.frame.log.logWidget (a QTextEditWrapper)
  by changing event.widget.
  QTextMixin sets supportsHighLevelInterface = True as a signal to k.handleDefaultChar.
- Eliminated redirection code from LeoQtBody class.
- LeoBody is no longer a subclass of the HighLevelInterface class.
    - The only changes, one or two new guards.
- Create WrapperAPI class whose text indicates expected type of the result.
- Removed wrapper.getFocus method.
- Removed all references to HighLevelInterface class in the core.
- Removed the evil set_focus synonym in the HighLevelInterface class.
#@+node:ekr.20141113102829.112: *6* Added support for qt5
It is not possible to use both the PyQt4 and PyQt5 installers at the same
time. But this is no big deal on Windows: just install PyQt5 for Python 3.4
only.
#@+node:ekr.20141113102829.113: *6* added the IdleTime class
@language rest

Rev 060c33a contains a spectacular collapse in complexity in idle-time
handling.

Instantly, registering idle-time event handlers can be considered
deprecated, though I have no plans to remove the horrendous older code.

The new pattern allows multiple, independent (or cooperating) idle-time
handlers, created at will as needed.

The new code is based on the IdleTime class in qtGui.py. Rather than access
this directly, code should use the g.IdleTime proxy::

@language python

    def IdleTime(c,handler,delay=500):
        '''A proxy for the g.app.gui.IdleTime class.'''
        if g.app and g.app.gui and hasattr(g.app.gui,'idleTimeClass'):
            return g.app.gui.idleTimeClass(c,handler,delay)
        else:
            return None
            
@language rest

g.IdleTime ensures that all is well when using gui's that don't have an IdleTime class.

Here is how to use the new code::

@language python

    def handler(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace(it.count,it.c.shortFileName(),'%2.4f' % (delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    it = g.IdleTime(c,handler,delay=500)
    if it: it.start()
    
@language rest

The code creates an instance of the IdleTime class that calls the given
handler at idle time, and no more than once every 500 msec. Here is the
output::

    handler 1 ekr.leo 0.5100
    handler 2 ekr.leo 1.0300
    handler 3 ekr.leo 1.5400
    handler 4 ekr.leo 2.0500
    handler 5 ekr.leo 2.5610
    handler done

Timer instances are completely independent.  For example:

@language python

    def handler1(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    def handler2(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 10:
            g.trace('done')
            it.stop()

    it1 = g.IdleTime(c,handler1,delay=500)
    it2 = g.IdleTime(c,handler2,delay=1000)
    if it1 and it2:
        it1.start()
        it2.start()
        
@language rest

Here is the output::

    handler1  1 ekr.leo 0.5200
    handler2  1 ekr.leo 1.0100
    handler1  2 ekr.leo 1.0300
    handler1  3 ekr.leo 1.5400
    handler2  2 ekr.leo 2.0300
    handler1  4 ekr.leo 2.0600
    handler1  5 ekr.leo 2.5600
    handler1 done
    handler2  3 ekr.leo 3.0400
    handler2  4 ekr.leo 4.0600
    handler2  5 ekr.leo 5.0700
    handler2  6 ekr.leo 6.0800
    handler2  7 ekr.leo 7.1000
    handler2  8 ekr.leo 8.1100
    handler2  9 ekr.leo 9.1300
    handler2 10 ekr.leo 10.1400
    handler2 done
#@+node:ekr.20141113102829.114: *6* All unit tests now pass when run externally
Fixed an important bug in addNode, a helper of createOutline: There was a
confusion about commanders: p is in the old commander. p2 must be in the
new commander.

Disabled a few unit tests when run externally:
This was due to missing nodes or copies of clones not being cloned.
#@+node:ekr.20141113102829.115: *6* API changes
- Converted all class names to pep8 style
- Removed g.choose from Leo's core & plugins
  This function is deprecated: use Python's ternary operator instead.
#@+node:ekr.20141113102829.116: *6* Changed most calls to k.setLabel to k.setStatusLabel
Leo's core now calls k.setStatusLabel, not k.setLael, to report the status
of a Leo command. This allows an option (does not exist yet) to use g.es
instead of the minibuffer to report status.
#@+node:ekr.20141113102829.117: *6* Cleaned up command-name handling a bit
Changed k.inverseCommandsDict to c.inverseCommandsDict.
Called vc.define commands from c.finishCreate.
Changed ecm.finishCreateEditCommanders to ecm.defineCommandNames.
The new c.createCommandNames copies entries in g.app.global_commands_dict to commander c.
    Note: @g.command makes entries in g.app.global_commands_dict.
#@+node:ekr.20141113102829.118: *6* code: regularized .wrapper and .widget ivars
@language rest

This post will summarize what has already been done and what will be done in the next few days.  Let's start with the basics...

===== About wrappers and widgets

Wrapper and widget classes are at the heart of Leo's design. Clarifying the
relationships between wrappers and widgets started the present avalanche.

Here is what you *must know* to understand Leo's core:

1. A **widget** is an actual Qt widget.

Leo's core seldom accesses widgets directly. Instead...

2. A **wrapper class** defines a standard api that hides the details of the
   underlying gui **text** widgets.

Leo's core uses this api almost exclusively. That is, Leo's core code
treats wrappers *as if* they were only text widgets there are!

There is, however, a back door for (hopefully rare!) special cases. All
wrapper classes define an official "widget" ivar, so core or plugin code
can gain access to the real Qt widget using wrapper.widget. Searching for
wrapper.widget will (or soon will) find all gui-dependent snippets of code
in Leo's core.

3. Wrappers are crucial, even if Leo *always* uses the Qt gui.

This has just become crystal clear to me. Indeed:

- Wrappers allow users to choose different Qt widgets for the body pane,
  without changing *any* of Leo's core code (except the startup code).

- Wrappers allow Leo's text-handling code to remain unchanged regardless of
  whether the body or log panes are a QTextBrowser or a QsciScintilla
  widget.

- Without wrappers, all of Leo's text-editing commands would have to know
  the details of the api of the actual Qt text widget!

==== Summary of the avalanche

Here is what is happening now in Leo's code base, and in my thinking!

1. A collapse in the complexity of relationships between Leo's most
   important classes and between the files containing those classes.

qt_text.py was supposedly a minor reorg. Wrong! It has become the road map
to the reorganization of all of Leo's fundamental classes:

- qt_text.py is *self contained*: it doesn't depend on any other classes!

- qt_text.py defines a QTextMixin class. This is a new kind of class for
  me. As its name suggest, it is not so much a base class as a helper
  class. It provides helper code for all of Leo's Qt wrapper widgets.

- All the classes that use QTextMixin implement the HighLevelInterface
  class in leoFrame.py.

The HighLevelInterface class will soon morph into the WrapperInterface
class. Th WrapperInterface class will contain only the definition of
methods and their docstrings. Unlike the HighLevelInterface class, the
WrapperInterface will contain *no* redirection code!

- If we were (heaven forbid) going to change Leo's gui, we would simply use
  a copy of qt_text.py, say new_gui.text.py, as a starting point.

2. All "redirection" code will soon be gone.

Ville, Terry and I will be much happier. Eliminating this cruft makes Leo's
code both lighter and thicker, to use the go terminology. It's lighter
because there is far less blah, blah, blah. It's thicker because there is
less to check and to fail.

It's easy to eliminate redirection. For example, the LeoBody methods that
just call the corresponding wrapper methods will soon be gone. We'll
change::

    c.frame.body.wrapperMethod

to::

    c.frame.body.wrapper.wrapperMethod

Doh! This should have been done years ago. Yes, it's more verbose, but it's
also more explicit. Furthermore, few such calls actually exist!

3. widget.widget and other type-checking horrors will soon be a thing of
   the past.

New coding conventions will remove all confusion between wrappers and
widgets. Wrappers will *always* be called wrappers, never widgets.

There is/was something both fundamentally wrong and confusing about
widget.widget. The first widget must have a different type than the second,
but there is *no* indication of this fundamental fact. The reorg changes
widget.widget to wrapper.widget everywhere.

4. I have a new approach toward type checking.

It is obvious now, in retrospect, that clarity of design is something much
more important than type checking! Leo's code will soon make the types of
objects *explicit* and this far more important in practice than even
"perfect" static type checking. This is a revolution in my thinking.

pylint, while supremely important for day-to-day programming, is *totally
inadequate* to have produced the design changes I have been discussing.

Now that widgets are always clearly distinct from wrappers, we could
imaging type-checking assertions to verify their apparent types. Imo, such
assertions are seldom pythonic, but in this case assertions might be good
documentation, if nothing else. The assertions would be based on the
following functions:

- g.isWrapper(obj): calls g.app.gui.isWrapper(obj)
- g.isWidget(obj): calls g.app.gui.isWidget(obj)

5. A dead-easy script shows how to enforce the relationships between types
   that really matter.

This is a big Aha. The script merely compares dir(o1) with dir(o2), where
o1 is the "template" HighLevelInterface class in leoFrame.py and o2 is one
of QTextEditWrapper or QScintillaWrapper. You could call this the "back
door" approach to type checking. It's sooo easy! No more messing with
ast's!

As a result of running this script, (given in the P.P.S.) I was able to
removed cruft from both the HighLevelInterface class, and other parts of
Leo's code.

===== Summary

None of these massive changes adds anything directly to Leo :-)

However, they make understanding and changing Leo's code far easier and
more pleasant. Leo's code is now more beautiful.

Imo, these changes are long overdue. They fundamentally improve Leo's code
base.

That's all for now. I'll keep you posted as I change code, but this post
covers all the essentials.

Edward

P.S. git and easier access to pylint contributed to the present avalanche
of energy and ideas.

Git has allowed me to revise Leo's source code radically, with complete
safety. I would never have done what I have done lately with bzr.

Leo's new pylint command allows me to run pylint *easily* on one or more
"recent" files, *without* having to change any list. As a result, I run
pylint much more often.

P.P.S. Here is the script that checks that all text wrapper classes
implement all required methods. This is, to the first approximation, the
only type checking that Leo really needs. It will probably become a unit
test.

@language python

    import leo.core.leoFrame as leoFrame
    import leo.plugins.qt_text as qt_text
    from leo.core.leoQt import Qsci,QtWidgets
    
    h = leoFrame.HighLevelInterface(c)
    w = Qsci.QsciScintilla()
    tw = QtWidgets.QTextBrowser()
    q = qt_text.QScintillaWrapper(widget=w,c=c,name='test')
    t = qt_text.QTextEditWrapper(widget=tw,name='test2')
    
    h_list = [z for z in sorted(dir(h)) if not z.startswith('__')]
    t_list = [z for z in sorted(dir(t)) if not z.startswith('__')]
    q_list = [z for z in sorted(dir(q)) if not z.startswith('__')]
    ignore = [
        'set_focus', # synonym for setFocus
        'mutable_methods', # To be removed.
    ]
    for z in h_list:
        if z not in t_list and z not in ignore:
            print('QTextEditWrapper: not in HighLevelInterface: %s' % z)
    for z in h_list:
        if z not in q_list and z not in ignore:
            print('QScintillaWrapper: not in HighLevelInterface: %s' % z)
    print('done')

@language rest

=====

This project appears to be a complete success. No further work is planned.
I have encountered no problems at all during this reorg, and don't expect
any, but we shall see...

Here are the highlights:

1. *All* of the odious redirection code in Leo is gone.
 
The redirection code appeared in various places, especially in the
HighLevelInterface class.

2. The HighLevelInterface class is gone: the LeoBody and LeoLog classes are
   now subclasses of object.

3. The logCtrl property is gone: the LeoLog class now defines a .logCtrl
   ivar.

This ivar is inherently tricky: depending on which log *tab* is selected,
LeoLog.logCtrl may be either a wrapper or a widget!

Because LeoLog no longer contains redirection code a hack was needed.
k.masterKeyHandler redirects text-related events originally sent to the
c.frame.log to c.frame.log.logWidget, which, confusingly enough, is
actually a text wrapper.

4. leoFrame.py contains several new API classes: ColorizerAPI, IconBarAPI,
   StatusLineAPI and WrapperAPI.

No class is a subclass of these classes: they are for unit testing only.

The new unit test, "@test interfaces using API classes", checks that
classes implement all the methods in the corresponding API class. This is
not a perfect solution and it is no substitute for pylint. Nevertheless,
these API classes are good documentation, and they did result in a few new
methods being added to each tested "Null" class.

That's all! You may not believe it, but I think of all this work as being
related to fixing bugs. I'll now return more directly to bug fixes.
#@+node:ekr.20141113102829.119: *6* Completed generalization of importers
- ic.createOutline and its helper, ic.dispatch, now use tables
  created by ic.createImporterData and its helper.

- Eliminated odious special cases involving self.treeType in
  ic.create_top_node and ic.init_import.
  
- self.treeType is used only in a limited way in the scanner classes:
  The only tests are against '@root' and '@file'.
  
- For now, the unit-tests wrappers are hard-coded.
#@+node:ekr.20141113102829.120: *6* Created g.IdleTime and qtGui.IdleTime
Rev 060c33a...Leo build: 20140825070951 contains a spectacular collapse in
complexity in idle-time handling. Instantly, registering idle-time event
handlers can be considered deprecated, though I have no plans to remove the
horrendous older code.

The new pattern allows multiple, independent (or cooperating) idle-time
handlers, created at will as needed.

The new code is based on the IdleTime class in qtGui.py. Rather than access
this directly, code should use the g.IdleTime proxy:: g.IdleTime ensures
that all is well when using gui's that don't have an IdleTime class.

Here is how to use the new code::

    def handler(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace(it.count,it.c.shortFileName(),'%2.4f' % (delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()
    it = g.IdleTime(c,handler,delay=500)
    if it: it.start()

The code creates an instance of the IdleTime class that calls the given handler at idle time, and no more than once every 500 msec.  Here is the output::

    handler 1 ekr.leo 0.5100
    handler 2 ekr.leo 1.0300
    handler 3 ekr.leo 1.5400
    handler 4 ekr.leo 2.0500
    handler 5 ekr.leo 2.5610
    handler done

Timer instances are completely independent.  For example:

    def handler1(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    def handler2(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 10:
            g.trace('done')
            it.stop()

    it1 = g.IdleTime(c,handler1,delay=500)
    it2 = g.IdleTime(c,handler2,delay=1000)
    if it1 and it2:
        it1.start()
        it2.start()

Here is the output::

    handler1  1 ekr.leo 0.5200
    handler2  1 ekr.leo 1.0100
    handler1  2 ekr.leo 1.0300
    handler1  3 ekr.leo 1.5400
    handler2  2 ekr.leo 2.0300
    handler1  4 ekr.leo 2.0600
    handler1  5 ekr.leo 2.5600
    handler1 done
    handler2  3 ekr.leo 3.0400
    handler2  4 ekr.leo 4.0600
    handler2  5 ekr.leo 5.0700
    handler2  6 ekr.leo 6.0800
    handler2  7 ekr.leo 7.1000
    handler2  8 ekr.leo 8.1100
    handler2  9 ekr.leo 9.1300
    handler2 10 ekr.leo 10.1400
    handler2 done
#@+node:ekr.20141113102829.121: *6* Delayed allocation of gnx's...
- fc.getLeoFile now calls ni.begin/end_holding
- Added gnx keyword arg to VNode ctor.
- Added traces to pd.restore_gnx

What I did:
    
- checked all calls to VNode ctor.
- checked all calls to getNewIndex.
- checked all calls to fileIndex =
#@+node:ekr.20141113102829.122: *6* Delayed allocation of vnodes
https://groups.google.com/d/msg/leo-editor/JWhlmJBiesk/RsC64VZ1gxQJ
#@+node:ekr.20141113102829.123: *6* Improved idle-time handling
@language rest

Simplified and generalized idle-time handling as follows:
    
- Removed g.app.afterHandler: g.app.idleTimeHook does the same thing now.
- The timer callback now calls g.app.idleTimeHook() if it exists.
- g.enableIdleTimeHook now has the following signature::
    
    def enableIdleTimeHook(idleTimeDelay=500,idleTimeHandler=None):
        
  The two args set g.app.idleTimeDelay and g.app.idleTimeHandler respectively.
  g.idleTimeHookHandler is used if idleTimeHandler is None.

The new code has these properties:
    
1. g.app.idleTimeHook() actually gets called only at idle-time,
2. There is no busy waiting, and
3. There is at least g.app.idleTimeDelay msec. between calls to g.app.idleTimeHook()

Here is an script illustrating the possibilities::

@language python

'''
A script illustrating interacting idle-time handlers.
Do Alt-x enable-idle-time-tracing before executing this script
'''
class Handlers:
    def h1(self):
        g.trace()
        g.enableIdleTimeHook(1000,self.h2)
    def h2(self):
        g.trace()
        g.enableIdleTimeHook(500,self.h1)
h = Handlers()
if g.app.idleTimeHook:
    g.disableIdleTimeHook()
else:
    g.enableIdleTimeHook(1000,h.h1)
#@+node:ekr.20141113102829.124: *6* Improved p.isAncestorOf and c.positionExists
- Added test for c.positionExists to p.isAncestorOf.
- Added v.isNthChildOf
- Rewrote c.positionsExists using v.isNthChildOf
#@+node:ekr.20141113102829.125: *6* Improved speed of selection logic
0. Added details timing traces throughout the selectHelper logic.
   These traces showed precisely where the performance bugs were.

1. updateSyntaxColorer now does nothing if the body text starts with @killcolor.

2. w.setSelectionRangeHelper and v.restoreCursorAndScroll had performance bugs
because they called code that computed the length of text slowly.

3. The solution: w.setSelectionRangeHelper and all setInsertPoint methods
now take an 's' keyword arg. In the selection logic, s is set to p.b.
If s is not None, the desired length is simply len(s)

As a result, w.setSelectionRangeHelper no longer calls lengthHelper.
lengthHelper used QTextCursor, which is *much* slower than getAllText.

4. Even though all w.setInsertPoint methods have an s keyword arg,
   v.restoreCursorAndScroll uses the following defensive code::
       
    try:
        w.widget.setInsertPoint(ins,s=v._bodyString)
    except TypeError:
        w.setInsertPoint(ins)
#@+node:ekr.20141113102829.126: *6* Leo imports importers & writers from home/.leo
Leo now imports from ~/.leo/plugins before importing from leo/plugins.

The new code is in at.createWritersData & helper and ic.at.createImportersData & their helpers.
#@+node:ekr.20141113102829.127: *7*  demo script
'''Load each plugins ~/.leo/plugins if possible, then from leo/plugins.'''
import glob
def report(message,kind,folder,name):
    g.trace('%7s: %5s %9s %s' % (message,kind,folder,name))
g.cls()
plugins1 = g.os_path_finalize_join(g.app.homeDir,'.leo','plugins')
plugins2 = g.os_path_finalize_join(g.app.loadDir,'..','plugins')
seen = set() # set of (folder,sfn)
for kind,plugins in (('home',plugins1),('leo',plugins2)):
    if g.os_path_exists(plugins):
        for folder in ('importers','writers'):
            path = g.os_path_finalize_join(plugins,folder)
            pattern = g.os_path_finalize_join(plugins,folder,'*.py')
            for fn in glob.glob(pattern):
                sfn = g.shortFileName(fn)
                if g.os_path_exists(fn) and sfn != '__init__.py':
                    moduleName = sfn[:-3]
                    if moduleName:
                        data = (folder,sfn)
                        if data in seen:
                            report('seen',kind,folder,sfn)
                        else:
                            m = g.importFromPath(moduleName,path) # Uses imp.
                            if m:
                                seen.add(data)
                                report('loaded',kind,folder,m.__name__)
                            else:
                                report('error',kind,folder,sfn)
                # else: report('skipped',kind,folder,sfn)
@language python
#@+node:ekr.20141113102829.128: *6* Leo now uses a new xml namespace
For several years the xml namespace line at the start of .leo files has been::

    <leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" >

The new line is::

    <leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
#@+node:ekr.20141113102829.129: *6* Rewrote & simplified k.getArg
What I did:
- Removed prefix arg to all calls to k.getArg.
  Not needed now that there is better convention for k.setLabelBlue.
- Removed protect argument from k.setLabelBlue.
  Some code now uses k.extendLabel to mix protect and unprotected parts of the label.
  
- k.fnc and k.getArgInstance now created by finishCreate.
  This guarantees that the c,k and log ivars are inited properly.
- Allow <tab> to escape to :r and :tabname code.
  This required several kludges.

#@+node:ekr.20141113102829.130: *6* Simplified gnx scan logic
1. createSaxVnode now does::
    
    v.fileIndex = ni.tupleToString(x.scanGnx(sax_node.tnx))
    
ni.tupleToString is substantially simpler than ni.toString.

This is the only call to tupleToString in Leo.

2. Removed ni.toString.

3. ni.scanGnx no longer converts n to an int.  It's going to become a string again anyway.

4. The new fc.setMaxNodeIndex *does* convert the n field to an int, but
   this very rarely happens.
#@+node:ekr.20141113102829.131: *6* Split qtGui.py into separate files
- qt_big_text.py contains support for the "big text" warning buttons.

- qt_commands.py contains several commands created by @g.commands.
  qt_gui.py now imports this file so the commands are actually defined.

- qt_events.py contains the LeoQtEventFilter class. The LeoKeyEvent class
  remains in leoGui.py: it is independent of gui.

- qt_frame.py contains most of the Qt-related code that creates the Leo
  window and frames.
  
- qt_idle_time.py contains the IdleTime class.

- qt_gui.py contains Qt-specific code that defines g.app.gui. leoGui.py is
  the gui-independent code and was essentially unchanged.

- qt_quickheadlines.py contains the QuickHeadlines class.

- qt_text.py contains most the code for Leo's Leo's text widgets.
  leoFrame.py contains a few gui-independent classes.

- qt_tree.py contains all the Qt tree code. It replaces baseNativeTree.py.

No longer used: baseNativeTree.py, qtGui.py. qtGui.py still exists, but
just prints a warning message when imported.
#@+node:ekr.20141113102829.132: *6* The @auto write code now uses writer plugins
What I did:
- at.createWritersData inits tables using the writers_dict in each plugin.
- at.writeOnAtAutoNode calls at.dispatch to find writers.
  An important escape hatch: at.writeOnAtAutoNode calls the *existing* rst.writer
  if the user deletes plugins/writers/rst.py.

Won't do:
- at.writeAllHelper has lots of special-case code, but that probably can't be helped.
- It would be way too dangerous to refactor the write code for @file, @shadow, etc.
#@+node:ekr.20141113102829.133: *6* Wanted: w.getTextLength and p/v.get_b_length
A head-slapping moment: the so-called high-level interfaced throughout
Leo's core to interact with Leo's text panes lacks a way of getting the
length of text *without* making a copy of the text.

This is more than a slight oversight: I imagine there are several place
were the code does s = w.getAllText() merely so it can use len(s)! This is
a huge strain on the GC for large p.b.

Worse, the absence of w.getTextLength() has lead to the most unfortunate
LeoQTextEditWidget.lengthHelper, which calculated the length of the text
using QTextCursor methods! This is catastrophically slow for large text.
This method was doubling node load times for large nodes.

@language rest

In other words, w.getTextLength() is an essential part of fixing git bug 28:
https://github.com/leo-editor/leo-editor/issues/28

But nooooooo... w.getTextLength() is far from easy to do. There is no
QTextEdit or QTextDocument method that delivers the length of the text!
This is a *huge* hole in the QTextEdit and QTextDocument api's, but there
is nothing we can do about that.

The simplest thing that could possibly work would be::

@language python

    def getTextLength(self):
        w = self.widget
        return len(w.getAllText())
        
@language rest

But this would be a step backwards because it hides the fact that it is
expensive.

It might be possible to cache the value of w.getAllText in an "text
changed" event handler in LeoQTextBrowser:(QTextBrowser). But I would like
to avoid this approach--any bug would lead to data loss or corruption. I
may play around with this, but for now it's not likely to happen. See below
for a workaround.

By analogy with w.getTextLength(), we can imagine a p.b_length method that
would simply return len(p.v._bodyString). This, at least, is worth doing.

===== Summary

w.getTextLength() isn't trivial.

Caching the value returned by w.getAllText() seems too dangerous.

As a work-around, the crucial node-selection logic will attempt to minimize
calls to w.getAllText. There, and *only* there, it should be possible to
create a *single* copy of the text and pass that copy around to all code
that needs it. It would be a complication, but a completely safe one.

Otoh, p/v.b_length are trivial and useful. They will be added asap.

-------------

Two parts to this reply:

===== Part 1: defining w.getTextLength

> w.getTextLength() isn't trivial...Caching the value returned by
w.getAllText() seems too dangerous.

Actually, defining w.getTextLength using a textChanged event handler in
LeoQTextBrowser is straightforward::

@language python

    def onTextChanged(self):
        '''The textChanged event handler.  Cached the text in self.leo_s.'''
        self.leo_s = s = g.u(self.toPlainText())

    def getTextLength(self):
        '''Return the length of all the text.'''
        if 1: # safe.
            s = g.u(self.toPlainText())
            if s != self.leo_s:
                g.trace('can not happen: text mismatch.')
                self.leo_s = s
            return len(self.leo_s)
        else: # fast
            return len(self.leo_s)
            
@language rest

We can use the "safe" version of getTextLength until we are *sure* the can
not happen message never happens ;-)

Otoh, we must be careful: onTextChanged will be called in the middle of the
node-switching logic.

===== Part 2: doing without w.getTextLength

Imo, the simplest thing that could possibly work is to avoid the extra call
to w.getAllText in the node switching logic in selectHelper.

Here are the relevant parts of selectHelper. (w is a LeoQTextEditWidget).

1. setBodyTextAfterSelect *already* calls w.getAllText() to get the
   "before" text. This is unavoidable.

The "after" text will be p.b, where p is the *new* position.

2. restoreCursorAndScroll calls w.setInsertPoint, which just calls
   w.setSelectionRangeHelper.

3. w.setSelectionRangeHelper is the problem It used to call the horribly
   slow lengthHelper. Now it calls w.getAllText()

But w.getAllText must be the new p.b! So the selectHelper logic could
simply pass an optional s argument to w.setInsertPoint and
w.setSelectionRangeHelper. If present, setSelectionRangeHelper will use s
rather than calling w.getAllText.

Imo, this is the safe, if not exactly elegant way.
#@+node:ekr.20141115093034.3: *6* c.executeScript adds '.' to sys.path
https://groups.google.com/forum/#!topic/leo-editor/cYWigOYtjUM

c.executeScript places '.' as the *second* element of
sys.path, following c.frame.openDirectory as before.
#@+node:ekr.20141113102829.134: *5* Features
#@+node:ekr.20141113102829.135: *6* New commands
#@+node:ekr.20141113102829.231: *7* Added focus-to-find/spell commands
The focus-to-spell command just makes the spell tab visible.

It would not be a good idea actually to transfer focus.
#@+node:ekr.20141113102829.136: *7* Added clone-find-parents command
As of rev 1d882d3. Leo supports an undoable clone-find-parents command.
Select a cloned node, then do:

    <alt-x>clone-find-parents<return>

This works somewhat like the clone-find-all command: it creates a node containing
clones of all the parents of the selected node.
#@+node:ekr.20141113102829.137: *7* Added clone-to-last-node
This does *not* change the selected node so it's easy to
clone several nodes.

Added c.cloneToLastNode.  
#@+node:ekr.20141113102829.138: *7* Added flatten-outline-to-node
Very useful when summarizing documentation nodes.
#@+node:ekr.20141113102829.139: *7* Added help-for-drag-and-drop command
#@+node:ekr.20141113102829.140: *7* Added idle-time commands
Added the following commands:
    
disable-idle-time-tracing
enable-idle-time-tracing
toggle-idle-time-tracing
disable-idle-time-events
enable-idle-time-events
toggle-idle-time-events
#@+node:ekr.20141113102829.141: *7* Added insert-file-name command
# The code is in leoEditCommands.py::insertFileName.
#@+node:ekr.20141113102829.142: *7* Added pylint command
When pylint is available on your machine, Leo's pylint
command will execute run pylint on all @<file> nodes in the
selected tree. This command is now available from the popup
menus created by the contextmenu plugin.

This command is a dynamic way of selecting files to check
with pylint. It is *much* easier to use than the old pylint
-r option in pylint-leo.py. There is no longer any need to
update a list of "recent" files. Hooray.

The command has significantly changed my work flow. I use
pylint much more often.

The details of the search process are as follows:

1. The command looks down the tree of the selected node,
   looking for @<file> nodes.
2. If now @<file> nodes are found, it looks up the tree,
   looking for @<file> nodes.
3. If the selected node is a clone, and no @<file> nodes
   have yet been found, it expands the search to all
   ancestors of all positions cloned to the selected node.

This means that you can check a file by selecting any
(possibly clone) node of the file.

**Important**: running pylint-leo.py is still often very
useful. In particular, I often run python pylint-leo.py -a
to check all files. Here is the recently improved docstring
for pylint-leo.py::

    '''
    This file runs pylint on predefined lists of files.
    
    The -r option no longer exists. Instead, use Leo's pylint command to run
    pylint on all Python @<file> nodes in a given tree.
    
    On windows, the following .bat file runs this file::
        python27 pylint-leo.py %*
    
    On Ubuntu, the following alias runs this file::
        pylint="python27 pylint-leo.py"
    '''
#@+node:ekr.20141113102829.143: *7* Added spell-as-you-type commands
Thanks to Terry Brown for these commands::

spell-as-you-type-toggle
  Enable / disable spell as you type mode.  When enabled, word ending
  keystrokes will put a short list of suggestions in the log window, if
  the word is unknown to the speller.  Only shows the first 5
  suggestions, even if there are more.

spell-as-you-type-next
  Cycle the word behind (left of, for ltr languages) the cursor through
  the full list of suggestions.

spell-as-you-type-undo
  Change the word behind (left of, for ltr languages) the cursor to
#@+node:ekr.20141113102829.144: *6* Improved commands
#@+node:ekr.20141113102829.145: *7* Improved find/replace-all commands
These commands now get their arguments from the Find Panel.

Changed the following methods:

generalChangeHelper,
minibufferFind/ReplaceAll,
searchWithPresentOptions,
setReplaceString,

Also fixed the bindings in create_find_buttons so buttons
are bound to the proper button-related methods. As a result,
the find-all and change-all buttons now work as expected.
#@+node:ekr.20141113102829.146: *7* (Optional) beautify command now uses PythonTidy
This is a major upgrade to the beautify command.

PythonTidy (tidy for short) does a full parse of the Python sources:
https://pypi.python.org/pypi/PythonTidy/

What I did today.  See the < < version info > > section for all the details::

1. Leonized tidy's sources: @file ../external/PythonTidy.py in in LeoPyRef.leo.

- Removed all pylint complaints and made other minor mods.
 
2. Suppressed features not appropriate for Leo:

- Adds shebang and encoding lines only for @<file> nodes.
- Suppress extra spacing between classes & functions.

3. Added settings to leoSettings.leo that control tidy operation:

    @bool tidy_add_blank_lines_around_comments =True
    @bool tidy_double_quoted_strings = False
    @bool tidy_keep_blank_lines = True
    @bool tidy_left_adjust_docstrings = False
    @int  tidy_lines_before_split_lit = 2
    @int  tidy_seps_before_split_line = 8

3. Fixed several important bugs:

- The original code deleted all comments because of a botch in Comments__init__.
- Tidy now properly handles the tidy_add_blank_lines_around_comments and
  tidy_double_quoted_strings settings.
#@+node:ekr.20141113102829.147: *7* Improved check outline
It now tests that all gnx's exist and are unique.
#@+node:ekr.20141113102829.148: *7* Added Yes To All and No To All buttons to dialogs
Added YesToAll and NoToAll capability to g.app.gui.runAskYesNoDialog
and uses this in the open file again? questions when opening Leo after a
crash.
#@+node:ekr.20141113102829.223: *7* Added more files to pylint -a & -p
Used glob to discover files, not static lists.
#@+node:ekr.20141117110823.5: *7* The clean-all-lines command strips trailing whitespace
#@+node:ekr.20141113102829.149: *6* Other features
#@+node:ekr.20141113102829.151: *7* Added some support for scintilla
I have been using a Scintilla widget in Leo's body pane today. It has been
the best incentive to improve it.

To enable it, set @bool qt-use-scintilla = True.

Almost everything works. It is certainly seems possible to do real work
safely and pleasantly.

The Scintilla code now honors the settings in @data qt-scintilla-styles,
but *only in leoSettings.leo, not myLeoSettings.leo. This is likely a bug
in the settings system, and I'll fix it soon.

Leo now switches between the native Scintilla colorizer and a custom,
do-nothing, colorizer depending on @language, @killcolor, etc. Creating a
custom Scintilla colorizer was unexpectedly easy. There is no native
Scintilla colorizer for @language rest. That will be the next custom
colorizer that I write.

Scintilla thinks Leo directives are decorators, so Leo directives are, in
effect, colorized.

No section references are ever colored. It *might* be possible to define a
custom colorizer that defers to a native colorizer in everything but
section references.

Most unit tests pass with @bool qt-use-scintilla = True. Something strange
is going on in the failing cases, but it doesn't seem strange enough to
cause real problems ;-) I'll be fixing these tests asap.

No other colorizing is available, but everything is in place to support
Scintilla's other native colorizers. They are:

AVS, Bash, Batch, CMake, CoffeeScript, CPP, CSS, D, Diff, Fortran77, HTML,
Lua, Makefile, Matlab, Pascal, Perl, PO, PostScript, POV, Properties,
Python, Ruby, Spice, SQL, TCL, TeX, Verilog, VHDL, YAML.
#@+node:ekr.20141117073519.9: *7* Added support for dart language
#@+node:ekr.20141113102829.152: *7* Added support for delegate languages
Allow colorizing for languages to be delegated to another language.

- Added g.app.delegate_language_dict, with three entries for David McNab.

- jEditColorizer.nameToRuleSetName now replaces the original language name
  with the delegated name.
  
There are two other changes you must make if you don't want
to use @language, as in your example with @nosent trees.

1. To write the proper delims for .hbs files, add the
   following entry in define_language_delims_dict in
   leoApp.py::

    "hbs" : "<!-- -->", # McNab: delegate to html.

2. To automatically use @language hbs in .hbs files, add the
   following entry in define_extension_dict in leoApp.py:
#@+node:ekr.20141113102829.150: *7* Added warning buttons when selecting large text
#@+node:ekr.20141113102829.230: *7* Eliminated cycle-all-focus command
Replaced by new focus-to-find and focus-to-spell commands.
#@+node:ekr.20141113102829.172: *7* Removed stand-alone globals
#@+node:ekr.20141113102829.153: *5* Plugins & leo/external
#@+node:ekr.20141113102829.154: *6* Added livecode plugin
Then livecode-show command shows the live code evaluation pane. Hover on
the buttons for helpful tool-tips.

It currently has a dependency on https://pypi.python.org/pypi/meta
which you can install with

    pip install meta

The dependency on `meta` is for recursively turning AST node trees back
into printable identifiers like "m[m[5]]"

i.e.

   a = 7

is easy,

   m[m[5]] = 7

is not.
#@+node:ekr.20141113102829.155: *6* Added nodetags.py plugin
This is only an API for tags, but I feel like it should simplify the
process and allow someone to focus on the important bits, i.e. UI hooks,
rather than low-level details. Also, it's usable now for scripts.

Here is the docstring:

Provides node tagging capabilities to Leo

By Jacob M. Peck

API
----

This plugin registers a controller object to c.theTagController, which
provides the following API::

    tc = c.theTagController
    tc.get_all_tags() # return a list of all tags used in the current
outline, automatically updated to be consistent
    tc.get_tagged_nodes('foo') # return a list of positions tagged 'foo'
    tc.get_tags(p) # return a list of tags applied to the node at
position p; returns [] if node has no tags
    tc.add_tag(p, 'bar') # add the tag 'bar' to the node at position p
    tc.remove_tag(p, 'baz') # remove the tag 'baz' from p if it is in
the tag list

Internally, tags are stored in `p.v.unknownAttributes['__node_tags']` as
a set.

UI
----

The "Tags" tab in the Log pane is the UI for this plugin.  The bar at
the top is a search bar, editable to allow complex search queries.  It
is pre-populated with all existing tags in the outline, and remembers
your custom searches within the given session.  It also acts double duty
as an input box for the add (+) button, which adds the contents of the
search bar as a tag to the currently selected node.

The list box in the middle is a list of headlines of nodes which contain
the tag(s) defined by the current search string.  These are clickable,
and doing so will center the focus in the outline pane on the selected node.

Below the list box is a dynamic display of tags on the currently
selected node.  Left-clicking on any of these will populate the search
bar with that tag, allowing you to explore similarly tagged nodes.
Right-clicking on a tag will remove it from the currently selected node.

The status line at the bottom is purely informational.

The tag browser has set-algebra querying possible.  Users may search for
strings like 'foo&bar', to get nodes with both tags foo and bar, or
'foo|bar' to get nodes with either or both.  Set difference (-) and
symmetric set difference (^) are supported as well.  These queries are
left-associative, meaning they are read from left to right, with no
other precedence.  Parentheses are not supported. See below for more
details.

Searching
---------

Searching on tags in the UI is based on set algebra.  The following
syntax is used::

    <tag>&<tag> - return nodes tagged with both the given tags
    <tag>|<tag> - return nodes tagged with either of the given tags (or
both)
    <tag>-<tag> - return nodes tagged with the first tag, but not the
second tag
    <tag>^<tag> - return nodes tagged with either of the given tags
(but *not* both)

These may be combined, and are applied left-associatively, building the
set from the left, such that the query `foo&bar^baz` will return only
nodes tagged both 'foo' and 'bar', or nodes tagged with 'baz', but *not*
tagged with all three.

Tag Limitations
---------------

The API is unlimited in tagging abilities.  If you do not wish to use
the UI, then the API may be used to tag nodes with any arbitrary
strings.  The UI, however, due to searching capabilities, may *not* be
used to tag (or search for) nodes with tags containing the special
search characters, `&|-^`.  The UI also cannot search for tags of
zero-length, and it automatically removes surrounding whitespace
(calling .strip()).
#@+node:ekr.20141113102829.156: *6* Added viewrendered2 plugin
https://groups.google.com/d/msg/leo-editor/3dH_NSQ4TsQ/ueVewAn50ZcJ

https://groups.google.com/d/msg/leo-editor/BDzmytlSegw/C0IbSz0US54J

As mentioned in my previous post I'll attempt to elaborate on the plugin
I've used to make Leo more useful to me, in case it is useful for others
also. Apologies for the very long post, but I wanted get get all its
features and warts exposed here to get some feedback on whether others see
this as useful or that this is only valuable to me. If it's useful to
others then it may be worth polishing up quite a bit.

Why a better viewrendered plugin?
---------------------------------

I like to use reStructuredText (reST) for all of my note-taking, idea
development, project and task management and automation of desktop
activities (e.g. initiating a backup). You could say it is the control
center of my daily activities, including calculating and showing dashboards
of where I am and where I'm going.

This means I need a tool which seamlessly shows me the full-fidelity
browser-rendered version of what I am writing and be able to print my notes
for meetings, cut and paste nicely formatted output to my office e-mails
and documents, as well as show some of the material as a slideshow.

The existing *viewrendered* plugin couldn't seem to do what I needed
(especially math) and I was almost ready to abandon Leo again. This time I
bit the bullet and created a more capable renderer in viewrendered2 (VR2).
Initially I made a plugin that rendered, on demand, to my normal web
browser. This worked well, but I really thought live rendering like
"viewrendered" would be better, and for that I needed close control over
scroll positions etc. that I couldn't get with an external browser. So the
plugin became much more complex as I merged it with the existing
viewrendered plugin, but was ultimately more powerful and useful to me.

Objectives
-----------

* Show a "full" html representation of any reST node or tree, without an
  @rst root node, including more features than the existing viewrendered
  plugin:

  - proper html layout
  - math (mathjax, etc.)
  - clickable URLs
  - clickable hyperlinks within the page (e.g. TOC)
  - good quality zoom
  - cut and paste html with ctl-C
  - s5 slideshows
  - javascript
  - svg images
  - configurable css

* Allow showing of node tree rather than just the current node. This can
  give a better overview perspective of the tree contents.

* Be able to lock the rendering on the root node of a tree, to view the
  effect editing a sub-node within the larger html document.

* Provide proper rendering of any combination of node types in a tree, so long as
  they have been properly designated by @language directives (i.e. reST, text,
  code, css, ...).

* Allow viewing (and printing) of an entire source file from an @file type
root node.

* Be able to *export* any of these renderings to a full web-browser to take advantage
  of the large rendering window (especially for slideshows, as well as printing, saving output.
  
* Be able to integrate automatically executed code nodes intermingled with
  reST nodes to provide an automatic calculation-based "Notebook" or "Report"
  type output.

* Don't increase the dependencies of Leo.

Implementation
--------------

VR2 is implemented mostly as an ~600 line expansion of the update_rst
method in the viewrendered.py plugin. The text-oriented class used for
rendering in VR1 has been replaced by the QWebView class which provides the
full rendering functionality of a real web-browser. To make this flexible,
a toolbar has been attached to the top with a few controls.

Because I wanted to retain compatibility with VR1, I created the
viewrendered2.py plugin, but retained all the class naming which occurred
within VR1. This means that it remains compatible with the existing
mechanisms (like free_layout) of showing and creating panes for VR1. I
tried this with an expectation that it would fail, but it appears to work
without any unintended side-effects.

Tooltips have been added where Qt allows, with the philosophy that a user
shouldn't need a manual to use this pane.

VR2 has been used a lot under Windows 7 and a little under Ubuntu 13.10.

Issues / Limitations
--------------------

I use VR2 every few minutes every working day. However, VR2 is likely to
still have a lot of rough edges and, in particular, bugs that show up with
different work flows or css folder layouts etc. In fact, VR2 is still a
work in progress and therefore still being fiddled with, so bugs creep in
regularly.

But overall, my perception of its deficiencies are:

* Does not handle reST headings within the node bodies well (sometimes very
  slow render, blocking Leo).

  - VR2 attempts to reconcile reST headings that originate from explicit
    headings within the nodes against reST headings that are automatically
    generated by the node hierarchy. In many cases, this is impossible,
    resulting in many errors which drastically slows down rendering. -
    Recommend not using headings within the nodes themselves, leaving the
    node hierarchy to do this automatically.

* If the node triggers one of the special viewrendered node header types
  (@md, @image, @movie, @html) VR2 simply defaults to the old handlers for
  those types. This means it jumps back to whatever pane type VR1 uses, so
  the features of VR2 disappear. I suspect that VR2 could incorporate these
  types into the new version and retain these new features. I should look
  at that.
    
* Doesn't integrate with rst3 plugin, especially honouring @others etc.
  There are some conflicts in objectives, so this may never be fully
  resolved. It would probably make sense for rst3 settings to get used for
  VR2 as well, along with additional VR2 specific settings. Currently, VR2
  has its own @settings-style settings. The rst3 code is not used.
  
* For slideshow purposes, a patch to docutils s5_writer is required to be
  able to handle an arbitrary hierarchy of nodes (forces all headings to
  start a new slide). Otherwise, only the 2nd level nodes (from the root)
  force a new slide.
  
* The integration of VR2 code into the existing viewrendered plugin code is
  rudimentary. I took the shortcut of not trying to understand this code
  well and confining my integration to the rst rendering only. Better
  integration would be a good future step.

With the plugin being able to execute javascript etc. there may be some
form of security issue, but I can't see it myself (given that Leo can
execute arbitrary python code anyway). Any thoughts?

Future?
-------

* Expand the export button if pandoc is installed, adding optional output
  formats such as docx, odt, plus additional slideshow formats. * Use new
  reST functionality to replace other media viewrendered methods for
  images, svg, movies, etc. * Integrate better with rst3?

Conclusion
----------

* I've attached the source as well as a bunch of screenshots. Feel free to
try out the source by putting viewrendered2 into your @enabled-plugins
instead of the usual viewrendered. I'd be interested in whether it works or
not - expect bugs to show up!

* I'm looking for feedback on whether this appears useful to others and not
just me. If so, it should probably be polished a bit more before being used
widely. Perhaps greater understanding of the existing viewrendered plugin
operation would help me here.
#@+node:ekr.20141113102829.157: *6* Added wikiview plugin
Hides text in the body editor, each time a new node is selected. Makes::

  file://#some-->headlines-->mynode     appear as mynode,
  http://www.google.com/search          appear as search, and
  `Python <https://www.python.org/>`_   appear as Python
  
There is a tiny dot to the left or right of the visible
text. Clicking that area, or clicking and dragging, or
clicking and using shift arrows *through* that area exposes
the hidden text.

full docs:
https://raw.githubusercontent.com/leo-editor/leo-editor/master/leo/plugins/wikiview.py

This plugin only addresses the visual aspects of wiki links.  Leo
already supports internal wikilinks as
file://#headline-->other%20headline-->Setup, which will now appear as
just 'Setup' with this pluing active.

#@+node:ekr.20141113102829.158: *6* Converted 7 plugins so they work with PyQt5
active_path.py, attrib_edit.py, contextmenu.py, graphcanvas.py,
notebook.py, projectwizard.py, stickynotes.py
#@+node:ekr.20141113102829.159: *6* leo/external/leoftsindex.py
From: Terry Brown <terry_n_brown@yahoo.com>

Indexing files for full text search

Just pushed leo/external/leoftsindex.py:

Stand alone GUI free index builder for Leo's full text search system::

  python leoftsindex.py <file1> <file2> <file3>...

If <file> does not contain '#' it's assumed to be a .leo file
to index, and is indexed.

If <file> does contain '#' it's assumed to be a .leo file
containing a list of .leo files to index, with the list in
the node indicated by the UNL after the #, e.g.::

   path/to/myfile.leo#Lists-->List of outlines

In the latter case, if the node identified by the UNL has children,
the list of files to scan is built from the first line of the body
of each child node of the identified node (works well with bookmarks.py).
If the node identified by the UNL does not have children, the
node's body is assumed to be a simple text listing of paths to .leo files).

note::
    
    It may be necessary to quote the "file" on the command line,
    as the '#' may be interpreted as a comment delimiter::
        
        python leoftsindex.py "workbook.leo#Links"
#@+node:ekr.20141113102829.160: *6* Rewrote at_produce plugin
This plugin used ancient coding technology, created menu items instead of
minibuffer commands, did not report progress and was probably not thread
safe.

All these defects have now been remedied. It could be quite useful in some
situations. For example, suppose node P has this body text::

    @produce echo pylint commands
    @produce pylint -v
    @produce pylint -f core\leoAtFile.py
    @produce pylint -g

Selecting node P and running the at-produce-selected command produces these
messages in the log pane::

    @produce pylint -g
    @produce pylint -g
    @produce pylint -g
    @produce pylint -g
    at-produce done

And produces a node whose headline is::

    produce.log from Sun Sep 21 06:35:37 2014

And whose body text is::

    produce: echo pylint commands
    pylint commands
    ===============
    produce: pylint -v
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -v
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -v
    pylint-leo.py 1.1.0,
    astroid 1.0.1, common 0.61.0
    Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
    ===============
    produce: pylint -f core\leoAtFile.py
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -f core\leoAtFile.py
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -f core\leoAtFile.py
    pylint-leo.py: core\leoAtFile.py
    time:  5.000 sec.
    ===============
    produce: pylint -g
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -g
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -g
    pylint-leo.py: plugins\free_layout.py
    pylint-leo.py: plugins\nested_splitter.py
    pylint-leo.py: plugins\qt_commands.py
    pylint-leo.py: plugins\qt_events.py
    pylint-leo.py: plugins\qt_frame.py
    pylint-leo.py: plugins\qt_idle_time.py
    pylint-leo.py: plugins\qt_gui.py
    pylint-leo.py: plugins\qt_text.py
    pylint-leo.py: plugins\qt_tree.py
    time: 40.073 sec.
    ===============
#@+node:ekr.20141113102829.161: *5* Settings & command-line options
#@+node:ekr.20141113102829.162: *6* Added --no-persist command-line option
removed new_auto switch in leoAtFile.py

added g.app.at_auto_persist

c.persistenceController exists only if g.app.auto_persist is True
#@+node:ekr.20141113102829.163: *6* Added --trace-plugins option
#@+node:ekr.20141113102829.164: *6* Added @int max-pre-loaded-body-chars
#@+node:ekr.20141113102829.165: *6* Added @bool auto-scroll-find-tab
The default is True, so as to enable the "fix" to bug
1254861: find - ctrl-f doesn't ensure find input field
visible https://bugs.launchpad.net/leo-editor/+bug/1254861

I found the new behavior extremely unpleasant. For me, it
was the worst fit-and-finish issues with Leo.
#@+node:ekr.20141113102829.166: *6* Added support for html handlebar syntax coloring
These are colored with the previously unused literal3 tag,
so you specify the color with:

    @color html_literal3_color = pink
#@+node:ekr.20141113102829.167: *6* Fully parameterized style sheet
Almost all settings in @data qt-gui-plugin-style-sheet in leoSettings.leo
are now defined in terms of @values. Traditional Leo settings nodes
(@strings, @color, @font, etc.) define these @values.

Most users, and certainly all newbies, will never have to touch, or even
look at, @data qt-gui-plugin-style-sheet. This is a really good thing,
because the slightest syntax error silently messes up everything that
follows.

Notes:

1. There is now a node called "Basic Fonts (change these first)"
   This node contains the basic font definitions. Changing only the
   settings in this tree (in myLeoSettings.leo, of course) should be enough
   to get Leo looking pretty much as it was.

2. Don't even *think* about changing @data qt-gui-plugin-style-sheet.
   Really, the whole point of this exercise is to be able to change all
   aspects of Leo's appearance without touching this stylesheet. As Terry
   points out, there will always be a place for @data qt-gui-user-style-sheet

3. In an emergency, there is at present a node called "OLD
   qt-gui-plugin-style-sheet" that you could use to revert to the old
   settings. Just rename it and copy it to your myLeoSettings.leo.

4. The new settings scheme will moot the need for leo10pt.leo, leo12pt.leo
   and all the rest. Instead, all font sizes are now defined in terms of
   three intermediate settings: @string font-size, @string medium-font-size
   and @string small-font-size. Changing just these three settings will
   suffice to change *all* the font sizes used in Leo.

5. When things don't look right, I execute this script::

    c.styleSheetManager.print_style_sheet()

This prints the complete stylesheet to the console. What I mainly look for
are lines like::

    background-color: @some-setting

An @value as the value of a setting indicates that no substitution took
place, that is, that there is no node::

    @string some-setting = aValue

Any user that wants to roll their own @data node will want to be aware of
this technique.

5. The @data qt-gui-**user**-style-sheet setting is deprecated. Indeed,
   @data qt-gui-**plugin**-style-sheet now takes care to define almost
   everything that any user would want to define. myLeoSettings.leo should
   contain overrides of only the @color and @string nodes in
   leoSettings.leo.
#@+node:ekr.20141113102829.168: *6* Leo stylesheets now support all color names in leoColor.py
For example, this setting works without any explicit definition of mistyrose2.
    
    @color head-bg = @mistyrose2
#@+node:ekr.20141103061944.55: *4* Leo 5.0a2 release notes
Leo 5.0 alpha 2                     November 8, 2014

Leo 5.0a2 is now available at:
http://sourceforge.net/projects/leo/files/Leo/

Leo is a PIM, an IDE and an outliner.
Video tutorials: http://leoeditor.com/screencasts.html
Text tutorials: http://leoeditor.com/tutorial.html

The highlights of Leo 5.0
--------------------------

* Better compatibility with vim, Emacs, pylint and PyQt:
    - Optional native emulation of vim commands.
    - Full support for Emacs org-mode outlines.
    - Better support for pylint.
    - Support for both PyQt4 and PyQt5.
* Better handling of nodes containing large text:
    - Idle time syntax coloring eliminates delay.
    - Optional delayed loading of large text.
* Power features:
    - Leo available via github repository.
    - File name completion.
    - Cloned nodes expand and contract independently.
    - @data nodes can be composed from descendant nodes.
    - No need to change Leo's main style sheet:
      it can be customized with @color and @font settings.
    - @persistence nodes save data in @auto trees.
    - A pluggable architecture for @auto nodes.
    - The style-reload command changes Leo's appearance instantly.
* Important new plugins for tagging, display and node evaluation.
* For beginners:
    - Leo's default workbook files contains Leo's quickstart guide.
* Hundreds of new/improved features and bug fixes.

Links:
------
Leo:       http://leoeditor.com
Docs:      http://leoeditor.com/leo_toc.html
Tutorials: http://leoeditor.com/tutorial.html
Videos:    http://leoeditor.com/screencasts.html
Forum:     http://groups.google.com/group/leo-editor
Download:  http://sourceforge.net/projects/leo/files/
Github:    https://github.com/leo-editor/leo-editor
Quotes:    http://leoeditor.com/testimonials.html
#@+node:ekr.20141103061944.246: *5* Highlights
#@+node:ekr.20141103113220.17: *6* Better integration with Vim, Emacs & pylint
#@+node:ekr.20141103061944.216: *7* vim mode
See: http://leoeditor.com/vimBindings.html#using-leo-s-native-vim-mode

do_visual_mode will extend the selection if visual_line_mode is True.

Affected methods: vc.vim_V and vc>do_visual_mode.

It would be good if LeoQTextEditWidget.setSelectionRangeHelper could handle
insert points in the middle of a text selection, but at present it can't.
#@+node:ekr.20141103113220.12: *7* Better support for pylint
Created g.run_pylint so pylint can run unmodified. This runs pylint (with
optional Sherlock tracing) in a separate process, thereby allowing Leo to
run pylint unchanged.

What I did:

1. pylint-leo.py: run now runs the following command in a separate process::

    <python> -c "import leo.core.leoGlobals as g; g.run_pylint(<args>)"
    
2. g.run_pylint uses Sherlock tracing if requested.

    
#@+node:ekr.20141103061944.208: *7* Full support for Emacs org-mode
Note: persistence applies to @auto-vimoutline-mode and @auto-org-mode

Done:
- Added @auto-org-mode to list of valid @auto nodes.
- Created org-mode importer.
- Create at.writeOneOrgModeNode, called from at.writeOneAtAutoNode
#@+node:ekr.20141103113220.18: *6* Power features
#@+node:ekr.20141103061944.86: *7* @data nodes can now be composed from a tree of nodes
How did we ever live without this?

@data nodes, like @data qt-gui-plugin-style-sheet may now be composed of
the body text of the @data node itself, concatenated to the body text of
all its descendants, in outline order.

For example, @data qt-gui-plugin-style-sheet node consists of some general
comments, with descendant nodes for the body pane, tree pane, etc. etc.
There is no limit of nesting: the Plugins node has a child for each plugin
that uses style sheets.

Not only does this new arrangement make it far easier to find the style
sheet of interest, it makes debugging style sheets easier. Typically, an
error in any part of the style sheet invalidates the whole style sheet.
With the new organization, one can swap nodes into or out of the @data node
to find the invalid node or nodes.

Two fine points about the concatenation of data:

1. Descendant nodes whose headlines start with '@' do not become part of
   the data. At present, no @data nodes have descendants, but this
   convention does something reasonable if nodes like @int or @string were
   descendants of an @data node.

2. The @data parser adds a newline to every "fragment" if necessary. This
   doesn't seem to matter for style sheets, but it could matter for other
   kinds of @data data.
#@+node:ekr.20141103061944.201: *7* Clones expand and contract independently
https://groups.google.com/forum/#!topic/leo-editor/Wd0NtBLEZZk

Leo now stores "ephemeral" or position-related data **in vnodes*. This is a
completely new idea in Leo's history!
#@+node:ekr.20141103061944.71: *7* File name completion
The :r, :tabnew, insert-file-name and  file-open-by-name commands now have file-name completion

I bind Ctrl-O to file-open-by-name to bypass the Windows open file dialog.
#@+node:ekr.20141103113220.13: *7* Better support for nodes containing large text
The user can lose text if they start typing before the body text completely loads!

- Added c.max_pre_loaded_body_chars = c.config.getInt('max-pre-loaded-body-chars')

- The "dummy" body text now contains a warning to wait until the text fully loads.
#@+node:ekr.20141103061944.78: *7* Leo now colors text at idle time
Leo now uses an all-Python replacement for the QSyntaxHighlighter class.

This fixes git bug 28: https://github.com/leo-editor/leo-editor/issues/28
Leo hangs when a node with too large body is selected

To see the effect of the new code:

1  Create a node with *lots* of colored text.
2. Move the cursor to the last line of the text.
3. Select another node, and then move back to the "big" node.

You should see the end of the text all in black at first, and then become
colored later.

In the meantime, Leo is responsive to all commands, mouse clicks, etc.
#@+node:ekr.20141103061944.87: *7* Fully parameterized style sheet
Almost all settings in @data qt-gui-plugin-style-sheet in leoSettings.leo
are now defined in terms of @values. Traditional Leo settings nodes
(@strings, @color, @font, etc.) define these @values.

Most users, and certainly all newbies, will never have to touch, or even
look at, @data qt-gui-plugin-style-sheet. This is a really good thing,
because the slightest syntax error silently messes up everything that
follows.

Notes:

1. There is now a node called "Basic Fonts (change these first)"
   This node contains the basic font definitions. Changing only the
   settings in this tree (in myLeoSettings.leo, of course) should be enough
   to get Leo looking pretty much as it was.

2. Don't even *think* about changing @data qt-gui-plugin-style-sheet.
   Really, the whole point of this exercise is to be able to change all
   aspects of Leo's appearance without touching this stylesheet. As Terry
   points out, there will always be a place for @data qt-gui-user-style-sheet

3. In an emergency, there is at present a node called "OLD
   qt-gui-plugin-style-sheet" that you could use to revert to the old
   settings. Just rename it and copy it to your myLeoSettings.leo.

4. The new settings scheme will moot the need for leo10pt.leo, leo12pt.leo
   and all the rest. Instead, all font sizes are now defined in terms of
   three intermediate settings: @string font-size, @string medium-font-size
   and @string small-font-size. Changing just these three settings will
   suffice to change *all* the font sizes used in Leo.

5. When things don't look right, I execute this script::

    c.styleSheetManager.print_style_sheet()

This prints the complete stylesheet to the console. What I mainly look for
are lines like::

    background-color: @some-setting

An @value as the value of a setting indicates that no substitution took
place, that is, that there is no node::

    @string some-setting = aValue

Any user that wants to roll their own @data node will want to be aware of
this technique.

5. The @data qt-gui-**user**-style-sheet setting is deprecated. Indeed,
   @data qt-gui-**plugin**-style-sheet now takes care to define almost
   everything that any user would want to define. myLeoSettings.leo should
   contain overrides of only the @color and @string nodes in
   leoSettings.leo.
#@+node:ekr.20141103061944.85: *7* The style-reload command changes Leo's appearance instantly
The style-reload reloads all visual settings.

Suppose you have the following @button node:

    @button reload-styles
    c.k.simulateCommand('style-reload')

And suppose you have the following setting in your local @setting tree::

    @string font-size = 12pt

Change the setting to 10pt (or 14pt), click the button, and see what happens :-)

The present code doesn't deal with themes, although there is some commented
out that hints about what might be done.
#@+node:ekr.20141103061944.211: *7* A plugable architecture for @auto nodes
The leo/plugins/importers folders now contains importer plugins.

The leo/plugins/writers folders now contain writer plugins.

Both importer and writer plugins can defined new kinds of @auto nodes.

Importers and writers can register either @auto-names or file extensions.
For example, @auto x.xyzzy will use both the importer and the writer for
the .xyzzy extension, that is, importers/test.py and writers/test.py. So,
for *unique* extensions, there is no need to use a separate @auto name, you
can just use @auto.
#@+node:ekr.20141103061944.230: *6* Leo's default workbook contains Leo's quickstart guide
The default workbook contains both the cheat sheet and an example from the
rst3 tutorial.

#@+node:ekr.20141103061944.94: *5* Bugs fixed
Over 70 bugs have been fixed.
#@+node:ekr.20141108044720.5: *6* Bugs fixed in 5.0a2
- Leo's desktop button now works properly with Python 3.x.
  The underlying cause was that Leo did not work with python34\pythonw.exe.

- Fixed name of a Qt class in richtext.py plugin.
#@+node:ekr.20141108044720.4: *6* Bugs fixed in 5.0a1
#@+node:ekr.20141103061944.240: *7* Fixed 14 github bugs
#@+node:ekr.20141103061944.152: *8* Fixed bug 12: when hoisted, the (alt-)arrow keys can't navigate to the top node
https://github.com/leo-editor/leo-editor/issues/12

The fix was to p.isVisible.
#@+node:ekr.20141104053638.7: *8* Fixed bug 28: Leo hangs when a node with too large body is selected
https://github.com/leo-editor/leo-editor/issues/28

Summary post:
https://groups.google.com/d/msg/leo-editor/b6TszFS_6NQ/gJrlRkqH9_oJ
#@+node:ekr.20141103061944.139: *8* Fixed bug 31: 'undo' on a freshly-loaded outline
https://github.com/leo-editor/leo-editor/issues/31
'undo' on a freshly-loaded outline containing chapters removes chapters

Chapter.afterCreateChapter does not push undo data when cc.initing is True.
#@+node:ekr.20141103061944.138: *8* Fixed bug 35: leoBridge sometimes assigns the same GNX to two distinct vnodes
https://github.com/leo-editor/leo-editor/issues/35
leoBridge sometimes assigns the same GNX to two distinct vnodes

c.initObjects sets c.hiddenRootNode.fileIndex to 'hidden-root-vnode-gnx'

fc.getLeoFile calls the new fc.setMaxNodeIndex after reading all nodes.
#@+node:ekr.20141103061944.153: *8* Fixed bug 36: @auto file not found produces a script error
https://github.com/leo-editor/leo-editor/issues/36

The report seems misleading: it says this happens when Leo tries to load an
@auto file that is in the outline but which's file was erased outside Leo,
but it worked for me.

I did add a guard in g.recureiveUNLFind to ensure that the IndexError shown
in the bug report can never happen.
#@+node:ekr.20141103061944.141: *8* Fixed bug 50: Important body text lost switching @file to @auto-rst
https://github.com/leo-editor/leo-editor/issues/50
Important: body text lost switching @file to @auto-rst

This case is so dangerous that Leo refuses to create the file and instead
reverts to the previous @file node.

Changes:
    
- v.at_read is now a dict: keys are full file names; values are lists of headlines.
- at.shouldPromptForDangerousWrite returns True if p.h is not in v.at_read.
- at.promptForDangerousWrite issues a warning and reverts the headline
#@+node:ekr.20141103061944.157: *8* Fixed bug 59: drag and drop: target too small
https://github.com/leo-editor/leo-editor/issues/59

When a file is dropped into any part of the Leo window, if the cursor is
not on a node it goes to the top or bottom of the tree as a root node.
#@+node:ekr.20141103061944.158: *8* Fixed bug 60: create relative paths & urls when dragging files to Leo
https://github.com/leo-editor/leo-editor/issues/60

It would be nice for Drag and drop files to have relative paths,taking into
account the @path settings of the part of the tree they're dropped into
(currently it is relative to the .leo file).
#@+node:ekr.20141104053638.8: *8* Fixed bug 63: refresh-from-disk does not clear big text load delay UI
https://github.com/leo-editor/leo-editor/issues/63
#@+node:ekr.20141104053638.9: *8* Fixed bug 64: https://github.com/leo-editor/leo-editor/issues/64
https://github.com/leo-editor/leo-editor/issues/64
#@+node:ekr.20141103061944.177: *8* Fixed bug 74: problems with @button if defined in myLeoSettings.leo
https://github.com/leo-editor/leo-editor/issues/74

What I did:

- ScriptingController now uses *gnxs* (not vnodes!) to detect duplicate buttons.
- Use AtButtonCallback for *all* buttons.
- QtIconBarClass.setCommandForButton always calls
  ScriptingController.build_rclick_tree.
- build_rclick_tree no longer assumes that command_p exists.

Rev 8413e2d fixes an important bug in the new code: "remote"
buttons (buttons defined in settings files) now work if the
settings file is not open.

There are some tricky details that must be handled. As an
example, consider a button defined as follows in
myLeoSettings.leo:

    @button print p.h
    print(p.h)

Detail 1: Leo must open myLeoSettings.leo to find the
@button node. Unlike the Goto Script rclick item, the search
does *not* leave myLeoSettings.leo open. That would be too
great a side effect of clicking the @button node!

Detail 2: We don't want to open myLeoSettings.leo every time
the user clicks the buttons, so the first time the user does
so the script is saved (cached). If the user clicks the
button later the cached value is used.

Detail 3: Caching is used "forever" (while Leo remains
open), even if the user opens myLeoSettings.leo and changes
the script. Sorry, this can't be helped. Don't ask me to
change this.

Detail 4: The new code is careful to execute the script in
the commander in which the button is *located*, not in the
commander in which the button is defined.

Report:

Putting @button definitions in myLeoSettings.leo (in an @buttons tree)
makes them available in all Leo files, a nice feature. Two problems:

- The buttons lack the 'Goto Script' rclick feature in all .leo files.
- There are duplicate buttons in myLeoSettings.leo

#@+node:ekr.20141103061944.147: *8* Fixed bug 75: write-opml-file always produces an empty file
https://github.com/leo-editor/leo-editor/issues/75
write-opml-file always produces an empty file

leoOPML.py's docstring needs updating.

Improved the packaging as follows:

- The leoOPML plugin no longer monkey patches any part of the FileCommands
  class. Instead the plugin sets the c.opmlController ivar.

- fc.writeToFileHelper calls c.opmlController.putToOPML(owner=self).
    
- OpmlController.putToOPML is just PutToOPML(owner) where PutToOPML is a
  class that creates the opml using the owner's put method.
#@+node:ekr.20141103061944.148: *8* Fixed bug 76: erroneous clone markers in @auto trees
https://github.com/leo-editor/leo-editor/issues/76
erroneous clone markers in @auto trees

The fixes were to several methods of the PersistenceDataController class.
#@+node:ekr.20141103061944.179: *8* Fixed bug 78: F3 find-next target not always highlighted
https://github.com/leo-editor/leo-editor/issues/78

This is a scrolling problem, not a failure to select text.

Changed the call to w.see in find.showSuccess.
#@+node:ekr.20141103061944.236: *7* Fixed 20+ Launchpad bugs
#@+node:ekr.20141103113220.20: *8* Cleared/investigated bugs
#@+node:ekr.20141103061944.95: *9* Cleared bug 1228457: Beginning find at the current node's body cursor when that cursor is not displayed
https://bugs.launchpad.net/leo-editor/+bug/1228457

This appears to have been fixed.
#@+node:ekr.20141103061944.96: *9* Cleared bug 1228713: Find-backward skips headlines under some conditions
https://bugs.launchpad.net/leo-editor/+bug/1228713

This appears to have been fixed at some time in the past, possibly as the result of fixing another bug.
#@+node:ekr.20141103061944.97: *9* Cleared bug 1254864: Can't search from current cursor position downward in body text
https://bugs.launchpad.net/leo-editor/+bug/1254864
#@+node:ekr.20141103061944.161: *9* Investigated bug  524890: Incomplete derived file
https://bugs.launchpad.net/leo-editor/+bug/524890
Incomplete derived file

This bug was fixed by the allow_cloned_sibs logic in leoAtFile.py 2013/01/20.
#@+node:ekr.20141103061944.166: *9* Investigated bug 1177355: node-only wrapped search does not work in long nodes
https://bugs.launchpad.net/leo-editor/+bug/1177355
node-only wrapped search does not work in long nodes

This works for me.
#@+node:ekr.20141103061944.143: *9* Investigated bug 1193820: Focus change on tree pane after saving current Leo file
From https://github.com/leo-editor/leo-editor/issues/73

https://bugs.launchpad.net/leo-editor/+bug/1193820
Focus change on tree pane after saving current Leo file
    
Using Qt. First reported here:
https://groups.google.com/forum/#!topic/leo-editor/hPwPG9OTC3U

This no longer seems to be a problem.
#@+node:ekr.20141104142429.5: *9* Investigated bug 1266269: Mac: alt-x does not work in body pane
https://bugs.launchpad.net/leo-editor/+bug/1266269
Mac: alt-x does not work in body pane

No problem with a clean homebrew install on MacOS 10.9 Mavericks.
#@+node:ekr.20141103061944.165: *9* Investigated bug 1268970: Leo does not remember window maximized state
https://bugs.launchpad.net/leo-editor/+bug/1268970

This works for me (Windows 7 and Ubuntu) with Python 2.7.8, PyQt version 4.8.6.
#@+node:ekr.20141103061944.181: *9* Investigated bug 1282362: shadow file name collisions cause spontaneous clone creation
[Fixed?] https://bugs.launchpad.net/leo-editor/+bug/1282362
shadow file name collisions cause spontaneous clone creation

Works for me. Furthermore, the scenario is bizarre enough not to be important.

- Create a new leo file.
- Create @shadow foo.txt
- Set body to @others, add two children, with different body texts.
- Copy / paste the @shadow node, change the path to x/foo.txt

(In shell, create x folder, saving shadow doesn't create path, which is
maybe another bug) save and close file

open file again, children of shadow nodes are clones of each other. I think
it's the name collision, not the copy pasting etc.

#@+node:ekr.20141103061944.140: *9* Investigated bug 869098: Context menu settings lost if save as used
https://bugs.launchpad.net/leo-editor/+bug/869098
Context menu settings lost if save as used

This report appears invalid.

The renamed file uses the @data contextmenu_commands node in that files.

Note that @data contextmenu_commands node in the file *replaces* any other
@data contextmenu_commands node in leoSettings.leo or myLeoSettings.leo.

#@+node:ekr.20141103061944.169: *8* Fixed bug 1028986: create relative urls when dragging binary files to Leo
https://bugs.launchpad.net/leo-editor/+bug/1028986
create relative urls when dragging binary files to Leo

This bug was fixed by #60: 
https://github.com/leo-editor/leo-editor/issues/60
create relative paths & urls when dragging files to Leo

Modified dropEvent and its helpers.

Added createLeoFileTree and isLeoFile.

Regular drag of .leo files from a file folder works like the open-outline
command.

Ctrl-drag of .leo files from a file folder copies all nodes of the .leo
file to the receiving outline.

#@+node:ekr.20141103061944.102: *8* Fixed bug 1041906: underlying C/C++ object has been deleted
https://bugs.launchpad.net/leo-editor/+bug/1041906

Changed LeoQtTree.closeEditorHelper as follows:
    
- Call w.setItemWidget(item,0,None) to make sure e is never referenced again.
    
- Catch RuntimeError exceptions.
#@+node:ekr.20141103061944.103: *8* Fixed bug 1090950: refresh from disk - cut node resurrection
Fixed bug 1090950: refresh from disk - cut node resurrection.
https://bugs.launchpad.net/leo-editor/+bug/1090950

refresh_rclick_cb in contextmenu.py now just calls c.refreshFromDisk,
which calls c.recreateGnxDict() before reading any file.

Also created the new refresh-from-disk command and the corresponding item in the File menu.
#@+node:ekr.20141103061944.160: *8* Fixed bug 1185933: insert-headline-time should insert at cursor
https://bugs.launchpad.net/leo-editor/+bug/1185933

Note: the insert-headline-time command must be bound to a shortcut in order for this to work.
#@+node:ekr.20141103061944.105: *8* Fixed bug 1228312: Find tab selected in log pane disables Minibuffer
https://bugs.launchpad.net/leo-editor/+bug/1228312

This was the so-called "greedy checkbox bug".
#@+node:ekr.20141103061944.113: *8* Fixed bug 1228452: related to the radio buttons in the Find pane
https://bugs.launchpad.net/leo-editor/+bug/1228452

#@+node:ekr.20141103061944.106: *8* Fixed bug 1228458: Inconsistency between Find-forward and Find-backward
https://bugs.launchpad.net/leo-editor/+bug/1228458
#@+node:ekr.20141103061944.162: *8* Fixed bug 1231656: File-Compare-Leo-Files leaves other file open-count incremented
https://bugs.launchpad.net/leo-editor/+bug/1231656

This bug may already have been fixed, but just to make sure compareLeoFiles
now calls g.app.forgetOpenFile
#@+node:ekr.20141103061944.163: *8* Fixed bug 1244461: Numpad 'Enter' key does not work in minibuffer
https://bugs.launchpad.net/leo-editor/+bug/1244461

LeoQtEventFilter.qtKey now changes a toString value of 'Enter' to 'Return'
#@+node:ekr.20141103061944.146: *8* Fixed bug 1245535: API allows headlines to contain newlines
https://bugs.launchpad.net/leo-editor/+bug/1245535
#@+node:ekr.20141103061944.150: *8* Fixed bug 1245616: Autocomplete ? function...does not work
https://bugs.launchpad.net/leo-editor/+bug/1245616
#@+node:ekr.20141103061944.167: *8* Fixed bug 1251252: Minibuffer commands created by mod_scripting.py have no docstrings
https://bugs.launchpad.net/leo-editor/+bug/1251252

F11 (help-for-command) now works for @button & @command nodes.
#@+node:ekr.20141103061944.107: *8* Fixed bug 1254861: Ctrl-f doesn't ensure find input field visible
https://bugs.launchpad.net/leo-editor/+bug/1254861
#@+node:ekr.20141103061944.144: *8* Fixed bug 1258373: failed find focus fails
https://bugs.launchpad.net/leo-editor/+bug/1258373
#@+node:ekr.20141103061944.108: *8* Fixed bug 1260415: exception writing external files" is insufficient
https://bugs.launchpad.net/leo-editor/+bug/1260415
Added more informative error messages
#@+node:ekr.20141103061944.109: *8* Fixed bug 1264350: Up-arrow on the first node in a chapter switches to another chapter
https://bugs.launchpad.net/leo-editor/+bug/1264350
#@+node:ekr.20141103061944.164: *8* Fixed bug 1267921: isearch-forward accepts non-alphanumeric keys as input
https://bugs.launchpad.net/leo-editor/+bug/1267921
#@+node:ekr.20141103061944.121: *8* Fixed bug 1276236: unicode problem in the log pane
https://bugs.launchpad.net/leo-editor/+bug/1276236

g.insertCodingLine adds coding line to start of all python scripts, except when unit testing.
#@+node:ekr.20141103061944.170: *8* Fixed bug 613153: unable to describe root directory on thumb drive
https://bugs.launchpad.net/leo-editor/+bug/613153

Use the %~dp0 syntax. Example::

  %~dp0\Python27\python.exe %~dp0\Leo-editor\launchLeo.py

http://ss64.com/nt/syntax-args.html
http://stackoverflow.com/questions/5034076/what-does-dp0-mean-and-how-does-it-work

I have just created a FAQ entry for this, so at last this issue is closed.
#@+node:ekr.20141103061944.159: *8* Fixed bug 735938: file association crash
https://bugs.launchpad.net/leo-editor/+bug/735938
#@+node:ekr.20141103061944.176: *8* Fixed bug 969391: setup.py confuses newbies
https://bugs.launchpad.net/leo-editor/+bug/969391
#@+node:ekr.20141103061944.237: *7* Fixed 30+ other bugs
#@+node:ekr.20141103061944.137: *8* eliminated "can not exedute commands from headlines"
Removed the odious "'Can not execute commands from headlines" message.

Leo now ends editing, replaces the event.widget and event.w fields with
c.frame.body.wrapper.widget and carries on.
#@+node:ekr.20141103061944.98: *8* find-all now uses exising find pattern
#@+node:ekr.20141103061944.99: *8* Fixed a startup error involving --ipython
Fixed a bug that caused Leo to exit during startup when
--python given on the command line but IPython is not installed.
#@+node:ekr.20141103061944.100: *8* Fixed annoyance: shift-ctrl-w leaves .leo file as dirty
- pd.update_before_write_foreign_file tells when an @data node has been
  changed. This explains why the .leo file is now dirty.
- at.saveOutlineIfPossible automatically saves the .leo file if only
  unchanged persistence nodes remain.
  
at.saveOutlineIfPossible makes the following hacks unnecessary:
    
- at.writeAllHelper writes an unchanged @auto file only if it is
  selected explicitly.
- Changed at.writeAll so that the no @<file> node written message now says
  that you must selected an unchanged @auto node directly in order to write
  it with the write-at-files-nodes command.
#@+node:ekr.20141103061944.125: *8* Fixed autocompleter bug
https://groups.google.com/d/msg/leo-editor/NGbogCgVmx4/nsJGngrS8BgJ
#@+node:ekr.20141103061944.59: *8* Fixed bug re the factor language
Fixed the entry in g.app.language_extension_dict
#@+node:ekr.20141103061944.110: *8* Fixed bug: activate events now properly restore focus
Previously, Ctrl-F Alt-tab Alt-tab would put focus in an inactive minibuffer.

The fix involved rewriting onActivate/DeactivateEvent.
#@+node:ekr.20141103061944.154: *8* Fixed bug: Find-previous fails at last node
https://groups.google.com/d/msg/leo-editor/RAzVPihqmkI/-tgTQw0-LtwJ

This only affected searches that were initiated using the buttons in the Find tab.

What I did:
    
- Init buttonFlag ivar in setup_button & setup_command.
- showSuccess sets was_in_headline ivar.
- focusInTree returns was_in_headline when buttonFlag is True.
- editLabelHelper now properly sets selection range for backward searches.
- Removed a selection hack in initNextText.
#@+node:ekr.20141103061944.111: *8* Fixed clone-find-all command
Changed find.findAll and helpers as follows:
    
- findAll inits onlyPosition for the clone-find-all commands.
    
- createCloneFindAllNode does not link the node into the outline.
  To do this, leoFind.py imports leo.core.leoNodes.

- linkCloneFindAllNode does this *after* the command completes. This keeps
  all positions unchanged while they are being scanned.
   
- The code now tests for either clone_find_all or clone_find_all_flattened
  in various places.
#@+node:ekr.20141103061944.112: *8* Fixed Crash deleting body editor
# Trying to delete a second body editor.

Traceback (most recent call last):
  File "c:\leo.repo\trunk\leo\core\leoCommands.py", line 560, in doCommand
    val = command(event)
  File "c:\leo.repo\trunk\leo\plugins\qtGui.py", line 2980, in deleteEditor
    name = w.leo_name
AttributeError: 'LeoQTextBrowser' object has no attribute 'leo_name'
#@+node:ekr.20141103061944.126: *8* Fixed find bug
https://groups.google.com/forum/#!topic/leo-editor/yR8eL5cZpi4

Another example of the wretched newline problem. @edit nodes preserve '\r'
characters, and that messes up the counts in the find command.

The fix was a hack to find.search: it removes '\r' characters.

#@+node:ekr.20141103061944.114: *8* Fixed important security hole in mod_scripting plugin
The ctor of the scriptingController does not allow::

    @bool scripting-at-script-nodes = True
    
in local .leo files. 
#@+node:ekr.20141103061944.115: *8* Fixed leoGlobals bug (per Reinhard Engle)
@language rest

Reinhard Engel reinhard.engel.de@googlemail.com

There seems to be a subtle bug in leoGlobals.py:

In the 'globalDirectiveList', the directive 'command' is missing. This
seems not to cause problems, because of the way 'aList' in
'compute_directives_re' is constructed. Then in 'get_directives_dict' the
directive is silently skipped.

The following pattern in 'compute_directives_re' solves this problem:

@language python

    aList = [x for x in globalDirectiveList if z != 'others']
    aList.sort(lambda a,b: len(b)-len(a))
        # Sort by length, longest first
    pat = "^@(%s)(?=( |\t|\n)+)" % "|".join(aList)
#@+node:ekr.20141103061944.116: *8* Fixed modes/md.py
@language python

import glob
pattern = g.os_path_finalize_join(g.app.loadDir,'..','modes','*.py')
for fn in glob.glob(pattern):
    sfn = g.shortFileName(fn)
    f = open(fn)
    s = f.read()
    f.close()
    if s.find(r'regexp="\\') > -1:
        g.es(sfn)

@language text

Possible automatic computation of First sets:
http://stackoverflow.com/questions/787134/can-i-determine-the-set-of-first-chars-matched-by-regex-pattern
http://www.cs.uky.edu/~lewis/texts/theory/automata/reg-sets.pdf

found: Rules indicated are dubious or broken

md.py:
    disabled: 6,7,
    changed: 8,12,20,21,23,24,25,47
    [ \t]   leadins: 8,20,24,25,50,51
    space   leadins: 23,46,49
    [=-]    leadins: 21,47
    [\\_]   leadins: 54,55
    other   leadins: 12,19,53

moin.py:
    [ \t]           rule 3.
    single-quote    rule 6.

erlang.py:  no obvious problem.
lilypond.py:no obvious problem.
perl.py:    no obvious problem.
pl1.py:     no obvious problm.
rest.py:    no obvious problem.
rtf.py:     no obvious problem.
scala.py:   no obvious problem.
yaml.py:    fixed
#@+node:ekr.20141103061944.117: *8* Fixed problem with 1-character reverse searches!
The problem was an off-by-one test in regexHelper.
#@+node:ekr.20141103061944.118: *8* Fixed problems with clone-expansion
Alt-End when the last top-level node was a clone caused all clones to expand.

The fix was in p.isAncestorOf.

Also, changed p.all_unique_positions() to p.all_positions() in places where p.contract was called.

I started this project by doing a clone-find-all for isExpanded.
#@+node:ekr.20141103061944.131: *8* Fixed QCompleter bug
http://i.imgur.com/1ZV45oB.png

There was a problem with hitting tab, and possibly with using the mouse in the QListWidget.

The fix was to define w as follows in lqlw.select_callback and lqlw.tab_callback:
    
    w = c.k.autoCompleter.w or c.frame.body.wrapper

In addition, I changed assert in lqlw.set_position to calls to g.trace.
#@+node:ekr.20141103061944.119: *8* Fixed recent bug in change command
The change pattern doesn't always get set properly.

The fix was in find.addChangeStringToLabel. It must never protect the
change string!
#@+node:ekr.20141103061944.129: *8* Fixed recursive import bug
https://github.com/leo-editor/leo-editor/issues/49

The file import code as found in scripts fails on reaching
Word backup files (file names prefixed with a ~)

The problem was that g.os_path_join automatically called
os.path.expanduser, which converts ~ to the users home directory.

The fix was to disable the call to os.pathexpanduser in g.os_path_join &
g.os_path_finalize if the new expanduser keyword argument is False.
#@+node:ekr.20141103061944.120: *8* Fixed serious bug in c.deletePositionsInList
https://groups.google.com/forum/#!topic/leo-editor/Uoa7ifVV_Aw
#@+node:ekr.20141103061944.180: *8* Fixed several crashers re no-to-all during startup
The present code just exists Leo, which imo is the reasonable thing to do. 
#@+node:ekr.20141103061944.155: *8* Fixed suboutline only find bug
https://groups.google.com/d/msg/leo-editor/ujDqUI68Sx4/EwTYCw7O38cJ

qtree.onItemClicked now calls c.findCommands.reset_state_ivars()
#@+node:ekr.20141103061944.124: *8* Fixed tab cycling
Tab cycling now works as expected in all my tests.

- Reset tab cycling if the user types backspace or any plain character.
- Start cycling *only* if len(label) == len(common_prefix)

These restriction appear to be essential.
#@+node:ekr.20141103061944.151: *8* Fixed tab-completion problems
It sometimes picked a shorter completion that is not a prefix of the present label!

Examples:
    print-se **sometimes** shows print-uas or print-bindings or...
    print-stat<tab>-h<tab> shows print-statusbar-hide
    print-st<tab> shows print-style-sheet.
    print-pr<tab> show print-plugin-handlers.
    
The fix was a single extra check in ga.do_tab.
#@+node:ekr.20141103061944.127: *8* Fixed unwanted scrolling in abbreviations
Saved and restored the y-scroll position in find_place_holder.
#@+node:ekr.20141103061944.122: *8* Gave the Find Tab the intended amount of border
dw.createGrid now honors the margin argument.
#@+node:ekr.20141103061944.132: *8* Improved ctrl-o code
- Non-plain keys are now ignored.
- Backspace and other characters now do something fairly reasonable when text is selected.
  This is an edge case, unless everything to the end of the text is selected.
#@+node:ekr.20141103061944.178: *8* Investigated bug: fill-region & format-body can hang
This was probably fixed earlier by the addition of progress guards
in ec.fillRegion and c.reformatBody.

Added one line for fillRegion.
#@+node:ekr.20141103061944.136: *8* Made beautify commands compatible with pep8
http://legacy.python.org/dev/peps/pep-0008/

https://github.com/leo-editor/leo-editor/issues/68

    (fixed) puts whitespace between function name and opening '('
    (fixed) puts whitespace between dictionary name and '['
    (fixed) removes whitespace between function arguments after ','
    (partially fixed) removes whitespace around operator inside parentheses
        (this is not so clear, depends on situation, can be correct or can be wrong)
    (fixed) puts whitespace between print and opening '('

print(obj) is correct and PEP8 style in Python 3, in Python 2.7 runs
correctly but print(obj) is not correct traditionally
#@+node:ekr.20141103061944.168: *8* Re-enabled command completion for @button commands
This had been disabled when completion for vim : commands was added.

Changed ga.get_command and ga.is_command.
#@+node:ekr.20141103061944.123: *8* Reported QTextEdit bug
https://bugreports.qt-project.org/browse/QTBUG-41153
#@+node:ekr.20141103061944.128: *8* Set the default syntax color for operators to black
This is required so that, for example, python coloring is correct after
selecting a node that sets another color for operators.
#@+node:ekr.20141103061944.130: *8* Suppressed duplicate console messages
g.es does nothing when g.app.gui.consoleOnly is True
#@+node:ekr.20141104143314.1: *8* Worked around a strange PyQt5 bug in LeoQtGui.runSaveFileDialog
For some strange reason, the PyQt5 version of LeoQtGui.runSaveFileDialog
returns a tuple instead of a string!
#@+node:ekr.20141103061944.182: *5* Code
#@+node:ekr.20141103061944.63: *6* A beautiful and general design pattern
In an earlier post I said:

QQQ

Strictly speaking, tab cycling doesn't have to be disabled for all colon
commands. One could imaging a list of commands that use tab to complete
file names. Otoh, maintaining that list would be clumsy, and it would add
still more special cases to ga.do_tab.

QQQ

This post describes a much better way, done at rev 3994eca.

The new code is gorgeous, if I do say so myself. Even better, the solution
is a design pattern with many applications.

The trick is to replace functions implementing commands by classes having
`__call__` methods. See the P.P.S for details.

Yes, this has all been done before. Several of Leo's commands are
implemented this way. But read on...

What's new is that classes can "advertise" their ability to do various
things. Here, the classes implementing vim commands advertise, by having a
tab_callback method, that they want to handle a tab that follows their
name. ga.do_tab then defers to the vim command.

There are several really cool things about this code.

1. ga.do_tab, and its helper, ga.do_tab_callback, no longer know *anything*
    about colon commands, or what any command intends to do with the
    tab(!!). If the command handler has a tab_callback attribute,
    ga.do_tab_callback just does::

     ga.reset_tab_cycling()
     k.functionTail = tail # For k.getFileName.
     handler.tab_callback()

Nothing could be simpler, or more general.

2. The code in the command classes is simplified as well. No need for a
   kludgy test event.get_arg_value. See the P.S. for the full
   implementation of the :tabnew command.

The overall result is a spectacular collapse in complexity, which the
attendant increase in power and generality.

Edward

P.S. Here is the flattened form of the class that handles the :tabnew
command (does not require vim-mode). In particular, note that the __call__
and tab_callback methods are trivial. This is the way it is written in The
Book.

class Tabnew:
    '''
    A class to handle Vim's :tabnew command.
    This class supports the do_tab callback.
    '''
    def __init__(self,vc):
        '''Ctor for VimCommands.tabnew class.'''
        self.vc = vc
    __name__ = ':tabnew'
        # Required.

    def __call__(self,event=None):
        '''Prompt for a file name, the open a new Leo tab.'''
        self.vc.c.k.getFileName(event,callback=self.open_file_by_name)
       
    def tab_callback(self):
        '''Called when the user types :tabnew<tab>'''
        self.vc.c.k.getFileName(event=None,callback=self.open_file_by_name)
       
    def open_file_by_name(self,fn):
        c = self.vc.c
        if fn and not g.os_path_isdir(fn):
            c2 = g.openWithFileName(fn,old_c=c)
            try:
                g.app.gui.runAtIdle(c2.treeWantsFocusNow)
            except Exception:
                pass
        else:
            c.new()

P.P.S. This pattern is particularly well suited to Leo, because the various
getPublicCommands methods reference those functions when create command
dictionaries. Here, we replace just two entries in the dict::

    ':r':   vc.LoadFileAtCursor(vc),
    ':tabnew': vc.Tabnew(vc),

This creates instances of the LoadFileAtCursor and Tabnew classes. In other
words, we replace a function by an instance of a class. All such classes
must have __call__ methods, so that Leo can "call" the instance as if it
were a function.
#@+node:ekr.20141103061944.194: *6* A major reorg of Leo's code
One change is required to all plugins and scripts:

    body.bodyCtrl.x -> body.wrapper.x
    
There is a script that does this automatically.

What I did
- Created "@test interfaces using API classes" based on the checking script.
- The various isTextWidget methods now check for the existence of a supportsHighLevelInterface ivar.
- StringTextWrapper is now a stand-alone class.
- Removed BaseTextWrapper.
- LeoLog is no longer a subclass of the HighLevelInterface class.
  This required a hack to handle keystrokes in the log pane:
  k.masterKeyHandler sends strokes to c.frame.log.logWidget (a QTextEditWrapper)
  by changing event.widget.
  QTextMixin sets supportsHighLevelInterface = True as a signal to k.handleDefaultChar.
- Eliminated redirection code from LeoQtBody class.
- LeoBody is no longer a subclass of the HighLevelInterface class.
    - The only changes, one or two new guards.
- Create WrapperAPI class whose text indicates expected type of the result.
- Removed wrapper.getFocus method.
- Removed all references to HighLevelInterface class in the core.
- Removed the evil set_focus synonym in the HighLevelInterface class.
#@+node:ekr.20141103061944.186: *6* Added support for qt5
It is not possible to use both the PyQt4 and PyQt5 installers at the same
time. But this is no big deal on Windows: just install PyQt5 for Python 3.4
only.
#@+node:ekr.20141103061944.66: *6* added the IdleTime class
@language rest

Rev 060c33a contains a spectacular collapse in complexity in idle-time
handling.

Instantly, registering idle-time event handlers can be considered
deprecated, though I have no plans to remove the horrendous older code.

The new pattern allows multiple, independent (or cooperating) idle-time
handlers, created at will as needed.

The new code is based on the IdleTime class in qtGui.py. Rather than access
this directly, code should use the g.IdleTime proxy::

@language python

    def IdleTime(c,handler,delay=500):
        '''A proxy for the g.app.gui.IdleTime class.'''
        if g.app and g.app.gui and hasattr(g.app.gui,'idleTimeClass'):
            return g.app.gui.idleTimeClass(c,handler,delay)
        else:
            return None
            
@language rest

g.IdleTime ensures that all is well when using gui's that don't have an IdleTime class.

Here is how to use the new code::

@language python

    def handler(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace(it.count,it.c.shortFileName(),'%2.4f' % (delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    it = g.IdleTime(c,handler,delay=500)
    if it: it.start()
    
@language rest

The code creates an instance of the IdleTime class that calls the given
handler at idle time, and no more than once every 500 msec. Here is the
output::

    handler 1 ekr.leo 0.5100
    handler 2 ekr.leo 1.0300
    handler 3 ekr.leo 1.5400
    handler 4 ekr.leo 2.0500
    handler 5 ekr.leo 2.5610
    handler done

Timer instances are completely independent.  For example:

@language python

    def handler1(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    def handler2(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 10:
            g.trace('done')
            it.stop()

    it1 = g.IdleTime(c,handler1,delay=500)
    it2 = g.IdleTime(c,handler2,delay=1000)
    if it1 and it2:
        it1.start()
        it2.start()
        
@language rest

Here is the output::

    handler1  1 ekr.leo 0.5200
    handler2  1 ekr.leo 1.0100
    handler1  2 ekr.leo 1.0300
    handler1  3 ekr.leo 1.5400
    handler2  2 ekr.leo 2.0300
    handler1  4 ekr.leo 2.0600
    handler1  5 ekr.leo 2.5600
    handler1 done
    handler2  3 ekr.leo 3.0400
    handler2  4 ekr.leo 4.0600
    handler2  5 ekr.leo 5.0700
    handler2  6 ekr.leo 6.0800
    handler2  7 ekr.leo 7.1000
    handler2  8 ekr.leo 8.1100
    handler2  9 ekr.leo 9.1300
    handler2 10 ekr.leo 10.1400
    handler2 done
#@+node:ekr.20141103061944.134: *6* All unit tests now pass when run externally
Fixed an important bug in addNode, a helper of createOutline: There was a
confusion about commanders: p is in the old commander. p2 must be in the
new commander.

Disabled a few unit tests when run externally:
This was due to missing nodes or copies of clones not being cloned.
#@+node:ekr.20141103061944.242: *6* API changes
- Converted all class names to pep8 style
- Removed g.choose from Leo's core & plugins
  This function is deprecated: use Python's ternary operator instead.
#@+node:ekr.20141103061944.191: *6* Changed most calls to k.setLabel to k.setStatusLabel
Leo's core now calls k.setStatusLabel, not k.setLael, to report the status
of a Leo command. This allows an option (does not exist yet) to use g.es
instead of the minibuffer to report status.
#@+node:ekr.20141103061944.214: *6* Cleaned up command-name handling a bit
Changed k.inverseCommandsDict to c.inverseCommandsDict.
Called vc.define commands from c.finishCreate.
Changed ecm.finishCreateEditCommanders to ecm.defineCommandNames.
The new c.createCommandNames copies entries in g.app.global_commands_dict to commander c.
    Note: @g.command makes entries in g.app.global_commands_dict.
#@+node:ekr.20141103061944.68: *6* code: regularized .wrapper and .widget ivars
@language rest

This post will summarize what has already been done and what will be done in the next few days.  Let's start with the basics...

===== About wrappers and widgets

Wrapper and widget classes are at the heart of Leo's design. Clarifying the
relationships between wrappers and widgets started the present avalanche.

Here is what you *must know* to understand Leo's core:

1. A **widget** is an actual Qt widget.

Leo's core seldom accesses widgets directly. Instead...

2. A **wrapper class** defines a standard api that hides the details of the
   underlying gui **text** widgets.

Leo's core uses this api almost exclusively. That is, Leo's core code
treats wrappers *as if* they were only text widgets there are!

There is, however, a back door for (hopefully rare!) special cases. All
wrapper classes define an official "widget" ivar, so core or plugin code
can gain access to the real Qt widget using wrapper.widget. Searching for
wrapper.widget will (or soon will) find all gui-dependent snippets of code
in Leo's core.

3. Wrappers are crucial, even if Leo *always* uses the Qt gui.

This has just become crystal clear to me. Indeed:

- Wrappers allow users to choose different Qt widgets for the body pane,
  without changing *any* of Leo's core code (except the startup code).

- Wrappers allow Leo's text-handling code to remain unchanged regardless of
  whether the body or log panes are a QTextBrowser or a QsciScintilla
  widget.

- Without wrappers, all of Leo's text-editing commands would have to know
  the details of the api of the actual Qt text widget!

==== Summary of the avalanche

Here is what is happening now in Leo's code base, and in my thinking!

1. A collapse in the complexity of relationships between Leo's most
   important classes and between the files containing those classes.

qt_text.py was supposedly a minor reorg. Wrong! It has become the road map
to the reorganization of all of Leo's fundamental classes:

- qt_text.py is *self contained*: it doesn't depend on any other classes!

- qt_text.py defines a QTextMixin class. This is a new kind of class for
  me. As its name suggest, it is not so much a base class as a helper
  class. It provides helper code for all of Leo's Qt wrapper widgets.

- All the classes that use QTextMixin implement the HighLevelInterface
  class in leoFrame.py.

The HighLevelInterface class will soon morph into the WrapperInterface
class. Th WrapperInterface class will contain only the definition of
methods and their docstrings. Unlike the HighLevelInterface class, the
WrapperInterface will contain *no* redirection code!

- If we were (heaven forbid) going to change Leo's gui, we would simply use
  a copy of qt_text.py, say new_gui.text.py, as a starting point.

2. All "redirection" code will soon be gone.

Ville, Terry and I will be much happier. Eliminating this cruft makes Leo's
code both lighter and thicker, to use the go terminology. It's lighter
because there is far less blah, blah, blah. It's thicker because there is
less to check and to fail.

It's easy to eliminate redirection. For example, the LeoBody methods that
just call the corresponding wrapper methods will soon be gone. We'll
change::

    c.frame.body.wrapperMethod

to::

    c.frame.body.wrapper.wrapperMethod

Doh! This should have been done years ago. Yes, it's more verbose, but it's
also more explicit. Furthermore, few such calls actually exist!

3. widget.widget and other type-checking horrors will soon be a thing of
   the past.

New coding conventions will remove all confusion between wrappers and
widgets. Wrappers will *always* be called wrappers, never widgets.

There is/was something both fundamentally wrong and confusing about
widget.widget. The first widget must have a different type than the second,
but there is *no* indication of this fundamental fact. The reorg changes
widget.widget to wrapper.widget everywhere.

4. I have a new approach toward type checking.

It is obvious now, in retrospect, that clarity of design is something much
more important than type checking! Leo's code will soon make the types of
objects *explicit* and this far more important in practice than even
"perfect" static type checking. This is a revolution in my thinking.

pylint, while supremely important for day-to-day programming, is *totally
inadequate* to have produced the design changes I have been discussing.

Now that widgets are always clearly distinct from wrappers, we could
imaging type-checking assertions to verify their apparent types. Imo, such
assertions are seldom pythonic, but in this case assertions might be good
documentation, if nothing else. The assertions would be based on the
following functions:

- g.isWrapper(obj): calls g.app.gui.isWrapper(obj)
- g.isWidget(obj): calls g.app.gui.isWidget(obj)

5. A dead-easy script shows how to enforce the relationships between types
   that really matter.

This is a big Aha. The script merely compares dir(o1) with dir(o2), where
o1 is the "template" HighLevelInterface class in leoFrame.py and o2 is one
of QTextEditWrapper or QScintillaWrapper. You could call this the "back
door" approach to type checking. It's sooo easy! No more messing with
ast's!

As a result of running this script, (given in the P.P.S.) I was able to
removed cruft from both the HighLevelInterface class, and other parts of
Leo's code.

===== Summary

None of these massive changes adds anything directly to Leo :-)

However, they make understanding and changing Leo's code far easier and
more pleasant. Leo's code is now more beautiful.

Imo, these changes are long overdue. They fundamentally improve Leo's code
base.

That's all for now. I'll keep you posted as I change code, but this post
covers all the essentials.

Edward

P.S. git and easier access to pylint contributed to the present avalanche
of energy and ideas.

Git has allowed me to revise Leo's source code radically, with complete
safety. I would never have done what I have done lately with bzr.

Leo's new pylint command allows me to run pylint *easily* on one or more
"recent" files, *without* having to change any list. As a result, I run
pylint much more often.

P.P.S. Here is the script that checks that all text wrapper classes
implement all required methods. This is, to the first approximation, the
only type checking that Leo really needs. It will probably become a unit
test.

@language python

    import leo.core.leoFrame as leoFrame
    import leo.plugins.qt_text as qt_text
    from leo.core.leoQt import Qsci,QtWidgets
    
    h = leoFrame.HighLevelInterface(c)
    w = Qsci.QsciScintilla()
    tw = QtWidgets.QTextBrowser()
    q = qt_text.QScintillaWrapper(widget=w,c=c,name='test')
    t = qt_text.QTextEditWrapper(widget=tw,name='test2')
    
    h_list = [z for z in sorted(dir(h)) if not z.startswith('__')]
    t_list = [z for z in sorted(dir(t)) if not z.startswith('__')]
    q_list = [z for z in sorted(dir(q)) if not z.startswith('__')]
    ignore = [
        'set_focus', # synonym for setFocus
        'mutable_methods', # To be removed.
    ]
    for z in h_list:
        if z not in t_list and z not in ignore:
            print('QTextEditWrapper: not in HighLevelInterface: %s' % z)
    for z in h_list:
        if z not in q_list and z not in ignore:
            print('QScintillaWrapper: not in HighLevelInterface: %s' % z)
    print('done')

@language rest

=====

This project appears to be a complete success. No further work is planned.
I have encountered no problems at all during this reorg, and don't expect
any, but we shall see...

Here are the highlights:

1. *All* of the odious redirection code in Leo is gone.
 
The redirection code appeared in various places, especially in the
HighLevelInterface class.

2. The HighLevelInterface class is gone: the LeoBody and LeoLog classes are
   now subclasses of object.

3. The logCtrl property is gone: the LeoLog class now defines a .logCtrl
   ivar.

This ivar is inherently tricky: depending on which log *tab* is selected,
LeoLog.logCtrl may be either a wrapper or a widget!

Because LeoLog no longer contains redirection code a hack was needed.
k.masterKeyHandler redirects text-related events originally sent to the
c.frame.log to c.frame.log.logWidget, which, confusingly enough, is
actually a text wrapper.

4. leoFrame.py contains several new API classes: ColorizerAPI, IconBarAPI,
   StatusLineAPI and WrapperAPI.

No class is a subclass of these classes: they are for unit testing only.

The new unit test, "@test interfaces using API classes", checks that
classes implement all the methods in the corresponding API class. This is
not a perfect solution and it is no substitute for pylint. Nevertheless,
these API classes are good documentation, and they did result in a few new
methods being added to each tested "Null" class.

That's all! You may not believe it, but I think of all this work as being
related to fixing bugs. I'll now return more directly to bug fixes.
#@+node:ekr.20141103061944.209: *6* Completed generalization of importers
- ic.createOutline and its helper, ic.dispatch, now use tables
  created by ic.createImporterData and its helper.

- Eliminated odious special cases involving self.treeType in
  ic.create_top_node and ic.init_import.
  
- self.treeType is used only in a limited way in the scanner classes:
  The only tests are against '@root' and '@file'.
  
- For now, the unit-tests wrappers are hard-coded.
#@+node:ekr.20141103061944.192: *6* Created g.IdleTime and qtGui.IdleTime
Rev 060c33a...Leo build: 20140825070951 contains a spectacular collapse in
complexity in idle-time handling. Instantly, registering idle-time event
handlers can be considered deprecated, though I have no plans to remove the
horrendous older code.

The new pattern allows multiple, independent (or cooperating) idle-time
handlers, created at will as needed.

The new code is based on the IdleTime class in qtGui.py. Rather than access
this directly, code should use the g.IdleTime proxy:: g.IdleTime ensures
that all is well when using gui's that don't have an IdleTime class.

Here is how to use the new code::

    def handler(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace(it.count,it.c.shortFileName(),'%2.4f' % (delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()
    it = g.IdleTime(c,handler,delay=500)
    if it: it.start()

The code creates an instance of the IdleTime class that calls the given handler at idle time, and no more than once every 500 msec.  Here is the output::

    handler 1 ekr.leo 0.5100
    handler 2 ekr.leo 1.0300
    handler 3 ekr.leo 1.5400
    handler 4 ekr.leo 2.0500
    handler 5 ekr.leo 2.5610
    handler done

Timer instances are completely independent.  For example:

    def handler1(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 5:
            g.trace('done')
            it.stop()

    def handler2(it):
        '''The IdleTime handler: called at idle time.'''
        delta_t = it.time-it.starting_time
        g.trace('%2s %s %2.4f' % (it.count,it.c.shortFileName(),delta_t))
        if it.count >= 10:
            g.trace('done')
            it.stop()

    it1 = g.IdleTime(c,handler1,delay=500)
    it2 = g.IdleTime(c,handler2,delay=1000)
    if it1 and it2:
        it1.start()
        it2.start()

Here is the output::

    handler1  1 ekr.leo 0.5200
    handler2  1 ekr.leo 1.0100
    handler1  2 ekr.leo 1.0300
    handler1  3 ekr.leo 1.5400
    handler2  2 ekr.leo 2.0300
    handler1  4 ekr.leo 2.0600
    handler1  5 ekr.leo 2.5600
    handler1 done
    handler2  3 ekr.leo 3.0400
    handler2  4 ekr.leo 4.0600
    handler2  5 ekr.leo 5.0700
    handler2  6 ekr.leo 6.0800
    handler2  7 ekr.leo 7.1000
    handler2  8 ekr.leo 8.1100
    handler2  9 ekr.leo 9.1300
    handler2 10 ekr.leo 10.1400
    handler2 done
#@+node:ekr.20141103061944.197: *6* Delayed allocation of gnx's...
- fc.getLeoFile now calls ni.begin/end_holding
- Added gnx keyword arg to VNode ctor.
- Added traces to pd.restore_gnx

What I did:
    
- checked all calls to VNode ctor.
- checked all calls to getNewIndex.
- checked all calls to fileIndex =
#@+node:ekr.20141103061944.199: *6* Delayed allocation of vnodes
https://groups.google.com/d/msg/leo-editor/JWhlmJBiesk/RsC64VZ1gxQJ
#@+node:ekr.20141103061944.206: *6* Improved idle-time handling
@language rest



Simplified and generalized idle-time handling as follows:
    
- Removed g.app.afterHandler: g.app.idleTimeHook does the same thing now.
- The timer callback now calls g.app.idleTimeHook() if it exists.
- g.enableIdleTimeHook now has the following signature::
    
    def enableIdleTimeHook(idleTimeDelay=500,idleTimeHandler=None):
        
  The two args set g.app.idleTimeDelay and g.app.idleTimeHandler respectively.
  g.idleTimeHookHandler is used if idleTimeHandler is None.

The new code has these properties:
    
1. g.app.idleTimeHook() actually gets called only at idle-time,
2. There is no busy waiting, and
3. There is at least g.app.idleTimeDelay msec. between calls to g.app.idleTimeHook()

Here is an script illustrating the possibilities::

@language python

'''
A script illustrating interacting idle-time handlers.
Do Alt-x enable-idle-time-tracing before executing this script
'''
class Handlers:
    def h1(self):
        g.trace()
        g.enableIdleTimeHook(1000,self.h2)
    def h2(self):
        g.trace()
        g.enableIdleTimeHook(500,self.h1)
h = Handlers()
if g.app.idleTimeHook:
    g.disableIdleTimeHook()
else:
    g.enableIdleTimeHook(1000,h.h1)
#@+node:ekr.20141103061944.188: *6* Improved p.isAncestorOf and c.positionExists
- Added test for c.positionExists to p.isAncestorOf.
- Added v.isNthChildOf
- Rewrote c.positionsExists using v.isNthChildOf
#@+node:ekr.20141103061944.193: *6* Improved speed of selection logic
0. Added details timing traces throughout the selectHelper logic.
   These traces showed precisely where the performance bugs were.

1. updateSyntaxColorer now does nothing if the body text starts with @killcolor.

2. w.setSelectionRangeHelper and v.restoreCursorAndScroll had performance bugs
because they called code that computed the length of text slowly.

3. The solution: w.setSelectionRangeHelper and all setInsertPoint methods
now take an 's' keyword arg. In the selection logic, s is set to p.b.
If s is not None, the desired length is simply len(s)

As a result, w.setSelectionRangeHelper no longer calls lengthHelper.
lengthHelper used QTextCursor, which is *much* slower than getAllText.

4. Even though all w.setInsertPoint methods have an s keyword arg,
   v.restoreCursorAndScroll uses the following defensive code::
       
    try:
        w.widget.setInsertPoint(ins,s=v._bodyString)
    except TypeError:
        w.setInsertPoint(ins)
#@+node:ekr.20141103061944.212: *6* Leo imports importers & writers from home/.leo
Leo now imports from ~/.leo/plugins before importing from leo/plugins.

The new code is in at.createWritersData & helper and ic.at.createImportersData & their helpers.
#@+node:ekr.20141103061944.213: *7*  demo script
'''Load each plugins ~/.leo/plugins if possible, then from leo/plugins.'''
import glob
def report(message,kind,folder,name):
    g.trace('%7s: %5s %9s %s' % (message,kind,folder,name))
g.cls()
plugins1 = g.os_path_finalize_join(g.app.homeDir,'.leo','plugins')
plugins2 = g.os_path_finalize_join(g.app.loadDir,'..','plugins')
seen = set() # set of (folder,sfn)
for kind,plugins in (('home',plugins1),('leo',plugins2)):
    if g.os_path_exists(plugins):
        for folder in ('importers','writers'):
            path = g.os_path_finalize_join(plugins,folder)
            pattern = g.os_path_finalize_join(plugins,folder,'*.py')
            for fn in glob.glob(pattern):
                sfn = g.shortFileName(fn)
                if g.os_path_exists(fn) and sfn != '__init__.py':
                    moduleName = sfn[:-3]
                    if moduleName:
                        data = (folder,sfn)
                        if data in seen:
                            report('seen',kind,folder,sfn)
                        else:
                            m = g.importFromPath(moduleName,path) # Uses imp.
                            if m:
                                seen.add(data)
                                report('loaded',kind,folder,m.__name__)
                            else:
                                report('error',kind,folder,sfn)
                # else: report('skipped',kind,folder,sfn)
@language python
#@+node:ekr.20141103061944.61: *6* Leo now uses a new xml namespace
For several years the xml namespace line at the start of .leo files has been::

    <leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" >

The new line is::

    <leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
#@+node:ekr.20141103061944.190: *6* Rewrote & simplified k.getArg
What I did:
- Removed prefix arg to all calls to k.getArg.
  Not needed now that there is better convention for k.setLabelBlue.
- Removed protect argument from k.setLabelBlue.
  Some code now uses k.extendLabel to mix protect and unprotected parts of the label.
  
- k.fnc and k.getArgInstance now created by finishCreate.
  This guarantees that the c,k and log ivars are inited properly.
- Allow <tab> to escape to :r and :tabname code.
  This required several kludges.

#@+node:ekr.20141103061944.196: *6* Simplified gnx scan logic
1. createSaxVnode now does::
    
    v.fileIndex = ni.tupleToString(x.scanGnx(sax_node.tnx))
    
ni.tupleToString is substantially simpler than ni.toString.

This is the only call to tupleToString in Leo.

2. Removed ni.toString.

3. ni.scanGnx no longer converts n to an int.  It's going to become a string again anyway.

4. The new fc.setMaxNodeIndex *does* convert the n field to an int, but
   this very rarely happens.
#@+node:ekr.20141103061944.62: *6* Split qtGui.py into separate files
- qt_big_text.py contains support for the "big text" warning buttons.

- qt_commands.py contains several commands created by @g.commands.
  qt_gui.py now imports this file so the commands are actually defined.

- qt_events.py contains the LeoQtEventFilter class. The LeoKeyEvent class
  remains in leoGui.py: it is independent of gui.

- qt_frame.py contains most of the Qt-related code that creates the Leo
  window and frames.
  
- qt_idle_time.py contains the IdleTime class.

- qt_gui.py contains Qt-specific code that defines g.app.gui. leoGui.py is
  the gui-independent code and was essentially unchanged.

- qt_quickheadlines.py contains the QuickHeadlines class.

- qt_text.py contains most the code for Leo's Leo's text widgets.
  leoFrame.py contains a few gui-independent classes.

- qt_tree.py contains all the Qt tree code. It replaces baseNativeTree.py.

No longer used: baseNativeTree.py, qtGui.py. qtGui.py still exists, but
just prints a warning message when imported.
#@+node:ekr.20141103061944.210: *6* The @auto write code now uses writer plugins
What I did:
- at.createWritersData inits tables using the writers_dict in each plugin.
- at.writeOnAtAutoNode calls at.dispatch to find writers.
  An important escape hatch: at.writeOnAtAutoNode calls the *existing* rst.writer
  if the user deletes plugins/writers/rst.py.

Won't do:
- at.writeAllHelper has lots of special-case code, but that probably can't be helped.
- It would be way too dangerous to refactor the write code for @file, @shadow, etc.
#@+node:ekr.20141103061944.67: *6* Wanted: w.getTextLength and p/v.get_b_length
A head-slapping moment: the so-called high-level interfaced throughout
Leo's core to interact with Leo's text panes lacks a way of getting the
length of text *without* making a copy of the text.

This is more than a slight oversight: I imagine there are several place
were the code does s = w.getAllText() merely so it can use len(s)! This is
a huge strain on the GC for large p.b.

Worse, the absence of w.getTextLength() has lead to the most unfortunate
LeoQTextEditWidget.lengthHelper, which calculated the length of the text
using QTextCursor methods! This is catastrophically slow for large text.
This method was doubling node load times for large nodes.

@language rest

In other words, w.getTextLength() is an essential part of fixing git bug 28:
https://github.com/leo-editor/leo-editor/issues/28

But nooooooo... w.getTextLength() is far from easy to do. There is no
QTextEdit or QTextDocument method that delivers the length of the text!
This is a *huge* hole in the QTextEdit and QTextDocument api's, but there
is nothing we can do about that.

The simplest thing that could possibly work would be::

@language python


    def getTextLength(self):
        w = self.widget
        return len(w.getAllText())
        
@language rest

But this would be a step backwards because it hides the fact that it is
expensive.

It might be possible to cache the value of w.getAllText in an "text
changed" event handler in LeoQTextBrowser:(QTextBrowser). But I would like
to avoid this approach--any bug would lead to data loss or corruption. I
may play around with this, but for now it's not likely to happen. See below
for a workaround.

By analogy with w.getTextLength(), we can imagine a p.b_length method that
would simply return len(p.v._bodyString). This, at least, is worth doing.

===== Summary

w.getTextLength() isn't trivial.

Caching the value returned by w.getAllText() seems too dangerous.

As a work-around, the crucial node-selection logic will attempt to minimize
calls to w.getAllText. There, and *only* there, it should be possible to
create a *single* copy of the text and pass that copy around to all code
that needs it. It would be a complication, but a completely safe one.

Otoh, p/v.b_length are trivial and useful. They will be added asap.

-------------

Two parts to this reply:

===== Part 1: defining w.getTextLength

> w.getTextLength() isn't trivial...Caching the value returned by
w.getAllText() seems too dangerous.

Actually, defining w.getTextLength using a textChanged event handler in
LeoQTextBrowser is straightforward::

@language python

    def onTextChanged(self):
        '''The textChanged event handler.  Cached the text in self.leo_s.'''
        self.leo_s = s = g.u(self.toPlainText())

    def getTextLength(self):
        '''Return the length of all the text.'''
        if 1: # safe.
            s = g.u(self.toPlainText())
            if s != self.leo_s:
                g.trace('can not happen: text mismatch.')
                self.leo_s = s
            return len(self.leo_s)
        else: # fast
            return len(self.leo_s)
            
@language rest

We can use the "safe" version of getTextLength until we are *sure* the can
not happen message never happens ;-)

Otoh, we must be careful: onTextChanged will be called in the middle of the
node-switching logic.

===== Part 2: doing without w.getTextLength

Imo, the simplest thing that could possibly work is to avoid the extra call
to w.getAllText in the node switching logic in selectHelper.

Here are the relevant parts of selectHelper. (w is a LeoQTextEditWidget).

1. setBodyTextAfterSelect *already* calls w.getAllText() to get the
   "before" text. This is unavoidable.

The "after" text will be p.b, where p is the *new* position.

2. restoreCursorAndScroll calls w.setInsertPoint, which just calls
   w.setSelectionRangeHelper.

3. w.setSelectionRangeHelper is the problem It used to call the horribly
   slow lengthHelper. Now it calls w.getAllText()

But w.getAllText must be the new p.b! So the selectHelper logic could
simply pass an optional s argument to w.setInsertPoint and
w.setSelectionRangeHelper. If present, setSelectionRangeHelper will use s
rather than calling w.getAllText.

Imo, this is the safe, if not exactly elegant way.
#@+node:ekr.20141103061944.200: *5* Features
#@+node:ekr.20141103061944.247: *6* New commands
#@+node:ekr.20141103061944.73: *7* Added clone-find-parents command
As of rev 1d882d3. Leo supports an undoable clone-find-parents command.
Select a cloned node, then do:

    <alt-x>clone-find-parents<return>

This works somewhat like the clone-find-all command: it creates a node containing
clones of all the parents of the selected node.
#@+node:ekr.20141103061944.225: *7* Added clone-to-last-node
This does *not* change the selected node so it's easy to
clone several nodes.

Added c.cloneToLastNode.  
#@+node:ekr.20141103061944.229: *7* Added flatten-outline-to-node
Very useful when summarizing documentation nodes.
#@+node:ekr.20141105055521.10: *7* Added help-for-drag-and-drop command
#@+node:ekr.20141103113220.19: *7* Added idle-time commands
Added the following commands:
    
disable-idle-time-tracing
enable-idle-time-tracing
toggle-idle-time-tracing
disable-idle-time-events
enable-idle-time-events
toggle-idle-time-events
#@+node:ekr.20141103061944.215: *7* Added insert-file-name command
# The code is in leoEditCommands.py::insertFileName.
#@+node:ekr.20141103061944.207: *7* Added pylint command
When pylint is available on your machine, Leo's pylint
command will execute run pylint on all @<file> nodes in the
selected tree. This command is now available from the popup
menus created by the contextmenu plugin.

This command is a dynamic way of selecting files to check
with pylint. It is *much* easier to use than the old pylint
-r option in pylint-leo.py. There is no longer any need to
update a list of "recent" files. Hooray.

The command has significantly changed my work flow. I use
pylint much more often.

The details of the search process are as follows:

1. The command looks down the tree of the selected node,
   looking for @<file> nodes.
2. If now @<file> nodes are found, it looks up the tree,
   looking for @<file> nodes.
3. If the selected node is a clone, and no @<file> nodes
   have yet been found, it expands the search to all
   ancestors of all positions cloned to the selected node.

This means that you can check a file by selecting any
(possibly clone) node of the file.

**Important**: running pylint-leo.py is still often very
useful. In particular, I often run python pylint-leo.py -a
to check all files. Here is the recently improved docstring
for pylint-leo.py::

    '''
    This file runs pylint on predefined lists of files.
    
    The -r option no longer exists. Instead, use Leo's pylint command to run
    pylint on all Python @<file> nodes in a given tree.
    
    On windows, the following .bat file runs this file::
        python27 pylint-leo.py %*
    
    On Ubuntu, the following alias runs this file::
        pylint="python27 pylint-leo.py"
    '''
#@+node:ekr.20141103061944.203: *7* Added spell-as-you-type commands
Thanks to Terry Brown for these commands::

spell-as-you-type-toggle
  Enable / disable spell as you type mode.  When enabled, word ending
  keystrokes will put a short list of suggestions in the log window, if
  the word is unknown to the speller.  Only shows the first 5
  suggestions, even if there are more.

spell-as-you-type-next
  Cycle the word behind (left of, for ltr languages) the cursor through
  the full list of suggestions.

spell-as-you-type-undo
  Change the word behind (left of, for ltr languages) the cursor to
#@+node:ekr.20141103061944.248: *6* Improved commands
#@+node:ekr.20141103061944.205: *7* Improved find/replace-all commands
These commands now get their arguments from the Find Panel.

Changed the following methods:

generalChangeHelper,
minibufferFind/ReplaceAll,
searchWithPresentOptions,
setReplaceString,

Also fixed the bindings in create_find_buttons so buttons
are bound to the proper button-related methods. As a result,
the find-all and change-all buttons now work as expected.
#@+node:ekr.20141103061944.223: *7* (Optional) beautify command now uses PythonTidy
This is a major upgrade to the beautify command.

PythonTidy (tidy for short) does a full parse of the Python sources:
https://pypi.python.org/pypi/PythonTidy/

What I did today.  See the < < version info > > section for all the details::

1. Leonized tidy's sources: @file ../external/PythonTidy.py in in LeoPyRef.leo.

- Removed all pylint complaints and made other minor mods.
 
2. Suppressed features not appropriate for Leo:

- Adds shebang and encoding lines only for @<file> nodes.
- Suppress extra spacing between classes & functions.

3. Added settings to leoSettings.leo that control tidy operation:

    @bool tidy_add_blank_lines_around_comments =True
    @bool tidy_double_quoted_strings = False
    @bool tidy_keep_blank_lines = True
    @bool tidy_left_adjust_docstrings = False
    @int  tidy_lines_before_split_lit = 2
    @int  tidy_seps_before_split_line = 8

3. Fixed several important bugs:

- The original code deleted all comments because of a botch in Comments__init__.
- Tidy now properly handles the tidy_add_blank_lines_around_comments and
  tidy_double_quoted_strings settings.
#@+node:ekr.20141103061944.226: *7* Improved check outline
It now tests that all gnx's exist and are unique.
#@+node:ekr.20141103061944.70: *7* Added Yes To All and No To All buttons to dialogs
Added YesToAll and NoToAll capability to g.app.gui.runAskYesNoDialog
and uses this in the open file again? questions when opening Leo after a
crash.
#@+node:ekr.20141103113220.14: *6* Other features
#@+node:ekr.20141104053638.10: *7* Added warning buttons when selecting large text
#@+node:ekr.20141103061944.72: *7* Added some support for scintilla
I have been using a Scintilla widget in Leo's body pane today. It has been
the best incentive to improve it.

To enable it, set @bool qt-use-scintilla = True.

Almost everything works. It is certainly seems possible to do real work
safely and pleasantly.

The Scintilla code now honors the settings in @data qt-scintilla-styles,
but *only in leoSettings.leo, not myLeoSettings.leo. This is likely a bug
in the settings system, and I'll fix it soon.

Leo now switches between the native Scintilla colorizer and a custom,
do-nothing, colorizer depending on @language, @killcolor, etc. Creating a
custom Scintilla colorizer was unexpectedly easy. There is no native
Scintilla colorizer for @language rest. That will be the next custom
colorizer that I write.

Scintilla thinks Leo directives are decorators, so Leo directives are, in
effect, colorized.

No section references are ever colored. It *might* be possible to define a
custom colorizer that defers to a native colorizer in everything but
section references.

Most unit tests pass with @bool qt-use-scintilla = True. Something strange
is going on in the failing cases, but it doesn't seem strange enough to
cause real problems ;-) I'll be fixing these tests asap.

No other colorizing is available, but everything is in place to support
Scintilla's other native colorizers. They are:

AVS, Bash, Batch, CMake, CoffeeScript, CPP, CSS, D, Diff, Fortran77, HTML,
Lua, Makefile, Matlab, Pascal, Perl, PO, PostScript, POV, Properties,
Python, Ruby, Spice, SQL, TCL, TeX, Verilog, VHDL, YAML.
#@+node:ekr.20141103061944.231: *7* Added support for delegate languages
Allow colorizing for languages to be delegated to another language.

- Added g.app.delegate_language_dict, with three entries for David McNab.

- jEditColorizer.nameToRuleSetName now replaces the original language name
  with the delegated name.
  
There are two other changes you must make if you don't want
to use @language, as in your example with @nosent trees.

1. To write the proper delims for .hbs files, add the
   following entry in define_language_delims_dict in
   leoApp.py::

    "hbs" : "<!-- -->", # McNab: delegate to html.

2. To automatically use @language hbs in .hbs files, add the
   following entry in define_extension_dict in leoApp.py:
#@+node:ekr.20141103061944.233: *5* Plugins & leo/external
#@+node:ekr.20141103061944.75: *6* Added livecode plugin
Then livecode-show command shows the live code evaluation pane. Hover on
the buttons for helpful tool-tips.

It currently has a dependency on https://pypi.python.org/pypi/meta
which you can install with

    pip install meta

The dependency on `meta` is for recursively turning AST node trees back
into printable identifiers like "m[m[5]]"

i.e.

   a = 7

is easy,

   m[m[5]] = 7

is not.
#@+node:ekr.20141103061944.77: *6* Added nodetags.py plugin
This is only an API for tags, but I feel like it should simplify the
process and allow someone to focus on the important bits, i.e. UI hooks,
rather than low-level details. Also, it's usable now for scripts.

Here is the docstring:

Provides node tagging capabilities to Leo

By Jacob M. Peck

API
----

This plugin registers a controller object to c.theTagController, which
provides the following API::

    tc = c.theTagController
    tc.get_all_tags() # return a list of all tags used in the current
outline, automatically updated to be consistent
    tc.get_tagged_nodes('foo') # return a list of positions tagged 'foo'
    tc.get_tags(p) # return a list of tags applied to the node at
position p; returns [] if node has no tags
    tc.add_tag(p, 'bar') # add the tag 'bar' to the node at position p
    tc.remove_tag(p, 'baz') # remove the tag 'baz' from p if it is in
the tag list

Internally, tags are stored in `p.v.unknownAttributes['__node_tags']` as
a set.

UI
----

The "Tags" tab in the Log pane is the UI for this plugin.  The bar at
the top is a search bar, editable to allow complex search queries.  It
is pre-populated with all existing tags in the outline, and remembers
your custom searches within the given session.  It also acts double duty
as an input box for the add (+) button, which adds the contents of the
search bar as a tag to the currently selected node.

The list box in the middle is a list of headlines of nodes which contain
the tag(s) defined by the current search string.  These are clickable,
and doing so will center the focus in the outline pane on the selected node.

Below the list box is a dynamic display of tags on the currently
selected node.  Left-clicking on any of these will populate the search
bar with that tag, allowing you to explore similarly tagged nodes.
Right-clicking on a tag will remove it from the currently selected node.

The status line at the bottom is purely informational.

The tag browser has set-algebra querying possible.  Users may search for
strings like 'foo&bar', to get nodes with both tags foo and bar, or
'foo|bar' to get nodes with either or both.  Set difference (-) and
symmetric set difference (^) are supported as well.  These queries are
left-associative, meaning they are read from left to right, with no
other precedence.  Parentheses are not supported. See below for more
details.

Searching
---------

Searching on tags in the UI is based on set algebra.  The following
syntax is used::

    <tag>&<tag> - return nodes tagged with both the given tags
    <tag>|<tag> - return nodes tagged with either of the given tags (or
both)
    <tag>-<tag> - return nodes tagged with the first tag, but not the
second tag
    <tag>^<tag> - return nodes tagged with either of the given tags
(but *not* both)

These may be combined, and are applied left-associatively, building the
set from the left, such that the query `foo&bar^baz` will return only
nodes tagged both 'foo' and 'bar', or nodes tagged with 'baz', but *not*
tagged with all three.

Tag Limitations
---------------

The API is unlimited in tagging abilities.  If you do not wish to use
the UI, then the API may be used to tag nodes with any arbitrary
strings.  The UI, however, due to searching capabilities, may *not* be
used to tag (or search for) nodes with tags containing the special
search characters, `&|-^`.  The UI also cannot search for tags of
zero-length, and it automatically removes surrounding whitespace
(calling .strip()).
#@+node:ekr.20141103061944.76: *6* Added viewrendered2 plugin
https://groups.google.com/d/msg/leo-editor/3dH_NSQ4TsQ/ueVewAn50ZcJ

https://groups.google.com/d/msg/leo-editor/BDzmytlSegw/C0IbSz0US54J

As mentioned in my previous post I'll attempt to elaborate on the plugin
I've used to make Leo more useful to me, in case it is useful for others
also. Apologies for the very long post, but I wanted get get all its
features and warts exposed here to get some feedback on whether others see
this as useful or that this is only valuable to me. If it's useful to
others then it may be worth polishing up quite a bit.

Why a better viewrendered plugin?
---------------------------------

I like to use reStructuredText (reST) for all of my note-taking, idea
development, project and task management and automation of desktop
activities (e.g. initiating a backup). You could say it is the control
center of my daily activities, including calculating and showing dashboards
of where I am and where I'm going.

This means I need a tool which seamlessly shows me the full-fidelity
browser-rendered version of what I am writing and be able to print my notes
for meetings, cut and paste nicely formatted output to my office e-mails
and documents, as well as show some of the material as a slideshow.

The existing *viewrendered* plugin couldn't seem to do what I needed
(especially math) and I was almost ready to abandon Leo again. This time I
bit the bullet and created a more capable renderer in viewrendered2 (VR2).
Initially I made a plugin that rendered, on demand, to my normal web
browser. This worked well, but I really thought live rendering like
"viewrendered" would be better, and for that I needed close control over
scroll positions etc. that I couldn't get with an external browser. So the
plugin became much more complex as I merged it with the existing
viewrendered plugin, but was ultimately more powerful and useful to me.

Objectives
-----------

* Show a "full" html representation of any reST node or tree, without an
  @rst root node, including more features than the existing viewrendered
  plugin:

  - proper html layout
  - math (mathjax, etc.)
  - clickable URLs
  - clickable hyperlinks within the page (e.g. TOC)
  - good quality zoom
  - cut and paste html with ctl-C
  - s5 slideshows
  - javascript
  - svg images
  - configurable css

* Allow showing of node tree rather than just the current node. This can
  give a better overview perspective of the tree contents.

* Be able to lock the rendering on the root node of a tree, to view the
  effect editing a sub-node within the larger html document.

* Provide proper rendering of any combination of node types in a tree, so long as
  they have been properly designated by @language directives (i.e. reST, text,
  code, css, ...).

* Allow viewing (and printing) of an entire source file from an @file type
root node.

* Be able to *export* any of these renderings to a full web-browser to take advantage
  of the large rendering window (especially for slideshows, as well as printing, saving output.
  
* Be able to integrate automatically executed code nodes intermingled with
  reST nodes to provide an automatic calculation-based "Notebook" or "Report"
  type output.

* Don't increase the dependencies of Leo.

Implementation
--------------

VR2 is implemented mostly as an ~600 line expansion of the update_rst
method in the viewrendered.py plugin. The text-oriented class used for
rendering in VR1 has been replaced by the QWebView class which provides the
full rendering functionality of a real web-browser. To make this flexible,
a toolbar has been attached to the top with a few controls.

Because I wanted to retain compatibility with VR1, I created the
viewrendered2.py plugin, but retained all the class naming which occurred
within VR1. This means that it remains compatible with the existing
mechanisms (like free_layout) of showing and creating panes for VR1. I
tried this with an expectation that it would fail, but it appears to work
without any unintended side-effects.

Tooltips have been added where Qt allows, with the philosophy that a user
shouldn't need a manual to use this pane.

VR2 has been used a lot under Windows 7 and a little under Ubuntu 13.10.

Issues / Limitations
--------------------

I use VR2 every few minutes every working day. However, VR2 is likely to
still have a lot of rough edges and, in particular, bugs that show up with
different work flows or css folder layouts etc. In fact, VR2 is still a
work in progress and therefore still being fiddled with, so bugs creep in
regularly.

But overall, my perception of its deficiencies are:

* Does not handle reST headings within the node bodies well (sometimes very
  slow render, blocking Leo).

  - VR2 attempts to reconcile reST headings that originate from explicit
    headings within the nodes against reST headings that are automatically
    generated by the node hierarchy. In many cases, this is impossible,
    resulting in many errors which drastically slows down rendering. -
    Recommend not using headings within the nodes themselves, leaving the
    node hierarchy to do this automatically.

* If the node triggers one of the special viewrendered node header types
  (@md, @image, @movie, @html) VR2 simply defaults to the old handlers for
  those types. This means it jumps back to whatever pane type VR1 uses, so
  the features of VR2 disappear. I suspect that VR2 could incorporate these
  types into the new version and retain these new features. I should look
  at that.
    
* Doesn't integrate with rst3 plugin, especially honouring @others etc.
  There are some conflicts in objectives, so this may never be fully
  resolved. It would probably make sense for rst3 settings to get used for
  VR2 as well, along with additional VR2 specific settings. Currently, VR2
  has its own @settings-style settings. The rst3 code is not used.
  
* For slideshow purposes, a patch to docutils s5_writer is required to be
  able to handle an arbitrary hierarchy of nodes (forces all headings to
  start a new slide). Otherwise, only the 2nd level nodes (from the root)
  force a new slide.
  
* The integration of VR2 code into the existing viewrendered plugin code is
  rudimentary. I took the shortcut of not trying to understand this code
  well and confining my integration to the rst rendering only. Better
  integration would be a good future step.

With the plugin being able to execute javascript etc. there may be some
form of security issue, but I can't see it myself (given that Leo can
execute arbitrary python code anyway). Any thoughts?

Future?
-------

* Expand the export button if pandoc is installed, adding optional output
  formats such as docx, odt, plus additional slideshow formats. * Use new
  reST functionality to replace other media viewrendered methods for
  images, svg, movies, etc. * Integrate better with rst3?

Conclusion
----------

* I've attached the source as well as a bunch of screenshots. Feel free to
try out the source by putting viewrendered2 into your @enabled-plugins
instead of the usual viewrendered. I'd be interested in whether it works or
not - expect bugs to show up!

* I'm looking for feedback on whether this appears useful to others and not
just me. If so, it should probably be polished a bit more before being used
widely. Perhaps greater understanding of the existing viewrendered plugin
operation would help me here.
#@+node:ekr.20141103061944.232: *6* Added wikiview plugin
Hides text in the body editor, each time a new node is selected. Makes::

  file://#some-->headlines-->mynode     appear as mynode,
  http://www.google.com/search          appear as search, and
  `Python <https://www.python.org/>`_   appear as Python
  
There is a tiny dot to the left or right of the visible
text. Clicking that area, or clicking and dragging, or
clicking and using shift arrows *through* that area exposes
the hidden text.

full docs:
https://raw.githubusercontent.com/leo-editor/leo-editor/master/leo/plugins/wikiview.py

This plugin only addresses the visual aspects of wiki links.  Leo
already supports internal wikilinks as
file://#headline-->other%20headline-->Setup, which will now appear as
just 'Setup' with this pluing active.

#@+node:ekr.20141103061944.195: *6* Converted 7 plugins so they work with PyQt5
active_path.py, attrib_edit.py, contextmenu.py, graphcanvas.py,
notebook.py, projectwizard.py, stickynotes.py
#@+node:ekr.20141015084905.18440: *6* leo/external/leoftsindex.py
From: Terry Brown <terry_n_brown@yahoo.com>

Indexing files for full text search

Just pushed leo/external/leoftsindex.py:

Stand alone GUI free index builder for Leo's full text search system::

  python leoftsindex.py <file1> <file2> <file3>...

If <file> does not contain '#' it's assumed to be a .leo file
to index, and is indexed.

If <file> does contain '#' it's assumed to be a .leo file
containing a list of .leo files to index, with the list in
the node indicated by the UNL after the #, e.g.::

   path/to/myfile.leo#Lists-->List of outlines

In the latter case, if the node identified by the UNL has children,
the list of files to scan is built from the first line of the body
of each child node of the identified node (works well with bookmarks.py).
If the node identified by the UNL does not have children, the
node's body is assumed to be a simple text listing of paths to .leo files).

note::
    
    It may be necessary to quote the "file" on the command line,
    as the '#' may be interpreted as a comment delimiter::
        
        python leoftsindex.py "workbook.leo#Links"
#@+node:ekr.20141103061944.228: *6* Rewrote at_produce plugin
This plugin used ancient coding technology, created menu items instead of
minibuffer commands, did not report progress and was probably not thread
safe.

All these defects have now been remedied. It could be quite useful in some
situations. For example, suppose node P has this body text::

    @produce echo pylint commands
    @produce pylint -v
    @produce pylint -f core\leoAtFile.py
    @produce pylint -g

Selecting node P and running the at-produce-selected command produces these
messages in the log pane::

    @produce pylint -g
    @produce pylint -g
    @produce pylint -g
    @produce pylint -g
    at-produce done

And produces a node whose headline is::

    produce.log from Sun Sep 21 06:35:37 2014

And whose body text is::

    produce: echo pylint commands
    pylint commands
    ===============
    produce: pylint -v
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -v
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -v
    pylint-leo.py 1.1.0,
    astroid 1.0.1, common 0.61.0
    Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
    ===============
    produce: pylint -f core\leoAtFile.py
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -f core\leoAtFile.py
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -f core\leoAtFile.py
    pylint-leo.py: core\leoAtFile.py
    time:  5.000 sec.
    ===============
    produce: pylint -g
   
    c:\leo.repo\leo-editor>python27 pylint-leo.py -g
   
    c:\leo.repo\leo-editor>c:\python27\python.exe pylint-leo.py -g
    pylint-leo.py: plugins\free_layout.py
    pylint-leo.py: plugins\nested_splitter.py
    pylint-leo.py: plugins\qt_commands.py
    pylint-leo.py: plugins\qt_events.py
    pylint-leo.py: plugins\qt_frame.py
    pylint-leo.py: plugins\qt_idle_time.py
    pylint-leo.py: plugins\qt_gui.py
    pylint-leo.py: plugins\qt_text.py
    pylint-leo.py: plugins\qt_tree.py
    time: 40.073 sec.
    ===============
#@+node:ekr.20141103061944.84: *5* Settings & command-line options
#@+node:ekr.20141103061944.224: *6* Added --no-persist command-line option
removed new_auto switch in leoAtFile.py

added g.app.at_auto_persist

c.persistenceController exists only if g.app.auto_persist is True
#@+node:ekr.20141103061944.221: *6* Added --trace-plugins option
#@+node:ekr.20141105055521.9: *6* Added @int max-pre-loaded-body-chars
#@+node:ekr.20141103061944.227: *6* Added @bool auto-scroll-find-tab
The default is True, so as to enable the "fix" to bug
1254861: find - ctrl-f doesn't ensure find input field
visible https://bugs.launchpad.net/leo-editor/+bug/1254861

I found the new behavior extremely unpleasant. For me, it
was the worst fit-and-finish issues with Leo.
#@+node:ekr.20141103061944.185: *6* Added support for html handlebar syntax coloring
These are colored with the previously unused literal3 tag,
so you specify the color with:

    @color html_literal3_color = pink
#@+node:ekr.20141103061944.87: *6* Fully parameterized style sheet
Almost all settings in @data qt-gui-plugin-style-sheet in leoSettings.leo
are now defined in terms of @values. Traditional Leo settings nodes
(@strings, @color, @font, etc.) define these @values.

Most users, and certainly all newbies, will never have to touch, or even
look at, @data qt-gui-plugin-style-sheet. This is a really good thing,
because the slightest syntax error silently messes up everything that
follows.

Notes:

1. There is now a node called "Basic Fonts (change these first)"
   This node contains the basic font definitions. Changing only the
   settings in this tree (in myLeoSettings.leo, of course) should be enough
   to get Leo looking pretty much as it was.

2. Don't even *think* about changing @data qt-gui-plugin-style-sheet.
   Really, the whole point of this exercise is to be able to change all
   aspects of Leo's appearance without touching this stylesheet. As Terry
   points out, there will always be a place for @data qt-gui-user-style-sheet

3. In an emergency, there is at present a node called "OLD
   qt-gui-plugin-style-sheet" that you could use to revert to the old
   settings. Just rename it and copy it to your myLeoSettings.leo.

4. The new settings scheme will moot the need for leo10pt.leo, leo12pt.leo
   and all the rest. Instead, all font sizes are now defined in terms of
   three intermediate settings: @string font-size, @string medium-font-size
   and @string small-font-size. Changing just these three settings will
   suffice to change *all* the font sizes used in Leo.

5. When things don't look right, I execute this script::

    c.styleSheetManager.print_style_sheet()

This prints the complete stylesheet to the console. What I mainly look for
are lines like::

    background-color: @some-setting

An @value as the value of a setting indicates that no substitution took
place, that is, that there is no node::

    @string some-setting = aValue

Any user that wants to roll their own @data node will want to be aware of
this technique.

5. The @data qt-gui-**user**-style-sheet setting is deprecated. Indeed,
   @data qt-gui-**plugin**-style-sheet now takes care to define almost
   everything that any user would want to define. myLeoSettings.leo should
   contain overrides of only the @color and @string nodes in
   leoSettings.leo.
#@+node:ekr.20141103061944.222: *6* Leo stylesheets now support all color names in leoColor.py
For example, this setting works without any explicit definition of mistyrose2.
    
    @color head-bg = @mistyrose2
#@+node:edream.110203163054.63: ** Latest version
#@-all
#@-leo
