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.
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
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.
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:
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)
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.
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
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.
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).
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.
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!