Move Branch Up/Down


#1

I love FoldingText’s Organize > Move Branch Up (or Down) command.

My understanding is that TaskPaper currently provides only the plain Move Up (or Down) command.

I know the question has been addressed in earlier discussion. But is there anything new to add to it? Any plans to add the command in a forthcoming version? Has anyone attempted a script? Thanks as ever.


#2

I’m away from my main computer for the next week and a half … so can’t dig into the code at the moment. But “move by branch” is already implemented in TaskPaper’s codebase, just not exposed through the UI. If you really wanted it should be possible to write a script that just calls in to the internal implementation… but sorry I don’t have code in front of me right now to give you specifics.

With that said I removed them because I think the current movement commands are easier to understand, and I didn’t want to have two different ways to do mostly the same thing.

What about instead using the Edit > Selection > Select Branch command in conjunction with the existing move up/down commands?


#3

Yes, this is what I’ve been doing so far, but I’d prefer the more integrated solution. There’s no rush, of course, and I’ll be happy to wait. Thanks!


#4

You could try creating 2 (or 4) scripts by adjusting the string constant in final line of this one

( 'up' | 'down' | 'left' | 'right' )

and assigning each to a keystroke (with Keyboard Maestro or FastScripts etc)

(function (strDirection) {
    'use strict';

    // TASKPAPER CONTEXT

    function TaskPaperContext(editor, options) {

        function toCapitalCase(s) {
            return s[0]
                .toUpperCase() +
                s.slice(1)
                .toLowerCase();
        }

        editor[
            'moveBranches' + toCapitalCase(
                options.direction
            )
        ]();

    }

    // JAVASCRIPT FOR AUTOMATION CONTEXT

    var tp3 = Application('com.hogbaysoftware.TaskPaper3'),
        ds = tp3.documents;

    return ds.length ? ds[0].evaluate({
        script: TaskPaperContext.toString(),
        withOptions: {
            direction: strDirection
        }
    }) : undefined;

})('up'); // 'up' or 'down', 'left', 'right'

Don't Violate Outline Hierarchy Mode
#5

Flawless and generously offered as usual, @complexpoint. Thank you.

While this is very useful indeed, what I had in mind was a functionality identical to that of the Move Branch [Up|Down] commands in FoldingText. In that case, the branch is not moved up or down by one line but by as many lines as required, so that the top node of the branch remains at the same level of the outline hierarchy. For example, with the following outline and the cursor positioned at Level 2:

  • Level 1
  • Level 1.1
  • Level 1.2
  • Level 2 <<< [cursor position]
  • Level 2.1
  • Level 2.2
  • Level 2.3

Move Branch Up once would move the entire branch above Level 1:

  • Level 2 <<< [cursor position]
  • Level 2.1
  • Level 2.2
  • Level 2.3
  • Level 1
  • Level 1.1
  • Level 1.2

This is indeed how the command works in Folding Text, and I find it more useful and intuitive than the current implementation, which mixes the two branches together:

  • Level 1
    • Level 1.1
  • Level 2 <<< [cursor position]
    • Level 2.1
    • Level 2.2
    • Level 2.3
    • Level 1.2

#6

Got it - I’ll take a look at the weekend


#7

I have the same request. Coming from OmniOutliner and Emac’s org-mode, being able to move branches like this would be a welcome addiion.