.. rst3: filename: html\tutorial-pim.html

.. |---| unicode:: U+02015 .. for quotes
   :trim:
   
###########################################
Using Leo as a Personal Information Manager
###########################################

..  "Cloning is pure genius!"---Michael Manti

..  "If you are like me, you have a kind of knowledge base with infos
..  gathered over time. And you have projects, where you use some of those
..  infos. Now, with conventional outliners you begin to double these
..  infos, because you want to have the infos needed for the project with
..  your project. With Leo you can do this too, but if you change text in
..  one place **it is updated in the other place too!** This is a feature I
..  did not see with any other outliner (and I tried a few). Amazing! Leo
..  directly supports the way I work!"---F. Geiger

This chapter tells how you can use Leo as a Personal Information Manager. It introduces `clones`_: one of Leo's most unusual and powerful features for organizing data.

.. contents:: Contents
    :depth: 2
    :local:

Clones
++++++

.. index::
    pair: Clone; Tutorial
    
A **clone** is a node that appears in more than one place in a Leo outline. Clones are marked with a small red arrow in its icon box. All clones of a node are actually *the same node*:

- Any change to one clone affects all clones.
- Inserting, moving or deleting any child of a clone will change all other clones on the screen.

Clones allow data to be stored in multiple places within an outline.

``Ctrl-` (clone-node)``
    Clones node A. The shortcut is a grave accent, *not* a single quote.  This is often on the same keyboard key as the tilde ``~`` character.

Please take a few moments to experiment with clones:

- Create a node whose headline is A.
- Clone node A with the ``clone-node`` command.
- Type some text into the body of A.
- All clones of A now have the same body.
- Insert a node, say B, as a child of any of the A nodes.
- Notice that *all* the A nodes now have a B child.
- See what happens if you clone B.
- See what happens if you insert, delete or move nodes that are children of A.
- When you delete a node's penultimate clone, the node becomes a regular node again.

Clones accelerate work flow by creating views
+++++++++++++++++++++++++++++++++++++++++++++

Clones can greatly accelerate your work flow. To start a project, clone nodes related to the project and drag them at or near the top level, where you can get at them easily. When the project is complete, just delete the clones. This work flow is surprisingly effective:

- The original nodes never move, but they change whenever their clones do.

- There is nothing to "put back in place" when you are done. Just delete the clones.
  
Used this way, **clones create views**: when you gather cloned nodes together for a project, you are, in effect, creating a project-oriented view of the outline. This view **focuses your attention** on only those nodes that are relevant to the task at hand.

Using abbreviations and templates
+++++++++++++++++++++++++++++++++

.. index::
    pair: Abbreviation; Tutorial

Leo optionally expands abbreviations as you type. Abbreviations typically end with something like ``;;`` so they won't trigger by accident.

To use abbreviations, you must enable them in myLeoSettings.leo::

    @bool enable-abbreviations = True

You define abbreviations in ``@data abbreviations`` nodes or ``@data global-abbreviations`` nodes. None come predefined, but ``leo/config/exampleSettings.leo`` contains example abbreviations in the node ``@data abbreviations examples``

Abbreviations can simply be shortcuts::

    ncn;;=@nocolor
    
Abbreviations can span multiple lines. Continued lines start with ``\:``, like this::

    form;;=<form action="main_submit" method="get" accept-charset="utf-8">
    \:<p><input type="submit" value="Continue &rarr;"></p>
    \:</form>\n

Abbreviations can define templates in which ``<|a-field-name|>`` denotes a field to be filled in::

    input;;=<input type="text/submit/hidden/button"
    \:name="<|name|>"
    \:value="" id="<|id|>">\n

Typing ``,,`` after inserting a template selects the next field.

Abbreviations can execute **abbreviation scripts**, delimited by ``{|{`` and ``}|}``::

    date;;={|{import time ; x=time.asctime()}|}
    ts;;={|{import time ; x=time.strftime("%Y%m%d%H%M%S")}|}
    
To use abbreviations scripts, enable them in myLeoSettings.leo as follows::

    @bool scripting-abbreviations = True

With abbreviation scripts enabled, typing ``ts;;`` gives::

    20131009171117
    
It's even possible to define a context in which abbreviation scripts execute. See leoSettings.leo for full details.

Using URLs
++++++++++

.. index::
    pair: URL; Tutorial
    pair: @url; Tutorial

Leo highlights URLs whenever syntax is coloring is enabled.

``Ctrl-Left-Click (open-url-under-cursor)``
    Opens the URL under the cursor.
``open-url``
    Opens a URL appearing either in the headline or the first line of body text. If a headline starts with ``@url``, the rest of the headline is take to be a url.
    
**Note**:

- Leo opens URLs that look like file names using os.startfile.
- Leo opens all other URLs with your default web browser.
- Any scheme (http, mailto, ftp, file, etc.) supported by your browser is valid.
- URL's should contain no spaces: use ``%20`` instead of spaces.

`See the Appendix <appendices.html#valid-url-s>`_ for a complete description of valid URLs.

Using Chapters
++++++++++++++

.. index::
    pair: Chapter; Tutorial
    pair: @chapter; Tutorial

@chapter trees denote a **chapter**. You can **activate** a chapter from the icon area, or with chapter-select commands. Activating a chapter makes only those nodes in the chapter visible. The ``main`` chapter represents the entire outline. Activating the ``main`` chapter shows all outline nodes.

``chapter-select-main``
    Selects the main chapter.
    
``chapter-select-<chapter-name>``
    Selects a chapter by name.

Summary
+++++++

Clones are nodes appearing multiple places in the outline.

- Changes to one clone affect all other clones.
- All clones of a node are *exactly the same node*.

Views allow multiple views of data to exist in a single outline.

- A view is simply a collection of nodes.
- Because of clones, a node may appear in many views at once.
- View focus attention on tasks and reduce searching for nodes.

Leo expands abbreviations as you type.

- Abbreviations range from simple shortcuts to multi-line templates containing fields.
- Type ``,,`` to move to the next field.
- Abbreviations can also insert the result of executing code.
    
Ctrl-left-clicking any URL opens the URL.

@chapter trees denote chapters. Activating a chapter shows only the nodes in that chapter.

