On Saturday, January 25, 2020 at 1:33:57 AM UTC-8, Mohammad wrote:
>
> Hello again Eric,
> Based on your recent reply, I made some change to *toc-item-drop* macro 
> the and it seems it work now!
> Please have a look and let me know if you confirm it.
>

Good Work!

However... it needed a little bit of tweaking...

* "drop after" wasn't working
* only do "list-before/list-after" fixups for "drop before" and "drop 
after" (not "drop into")

Here's my updated code (which has been uploaded to 
http://www.TiddlyTools.com/InsideTW)
\define toc-item-drop()
<$reveal default=<<actionTiddler>> type="nomatch" text=<<item>>> <!-- DON'T 
DROP ON SELF -->
   <!-- get OLDTAG and NEWTAG, exclude special TiddlyBook tags -->
   <$vars sourcetags={{{ [<actionTiddler>get[tags]] }}}
          targettags={{{ [<item>get[tags]] }}}>
   <$vars oldtag={{{ [enlist<sourcetags>!enlist<toc-ignore-tags>] }}}
          newtag={{{ [enlist<targettags>!enlist<toc-ignore-tags>] }}}>
   <$reveal default=<<modifier>> type="match" text="normal"> <!-- DROP 
BEFORE SIBLING -->
      <$set name="order" filter="[<newtag>tagging[]]">
      <$list filter=<<order>>> <$action-deletefield $field="list-before"/> 
<$action-deletefield $field="list-after"/> </$list>
      <$action-listops $tiddler=<<actionTiddler>> $field="tags" 
$subfilter="-[<oldtag>]" />
      <$action-listops $tiddler=<<actionTiddler>> $field="tags" 
$subfilter="[<newtag>]" />
      <$action-listops $tiddler=<<oldtag>>        $field="list" 
$subfilter="-[<actionTiddler>]" />
      <$action-listops $tiddler=<<newtag>>        $field="list" 
$subfilter="[enlist<order>] -[<actionTiddler>] 
+[append<actionTiddler>putbefore<item>]" />
      </$set>
   </$reveal>
   <$reveal default=<<modifier>> type="match" text="shift"> <!-- DROP AFTER 
SIBLING -->
      <$set name="order" filter="[<newtag>tagging[]]">
      <$list filter=<<order>>> <$action-deletefield $field="list-before"/> 
<$action-deletefield $field="list-after"/> </$list>
      <$action-listops $tiddler=<<actionTiddler>> $field="tags" 
$subfilter="-[<oldtag>]" />
      <$action-listops $tiddler=<<actionTiddler>> $field="tags" 
$subfilter="[<newtag>]" />
      <$action-listops $tiddler=<<oldtag>>        $field="list" 
$subfilter="-[<actionTiddler>]" />
      <$action-listops $tiddler=<<newtag>>        $field="list" 
$subfilter="[enlist<order>] -[<actionTiddler>] 
+[append<actionTiddler>putafter<item>]" />
      </$set>
   </$reveal>
   <$reveal default=<<modifier>> type="match" text="ctrl"> <!-- DROP AS 
CHILD -->
      <$action-listops $tiddler=<<actionTiddler>> $field="tags" 
$subfilter="-[<oldtag>]" />
      <$action-listops $tiddler=<<actionTiddler>> $field="tags" 
$subfilter="[<item>]" />
      <$action-listops $tiddler=<<oldtag>>        $field="list" 
$subfilter="-[<actionTiddler>]" />
      <$action-listops $tiddler=<<item>>          $field="list" 
$subfilter="[<actionTiddler>]" />
   </$reveal>
   </$vars>
   </$vars>
</$reveal>
\end

Notes:
* To make "drop after" work, it was necessary to first *remove* the 
actionTiddler from the list, and then re-add it
* The "[enlist<order>]" didn't need a leading "+", since it will, by 
definition, override all previous ordering in the list
* Strictly speaking, clearing the list-before/list-after *could* be 
skipped, allowing items to remain "locked" into a specific sequence.  
However, since the effective ordering is preserved by the [enlist<order>], 
its OK to clear list-before/list-after, and "unlocking" the list ordering 
is probably more intuitive overall.

Thank you VERY much for your help.  You saved me quite a bit of 
experimentation and debugging!  Great bit of collaborative effort here!

-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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/e34f905e-28b3-4b47-b058-f7c26d3bd1b3%40googlegroups.com.

Reply via email to