Linking mails from Mail App

Maybe I’m doing something wrong, but unlike TaskPaper, dragging an email from the Mac Mail App does not generate a valid link.

The issue seems to be a missing //

Where we might need:

message://%3C ... %3E

the drag and drop from Mail to Bike appears, at the moment, to be creating:

message:%3C ... %3E

(macOS 13.31, Bike 1.11.1)


In the interim, FWIW, I personally copy labelled Bike and MD links from Mail and other apps using:

1 Like

I’ve added this to my todo list. I think I just need to do some special handling for mail links that I haven’t implement in Bike yet.

2 Likes

The interim manual fix for a link dragged from Mail is, of course, to:

  • Control click on the right-hand link icon (arrow in box)
  • Choose Edit Link
  • Insert // between message: and %3C

(If volume is large, we could sketch a quick Fix drag-dropped Mail links script for you)

1 Like

Thank you @complexpoint and @jessegrosjean !

Here, if you want to experiment with some test files rather than working data, is a script which aims to find and fix any links in the front document which have URLs starting with message:%3C.

(Changing them to start with message://%3C)

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

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

    // Fix, in front Bike document,
    // any links to messages dragged from Mail to Bike
    // in Bike 1.11.1 or before.

    // (Supplying `//` after `message:`)

    // Rob Trew @2023
    // Ver 0.2

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

        return doc.exists()
            ? doc.rows().flatMap(
                row => {
                    const runs = row.textContent.attributeRuns;

                    return zip(runs)(runs.link())
                    .flatMap(
                        ([run, link]) => "string" === typeof link
                            ? link.startsWith("message:%3C")
                                ? [(
                                    run.link = `message://${link.slice(8)}`,
                                    run.link()
                                )]
                                : ((link && [link]) || [])
                            : ((link && [link]) || [])
                    );
                }
            )
            .join("\n")
            : "No document open in Bike.";
    };

    // --------------------- GENERIC ---------------------

    // zip :: [a] -> [b] -> [(a, b)]
    const zip = xs =>
    // The paired members of xs and ys, up to
    // the length of the shorter of the two lists.
        ys => Array.from({
            length: Math.min(xs.length, ys.length)
        }, (_, i) => [xs[i], ys[i]]);

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

See: Using Scripts - Bike

2 Likes

Thank you, works great!!

1 Like

I think this is fixed in latest Bike preview release:

1 Like

Yes, indeed. Thank you Jesse!