What's the latest on "Quick Entry" solutions for TaskPaper 3?

I just created and uploaded a new Launchbar action as suggested above. You can get it from my GitHub account: GitHub - raguay/MyLaunchBarActions: This is my public repository for LaunchBar 6 Actions.

This action is used to add a new task to a TaskPaper project. If you send a path of a TaskPaper file to this action, it stores that path to add tasks to. Otherwise, if TaskPaper is running while you run this action, it will get that files path, store it, and use that file. If you run the action again when TaskPaper isnā€™t running, it will use the last stored file name.

Once it has determined what file to use, it asks the user for the task line and which project to add it to. The user simply types the name of the task, and selects the project. That new task will be added to the top of that project.

This action just modifies the text file. It doesnā€™t go through the TaskPaper API. I did it that way so that TaskPaper doesnā€™t have to be running.

Let me know if this works well for your use case.

4 Likes

This is great!! Iā€™ve tried it and it works great! (Finally some Launchbar goodies - Iā€™m surprised of how many Keyboard-Maestros there are here.)

Only one remark: After entering the text/task, selecting the project and hitting enter, the task gets added at the perfect spot - only my launchbar-bar stays afloat.
If I then hit enter again to make it disappear, I get the same task twice - or I have to hit ESC, which works. But maybe you can make the launchbar-bar go and/or have another type of feedback, eg. a notification: Task X added.

But besides - this is awesome and makes me like TaskPaper+Community so much more :wink:

Yea, I finally figured it out. If I do not use a LaunchBar internal command with the action, it doesnā€™t close the bar. I now have a dummy command in there and the bar closes properly. You will have to redownload it and re-install it.

Iā€™ll be adding this to my Alfred TaskPaper workflow. It has even more actions: A monthly, weekly, daily task adding with possible repeats. It is my complete todo list workflow, but I have a small bug in it that I am trying to work out first.

I use both LaunchBar and Alfred (I know, Iā€™m weird. A true gadget freak!). So you can bug me with questions about either.

Useful work ! Many thanks for sharing this.

There may be scope, I think, for refining the project listing a little. At the moment, if we take, for example, the standard test file, and add a @due date to the To Organize Items: project, we hit a couple of minor problems:

  1. The code loses one of the projects (it doesnā€™t yet have a mechanism for recognising the project colon when itā€™s followed by a tag)
  2. The code thinks that the last project, To Fold, Focus, and Filter Items: is three different projects (it gets confused by finding commas in the project name)

The only other comment is that I did hit an error message a few times before I figured out how to set the default project path : - ) ( but thatā€™s probably my fault ā€¦ maybe just a little more text on it in the documentation ? )

Yes, I am currently searching for lines that end in ā€œ:ā€ to be projects. I guess I need to make that search more generic. First pass and adding new featuresā€¦

What error are you getting? If you have TaskPaper already open with a file, it should query TaskPaper for the file path and use it. Or, you can navigate to the file in LaunchBar and use the ā€œSend Toā€ feature (tab on the file) and then select the action using tpa (or the abbreviation you have trained in). Either way should save the file to use for adding items.

I only use tags like that on items and not projects.

If youā€™re using (presumably) regular expressions to identify projects, you might want to look at the ones in my TaskPaperRuby code. They do recognise projects containing commas, or ending with one or more tags. Thereā€™s also a regexp to right-strip groups of tags from lines.

The regexps are in the TaskPaperItem class.

What error are you getting? If you have TaskPaper already open with a file, it should query TaskPaper for the file path and use it.

Your code probably needs to handle the case where ~/.tpProjectFile doesnā€™t yet exist.

(Users are quite likely to hit that case when they first try to use the action).

Just updated to fix that use can. Projects are now anything that doesnā€™t start with a ā€˜-ā€™ and has a ā€˜:ā€™ somewhere in the line. I tried using Regular Expressions, but they made the script run much slower. Doing spot checks like this runs a whole lot faster. You will need to redownload from the GitHub Repository.

That might catch notes that use colons, too. Projects are lines that donā€™t start with "- ", and whose last (rightmost) non-tag-or-whitespace text ends with a colon. Runs of tags and/or whitespace after the colon donā€™t disqualify a line from being a project, but any other text does, making it a note instead.

Here's an example: this line should be a note, even though it has a colon.

But this is a project: @today @flag

Okay. I was able to get a good RegExp version that seems to work. @mattgemmellā€™s RegExp would not work in JavaScript.

I also was able to get proper error messages if there isnā€™t a designated file or TaskPaper isnā€™t open.

It is on my GitHub. Please give it a try and let me know if there are any other issues.

1 Like

Quick progress !

There still seems to be a difficulty in getting or using the path of a saved file in the active document on first use (perhaps still because of the initial absence of ~/.tpProjectFile ?)

On using regexes ā€“ you mentioned performance ā€“ I notice that you are compiling a fresh regex in each iteration of the inner loop. You may find it more run-time-efficient to create the regex once (outside the .forEach process) bind a variable name to it, and then use that name inside the .forEach() function.

Good luck !

PS - UPDATE

just took a closer look - I think you may find, if you insert a debugging alert, that your LaunchBar.executeAppleScript call is returning an empty string in lieu of an active document filepath:

    var pFile = LaunchBar.executeAppleScript('if application "TaskPaper" is running then',
        'tell application id (id of application "TaskPaper")',
        '	set a to file of the front document',
        ' 	return POSIX path of a',
        'end tell',
        'else',
        '	return ""',
        'end if').trim();

    LaunchBar.alert('Path returned: ->' + pFile + '<-');

That happens if the file is in a sandboxed location that I can not access or has not truly been saved to the file system yet. Iā€™ve never ran across a case where that would not give a path other than for the mentions cases. Iā€™ll keep looking into it.

Iā€™m moving it out and it does help (the RegExp). Iā€™ll post the new version tomorrow. Itā€™s late here in Thailand. :smile:

It also depends, of course, on the process which runs the script. If you try running AppleScript code of increasing curiosity and ambition from that LaunchBar.executeApplescript() method, I think you may find that you get as far as persuading the TaskPaper Application to reveal its name, but that it will withhold the number of documents that are open.

It may prove simpler to forgo the convenience of the LaunchBar methods, and run your JavaScript in a JavaScript for Automation context (rather than a LaunchBar engine context), by choosing ā€˜AppleScriptā€™ as the type of the default script in LaunchBarā€™s Action Editor, and supplying it with a JavaScript for Automation .scpt.

(That might also spare you from calling out to smaller osascript fragments here and there)

Hi, Just updated the LaunchBar action to run a little faster. Not sure about doing @complexpoint suggestion as I canā€™t reproduce the problem and I do not know that much about that flavor of JavaScript (like how to read files from it).

I would like to see an Alfred app version of this this script. Would that be very hard to do?

1 Like

Yes, I am adding it to my Todo Workflow which you can get here: GitHub - raguay/MyAlfred: This is where I am keeping my Alfred 2, Alfred 3, and Alfred 4 workflows.

Iā€™m still working on a few bugs with it, but I should have it added by Monday Thailand time. Iā€™ll announce it here as well.

1 Like

Just added it to my Todo Workflow for Alfred. You can download it from Packal (Todo Workflow | Packal) or my GitHub account above. It is the t:addtask command.

2 Likes

Great! Thank you. Will try it.

The workflow doesnā€™t seem to work on my machine: t:settodo is not responding

t:settodo requires you to start typing the name of the directory you want your todo list directory made. Therefore, if you type ā€œdocumā€, it should give the ~/Documents" directory as an option. I place it in a Dropbox folder and use it on two computers. Very handy!