Macro that creates a task

Hi all,

In my workflow, I would like to use a macro for creating task with a tag “#call”, and if possible, an optional value for a ‘SCHEDULED:’ field. I tried and searched all over to find a solution, with no success.

In config.edn I’ve put the following:

:macros
{
:call "TODO $1 #call \nSCHEDULED: < $2 > "
}

When I use the macro, e.g {{call mother, 2024-03-25}}, it renders:

image

but without making it a real task with checkbox and ‘TODO’ marker.

I also haven’t got a clue on how to make the ‘scheduled’ part optional (I could make a seperate macro of course, without that part, but I’m really curious if there isn’t a way to make a placeholder and part of the string optional.

All suggestions are very welcome!

I’m afraid that this is not possible with a plain macro. Consider Make custom macros that replace themselves with their value on first run

Hello, @marcoder! You can use 🏛 Full House Templates plugin here:

2024-02-25 04.43.26

Setup instructions:

  1. Install the plugin
  2. Create template anuwhere in Logseq:
- template:: task
  template-list-as:: template
  template-usage:: `{|}`
	- `'TODO ' + c.args.$1 + ' #call'`
	  `c.args.$2 ? 'SCHEDULED: <' + date.from(c.args.$2).format('YYYY-DD-MM ddd') + '>' : ''`
  1. Use ⌘T (or Ctrl+T) to open Insertion UI and chose «task» template

Hi there, thanks for the suggestions. Past weeks, I did already play around with kits for executing JS, @mentaloid, and studied your excellent advices and suggestions in various topics about its use. I’m really fascinated, even though it feels like climbing a steep hill in my very early journey into the programming world. I will try your suggestion in the linked post. I’m also sure it is going to help me in the further development of my ‘ideal’ logseq workflow (if there even is such a thing :wink: ), thanks for all the input!

And @stdword, what an interesting plugin! Although I’m mostly looking for a solution without plugins, it really tickles my curiousity, mostly because of what’ under the hood :wink:

Thanks, both!

1 Like