How add the icon ahead of a internal link as default?

I asked a related question before in here:

I want the internal link auto add the icon of the tid as default.
At first I wrote a macro to make it.
But something wrong with it:

  1. the macro is like this:
\define ML(name:"Macro")
<$transclude tiddler={{$name$!!icon}}/><$link />
\end

So you can use it like <<ML The_Link>>

If you use this macro instead of [[]], it wont be shown in the “backlinks” panel.
2. And I use tiddlywiki-vim plugin which cant recognize my own macro "<<ML xxx>>", which is very unconvenient for me.

So how to add an icon to [[]] as default?

Here is a little brainstorm of the issues you raise. I hope it helps :nerd_face:

There are many ways to do this however given the code you shared there are ways to debug this,

  • Such as use {{$name$!!icon}} outside the transclude to see if it is returning the value you expect,
  • You can also expand your code to use intermediate steps.
    • <$set name=icon-tiddler value={{$name$!!icon}}> to get the value before you use it.
    • With additional intermediate steps its easier to display intermediate values and find out where it is breaking.
  • This is true but there are alternative ways to do this, is your key outcome being able to use the icon of the linked tiddler?
  • Perhaps a macro just to retrieve the icon?
  • Sorry I don’t use the vim plugin
  • I see why you may want to place icons automatically in links [[tiddlername]] however this is a fundamental part of tiddlywiki and altering that could have unforseen results, and a little complex.
    • So I suggest we step back and reconsider your needs
    • Search and other methods can find the tiddler title even if used inside transclusions and macros when can be included to complement the backlinks.

Requirements?

  • Ability to have internal links include the icon if one exists in the tiddler
    • Maintain the backlink functionality when using this solution

Keep in mind we can automate things somewhat with editor toolbar buttons, that wrap each line in a selection with the macro to invoke this.

Have you looked at the freelinks plugin perhaps this could be modified to also display the icon when highlining links for tiddler titles?

Some tips;

  • Try and always write macros to make use of the currentTiddler value
\define i() <$transclude tiddler={{!!icon}}/>

<<i>>

<$list filter="[all[tiddlers]has[icon]]">
  <<i>><$link/><hr>
</$list>
  • in this example what is not obvious is the transclude first gets “transcludes” the tiddler name (from the icon field) then transcludes it.