Re: Search for node by GNX with g.findGnx
Hmm - I know there is a smiley here, but ... really? Seems like a rather tautological approach to code and testing quality to me. J^n On Thursday, July 20, 2023 at 5:43:54 PM UTC+1 Edward K. Ream wrote: > On Thu, Jul 20, 2023 at 9:21 AM Thomas Passin wrote: > >> I'm inclined to agree. >> > > Functions do what they do, regardless of their names or docstrings :-) > > If you want to know what they are guaranteed to do, look at their unit > tests. > > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/f066032e-3321-49b1-b63a-df95fefdbf2fn%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
By the way, I've just looked at g.findGnx it uses c.all_unique_positions to visit all positions (skipping sub-trees of clones) and checking if the gnx matches. There is much faster way to generate all positions having same vnode. It is called c.all_positions_for_v(v). # to find a position of a v-node with the given gnx # all you really need to do is v = c.fileCommands.gnxDict[gnx] p = next(c.all_positions_for_v(v)) This is a generator and it visits all parents, grand parents, grand grand parents, ... and their direct children (complexity O(log n)), not all unique positions in the outline (which would have complexity of O(n)). On Thursday, July 20, 2023 at 6:43:54 PM UTC+2 Edward K. Ream wrote: > On Thu, Jul 20, 2023 at 9:21 AM Thomas Passin wrote: > >> I'm inclined to agree. >> > > Functions do what they do, regardless of their names or docstrings :-) > > If you want to know what they are guaranteed to do, look at their unit > tests. > > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/9a054a04-b72b-4acd-8837-8ecceed7c789n%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
On Thu, Jul 20, 2023 at 9:21 AM Thomas Passin wrote: > I'm inclined to agree. > Functions do what they do, regardless of their names or docstrings :-) If you want to know what they are guaranteed to do, look at their unit tests. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS24E%3Dbz4rEwidcL_NpaKh-5HuwLf-6ONGqhpPTpJnfiqg%40mail.gmail.com.
Re: Search for node by GNX with g.findGnx
I'm inclined to agree. On Thursday, July 20, 2023 at 9:06:14 AM UTC-4 lewis wrote: > @tbpassin thanks for your observation that the script works. Occasionally > I use the script to locate a Gnx that appears in a console ouput. > > From Leo's glossary on Gnx: > *Such gnx’s permanently and uniquely identify nodes. Gnx’s have the > form:* > > *id.mmddhhmmssid.mmddhhmmss.n* > > So it seemed reasonable to me that if I enter such a Gnx that g.findGnx > would work. > > On Wednesday, July 19, 2023 at 6:07:43 AM UTC+10 tbp1...@gmail.com wrote: > >> I didn't word that right. I meant that the string returned by the dialog >> isn't a gnx string that can be found. In my test case, the gnx in the >> clipboard started with "*gnx:*" When I manually removed the "*gnx:*" >> prefix, @Lewis's script ran correctly. >> >> On Tuesday, July 18, 2023 at 3:58:56 PM UTC-4 Thomas Passin wrote: >> >>> The problem here is not with findGnx() or es_clickable_link(). The >>> problem is that g.app.gui.runAskOkCancelStringDialog(c,'SEARCH Node by >>> GNX',"Enter search GNX: ") is failing to find an existing gnx*.* >>> Checking to see if it has returned None or not will prevent a exception, >>> but the failure is a bug. >>> >>> This statement is based on the one test case I ran, in which I got the >>> gnx into the clipboard and pasted it from there into the dialog. >>> On Tuesday, July 18, 2023 at 9:20:47 AM UTC-4 Edward K. Ream wrote: >>> On Tue, Jul 18, 2023 at 7:11 AM lewis wrote: Have you used > *p0 = g.findGnx(GNX_ID, c) # moves to position p0 * > to replicate the issue? > No. Why should I? The problem is with GNX_ID. execute-script with the following works for me: print(p) prev = p.back() gnx = prev.gnx p0 = g.findGnx(gnx, c) # moves to position p0 print(p0) The result: >>> response re script error> >>> response re script error> >>> response re script error> >>> code> This is *your* scripting problem, not mine. Edward >>> -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/8893f259-f23a-4cc8-bf7b-49f903ac6676n%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
@tbpassin thanks for your observation that the script works. Occasionally I use the script to locate a Gnx that appears in a console ouput. >From Leo's glossary on Gnx: *Such gnx’s permanently and uniquely identify nodes. Gnx’s have the form:* *id.mmddhhmmssid.mmddhhmmss.n* So it seemed reasonable to me that if I enter such a Gnx that g.findGnx would work. On Wednesday, July 19, 2023 at 6:07:43 AM UTC+10 tbp1...@gmail.com wrote: > I didn't word that right. I meant that the string returned by the dialog > isn't a gnx string that can be found. In my test case, the gnx in the > clipboard started with "*gnx:*" When I manually removed the "*gnx:*" > prefix, @Lewis's script ran correctly. > > On Tuesday, July 18, 2023 at 3:58:56 PM UTC-4 Thomas Passin wrote: > >> The problem here is not with findGnx() or es_clickable_link(). The >> problem is that g.app.gui.runAskOkCancelStringDialog(c,'SEARCH Node by >> GNX',"Enter search GNX: ") is failing to find an existing gnx*.* >> Checking to see if it has returned None or not will prevent a exception, >> but the failure is a bug. >> >> This statement is based on the one test case I ran, in which I got the >> gnx into the clipboard and pasted it from there into the dialog. >> On Tuesday, July 18, 2023 at 9:20:47 AM UTC-4 Edward K. Ream wrote: >> >>> On Tue, Jul 18, 2023 at 7:11 AM lewis wrote: >>> >>> Have you used *p0 = g.findGnx(GNX_ID, c) # moves to position p0 * to replicate the issue? >>> >>> No. Why should I? The problem is with GNX_ID. >>> >>> execute-script with the following works for me: >>> >>> print(p) >>> prev = p.back() >>> gnx = prev.gnx >>> p0 = g.findGnx(gnx, c) # moves to position p0 >>> print(p0) >>> >>> The result: >>> >>> >> response re script error> >>> >> response re script error> >>> >> response re script error> >>> >>> >>> This is *your* scripting problem, not mine. >>> >>> Edward >>> >> -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/d75ffa41-6ab0-4528-b5d1-252436ad3fb1n%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
On Tue, Jul 18, 2023 at 4:08 PM Thomas Passin wrote: > I think that findGnx() should work whether or not the string starts with > the "gnx:" prefix. > That would be another function. I'm not going to change anything just because people are confused. Why are we discussing this? Copy a gnx-base unl from the status area. Paste into body text. Ctrl-click. Or understand the existings functions. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS15hRA_h7fnMz3CvkSaLnQOsV2qMuTJdurGmNJqYpj%3D-g%40mail.gmail.com.
Re: Search for node by GNX with g.findGnx
I think that findGnx() should work whether or not the string starts with the "gnx:" prefix. On Tuesday, July 18, 2023 at 4:16:31 PM UTC-4 Edward K. Ream wrote: > On Tue, Jul 18, 2023 at 3:07 PM Thomas Passin wrote: > >> I didn't word that right. I meant that the string returned by the dialog >> isn't a gnx string that can be found. In my test case, the gnx in the >> clipboard started with "*gnx:*" When I manually removed the "*gnx:*" >> prefix, @Lewis's script ran correctly. >> > > Thanks for your analysis. The OP might be better off using g.findAnyUnl. > > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/f16b6013-f9cb-4056-964d-beab5e462f98n%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
On Tue, Jul 18, 2023 at 3:07 PM Thomas Passin wrote: > I didn't word that right. I meant that the string returned by the dialog > isn't a gnx string that can be found. In my test case, the gnx in the > clipboard started with "*gnx:*" When I manually removed the "*gnx:*" > prefix, @Lewis's script ran correctly. > Thanks for your analysis. The OP might be better off using g.findAnyUnl. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS07uAezC5vpCuNOTus_YpgCaVPL%2BpeUo7Pr9QS0iRAnOA%40mail.gmail.com.
Re: Search for node by GNX with g.findGnx
I didn't word that right. I meant that the string returned by the dialog isn't a gnx string that can be found. In my test case, the gnx in the clipboard started with "*gnx:*" When I manually removed the "*gnx:*" prefix, @Lewis's script ran correctly. On Tuesday, July 18, 2023 at 3:58:56 PM UTC-4 Thomas Passin wrote: > The problem here is not with findGnx() or es_clickable_link(). The > problem is that g.app.gui.runAskOkCancelStringDialog(c,'SEARCH Node by > GNX',"Enter search GNX: ") is failing to find an existing gnx*.* > Checking to see if it has returned None or not will prevent a exception, > but the failure is a bug. > > This statement is based on the one test case I ran, in which I got the > gnx into the clipboard and pasted it from there into the dialog. > On Tuesday, July 18, 2023 at 9:20:47 AM UTC-4 Edward K. Ream wrote: > >> On Tue, Jul 18, 2023 at 7:11 AM lewis wrote: >> >> Have you used >>> *p0 = g.findGnx(GNX_ID, c) # moves to position p0 * >>> to replicate the issue? >>> >> >> No. Why should I? The problem is with GNX_ID. >> >> execute-script with the following works for me: >> >> print(p) >> prev = p.back() >> gnx = prev.gnx >> p0 = g.findGnx(gnx, c) # moves to position p0 >> print(p0) >> >> The result: >> >> > re script error> >> > re script error> >> > re script error> >> >> >> This is *your* scripting problem, not mine. >> >> Edward >> > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/91752e4b-731e-43ad-b52c-701cf3f27fc8n%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
The problem here is not with findGnx() or es_clickable_link(). The problem is that g.app.gui.runAskOkCancelStringDialog(c,'SEARCH Node by GNX',"Enter search GNX: ") is failing to find an existing gnx*.* Checking to see if it has returned None or not will prevent a exception, but the failure is a bug. This statement is based on the one test case I ran, in which I got the gnx into the clipboard and pasted it from there into the dialog. On Tuesday, July 18, 2023 at 9:20:47 AM UTC-4 Edward K. Ream wrote: > On Tue, Jul 18, 2023 at 7:11 AM lewis wrote: > > Have you used >> *p0 = g.findGnx(GNX_ID, c) # moves to position p0 * >> to replicate the issue? >> > > No. Why should I? The problem is with GNX_ID. > > execute-script with the following works for me: > > print(p) > prev = p.back() > gnx = prev.gnx > p0 = g.findGnx(gnx, c) # moves to position p0 > print(p0) > > The result: > > re script error> > re script error> > re script error> > > > This is *your* scripting problem, not mine. > > Edward > -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/b6e8f7bb-95b8-4e50-99b0-c32115b6a8bbn%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
On Tue, Jul 18, 2023 at 7:11 AM lewis wrote: Have you used > *p0 = g.findGnx(GNX_ID, c) # moves to position p0 * > to replicate the issue? > No. Why should I? The problem is with GNX_ID. execute-script with the following works for me: print(p) prev = p.back() gnx = prev.gnx p0 = g.findGnx(gnx, c) # moves to position p0 print(p0) The result: This is *your* scripting problem, not mine. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS2WnDvtFmXoBwGH%2B73%3DzU11mPkqp%2BW%3DGWQzDAjMZ%2BAeXw%40mail.gmail.com.
Re: Search for node by GNX with g.findGnx
On Tuesday, July 18, 2023 at 9:33:33 PM UTC+10 Edward K. Ream wrote: GNX_ID may not be correct, but that depends on what you entered. I know that the GNX_ID is correct as I have used (p.v.gnx) to get the GNX. The following @button script works for me, regardless of p (or p.b): g.es_clickable_link(c, p, 0, p.h) Edward Have you used *p0 = g.findGnx(GNX_ID, c) # moves to position p0 * to replicate the issue? I do not have the same errors and the clickable link persists if script searches for node by node name using: *p = g.findNodeAnywhere(c, node_name)* Lewis -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/243832fa-ff1d-474d-886c-a6dd49b8b801n%40googlegroups.com.
Re: Search for node by GNX with g.findGnx
On Tue, Jul 18, 2023 at 6:15 AM lewis wrote: > Using this script to search for a node by a Gnx: > > > > *GNX_ID: str = g.app.gui.runAskOkCancelStringDialog(c,'SEARCH Node by > GNX',"Enter search GNX: ").strip()p0 = g.findGnx(GNX_ID, c) # moves to > position p0 g.es_clickable_link(c, p0, 0, (p0.h)) # clickable-link, use > p.h* > > If the node matching GNX is empty (no body text) it displays a persistent > clickable link in Log pane. > Your script should ensure that p0 is not None. GNX_ID may not be correct, but that depends on what you entered. The following @button script works for me, regardless of p (or p.b): g.es_clickable_link(c, p, 0, p.h) Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/CAMF8tS0M9qT9P4oaXtyb1LbTe4_DOPmDoDBkmNGpjmRecCm7Kw%40mail.gmail.com.
Search for node by GNX with g.findGnx
Using this script to search for a node by a Gnx: *GNX_ID: str = g.app.gui.runAskOkCancelStringDialog(c,'SEARCH Node by GNX',"Enter search GNX: ").strip()p0 = g.findGnx(GNX_ID, c) # moves to position p0 g.es_clickable_link(c, p0, 0, (p0.h)) # clickable-link, use p.h* If the node matching GNX is empty (no body text) it displays a persistent clickable link in Log pane. However if the node matching GNX contains body text it gives errors: is_sentinel: can not happen. delims: (None, '') is_sentinel: can not happen. delims: (None, '') is_sentinel: can not happen. delims: (None, '') is_sentinel: can not happen. delims: (None, '') A clickable link displays in Log pane but when pressed the link is not persistent, the clickable link disappears and the errors repeat. -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/84f9e33e-4440-4242-a1b0-5dc94172579cn%40googlegroups.com.