link notes across documents - filter functionality

36 views
Skip to first unread message

info.sim...@googlemail.com

unread,
Sep 7, 2020, 3:26:24 PM9/7/20
to Notecase Pro

When using tags all notes with the tags are shown in a list view when a tagged is selected for filtering. What I am after is a filter capability to filter by a tag and keep the tree structure of the tagged note and all child notes

I understand that linking notes is only possible within a document. My 2 ideas been

1.
let user select the tag(s) to filter and then copy the tree structures to a new document as linked documents so any change will be reflected in the source document

2.
mark the documents with the filter tags and all child notes and then display only marked notes

My questions are

re 1. is it possible to have linked notes across documents or what is the internal structure for linked notes so I can mirror it with some scripting - if possible at all

re 2. is there a way to display only marked notes?

as always I welcome any feedback ;-)

Best regards

Raimund

Paul Merrell

unread,
Sep 7, 2020, 6:40:10 PM9/7/20
to Notecase Pro
On Mon, Sep 7, 2020 at 12:26 PM 'info.sim...@googlemail.com' via
Notecase Pro <noteca...@googlegroups.com> wrote:
>
>
> When using tags all notes with the tags are shown in a list view when a tagged is selected for filtering. What I am after is a filter capability to filter by a tag and keep the tree structure of the tagged note and all child notes
>
> I understand that linking notes is only possible within a document.

Vocabulary: I think that you're referring to cloning notes rather than
hyper-linking notes, yes?

My 2 ideas been
>
> 1.
> let user select the tag(s) to filter and then copy the tree structures to a new document as linked documents so any change will be reflected in the source document

Not possible. Cloned notes can only exist in the same document as
their source original note.

> 2.
> mark the documents with the filter tags and all child notes and then display only marked notes

If I understand this correctly, that is scriptable.

> My questions are
>
> re 1. is it possible to have linked notes across documents or what is the internal structure for linked notes so I can mirror it with some scripting - if possible at all

Not possible at all. But you can easily get the structure by creating
a clone in an .ncd and then viewing it in a text editor. Also, there's
some code in the attached script, Clone List to Clipboard, that should
generate clones. (My notes say that there's an issue with this script
but I do not remember what it is.

> re 2. is there a way to display only marked notes?

Yes. The attached script, List All Marked Notes, shows one of many
ways to list all marked notes.

A caution on processing note lists. If your script removes notes from
the list, the list must be processed from bottom to top. There is a
function in the attachment that enables processing a list optionally
in either ascending or descending order, the Process_List_Notegroup
Function.

Best regards,

Paul

--
[Notice not included in the above original message: The U.S. National
Security Agency neither confirms nor denies that it intercepted this
message.]
¯\_(ツ)_/¯
Tmp.ncz

Miroslav Rajcic

unread,
Sep 8, 2020, 12:14:45 AM9/8/20
to Notecase Pro
Hi Raimund,

comments:
#1 when copying/pasting marked notes in the new document, currently you lose the hierarchy. The reason is simple, it's hard to reconstruct the tree if you select a grandparent and grandchild note, but not the parent (one in between). Many similar cases can happen to make this operation complex.

#Q1 You can link notes stored in another document, "Link Properties" window supports that. Generated HTML is like this:
<A href="file:///C:\temp\format_old.ncdb#rpgHysvrxmqDjlXxxCxRSA">install</A>
i.e. you have a path to document followed by # and a note ID string.
Clicking to such link opens target document and positions to the target note.

#Q2 there is no support to display only marked notes (see above), you can only fill the List Pane (not the main Tree Pain) with whatever note set you like, but this is a flat list (not a tree)

Regards,
  Miro

From: 'info.sim...@googlemail.com' via Notecase Pro <noteca...@googlegroups.com>
Sent: Monday, September 7, 2020 9:26 PM
To: Notecase Pro <noteca...@googlegroups.com>
Subject: link notes across documents - filter functionality
 
--
You received this message because you are subscribed to the Google Groups "Notecase Pro" group.
To unsubscribe from this group and stop receiving emails from it, send an email to notecase-pro...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/notecase-pro/c252bfd3-e8b9-40a2-b58e-2843d489bda4n%40googlegroups.com.

info.sim...@googlemail.com

unread,
Sep 20, 2020, 6:37:44 AM9/20/20
to Notecase Pro
Thanks Paul, Miro for your thoughts and ideas. looks like I park this idea of filtering for a while and give it some more thoughts ;-)

Best regards

Raimund

info.sim...@googlemail.com

unread,
Sep 21, 2020, 10:21:36 AM9/21/20
to Notecase Pro
Hi

I think I found a solution for filtering notes - root notes and all their childs only for now. The idea is to

create a root note for the filter - the "filter note"
search all existing root notes for the filter criteria
create a clone of the matching root node with all child notes underneath the "filter note"
hoist the "filter note"

this should yield exactly what I am looking for - in theory ;-) - a filtered tree structure whereby any edit will be reflected in the original note

Curious how tricky it will be to code the stuff...

Stay tuned ;-)

Raimund

Paul Merrell

