lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Interactive PDF Link to Notes in Preview


From: Mats Behre
Subject: Re: Interactive PDF Link to Notes in Preview
Date: Mon, 9 Jul 2018 20:32:55 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.0

On 2018-07-09 07:56, Federico Bruni wrote:


As the syntax is not Emacs, I guess that Eddie is the editor you want to use 
and all the emacsclient variables are just the variables you took from the 
original example. (BTW, I don't think you found it on lilypond website)


You're guessing right.
And where I got it - who knows ... If I'd written it from scratch I wouldn't 
have called the variables emacs :-) so obviously I found it somewhere, but 
never mind that.


My problem now is that SwiftDefaultApps silently fails to set this as the 
textedit target, possibly because my info.plist is too old (it has worked in 
the past):



This is the info.plist of which application? Eddie?

No, of the helper app. Back when I did this that was a (the?) way to tell the 
OS that this app handled the textedit URI, but now that I've tested some more 
it appears that it isn't necessary (anymore?) - I could just create a new 
AppleScript app and add it in SwiftDefaultApps (I'm not sure exactly what I did 
to make the adding work though, and I'm not totally convinced that 
SwiftDefaultApps is bug-free).

One thing I had to change in the script was quoting, see below. I removed the 
backslash from the space and replaced %2b with an actual plus, because I have 
one in my path. It's possible that there's some more generic way to translate 
from the URL encoding, but now it works for me. (And by works I mean that the 
editor is open with the cursor at the selected note.)
... and then I had to override the security setting for Eddie so it was allowed 
to be started (it is not created by an 'identified developer').

property urlPrefix : "textedit://"

on replaceText(find, replace, subject)
        set prevTIDs to text item delimiters of AppleScript
        set text item delimiters of AppleScript to find
        set subject to text items of subject
        
        set text item delimiters of AppleScript to replace
        set subject to "" & subject
        set text item delimiters of AppleScript to prevTIDs
        
        return subject
end replaceText

on open location texteditURL
        
        -- strip prefix
        set the character_count to the number of characters of the urlPrefix
        set the emacsclientURL to (characters (the character_count + 1) thru -1 
of the texteditURL) as string
        
        -- extract PATH LINE and COLUMN
        set AppleScript's text item delimiters to ":"
        set emacsclientPATH to first text item of emacsclientURL
        set emacsclientLINE to second text item of emacsclientURL
        set emacsclientCOLUMN to third text item of emacsclientURL
        set AppleScript's text item delimiters to ""
        
        set emacsclientPATH to replaceText("%20", " ", emacsclientPATH)
        set emacsclientPATH to replaceText("%2b", "+", emacsclientPATH)
        
        -- launch emacsclient
        do shell script "/Applications/Eddie/tellEddie " & quoted form of emacsclientPATH & ":" & 
emacsclientLINE & ":" & emacsclientCOLUMN
        
end open location

Good luck,
Mats



reply via email to

[Prev in Thread] Current Thread [Next in Thread]