Is there a way to customize the menu items under "Tag with..."

I’d love to add my custom tags so I can use keyboard shortcuts as I don’t use the default tags - Due, Today, Start, Done.

Can I override them?

Thanks

You can write a script (to toggle a particular tag on and off in selected lines), and attach that script to a keystroke with something like Keyboard Maestro or Fastscripts.

I’m personally out of town at the moment, without a macOS machine to hand - but if no-one else has sketched a script for you by then, I should be able to take a look in the latter half of next week.

In the meanwhile, it may be worth looking at the tags section of the extensions wiki:

https://support.hogbaysoftware.com/t/taskpaper-extensions-wiki/

2 Likes

This script may help — it will toggle through a list of tags:

/* eslint-disable max-lines-per-function */
(() => {
    "use strict";

    // Ver 0.02
    // A bit of tidying

    // - TOGGLING SELECTED ITEMS THROUGH A CYCLE OF TAGS -

    // main :: IO ()
    const main = () =>
        Application("TaskPaper").documents.at(0)
        .evaluate({
            script: `${TaskPaperContextScript}`,
            withOptions: {
                tagCycle: [
                    "important",
                    "next",
                    "today",
                    "incubate",
                    "waiting",
                    "declined"
                ]
            }
        });

    // -------------------- TASKPAPER --------------------

    const TaskPaperContextScript = (editor, options) => {

        const tpMain = () => {
            const
                outline = editor.outline,
                selection = editor.selection,
                tagCycle = options.tagCycle;

            outline.groupUndoAndChanges(() =>
                selection.selectedItems.forEach(
                    item => bimap(
                        k => k && item.removeAttribute(
                            `data-${k}`
                        )
                    )(
                        k => k && item.setAttribute(
                            `data-${k}`, ""
                        )
                    )(
                        foundAndNext(tagCycle)(item)
                    )
                )
            );

            editor.moveSelectionToItems(selection);
        };

        // foundAndNext :: [String] ->
        // Item -> (String, String)
        const foundAndNext = tagNames =>
            // A Tuple of the first found tag in the cycle,
            // if any, and the next tag in the cycle, if any.
            item => {
                const
                    iLast = tagNames.length - 1,
                    mbi = tagNames.findIndex(
                        k => item.hasAttribute(`data-${k}`)
                    );

                return 0 <= iLast ? (
                    -1 !== mbi ? (
                        iLast !== mbi ? [
                            tagNames[mbi],
                            tagNames[1 + mbi]
                        ] : [tagNames[iLast], ""]
                    ) : ["", tagNames[0]]
                ) : ["", ""];
            };


        // bimap :: (a -> b) -> (c -> d) -> (a, c) -> (b, d)
        const bimap = f =>
            // Tuple instance of bimap.
            // A tuple of the application of f and g to the
            // first and second values respectively.
            g => ab => [f(ab[0]), g(ab[1])];


        // TaskPaper context main function called.
        return tpMain();
    };

    // Script main function called.
    return main();
})();
2 Likes

Thanks. I do use the Command + T Option but I would’ve loved to use specific key strokes for specific tags, and use that “Tag” menu item that is just sitting there unused.