unread,
Sep 21, 2020, 1:25:52 PM9/21/20
to Notecase Pro
On Mon, Sep 21, Pro2020 at 7:21 AM 'info.sim...@googlemail.com' via
Notecase Pro <noteca...@googlegroups.com> wrote:
>
> Hi
>
> I think I found a solution for filtering notes - root notes and all their childs only for now. The idea is to
>
> create a root note for the filter - the "filter note"
> search all existing root notes for the filter criteria
> create a clone of the matching root node with all child notes underneath the "filter note"
> hoist the "filter note"

I think that should be hoist the "filter note" *clone,* yes?

> this should yield exactly what I am looking for - in theory ;-) - a filtered tree structure whereby any edit will be reflected in the original note
>
> Curious how tricky it will be to code the stuff...

This would be easier to code if the goal was to clone the filter note
and all descendants of it, rather than just the children, which I
suspect is your longer term goal. Under the Notes Menu's Current Note
submenu, there is an action, "Insert Branch Clone," that can be
invoked programmatically. This action clones the entire branch.
preserving the hierarchy in the clones. To use this action, see Help
file > Automation, Scripts and Plugins > Scripting NoteCase Pro >
Scriptable Program Commands > Application Commands >
Nc_App_Action_Execute. The short action name you'd use is
"tree_clone_branch".

Unfortunately, there is no return from that action that would give you
the note ID for the cloned root note to hoist. One way to fetch the
note ID might be (untested) before cloning the branch, walk the tree
to identify the note ID of the last descendant of that root note. See
Help file > Automation, Scripts and Plugins > Scripting NoteCase Pro >
Code Snippets and Tips > Traversing Trees > Walking Down a Tree.

Fetch that note's recursive index using
Nc_Note_RecursiveIdx_GetByID(). Then navigate to the next note, which
is the clone root note, using Nc_Note_ID_GetByIdx(). (Add 1 to the
last descendant's recursive Idx to identify the clone root note.)

There are other ways you could get to the cloned root note. E.g., get
lists of all root note IDs before and after the clone branch is
created then look for the note ID in the second list that does not
exist in the first.

If you do want only the filter note's children to be cloned, let me
know and I'll give some thought to that problem.

Hope this helps.

info.sim...@googlemail.com

unread,
Sep 21, 2020, 2:59:42 PM9/21/20
to Notecase Pro
Hi Paul,

it is actually simple. Here my test code using static nodeIDs for testing

nDocID = Nc_Doc_ID_GetCur()
strParentID = "ta1QKwV4p05VbRGMcymyTg"
strRootID = "CPVxu0B5TZKrpAofYOWiqw"
strRootID2 = "8K64qfVgJEqbZZ8qV646xA"

rc = Nc_Note_InsertClone(nDocID, strRootID, strParentID, -1, "", 1)
rc = Nc_Note_InsertClone(nDocID, strRootID2, strParentID, -1, "", 1)

-- make filter note active
Nc_Note_ID_SetCur(strParentID)

-- hoist filter node
Nc_App_Action_Execute("tree_hoist")

Now I am on to the filter logic ;-)

Best regards

Raimund

Paul Merrell

unread,
Sep 21, 2020, 3:02:53 PM9/21/20
to Notecase Pro
On Mon, Sep 21, 2020 at 11:59 AM 'info.sim...@googlemail.com' via
Notecase Pro <noteca...@googlegroups.com> wrote:
>
> Hi Paul,
>
> it is actually simple. Here my test code using static nodeIDs for testing

That should work. Nice.

Best regards,

info.sim...@googlemail.com

unread,
Sep 23, 2020, 5:20:18 PM9/23/20
to Notecase Pro
Hi all,

I have a first beta version of a filter plugin ready for those interested in being able to filter a tree by tag or/and custom property. it has 3 routines

Create filter: allows one to define whether the tree should be filtered by tags and / or custom property
a root filter note will be created - matching root notes will be cloned and added as child notes. then the filter note will be hoisted so we ony see the atching notes with all childs
clear filter

Keep All simply unhoists the filter note
Kepp filter only just removes the clones but keep the filter notes so the filter can be applied later again
Clear all removes the filter note and all cloned child notes

apply filter
when a filer note is selected the filter is applied without any further user input. so you can have mutiple pre-defined filters and use them as needed

Problems:
only tested on Linux 64bit - Windows will follow shortly
there seems to be a timing issue with Nc_App_Action_Execute. Sometimes it works as expected sometimes it doesn't - need to investigat further :-(

so stay tuned ;-)

Best regards

Raimund
sn_filter_V10.ncdb

info.sim...@googlemail.com

unread,
Sep 27, 2020, 10:52:35 AM9/27/20
to Notecase Pro
After fixing the timing issue I encountered with Nc_App_Action_Execute by simply adding a short pause (Nc_Util_Sleep(1) ) before calling Nc_App_Action_Execute I successful teted the plugin on Linux 64bit and Windows 10 64bit.

Documentation has been added as well. Attached is now the final Version 1.0

Kind regards

Raimund
sn_filter_V10.ncdb
Reply all
Reply to author
Forward
0 new messages