A long time irritation for me has been tkinter's dumb decision to force
all paths returned by the file selection dialog into canonical form, so
when I navigate to /home/tbrown/Desktop/some/thing.leo it gets changed
to /mnt/usr1/home/tbrown/Desktop/some/thing.leo, which doesn't work on
a different machine where it would
be /ext/users/tbrown/Desktop/some/thing.leo or some such, but if
tkinter had just left it alone /home/tbrown/Desktop/some/thing.leo
would have worked on both machines.
Anyway, finally occured to me to add this trivial button script to my
main leo file:
orig = [i for i in c.recentFiles if i.startswith("/")]
c.clearRecentFiles()
for i in orig:
c.updateRecentFiles(i
.replace("/mnt/usr2/bkup/tb_usr1","")
.replace("/mnt/usr2/bkup/tb_proj","/home/tbrown/Desktop/Proj")
.replace("/media/hdd1/usr1","")
.replace("/media/hdd1/proj","/home/tbrown/Desktop/Proj")
.replace(".gnome-desktop","Desktop"))
which unmangles the list very nicely. There was an entry on the list
without a leading '/', so I made it filter those.
c.updateRecentFiles() filters duplicates, so that's taken care of for
free.
Assuming I'm not the only person with this annoyance, posted here for
others.
Cheers -Terry
Anyway, finally occured to me to add this trivial button script to my main leo file: [snip]
> What do you think? This could be a nice addition to Leo.
I have clicked the Todo button in my email client, which as previously
(long ago) described copies the email to a folder where leo will find
it and suck it into my todo list. Now I just need a "Complete todo
item" button :-)
Cheers -Terry
> I wonder if there is a way to generalize this script. The new
> @ifhostname setting would allow you to specify the munges for any
> machine. Oh. I have it: put a representation of the patterns in an
> @data node, say @data path-demangle and drive the script from that
> node if it exists.
This is the second time in a week I've run into the big difference in
complexity between a simple "works for me" solution, and a tidy,
generalized, shareable solution.
For example, how to represent (replace,with) pairs in a @data node?
Some people, I've heard, will put spaces in file names, hard to believe
though that sounds.
I propose this heavy handed but simple format for the @data node:
# pairs of lines in this text indicate search and replace targets for
# cleaning the recent files list. Each pair of lines should start with
# either "REPLACE:" (first line) and "WITH:" (second line), or "REGEX:"
# (first line) and "TO:" (second line). For example:
#
# REPLACE: .gnome-desktop
# WITH: My Desktop
# REPLACE: /mnt/usr1/
# WITH: /
# REGEX: C:\\temp\\(*.\.leo)
# TO: D:\\Users\\Me\\leoFiles\\\1
#
# specifies three replacements, one of which will be done using regular
# expressions - the only significant space in the above is in
# "My Desktop"
The regex example is hideous, but that's normal for regex, I'm not sure
if it's correct, I'd test it.
I'm not sure if this kind of markup in body text in @settings is
leoine, but can't think of a better way off hand - I'll move in this
direction and change it if someone suggests something better.
Cheers -Terry
> I wonder if there is a way to generalize this script. The newThis is the second time in a week I've run into the big difference in
> @ifhostname setting would allow you to specify the munges for any
> machine. Oh. I have it: put a representation of the patterns in an
> @data node, say @data path-demangle and drive the script from that
> node if it exists.
complexity between a simple "works for me" solution, and a tidy,
generalized, shareable solution.
For example, how to represent (replace,with) pairs in a @data node?
Some people, I've heard, will put spaces in file names, hard to believe
though that sounds.
I propose this heavy handed but simple format for the @data node:
I'm not sure if this kind of markup in body text in @settings is
leoine, but can't think of a better way off hand - I'll move in this
direction and change it if someone suggests something better.
har! Don' we all? Nahh... that describes slavery...hmmm.......but it's not bad to enslave a machine...
just tricky, which gets us back to the to do list again....
JG
> This is the second time in a week I've run into the big difference in
> complexity between a simple "works for me" solution, and a tidy,
> generalized, shareable solution.
>
> For example, how to represent (replace,with) pairs in a @data node?
I don't think regex's have enough "AI" to be useful for this kind of thing...
JG
Executive Summary:
Recent Files menu now has Clean Recent Files and Sort Recent Files.
Clean Recent Files looks for @data path-demangle in @settings.
These changes on the trunk.
Long tail of woe:
Took me ages to get this done. The special code that creates the
Recent Files menu created the "Clear Recent Files" item as a special
case. Seemed fine when there was only one, but I wanted to add two
more, so it seemed better the define the static part of the menu in
@menus, and then just delete / update the dynamic part.
It wasn't hard to count the entries in the static part, but getting the
code to not delete them drove me nuts, I really don't know what was up,
although I wonder if Tk.delete_range is insane. Or perhaps it's me.
Anyway, finally realized rather than just counting them, I could store
the menu table, then delete all the entries and recreate the static
part each time.
Anyway, seems to work, I added @data path-demangle to @settings, but
without any active rules, just docs. I also corrected the spelling of
some menu related method, don't think it was used anywhere, but it was
getManuLabel.
I was going to work on the after-auto hook, but straight away stubbed
my toe on the messed up recent file list and decided to fix it once and
for all.
Cheers -Terry