Zettelkasten Forum


Feature Request: automatic completion when adding link to zettel

edited February 2019 in The Archive

I will be typing along, and realize I want to link to an extant zettel. I have to go to the search field, search, copy the link for the relevant target, clear the search field, find the note I was working on originally, find my place in it, and paste the link. This is a lot of cognitive overhead and always takes me out of the flow.

Nearly every time I use The Archive I miss this feature from @rene 's work. In sublime-zk or sublimeless, I can type [[ while writing and get a pop-up list of all zetteln, which narrows as I type. Then, when I hit return, the correct one is inserted.

The [[ trigger is not necessary, a hotkey to bring up an auto-narrowing list would also work. In emacs with zetteldeft I can do the same thing with a hotkey, and that works fine as well.

Honestly, this is the number one thing that makes me minimize The Archive and open another app.

Comments

  • I completely agree with @mediapathic that this feature would be great, and I would like to see a design solution in which, when one types a character like [ or #, and continues to write a letter directly after this, a list like the following pops up.

  • Keyboard Maestro to the rescue!

    The Archive Macros

    Four macros. The first is triggered by [[ then it does a type ahead search of your notes. Then it places the UID within [[ ]]. The other three are for duplicating the same funtionality with tags. Refresh Tag Varible keeps tract of tags. Refresh Tag Cloud creates a "Tag Cloud" note and finally, Insert Tag is activated by typing the # key with the same type ahead search.

    Thanks for the inspiration to create these. I'm finding them very helpful already.
    I'm really an amateur at this Keyboard Maestro but I'm enjoying it so far.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • @Will said:
    Keyboard Maestro to the rescue!

    Oh no.
    I mean, uh, thank you!

  • @mediapathic said:

    @Will said:
    Keyboard Maestro to the rescue!

    Oh no.
    I mean, uh, thank you!

    Thanks, I consider Keyboard Maestro in this use case a crutch till @ctietze's further developments.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • Hey Will... I just wanted to thank you for sharing your macros. I've been banging my head against the Keyboard Maestro wiki trying to figure out how to do these things. The macros you've put together helped me immensely (both in terms of getting my stuff done and in terms of learning a bit more how to bend KM to my will).

  • Thank you. Credit is shared amongst my teachers and those who inspired me. @kaidoh, @onlyskin, several people for the Keyboard Maestro users forum. And everyone who was kind enough to share tips on Regex. Testers and onlookers. Special thanks to @ctietze for creating this forum and The Archive. Thanks to all of you.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • @Will Sorry for my ignorance but I was only able to get Inline Note Link to work. Are there a few common stumbling blocks in Keyboard Maestro you may be able to identify and help me overcome? I have changed the filepath from yours to mine; that was easy enough to get Inline Note Link working.

  • @nickmilo22, glad you could get the _Inline Note Link _ working. Is there a specific macro you are trying to get to work? I'll try and help.

    1. For some of the macros, there is an expected variable needed that is provided by another macro.
    2. One tip that has helped me tremendously is to test the regex part of the scripts in terminal first to be sure that the output is what you want.
    3. I found it helpful to keep Keyboard Maestro's preferences open to the variables and keep checking that I'm referring to the correct variable.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • @nickmilo22, glad you could get the _Inline Note Link _ working. Is there a specific macro you are trying to get to work? I'll try and help.

    1. For some of the macros, there is an expected variable needed that is provided by another macro.
    2. One tip that has helped me tremendously is to test the regex part of the scripts in terminal first to be sure that the output is what you want.
    3. I found it helpful to keep Keyboard Maestro's preferences open to the variables and keep checking that I'm referring to the correct variable.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • edited April 2019

    Thanks @will . I think some of this is more than a few steps beyond my level of programming at the moment. I'm going to punt for the time being until I level up a bit.

  • Hi @Will -
    I've been using both your tag and zettel autocomplete KM macros and am a huge fan. My only complaint is that I'd like a smoother way of creating new tags and zettels. In action, when hit # and type a tag that does not yet exist in the list, it would be great if I could hit simply hit return and insert "# + what I've typed in the 'Prompt with List' dialog" at my cursor location. I've been trying and can't figure it out. Any ideas?

    Thanks-

  • I ask in Keyboard Maestro's forum about this and consensus there isn't a way to add a tag on the fly. Once you have discovered that a new tag is needed, a double tap on the esc key will end the macro and place the cursor for the new tag.

    My tag strategy is such that I don't have many (maybe 30) and am reluctant to create more. Still, haven't found a use case for tagging. Tagging, as a level of zettel grouping, feels good though.

    A far a smoother way of creating zettels. I'm not sure what you are asking. I use a KM template to create zettels.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • @scook, I did discover a workflow that might help with creating a new tag while using the "Insert Tag" KM.
    Add a unique tag like --Create-New-Item-- or similar that would sort at the top of the tag list. Also, set the "Default:" in the KM Action to "-". Now when run you will see the list of tags to choose from (type-ahead search still works) and if you feel the need to create a new one select --Create-New-Item--. Still not ideal but maybe a little smoother.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • @will, yes, I had thought of something similar. The trick there is that you'd need to know in advance that you were going to create a new tag. For me, one of the most useful functions of your autocomplete macro is that it suggests options as I type, eliminating the possibility of creating slightly different but redundant tags.

    Another possibility I tried was to tigger another macro that records what I into the "Prompt with List" dialog to a variable when the autocomplete macro initiates. Using and If/Then action, I would have that recorded text variable inserted at the cursor location if the "Prompt with List" fails (by hitting escape, or something). Sadly, I couldn't get it to work.

    Thanks for the feedback!

  • edited July 2019

    Instead of creating a new thread, I'm concatenating to this one. I hope that is ok. I basically want to second what has been said already, but also to extend the request for generic tag auto-completion.

    I'm really missing this feature or rather some kind auto-tag-suggestion. When initially tagging Zettels in my preamble I have to check all instances for conformance. For if I fail to do so, the Zettel of course won't show up with applied filters although I would want it to.

    It'd be great if TheArchive would grep all # or [[ - initiated strings, store them in a separate file and generate suggestions from them if one types # or [[. Perhaps with some CoreData/ UserDefaults integration and filter predicate magic.

    A quick search presented me with this blog post. While (of course..) it is for iOS, it may yield some functional insight on how to do it.

    Thanks!~

    -edit
    Maybe the complete(_:) method can be modified to that end?. Here's another possibly helpful source via this stack overflow question. And another, possibly directly pertaining to the problem; suggests to use textView(_:completions:forPartialWordRange:indexOfSelectedItem:).

    Post edited by zeitlings on
  • @zeitlings Not sure I understand your request but you might check out this discussion. This creates a zettel that is basically a tag cloud, a listing of previously used tags.

    "It'd be great if TheArchive would grep all # or [[ - initiated strings, store them in a separate file..."

    Bits of help preventing minor spelling or syntax multiples and will jog the memory. (Looks pretty to.)

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • edited July 2019

    @Will thanks for your reply.

    Not sure I understand your request

    Compare it to the built-in MacOS tagging feature in Finder. When assigning tags, you start with typing a letter and as you are typing on, you will be presented with a list of previously used tags relative to the prefix you've already been entering.

    As for how I imagine this to work with TheArchive, you can compare it to most IDEs, e.g. Sublime Text. Once you've defined a variable in your code, you will be presented with an in-line dropdown of already defined variables once you start typing, similar to what you've started typing.

    Bits of help preventing minor spelling or syntax multiples and will jog the memory. (Looks pretty to.)

    While this would be a more convenient overview of available tags, it would still require me to manually check some tags either before I add them to the preamble or after :# I'd like TheArchive to be "smart" about it πŸ™„

    • -edit

    I just discovered a Keyboard Maestro macro to do just that. That's nice, but, well, Keyboard Maestro. I guess I could convert this to an Alfred workflow πŸ€·β€β™‚οΈ

  • I have decided to go all in on The Archive with KM enhancements. That said, the autocompletion of tags with look ahead has me flummoxed. It works great for tags already in the files. I have two problems, however:

    1. How do you do headers #, ##, ### etc. Every time I try to do a header, it pulls up the tags list. When I escape out of the tags list macro, it puts me in the document, without the #. When I try again, the whole thing repeats. The escape does not seem to temporarily disable the macro. Double [ESC] as mentioned does not seem to do right either. Double escape exists the macro (first [ESC]) and clears the omni bar (second [ESC]).

    2. Creating new tags is also a problem. @Will suggests doing the double [ESC] to exit the macro and go to the document to insert the new tag. For me Double [ESC] does as noted above. If I do one [ESC] to get out of the macro, and then do the # for the new tag, I am once more in the cycle noted above.

    Any insights greatly appreciated. I know it must be something simple. both of these problems would be solved if I use a hot key instead of the string trigger. Is that the solution?

    Thanks - BWB

  • The principal reason that I migrated from The Archive to Drafts was the friction involved with creating titles, filenames, links, and tags. I'm a big fan of Keyboard Maestro and was intrigued by the excellent macros created by @will. But, Drafts also works on my iPhone and iPad as well as on my iMac. Keyboard Maestro, unfortunately, does not. Moreover, KM is an extra purchase and requires more than a minimal commitment to learning how it works, even if someone like @will does the heavy lifting.

    Drafts eliminates most of the problems that are discussed in this thread.

    • Tags are created with a look-ahead capability, both on the Mac and on iOS devices.
    • Alternatively, I downloaded a Drafts Action created by someone else (my JavaScript capability is very limited). It allows you to create a pop up list of tags from which to select. It was not hard to modify the JS code to display the tags I was interested in seeing. You could have multiple versions of this Action.
    • In Drafts, the left-hand panel displays notes (called drafts in Drafts) in a manner similar to TA. You can sort based on Date Created, Date Accessed, Date Modified or in alpha order. You can flag frequently used drafts (think structure notes) to sort at the top where they can be easily found.
    • There is a built-in Action to open the "last draft" you were using.
    • There is another capability that will display the last ten drafts you have accessed. "Recently used."
    • When editing a draft - say a structure note - you can select an action that pops up a dialog and asks for a title. The title is then used to create a new draft. The parent and child drafts are automatically cross-linked. The tags from the "parent" draft are assigned to the "child."
    • When editing a draft you can click on an Action to create a link to another draft. A dialog appears. You can scroll through the list of drafts or start typing the title of the draft you are looking for to narrow the list. When you find the draft you are looking for, double click it and the link is created for you.
    • If you need to know which drafts link to "this" draft, a "Back links" Action will immediately display them.
    • If you need a date stamp or a "template" for use with most of your drafts, you can create them easily with Actions.

    All of the above is done using built-in Drafts functionality or Actions that make use of the extensive scripting capability provided by Drafts. Fortunately, you don't have to know JavaScript to use them. I am a parasite -- I make use of the Actions created by others. If you are good at JSA, then the options are pretty much unlimited. If you are not, there are hundreds of Actions created by others to choose from.

    Of course you can still use Keyboard Maestro on a Mac. KM macros are not available on iOS devices, but changes made to drafts using KM sync across iCloud. Similarly, if you are on an iOS device you can make use of Shortcuts. Unsurprisingly, Drafts provides lots of app-specific actions available for use with Shortcuts. Again, any changes made to a draft (or multiple drafts) will sync through iCloud.

    The friction I experienced with managing notes on my iMac using TA is no longer an issue for me. Moreover, the processing options that open with iOS devices are tremendous. I'd much rather read a book sitting in a recliner using my iPhone to jot down (or dictate) notes. If something occurs to me while walking the dog, I tap on the Drafts complication on my Watch and dictate the beginnings of a note that will end up in a ZK. I can review a note on my iPhone will standing in line to check out at the grocery store. I can easily sit outside on a nice day and work using my iPad.

    Much as I appreciate everything I learned while using The Archive, at this point I don't think its functionality is competitive with Drafts. And, the Drafts development/release cycle is much faster.

    I was about to end this posting when I opened the Drafts Community forum and found a new posting from a Drafts user that I quote below. It provides a flavor for the activity within the Drafts community - new options are created almost faster than you can evaluate them and, if you wish, incorporate them into your workflows. To understand this post it is important to know that Drafts provides extensive interactions with many applications and services including Mail, Messages, Reminders, OmniFocus, Things, Fantastical, OneNote, Dropbox and many more. It is great for a ZK, but that is the tip of a very large iceberg. The post...


    UPDATED two of these Actions to work with the new [[wiki style]] linking and added a new action to find drafts by title. These actions help you work with links between drafts and ease interaction with other applications.

    • Select Drafts to Link UPDATED β€” Select drafts from customizable Workspace and insert markdown links
    • Copy Markdown Link β€” Copy link to selected draft in markdown format
    • Link to New Draft UPDATED β€” Create a new draft with the selected text as it’s title, and insert markdown crosslinks in both current and new draft
    • Find Draft to Link NEW β€” Search drafts (with selection if it exists) to insert [[wiki style]] link to at cursor.

    Would love your feedback


  • @BWB I use a hotkey trigger of ⌘3 which is similar to but not the same the as ⇧3 that produces the header markdown #, ##, ###. The key command for the macro is different from the key command for a "#", so I have no problem with markdown headers. Double [ESC] was never meant to "temporarily disable the macro". It just returns you to the note so you can create the new tag manually. After the macro refreshes itself the new tag becomes available for selection.

    I'm not a big fan of tags. I have a few I use to gather notes for writing projects, as my inbox, and keep my hub notes together for quick reference when adding new notes. Most of my tagging efforts go unused so I use them less and less.

    Switch your trigger to a different hotkey and your issues will be solved. Be sure you are using [Shift]3 for the "#" symbol and the [Command]3 for the hotkey for tag insertion.

    Will Simpson
    I'm a Zettelnant.
    Research: Rationalism, Zen, Non-fiction Creative Writing
    kestrelcreek.com

  • @Will thanks. I set up the hot key as suggested and works like a charm. Part of my problem was a perception that I could use a string trigger, which is not the case. Thanks for the assist.

Sign In or Register to comment.