**usage: ** now everytime I use slash command /iframe I can quickly embed a url or I can use /iframe-wikipedia | /iframe-google | /iframe-google-images followed by a search term and get embedded results from which I can pull data without switching to a browser window
Depending on how technically proficient you are, I’d warn against using macros if you’re new to Logseq.
As the OP points out, you’d need to change the config.edn file. If you don’t know what that is, I suggest you first get some more experience with simpler stuff like a daily template: How to Set Up an Automated Daily Template in Logseq
It also helps if you get experience with queries, starting with simple queries and then slowly move up to Datalog queries. See #learning-sprints:queries for learning resources.
How can I create nested blocks with a macro or a command?
Is it possible to have a macro that expands into multiple blocks possibly nested?
Or a command that creates more blocks?
I would also appreciate pointers for: documentation or source code files defining :editor/input and :backward-pos
:editor/input will write the string to the block :backward-pos is a way to move the caret x characters backwards to wait for user input at the correct location once a macros has been entered, I don’t have links to docs, but you should into the examples in config.edn
Hi Cannibalox, thank you for your answer.
I was thinking about an easier method of writing question-answer LogSeq flashcards.
I was wondering if macros could be used to do something like:
Type the following in a LogSeq block: {{makecard question answer}}
Press enter
Have the macro to expand into the following:
I’m aware of templates but they don’t seem to accept arguments (i.e. I can’t input “quesiton” nor “answer” to a template), if they did they would be perfect for this I think.
Do you think I can somehow use :editor/new-block in a macro to achieve this?
afaik, you can’t create flashcards using macros (not sure we can create sub bullet via macros, and I’m not a flashcards user myself).
that said, I would recommend a text expander like Espanso, Autohotkey or fastkeys… although not dedicated to logseq, these tools work great in conjunction with logseq (you can search the discord for scripts or use-cases examples).
alternatively, you can try logseq plugins like : Smart Blocks, Power Blocks or Full House Templates that should theorically achieve what you want.
Hi all, thanks for these macros, pretty interesting. Have any of you figured out a way to produce a macro which turns dynamic variables into strings? My goal is to build a template that creates a series of pages based on the page the template is currently built on. Thanks!
If I am not mistaken, you can have exactly what you want → turn dynamic variables into editable strings, stripping the “dynamic” from the Macro with @mentaloid’s code here;
There is a section that covers Macros briefly, referenced in the Templates page listed in docs.logseq.com. I have not seen anything on how to build custom commands in the official docs. But I do not fully grasp their usefulness over templates. They cannot have Dynamic variables like %time% can they? And they are limited to one block without properties only.
They differ from Templates in that they are defined in config.edn. As are Macros. Templates are or can be defined in a page.
I imagine that command/macros could have the benefit to be faster to call with few types. instead of /template and then template name.
Do you know any solution to call the template faster?