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)

3 Likes

Great!

is it also possible to make Bike remember my choice when opening? I collapse all rows, close Bike, then open it again → all rows are expanded.

This should already be happening if:

  1. You leave the document open when you close Bike … ie it won’t work if you first close the document and then close Bike. But if you close Bike with documents open then those documents (and expanded state) should be restored.

  2. Make sure the “Settings > Document > When close Bike Close Documents” is NOT checked.

1 Like

I see… yes, it works as you described above. I usually have only 1 window opened with several tabs. would be nice if you could close and reopen the window → and the tabs would show content as before closing Bike.

if you could close and reopen the window → and the tabs would show content as before closing Bike.

It gets a bit complex … because a window’s tabs can be:

  1. Tabs that contain different views on the same document
  2. Tabs that contain completely different documents

With work I might be able to make it so that:

  1. Close window with multiple views of the same document
  2. Re-open that document manually (this is already working as described above if you just close Bike.app and reopen it) and it will create a window with the same tabs. I don’t think it I could make it work so that opening one document opens the other documents that were in the tabs.

Eventually I expect that I will add a “workspace” feature to Bike. Where instead of opening a specific file you open a folder and through that folder can open and mange multiple Bike files. I think that might really be what you are wanting?

2 Likes

yes, I think that would be ok, since I only use one folder with a few files (so could just open that only folder). thank you.

In the latest preview release Bike will store expanded state even for closed documents: Bike 1.16 (Preview) - #11 by jessegrosjean

1 Like