As I rename documents or move them in the binder, the document link changes. What are the rules ?

do
dorindon
Posts: 132
Joined: Mon Nov 30, 2015 6:36 am
Platform: Mac

Fri Apr 16, 2021 2:53 pm Post

I have written quite a few keyboard maestro macros to manage Scrivener documents which use the document link. I notice that in some circumstances, the macros cease to work. I am just guessing, but I think that the link changes when the document is moved in the binder ? when it is renamed ?
I would like to understand the rules, ie under which circumstances my macros will no longer work until I change the document link in the macro.
thank you very much

User avatar
AmberV
Posts: 24874
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Fri Apr 16, 2021 3:16 pm Post

Internal document links, bookmarks and for that matter external links between projects or from other software, all operate upon the internal ID that is assigned to an item when you create it. No amount of moving it around or renaming it will ever sever that link. The only action I can think of off of the top of my head that would break a link is if you drag an item with internal links from one project into another—but in that case, it should be removing the link formatting from the text (unless it was dragged along with the target, and then the link should be fixed to point to the new internal ID).

So I would suspect there is some other issue going on with the macro. I would suggest running Keyboard Maestro in debugging mode when this happens, so you can step through each action one by one and observe where the failure occurs.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

do
dorindon
Posts: 132
Joined: Mon Nov 30, 2015 6:36 am
Platform: Mac

Fri Apr 16, 2021 3:19 pm Post

Thank you IOA. Its strange because
1- the macro works
2- I rename or move the document
3- the macro stops working
4- I re-copy the link into the macro
5- the macro works.
I wil so more testing and give you a follow-up. thanks again.

User avatar
AmberV
Posts: 24874
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Fri Apr 16, 2021 3:33 pm Post

All right, I can only say what Scrivener is expecting. Lacking any knowledge of what the macro is meant to do, how it works, or what parts of the Scrivener UI it is tapping into, I couldn’t say what is going wrong.

The only thing I can think to elaborate on is that if you copy some text with an internal link into another program that takes rich text, like TextEdit, and then edit the link from there, you should see what the internal URL looks like. As you can see, it has nothing to do with the name or position of the item. If you then copy and paste that text from TextEdit back into the same project, it should continue working as an internal link. So long as KM is doing something similar to that interaction, and not attempting to “fix” the link or anything, then in theory that hyperlink should permanently work within that project. In my testing, this works fine:

  1. Copy text with a link into TextEdit in rich text mode.
  2. Change the name of the target item in Scrivener.
  3. Copy the text from TextEdit.
  4. Create a new item in Scrivener and paste the text in, then click the link.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

jc
jcarman
Posts: 193
Joined: Sun Nov 01, 2009 6:28 pm

Fri Apr 16, 2021 5:57 pm Post

I tried the instructions at the end of your post, AmberV, and find that Textedit throws and error saying that there is no application to open the link. When I go to Applications to choose Scrivener to open the link, Scrivener is greyed out. Odd. I remember this working fine.

do
dorindon
Posts: 132
Joined: Mon Nov 30, 2015 6:36 am
Platform: Mac

Fri Apr 16, 2021 7:56 pm Post

jcarman wrote:I tried the instructions at the end of your post, AmberV, and find that Textedit throws and error saying that there is no application to open the link. When I go to Applications to choose Scrivener to open the link, Scrivener is greyed out. Odd. I remember this working fine.


this is probably what is happening with the macro which is one line: open this link in Scrivener. Note that the link is not formatted so it's not a formatting issue.

So to rephrase my problem: it's not that the link has changed (IOA you are right). It is that the link can no longer open in Scrivener. Why this would or could be I have no clue.

thank you for your post

User avatar
drmajorbob
Posts: 924
Joined: Sun Jul 01, 2012 1:38 am
Platform: Mac

Fri Apr 16, 2021 8:26 pm Post

dorindon wrote:I have written quite a few keyboard maestro macros to manage Scrivener documents which use the document link. I notice that in some circumstances, the macros cease to work. I am just guessing, but I think that the link changes when the document is moved in the binder ? when it is renamed ?
I would like to understand the rules, ie under which circumstances my macros will no longer work until I change the document link in the macro.
thank you very much

When you say "the document link", what exactly do you mean? How do you create it and put it in KM? What Action do you use to activate it?

This seems reliable, as far as I can tell:

open.png
open.png (179.91 KiB) Viewed 216 times
Teeth, without gums, fall loosely in the mouth.

(I'm not a Literature & Latte employee. Just another user.)

do
dorindon
Posts: 132
Joined: Mon Nov 30, 2015 6:36 am
Platform: Mac

Sat Apr 17, 2021 5:34 am Post

drmajorbob wrote:
dorindon wrote:I have written quite a few keyboard maestro macros to manage Scrivener documents which use the document link. I notice that in some circumstances, the macros cease to work. I am just guessing, but I think that the link changes when the document is moved in the binder ? when it is renamed ?
I would like to understand the rules, ie under which circumstances my macros will no longer work until I change the document link in the macro.
thank you very much

When you say "the document link", what exactly do you mean? How do you create it and put it in KM? What Action do you use to activate it?

This seems reliable, as far as I can tell:

open.png


I think that the issue lies with the macro settings (gear to the top right of the macro).
Discussed here
https://forum.keyboardmaestro.com/t/can ... ile/6992/8
thank you for your post and illustration

User avatar
drmajorbob
Posts: 924
Joined: Sun Jul 01, 2012 1:38 am
Platform: Mac

Sat Apr 17, 2021 5:40 am Post

dorindon wrote:I think that the issue lies with the macro settings (gear to the top right of the macro).
Discussed here
https://forum.keyboardmaestro.com/t/can ... ile/6992/8
thank you for your post and illustration

Hmm ...

process text normally.png
process text normally.png (438.3 KiB) Viewed 194 times
Teeth, without gums, fall loosely in the mouth.

(I'm not a Literature & Latte employee. Just another user.)

User avatar
AmberV
Posts: 24874
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Ourense, Galiza
Contact:

Mon Apr 19, 2021 11:58 am Post

jcarman wrote:I tried the instructions at the end of your post, AmberV, and find that Textedit throws and error saying that there is no application to open the link. When I go to Applications to choose Scrivener to open the link, Scrivener is greyed out. Odd. I remember this working fine.


That would be expected behaviour, it is a meaningless link outside of Scrivener. This test that I described was not meant to be used to test the link inside of TextEdit, but rather only to demonstrate that the URL does not change when passed through the pasteboard, even when coming from other software. It is still going to be an invalid URL everywhere except for in Scrivener, and then only within a project where that UUID is present.

External links, on the other hand, should work from anywhere, and continue to work so long as the project itself is never renamed or moved.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles