This fix works on Windows, too - the "~" expands correctly to my user home 
directory.

On Friday, April 9, 2021 at 10:11:49 PM UTC-4 [email protected] wrote:

> It looks like there is a simple fix.  This hasn't had hardly any testing, 
> but on the surface it's doing the right thing.  The little example that 
> failed in an earlier post created the right directories.
>
> In *leoCommands.py*, in the method *expand_path_expression(self, s)*, add 
> the line marked below
>
>     val = ''.join(aList)
>     *val = os.path.expanduser(val)  # <===== Add this line*
>     if g.isWindows:
>         val = val.replace('\\', '/')
>     return val
>
> @n00b, if you know how to find Leo's python code files, would you make 
> this change and see if it works for you?  They would be in the 
> *Lib/sitepackages/leo* directory for the python executable you are 
> using.  There may be more than one *sitepackages *directory.  You can 
> locate them this way:
>
> import site
> print(site.getsitepackages())
> On Friday, April 9, 2021 at 9:36:55 PM UTC-4 TEK42 wrote:
>
>>
>> I checked this on os x and get the same results:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *import osg.cls() # <-- does nothing on macos (darwin), probably same 
>> with linux since the procedure checks for "win" onlyg.es 
>> <http://g.es/>(os.path.expanduser('~'))# --> /Users/leodudeg.es 
>> <http://g.es/>(os.environ["HOME"])# --> /Users/leodudeg.es 
>> <http://g.es/>(c.expand_path_expression('~'))# --> ~g.es 
>> <http://g.es/>(c.expand_path_expression('$HOME'))# --> $HOME*
>>
>> It looks like there is opportunity to bring Leo into better usability 
>> with Linux-ey OS’s.
>>
>> Depending on how much I end up using Leo (I already spent more time in 
>> Leo than in emacs org-mode this week), I may be up for contributing towards 
>> that end - at least for macos. 
>>
>>
>> Subject to correction by Edward or some else who knows more, it looks 
>>> like the place to intervene is in c.expand_path_expression() because  
>>> on even on Linux it returns this:
>>>
>>> >>> c.expand_path_expression('~')
>>> '~'
>>>
>>> This method is in the class *Commands*.  I'm not sure how tricky this 
>>> would be to adjust, because you would only want to substitute 
>>> */home/{user}* for "~" if it appears at the start of a path expression, 
>>> and I don't know yet how to know.  Also, it needs to be checked if a change 
>>> here would cause troubles anywhere else.
>>
>>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/52e01bf1-056e-4e1d-80be-c1cd2592d071n%40googlegroups.com.

Reply via email to