Can't make close shortcut work

The shortcut body is below. If I add an $action-log inside navigator I can see it appear in the console.

<$navigator story="$:/StoryList" history="$:/HistoryList">
	<$action-sendmessage $message="tm-close-tiddler"/>
</$navigator>

The problem is that you need to pass a param to the action-send message that specifies the tiddler you want to close.


<$navigator story="$:/StoryList" history="$:/HistoryList">
	<$action-sendmessage $message="tm-close-tiddler" param="my title here"/>
</$navigator>

With a global shortcut this is tricky unless you are using one of the plugins that has a concept of an active tiddler in the story.

2 Likes

Thanks. This works (with my history and instory filters that I posted in another thread)

<$navigator story="$:/StoryList" history="$:/HistoryList">
  <$action-log last={{{ [history[]last[]] }}} />
	<$action-sendmessage $message="tm-close-tiddler" $param={{{ [history[]instory[]last[]] }}}/>
</$navigator>

1 Like

Note that as I mentioned in the other thread, you don’t need the instory operator.

[history[]] :intersection[list[$:/StoryList]] :and[last[]]

1 Like

Thanks.
I see that when I try to add $action-navigate, so as to navigate to the previous tiddler, then the navigation doesn’t really happen.

\whitespace trim
<$navigator story="$:/StoryList" history="$:/HistoryList">
	<$let current={{{ [{$:/HistoryList!!current-tiddler}] }}} previous={{{ [history[]instory[]reverse[]nth[2]] }}}>
		<$action-log current=<<current>> previous=<<previous>>/>
		<$action-sendmessage $message="tm-close-tiddler" $param=<<current>>/>
		<$action-navigate $to=<<previous>> />
	</$let>
</$navigator>

What do you mean when you say that navigation isn’t happening? Does the new tiddler not open in the story?

Please post a wiki with your code for debugging.

It is open. I want to close the current one and then navigate to the previous one that is in the story. So if I open tiddlers ‘one’, ‘two’, ‘three’, then close ‘three’, I want ‘two’ to get the focus, so that if I know use the shortcut, it’ll be closed (and ‘one’ will get the focus). (I’m using a tabbed view)

How do I post a wiki?

You can upload a TiddlyWiki file to any hosting service you have access to, or create a free wiki at TiddlyHost.com

The problem is likely the tabbed view. TW does not have a concept of a tiddler having focus and therefore navigation does not focus tiddlers. Probably the tabbed view implementation does not change tabs upon navigating to already open tiddlers.

However, this is all supposition without being able to inspect your wiki.

It is at https://closeshortcut.tiddlyhost.com/.

If I open ‘one’, ‘two’, ‘three’, then click (in the recent tab) on ‘two’ and ‘one’, then use the shortcut ctrl-shift-q, then ‘one’ is closed, but then another click doesn’t close ‘two’, another one and ‘two’ is closed, another doesn’t close ‘three’, and a fifth one ends up closing it.

In particular, I can’t figure out why when it doesn’t work the log shows that it has the current tiddler also as the previous one, even though i filter it out

Try modifying your history[] operator to return a deduplicated list of items which preserves the last occurrence of each item.

You can confirm if this resolves the problem by changing the filter for the previous tiddler as follows:

[history[]reverse[]unique[]reverse[]] :intersection[list[$:/StoryList]] :except[<currentTiddler>] :and[last[]]

I am a bit uncertain overall as to how well this approach to walking back through the history will work, since you are also adding a title to the history list each time the shortcut is invoked.

Thank you! Tried to fix the duplication with the ‘:or’ prefix, no effect. So using your method now.

1 Like