The clone-find commands in 3 minutes

102 views
Skip to first unread message

Edward K. Ream

unread,
Sep 23, 2020, 10:07:01 AM9/23/20
to leo-editor
The clone find commands are one of Leo's killer features. This post will get you up to speed in a hurry.

Suppose you want to find all the calls to a method (or ivar) x.  Use the cff (clone-find-flattened) command:

<Alt-x>cff<return> prompts you for a search pattern in the minibuffer. Enter the search pattern. You can change search settings while entering the pattern. See the second post script.

When you hit <return> the cff command creates an organizer node as the last top-level node of the outline. This organizer node contains a clone of every node containing a match of the search pattern.

That's all!

"What's the big deal?", you ask. The big deal is:

1. You now have live (cloned) nodes containing all the matches. Changing any of the cloned nodes changes all of the cloned nodes.

2. You can keep the organizer node as long as you like. The organizer node is a record of your researches.

3. Most importantly, you can organize the cloned nodes. For example, you can create a node called "not likely to be significant" and move some of the clones so they are children of that node.  Or you can just delete nodes that aren't likely to be significant :-)

Summary

The clone find commands allow you to see how classes, methods or ivars are used.

You can organize the results of these commands as you see fit, and keep the results for as long as you like.

I use cff commands continually while refactoring code.

Edward

P.S. The cffm command (clone-find-flattened-marked) doesn't use a search pattern. Instead, it makes clones of all the marked nodes of an outline. This is a supremely simple way of "gathering" nodes.  Just mark any set of nodes you like, then do <Alt-x cffm<return>.

P.P.S While entering the search pattern, you can change search settings with shortcuts that start with Alt-Ctrl:

- Alt-Ctrl-B: toggle search bodies.
- Alt-Ctrl-E: search the entire outline.
- Alt-Ctrl-H: toggle search headlines.
- Alt-Ctrl-I: toggle Ignore-case.
- Alt-Ctrl-N: search selected node only.
- Alt-Ctrl-S: search only the selected outline.
- Alt-Ctrl-W: toggle whole-word.
- Alt-Ctrl-X: toggle regex mode.

You did know about these shortcuts, didn't you?

EKR

gar

unread,
Sep 23, 2020, 1:05:47 PM9/23/20
to leo-e...@googlegroups.com
Thanks for this tutorial, Edward!
Long time ago I stopped using clone-find-* commands because I need to use @clean nodes. Cloning of @clean nodes is a really bad idea - one who is brave enough to use can suddenly (just after saving the .leo project) discover unwanted files somewhere in the filesystem and other artifacts.
So as a matter of fact, it is good to use cf* commands with plain .leo or @file nodes.

ср, 23 сент. 2020 г. в 17:07, Edward K. Ream <edre...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/2a00cbf8-ec78-4b89-a35a-9f89dc4b4906o%40googlegroups.com.

Edward K. Ream

unread,
Sep 23, 2020, 3:39:00 PM9/23/20
to leo-editor
On Wed, Sep 23, 2020 at 12:05 PM gar <gar...@gmail.com> wrote:

Cloning of @clean nodes is a really bad idea - one who is brave enough to use can suddenly (just after saving the .leo project) discover unwanted files somewhere in the filesystem and other artifacts.
So as a matter of fact, it is good to use cf* commands with plain .leo or @file nodes.

Have you tried putting @path directives in the @clean nodes?

Edward

gar

unread,
Sep 24, 2020, 3:11:19 AM9/24/20
to leo-e...@googlegroups.com
i tried to put @clean under @path - but cloned nodes do not respect it
i tried to use most-full relative path for @clean - then if it does not start from .leo's file dir then clones are written elsewhere
the only thing worked - abs path (afair), but I cannot use it since work under various oses and environments
since that I stopped to use clones totally (more mess the pleasure for my liking)

ср, 23 сент. 2020 г. в 22:39, Edward K. Ream <edre...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.

Edward K. Ream

unread,
Sep 24, 2020, 7:24:43 AM9/24/20
to leo-editor
On Thu, Sep 24, 2020 at 2:11 AM gar <gar...@gmail.com> wrote:

i tried to put @clean under @path - but cloned nodes do not respect it

Sorry, I wasn't clear.  You can put the @path directive in the body text of the @clean node itself.
i tried to use most-full relative path for @clean - then if it does not start from .leo's file dir then clones are written elsewhere

Try using path expressions to make @path more flexible.

Edward

gar

unread,
Sep 24, 2020, 3:31:56 PM9/24/20
to leo-e...@googlegroups.com
If I use @path in the body of the @clean node and clone a subnode w/o it - this subnode would get all things right?
Hmmm, I'll try it, thank you

чт, 24 сент. 2020 г. в 14:24, Edward K. Ream <edre...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.

Félix

unread,
Sep 24, 2020, 10:03:02 PM9/24/20
to leo-editor
Thanks for this post! 

Alexey Tikhonov

unread,
Sep 25, 2020, 4:26:03 AM9/25/20
to leo-editor
Edward, thanks for sharing! I've just tried cff and it helped me to filter out 100+ irrelevant files, saving huge amount of time and effort!
пятница, 25 сентября 2020 г. в 09:03:02 UTC+7, Félix:

Edward K. Ream

unread,
Sep 25, 2020, 7:27:55 AM9/25/20
to leo-editor


On Thu, Sep 24, 2020 at 9:03 PM Félix <felix...@gmail.com> wrote:
Thanks for this post! 

You're welcome.

Edward

Edward K. Ream

unread,
Sep 25, 2020, 7:29:11 AM9/25/20
to leo-editor
On Fri, Sep 25, 2020 at 3:26 AM Alexey Tikhonov <tickli...@gmail.com> wrote:
Edward, thanks for sharing! I've just tried cff and it helped me to filter out 100+ irrelevant files, saving huge amount of time and effort!

Glad you find cff useful. Imo, Leo's clone find commands are one of Leo's killer features.

Edward
Reply all
Reply to author
Forward
0 new messages