[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread 'Mark S.' via TiddlyWiki


On Friday, January 14, 2022 at 8:50:34 AM UTC-8 reinhard..wrote:

> I have a hard time to come up with a use case why I would want to mix 
> (unknowingly or inadvertently) titles and captions in a list created with 
> "list-links". If I would want to look for captions, I would do so 
> explicitly in my filter expression. 
>
>
Because the title field serves as an ID field, a title field, and a system 
field, the titles are often long and/or unwieldy. Having a fall back 
display field (e.g. caption) makes a lot of sense in that context. The tabs 
macro also follow this structure, since tab titles often need to be much 
shorter than the descriptive title of the tab.
 

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c464bbdf-5894-4609-adff-b0148eca0e18n%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread Reinhard Engel
I have a hard time to come up with a use case why I would want to mix 
(unknowingly or inadvertently) titles and captions in a list created with 
"list-links". If I would want to look for captions, I would do so 
explicitly in my filter expression. 

So, wouldn't it be better, instead of making the "list-links" macro more 
complex to remove this special case (showing the caption, if present) 
completely and leave it to the user to search for captions if he wants to?

Right now, the "list-links" macro does more than is asked for: 
- it  outputs a bullet list of link, what is its stated purpose,
- but then it also chooses between the "title" and the "caption" fields.
So we have one function (macro), thats doing two totally unrelated jobs.

-Reinhard

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/300199ee-619c-4ca5-986a-d57cffc4165dn%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread Reinhard Engel
Maybe some more remarks:
With the current situation, *it is not possible to safely test filter 
expressions* in "Advanced search",
because, depending on the context, the same filter expression produces 
different results.
That's a violation of the Principle of least astonishment 
.
On Friday, January 14, 2022 at 3:50:23 PM UTC+1 PMario wrote:

> Just for completeness. I was searching for other elements in the core that 
> may have the same problem. 
>
> I found an old PR-discussion, which "scratches" the same topic: 
> https://github.com/Jermolene/TiddlyWiki5/pull/1191
> and probably has the same problems. .. 
>
> So there are definitely some other elements which could / should be 
> improved. .. The downside is, that it will be much more work and it may 
> eventually touch more core elements as I wanted to change :/
>
> So the way to go may be to make a proposal instead of a PR first. 
>
> -mario
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/55796621-77be-4335-83b4-3c37699bab64n%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread PMario
On Friday, January 14, 2022 at 4:35:41 PM UTC+1 Eric Shulman wrote:
...

> However, neither suggested core change would actually address Reinhard's 
> stated use-case, which is:
> "...*to always display the title, rather than the caption."*
>

Uuups, I didn't read the whole thing ... my bad. 

But still the workaround is simple. my-list-fix can be

I did name the macro: `my-list-links` so it doesn't overwrite the core 

```
\define my-list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage)
\whitespace trim
<$type$ class="$class$">
  <$list filter="$filter$" emptyMessage=<<__emptyMessage__>>>
<$subtype$>
<$link to={{!!title}}>
<$view field="title"/>


  

\end
```

-m

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/5a1b0520-d8d9-4fcd-980e-571f6f5e6caen%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread Eric Shulman
On Friday, January 14, 2022 at 6:26:11 AM UTC-8 PMario wrote:

> On Friday, January 14, 2022 at 1:24:16 PM UTC+1 Eric Shulman wrote:
> ...
>
>> However, `<>` is a merely a "convenience" macro for 
>> outputting a bullet list of links.
>> If you want a more specific behavior, you should use the `<$list>` widget 
>> directly, like this:
>>
>
> As  Eric pointed out `<>` is a convenience macro ... and it is 
> really "old" code, where the transclusion "title-fallback" code was the 
> only possibility we had. 
> With version 5.2.1 we do have a lot more possibilities to create "filtered 
> logic" ... IMO the solution is relatively simple.
> We would need to redefine the list-links macro a little bit. See the new 
> `<$set name="field-name" ...` instructions.
>

Actually, the change to `<>` can be even simpler...

Just replace the `<$transclude>` widget with the `<$view>` widget, like 
this:
```
<$view field="caption"> <$view field="title"/> 
```
The reason why this works is that, unlike `<$transclude field="caption">`,  
`<$view 
field="caption">` applies its fallback content if "the field or property is 
missing *or empty*."

However, neither suggested core change would actually address Reinhard's 
stated use-case, which is:
"...*to always display the title, rather than the caption."*

-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/b1f04b29-be6d-404a-a9d6-0aa711d930c4n%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread PMario
On Friday, January 14, 2022 at 4:10:06 PM UTC+1 reinhard...@gmail.com wrote:

> @Eric Schulman @PMario
>
> Thanks for the fast response and the solution.
> I'm quite a newbie to TiddlyWiki  and still try to grok the finer points.
>

As a workaround you can redefine the core macro without modifying the core 
tiddler, if you 

 - Create a new tiddler eg: `my-list-fix ` 
 - tag it with: ` $:/tags/Macro`
 - put my code from above into the text 
 - save. 

Now your example should work. .. Since user macros are defined after core 
macros it should work that way. 

I did test it with your demo wiki.

The proposal discussion at github is here: 
https://github.com/Jermolene/TiddlyWiki5/issues/6397

... You see: It seems to be an easy fix, but if done right it will trigger 
a bit more work.

have fun!
-mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/fd4b1aa7-a2e2-4dee-bfc3-2dab9576bbefn%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread Reinhard Engel
@Eric Schulman @PMario

Thanks for the fast response and the solution.
I'm quite a newbie to TiddlyWiki  and still try to grok the finer points.

-Reinhard

On Friday, January 14, 2022 at 3:26:11 PM UTC+1 PMario wrote:

> On Friday, January 14, 2022 at 1:24:16 PM UTC+1 Eric Shulman wrote:
> ...
>
>> However, `<>` is a merely a "convenience" macro for 
>> outputting a bullet list of links.
>> If you want a more specific behavior, you should use the `<$list>` widget 
>> directly, like this:
>>
>
> As  Eric pointed out `<>` is a convenience macro ... and it is 
> really "old" code, where the transclusion "title-fallback" code was the 
> only possibility we had. 
>
> With version 5.2.1 we do have a lot more possibilities to create "filtered 
> logic" ... IMO the solution is relatively simple. 
>
> We would need to redefine the list-links macro a little bit. See the new 
> `<$set name="field-name" ...` instructions. 
>
> ```
> \define list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage)
> \whitespace trim
> <$type$ class="$class$">
>   <$list filter="$filter$" emptyMessage=<<__emptyMessage__>>>
> <$set name="field-name" 
> filter="[all[current]get[caption]!is[blank]then[caption]else[title]]">
> <$subtype$>
> <$link to={{!!title}}>
> <$view field=<>/>
> 
> 
> 
>   
> 
> \end
> ```
>
> I think I'll create a PR with a suggestion to change this code and the 
> docs in the core. ... 
>
> @Eric could you have a second look at the new code. 
>
> -mario
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c275841a-67e6-4a64-a18a-2eae86854835n%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread PMario
On Friday, January 14, 2022 at 3:50:23 PM UTC+1 PMario wrote:
...

> So the way to go may be to make a proposal instead of a PR first. 
>

I think the most elegant way to go is: 
https://github.com/Jermolene/TiddlyWiki5/pull/1191#issuecomment-65532894

We would need to have a closer look if there are unwanted side-effects. 

-mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e1b7ab17-87c2-4c7f-bed1-a4fabc8d70ecn%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread PMario
Just for completeness. I was searching for other elements in the core that 
may have the same problem. 

I found an old PR-discussion, which "scratches" the same topic: 
https://github.com/Jermolene/TiddlyWiki5/pull/1191
and probably has the same problems. .. 

So there are definitely some other elements which could / should be 
improved. .. The downside is, that it will be much more work and it may 
eventually touch more core elements as I wanted to change :/

So the way to go may be to make a proposal instead of a PR first. 

-mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/cdb79034-5746-4438-b48c-4426353881e2n%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread PMario
On Friday, January 14, 2022 at 1:24:16 PM UTC+1 Eric Shulman wrote:
...

> However, `<>` is a merely a "convenience" macro for outputting 
> a bullet list of links.
> If you want a more specific behavior, you should use the `<$list>` widget 
> directly, like this:
>

As  Eric pointed out `<>` is a convenience macro ... and it is 
really "old" code, where the transclusion "title-fallback" code was the 
only possibility we had. 

With version 5.2.1 we do have a lot more possibilities to create "filtered 
logic" ... IMO the solution is relatively simple. 

We would need to redefine the list-links macro a little bit. See the new 
`<$set name="field-name" ...` instructions. 

```
\define list-links(filter,type:"ul",subtype:"li",class:"",emptyMessage)
\whitespace trim
<$type$ class="$class$">
  <$list filter="$filter$" emptyMessage=<<__emptyMessage__>>>
<$set name="field-name" 
filter="[all[current]get[caption]!is[blank]then[caption]else[title]]">
<$subtype$>
<$link to={{!!title}}>
<$view field=<>/>



  

\end
```

I think I'll create a PR with a suggestion to change this code and the docs 
in the core. ... 

@Eric could you have a second look at the new code. 

-mario

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a1bad59b-6861-4ff3-b0a9-9c6089edfc6bn%40googlegroups.com.


[tw5] Re: Possible bug in list-links macro

2022-01-14 Thread Eric Shulman
The behavior you describe (showing the tiddler's caption field if present, 
even if blank)
is specifically described in the macro documentation (see 
https://tiddlywiki.com/#list-links%20Macro).

However, `<>` is a merely a "convenience" macro for outputting 
a bullet list of links.
If you want a more specific behavior, you should use the `<$list>` widget 
directly, like this:
```
<$list filter="...your filter here..."><$link/>
```
enjoy,
-e

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/398abd59-6d9b-455e-b164-adbfa31a010cn%40googlegroups.com.