OK, after some more testing and thought:

1. Edward's example can't work as claimed, even if '.' is replaced by *path*.  
The expression for *path*  returns a path that a) has forward slashes and 
won't work in Windows when you open explorer on it - confirmed by test with 
both a console and in Leo - and 2) If the node contains an external file, 
the *path *is to that file and so Explorer wouldn't get opened on its 
directory anyway.  Instead, the system's default program for that file type 
will be invoked by Explorer.
2. By actual test, I get the same result whether I comment *path* out or 
not.
3. If I do replace "." with *path*, explorer opens but not at the intended 
directory because of the forward slashes in *path*.

So to make it work in Windows, we have to 1) fix the path separators, and 
2) test whether the path is to a file or directory, and if it's a file then 
find its parent directory.
On Tuesday, April 6, 2021 at 5:58:43 PM UTC-4 tbp1...@gmail.com wrote:

> But in your snippet, you also use "." without (apparently) changing it.
>
> import os
> from subprocess import run
> path = g.fullPath(c, p) or os.path.abspath('.')
>
> cmd = ['explorer.exe', '.']
> run(cmd)
>
> How is that supposed to work?  Wouldn't you want to use *path* instead of 
> "."?
> On Tuesday, April 6, 2021 at 5:18:14 PM UTC-4 tbp1...@gmail.com wrote:
>
>> But I suppose it would be better to use a more comprehensive method in 
>> case you accidentally delete this "feature" in the future.
>>
>> On Tuesday, April 6, 2021 at 5:16:54 PM UTC-4 tbp1...@gmail.com wrote:
>>
>>> Well, it's more than that.  Using "." works for @path subtrees that are 
>>> not even on the same drive (that is, Windows drive) as the leo outline they 
>>> are in.  It's not just that "." sends you to the directory, say for the 
>>> workbook in *%USERPROFILE%\.leo* (Windows).  In the workbook outline at 
>>> that location, for any of the following nodes begin selected, the 
>>> command(s) go to the right directory:
>>>
>>> - head
>>> - @path d:\temp
>>>     @path dir_1
>>>        @path dir_2
>>>             @clean test.txt
>>>
>>> On Tuesday, April 6, 2021 at 4:14:46 PM UTC-4 Edward K. Ream wrote:
>>>
>>>> On Tue, Apr 6, 2021 at 10:29 AM tbp1...@gmail.com <tbp1...@gmail.com> 
>>>> wrote:
>>>>
>>>>>
>>>>>
>>>>> On Tuesday, April 6, 2021 at 10:14:19 AM UTC-4 Edward K. Ream wrote:
>>>>>
>>>>>> On Tue, Apr 6, 2021 at 7:15 AM tbp1...@gmail.com <tbp1...@gmail.com> 
>>>>>> wrote:
>>>>>>
>>>>>> BTW, I have put a button into MyLeoSettings.leo that will open a file 
>>>>>>> manager window (File Explorer on Windows) at the current directory of 
>>>>>>> the 
>>>>>>> selected node, whatever it is.  This has been awfully handy.  
>>>>>>>
>>>>>>
>>>>>> Great idea.  However, I don't understand how '.' gets bound to the 
>>>>>> directory of the selected node. Here is tested code for Windows that 
>>>>>> works 
>>>>>> as I expect.
>>>>>>
>>>>>
>>>>> I don't understand it either, but it works as I showed on both Linux 
>>>>> and Windows.  Sure makes for simple code!  These commands have worked 
>>>>> this 
>>>>> way for a long time (years).  A great undocumented feature!
>>>>>
>>>>
>>>> I strongly suspect that the code works by accident because loading a 
>>>> .leo file effectively changes ".".  But outlines like LeoPyRef.leo 
>>>> contains 
>>>> files in several directories. There is no way the OS can know how to 
>>>> relate 
>>>> '.' to the various directories.
>>>>
>>>> In short, I would recommend my code ;-)
>>>>
>>>> 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/72847f7d-abf3-4ada-ab57-91ad0b38753an%40googlegroups.com.

Reply via email to