When you open a file, it should not expand every line

My files always expand every level when opened. There should be a user preference to not expand on opening. Or, a preference to open the ones that were opened when the file was saved.

Option to open in collapsed state is interesting idea. I might add. Would anyone else want or use that option?

I do plan to add add this eventually, but in the meantime Bike will restore collapsed state for documents that you leave open when quitting Bike. See the section “Window Restoration” here:

1 Like

I wonder if the number of those who found it useful would be increased by making the option value an integer number (expanded to level N on open) rather than an on-off boolean checkmark ?

I think I personally might find an opening state like:

Screenshot 2022-11-14 at 01.03.45

a little too information-free (I remember it jarring, for some reason, with OPML imports to Omni’s outliner – perhaps a feeling that I had to click at least once before I could see anything useful at all ?)

But a default of expanding to level 2 (or level 3) might yield something more like a Table of Contents.

Screenshot 2022-11-14 at 00.53.45


I’m experimenting, FWIW, with the expand to level N script below:

Expand disclosure triangle to view JS source
(() => {
    "use strict";

    // Ver 0.2

    // -------- EXPAND A BIKE OUTLINE TO LEVEL N. --------

    const nLevel = 2;

    // main :: IO ()
    const main = () => {
        const doc = Application("Bike").documents.at(0);

        return doc.exists() ? (
            expandedToLevelN(nLevel)(doc)
        ) : "No documents open in Bike";
    };

    // ------------- OUTLINE EXPANSION STATE -------------

    // expandedToLevelN :: Int -> Doc -> IO Int
    const expandedToLevelN = n =>
        doc => {
            const bike = Application("Bike");

            bike.collapse(
                doc.rows.where({
                    level: {">=": n}
                })
            );
            bike.expand(
                doc.rows.where({
                    level: {"<": n}
                })
            );

            return n;
        };

    // MAIN ---
    return main();
})();

(To test in Script Editor, set the language selector at top left to JavaScript)

Using Scripts - Bike

3 Likes

PS not sure how feasible an init file, or an on_open script event, might look at some point …

Can you list a few apps that support AppleScript event handlers now days? It looks pretty strait forward to call a given script, but I’m curious how apps guide the user to setting everthing up.

The first thing that comes to mind is the event handling in DEVONthink smart group scripts:

Automation : Smart Rule Scripts


Also, OmniGraffle object event scripts:


Apple’s own folder events:

Mac Automation Scripting Guide: Watching Folders


and, perhaps most widely used ?

Noodlesoft’s Hazel

About Folders & Rules – Noodlesoft

Depending on the content it may be useful but not as a generic preference. org-mode has a similar preference (what level to show when opening) that can be specified by file.

Some files I’ll open and navigate to the branch I need, because every time it could be different, other files - such as drafts I am working on I want them expanded (or the way I have left them at last save).

Definitely. To me Bike should launch in the state it was closed, having to open files, then collapse all, then find where I was and expand appropriately is, while tolerable, not the most enjoyable experience.

2 Likes

An afterthought – the DEVONthink osascript interface list of event types which can be bound as triggers to DEVONthink’s smart rules (which may themselves be defined by scripts).

1 Like

I’ve added options for this in Bike 1.7 Preview (91)

2 Likes

Great!