Could you please change `refresh_viewer.scpt` by adding a `display alert`
Ren,
I actually did some checking along those lines before I got your message. I used a notification instead of a display alert, but the result is that the "TeXShop" block of code is definitely not being executed. Never the less, deleting the tell block from that code will still stop TeXShop from opening. I noticed you had to delete the tell block and not just the code within the tell block. Some online searching led me to the following which seems likely to be the root of the problem:
http://stackoverflow.com/questions/12431811/how-to-make-applescript-not-auto...
Apparently the script should be compiled so that Skim and TeXShop are not both automatically opened. I am not sure why Angelo and I seem to be the only ones having this issue. If the above is correct then this behavior should happen to everyone.
-Jim
Hi Jim,
On 07 Jan 2015, at 20:35 , Starx jstarx@gmail.com wrote:
Could you please change `refresh_viewer.scpt` by adding a `display alert`
Ren,
I actually did some checking along those lines before I got your message. I used a notification instead of a display alert, but the result is that the "TeXShop" block of code is definitely not being executed. Never the less, deleting the tell block from that code will still stop TeXShop from opening. I noticed you had to delete the tell block and not just the code within the tell block. Some online searching led me to the following which seems likely to be the root of the problem:
http://stackoverflow.com/questions/12431811/how-to-make-applescript-not-auto...
Apparently the script should be compiled so that Skim and TeXShop are not both automatically opened.
that is very valuable information. Thank you.
I compiled the script and updated the bundle accordingly. Could you please check if the changes work for you by following these steps:
1. Uninstall the LaTeX bundle inside TextMate 2. Clone the newest version of the bundle from GitHub in “Terminal”:
cd ~/Library/Application\ Support/TextMate/Managed/Bundles/ git clone https://github.com/textmate/latex.tmbundle.git
I am not sure why Angelo and I seem to be the only ones having this issue. If the above is correct then this behavior should happen to everyone.
Maybe Apple changed the behaviour in OS X 10.10. This would also explain why I am not able to reproduce the problem.
-Jim
Kind regards, René
Hi René, I followed your suggestion and cloned the new LaTeX bundle. Now TeXShop doesn't open anymore after the second (and successive) LaTeX compiles.
Cheers, Angelo
René Schwaiger wrote:
Hi Jim,
On 07 Jan 2015, at 20:35 , Starx jstarx@gmail.com wrote:
Could you please change `refresh_viewer.scpt` by adding a `display alert`
Ren,
I actually did some checking along those lines before I got your message. I used a notification instead of a display alert, but the result is that the "TeXShop" block of code is definitely not being executed. Never the less, deleting the tell block from that code will still stop TeXShop from opening. I noticed you had to delete the tell block and not just the code within the tell block. Some online searching led me to the following which seems likely to be the root of the problem:
http://stackoverflow.com/questions/12431811/how-to-make-applescript-not-auto...
Apparently the script should be compiled so that Skim and TeXShop are not both automatically opened.
that is very valuable information. Thank you.
I compiled the script and updated the bundle accordingly. Could you please check if the changes work for you by following these steps:
Uninstall the LaTeX bundle inside TextMate
Clone the newest version of the bundle from GitHub in “Terminal”:
cd ~/Library/Application\ Support/TextMate/Managed/Bundles/ git clone https://github.com/textmate/latex.tmbundle.git
I am not sure why Angelo and I seem to be the only ones having this issue. If the above is correct then this behavior should happen to everyone.
Maybe Apple changed the behaviour in OS X 10.10. This would also explain why I am not able to reproduce the problem.
-Jim
Kind regards, René
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Hi Angelo,
On 08 Jan 2015, at 11:25 , Angelo Varlotta angelovarlotta@gmail.com wrote:
Hi René, I followed your suggestion and cloned the new LaTeX bundle. Now TeXShop doesn't open anymore after the second (and successive) LaTeX compiles.
yay. Thanks for the quick reply. The LaTeX bundle (inside TextMate) should be automatically updated sometimes in the next days, when Allan (Odgaard) or Michael (Sheets) have time to push the changes.
Cheers, Angelo
Kind regards, René
Rene,
After the initial clone the behavior stopped, but because it started back up again last time I decided to wait a day before saying it worked and unfortunately this morning TeXShop has started opening again.
I do not know the difference between a compiled applescript and an uncompiled applescript. There is still just a file, refresh_viewer.scpt, no application or anything like that in the bin directory. Could my textmate have updated itself back to the uncompiled version? How do I check if this script is compiled or not?
-Jim
On Thu, Jan 8, 2015 at 2:50 AM, René Schwaiger sanssecours@f-m.fm wrote:
Hi Angelo,
On 08 Jan 2015, at 11:25 , Angelo Varlotta angelovarlotta@gmail.com
wrote:
Hi René, I followed your suggestion and cloned the new LaTeX bundle. Now TeXShop
doesn't open anymore after the second (and successive) LaTeX compiles.
yay. Thanks for the quick reply. The LaTeX bundle (inside TextMate) should be automatically updated sometimes in the next days, when Allan (Odgaard) or Michael (Sheets) have time to push the changes.
Cheers, Angelo
Kind regards, René
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Hi Jim,
On 08 Jan 2015, at 18:51 , Starx jstarx@gmail.com wrote:
Rene,
After the initial clone the behavior stopped, but because it started back up again last time I decided to wait a day before saying it worked and unfortunately this morning TeXShop has started opening again.
I do not know the difference between a compiled applescript and an uncompiled applescript.
as far as I know an uncompiled AppleScript is just a text file. A compiled script on the other hand is a binary. If you open a compiled AppleScript in an editor — that unlike TextMate — does not support decompilation then you should see “gibberish” instead of the source code. You can try it yourself by opening `refresh_viewer` in “vim” or “TextEdit”.
There is still just a file, refresh_viewer.scpt, no application or anything like that in the bin directory. Could my textmate have updated itself back to the uncompiled version?
If the checkbox on the left of the LaTeX bundle in Preferences→Bundles is selected, then TextMate might have overwritten your changes. If that is not the case, then TextMate should not overwrite the cloned version.
How do I check if this script is compiled or not?
Just try to open `refresh_viewer.scpt` inside `Support/bin` with “Script Editor”. You should get an error message containing something like the following text:
The document “refresh_viewer.scpt” could not be opened.
Unable to read the file because the script is not editable (it was saved as run-only).
-Jim
Kind regards, René
Rene,
LaTeX is indeed checked under bundle preferences, but it was checked as soon as I cloned the latex bundle, I assumed this just indicated that Textmate knew that a latex bundle was present. The refresh_viewer.scpt can be opened by the apple script editor and by textedit as well. When I do this I can see the code in the script. I assume this means it's not compiled.
-Jim
On Thu, Jan 8, 2015 at 10:41 AM, René Schwaiger sanssecours@f-m.fm wrote:
Hi Jim,
On 08 Jan 2015, at 18:51 , Starx jstarx@gmail.com wrote:
Rene,
After the initial clone the behavior stopped, but because it started
back up again last time I decided to wait a day before saying it worked and unfortunately this morning TeXShop has started opening again.
I do not know the difference between a compiled applescript and an
uncompiled applescript.
as far as I know an uncompiled AppleScript is just a text file. A compiled script on the other hand is a binary. If you open a compiled AppleScript in an editor — that unlike TextMate — does not support decompilation then you should see “gibberish” instead of the source code. You can try it yourself by opening `refresh_viewer` in “vim” or “TextEdit”.
There is still just a file, refresh_viewer.scpt, no application or
anything like that in the bin directory. Could my textmate have updated itself back to the uncompiled version?
If the checkbox on the left of the LaTeX bundle in Preferences→Bundles is selected, then TextMate might have overwritten your changes. If that is not the case, then TextMate should not overwrite the cloned version.
How do I check if this script is compiled or not?
Just try to open `refresh_viewer.scpt` inside `Support/bin` with “Script Editor”. You should get an error message containing something like the following text:
The document “refresh_viewer.scpt” could not be opened. Unable to read the file because the script is not editable (it was
saved as run-only).
-Jim
Kind regards, René
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
Hi Jim,
On 08 Jan 2015, at 21:49 , Starx jstarx@gmail.com wrote:
Rene,
LaTeX is indeed checked under bundle preferences, but it was checked as soon as I cloned the latex bundle, I assumed this just indicated that Textmate knew that a latex bundle was present.
I tried it out myself and indeed the LaTeX bundle was checked after I cloned the bundle. So it might indeed be the case that TextMate has overwritten the cloned bundle — especially since the preferences showed that the cloned bundle was updated 14 years [sic] ago. Sorry, for providing flawed instructions. Here are hopefully correct ones:
1. Uninstall the LaTeX bundle inside TextMate preferences
2. There should be no `latex.tmbundle` or `LaTeX.tmbundle` in `~/Library/Application Support/TextMate/Managed/Bundles/`. If there still is a bundle with such a name please delete it.
3. Create the folder `~/Library/Application Support/Avian/Bundles/` if it does not already exist. You can use the following Terminal command:
mkdir -p ~/Library/Application\ Support/Avian/Bundles/
4. Clone the LaTeX bundle into `Avian/Bundles`:
cd ~/Library/Application\ Support/Avian/Bundles/ git clone https://github.com/textmate/latex.tmbundle.git
After the bundle inside preferences is update the next time you can remove the cloned bundle, and install the one from preferences.
The refresh_viewer.scpt can be opened by the apple script editor and by textedit as well. When I do this I can see the code in the script. I assume this means it's not compiled.
I assume so too. Just for reference, here is the alert dialog I get:
-Jim
Kind regards, René
On 9 Jan 2015, at 4:58, René Schwaiger wrote:
On 08 Jan 2015, at 21:49 , Starx jstarx@gmail.com wrote:
LaTeX is indeed checked under bundle preferences […]
I tried it out myself and indeed the LaTeX bundle was checked after I cloned the bundle. So it might indeed be the case that TextMate has overwritten the cloned bundle […]
No, this is just because it has recorded that the LaTeX bundle is installed in the local index and/or the bundle is present on disk (a newer version). TextMate isn’t able to tell if the one on disk is one that TextMate itself put there.
— especially since the preferences showed that the cloned bundle was updated 14 years [sic] ago.
The “14 years” would (sort of) verify that it’s the custom bundle, since TextMate lack the proper “last updated” meta-data.
The refresh_viewer.scpt can be opened by the apple script editor and by textedit as well. When I do this I can see the code in the script. I assume this means it's not compiled.
I assume so too. Just for reference, here is the alert dialog I get:
I’m jumping into the middle of this, so I might have missed some, but uncompiled AppleScripts are problematic because the system needs to compile them before it’s able to execute them, and for that, it need the scripting dictionaries of all programs referenced. If the user lack one of the programs, it will fail to compile.
I suggest dropping the external AppleScript and making two branches in the Python script instead, which each use: osascript -e 'tell app "…" to …'
We had a bunch of similar problems with the “Paste Online” functionality, since we used AppleScript to insert the URL in the destination app that the user picked, and I believe we did at one point also have the problem that applications would launch even though we didn’t send them any commands (but they were mentioned in the AppleScript we used).
Sorry I have not been following this thread (since I don't use LaTeX, though some day I'd like to learn it). But I take it that the question has to do with AppleScript causing targeted applications to launch? I wrote a rather well-known book about AppleScript so this is something I know a bit about. This opening is necessary, particularly in the case of certain applications, in order to obtain the application's dictionary. If an AppleScript script uses any terminology from an application, it must be resolved by looking in the application's dictionary. If I remember correctly (which may not be the case - it's been a long time), this is one of the thing the "using terms from" block was supposed to help with:
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual...
The idea is that the developer can compile the script with the relevant terminology without that terminology having to be resolved at runtime. Of course, if the application is actually targeted, then it must be opened, but that's okay because it makes sense to the end-user (the application is actually _doing_ something).
Hope this helps; the new "use" block may also be helpful here, but I have not tried it - it's after my time... m.
-- matt neuburg, phd = http://www.apeth.net/matt/ pantes anthropoi tou eidenai oregontai phusei Programming iOS 8! http://shop.oreilly.com/product/0636920034261.do iOS 7 Fundamentals! http://shop.oreilly.com/product/0636920032465.do RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html
Hi,
first: Thanks for all the helpful advice and sorry for the late response.
I looked a little bit further into the matter and it seems that AppleScripts launches Applications “hidden” since OS X 10.5 [1]. I believe this “silent” launching is the behaviour that I encountered when describing the growing and shrinking of my Dock when `texmate` called (the uncompiled script) `refresh_viewer.scpt`.
[1]: https://developer.apple.com/library/mac/releasenotes/AppleScript/RN-AppleScr...
I do not get this behaviour at all when `texmate` uses the compiled version of the script [2]. This could be because either the compiled version is much faster, or as pointed out by the Stack Overflow article mentioned by Jim [3], that compiled version of AppleScripts do not open Applications if they do not need to.
[2]: https://github.com/textmate/latex.tmbundle/blob/master/Support/bin/refresh_v... [3]: http://stackoverflow.com/questions/12431811/how-to-make-applescript-not-auto...
Angelo: You mentioned that your problems have been gone after you used the compiled version of the script. Is this still the case?
Jim: You said that the problem continues but you still could open `refresh_viewer.scpt` inside `Support/bin` after the changes. Could you please try to remove all LaTeX bundles and then clone the one from GitHub (again). After that, if the problem continues, please try to open `refresh_viewer.scpt` inside `Support/bin` with “Script Editor”. If that works, then it seems something overwrites the bundles content. If it does not, then I guess I have to come up with better solution to fix the command.
On 09 Jan 2015, at 19:40 , Matt Neuburg matt@tidbits.com wrote:
If an AppleScript script uses any terminology from an application, it must be resolved by looking in the application's dictionary. If I remember correctly (which may not be the case - it's been a long time), this is one of the thing the "using terms from" block was supposed to help with:
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual...
Thanks for the helpful resource. I guess this will be the next thing I will check out if the current compiled version of the script does not work.
On 09 Jan 2015, at 4:45 , Allan Odgaard mailinglist@textmate.org wrote:
No, this is just because it has recorded that the LaTeX bundle is installed in the local index and/or the bundle is present on disk (a newer version). TextMate isn’t able to tell if the one on disk is one that TextMate itself put there.
— especially since the preferences showed that the cloned bundle was updated 14 years [sic] ago.
The “14 years” would (sort of) verify that it’s the custom bundle, since TextMate lack the proper “last updated” meta-data.
Thanks for the clarification.
I’m jumping into the middle of this, so I might have missed some, but uncompiled AppleScripts are problematic because the system needs to compile them before it’s able to execute them, and for that, it need the scripting dictionaries of all programs referenced. If the user lack one of the programs, it will fail to compile.
Oh. It honestly did not know that. It seems that running scripts without installing all the referenced Application seems to work nowadays tough. If I remove “TeXShop”, open “Skim” and then run the `refresh_viewer.scpt Skim some.pdf`, where `refresh_viewer` is the uncompiled AppleScript I get no error.
If I run `refresh_viewer.scpt TeXShop some.pdf` the script returns with the expected error status and prints “./refresh_viewer.scpt:786:796: execution error: The variable refreshpdf is not defined. (-2753)”. The behaviour seems to be pretty much the one a programmer that has little to no knowledge of AppleScript — like myself — would expect.
I suggest dropping the external AppleScript and making two branches in the Python script instead, which each use: osascript -e 'tell app "…" to …'
This was actually the old behaviour. I did change it to fix the quoting of filenames with special characters [4]. Using an external script was an easy solution to get the proper filename trough to the AppleScript command.
[4]: https://github.com/textmate/latex.tmbundle/commit/d7e9a3916311af1849932f04aa...
Kind regards, René
Hi René, I was holding back before replying this time so that I could try more thoroughly your bundle. So far, the compiled version of refresh_viewer.scpt seems to be playing nicely. I haven't found any issues, TeXShop doesn't open after successive LaTeX compiles. I've installed your bundle according to your instructions in the previous email, and I made sure that the default LaTeX version is unselected, no other versions of LaTeX are present and that your bundle is cloned from Github in the Avian directory. So far, things are looking good with this LaTeX bundle!
Cheers, Angelo
René Schwaiger wrote:
Hi,
first: Thanks for all the helpful advice and sorry for the late response.
I looked a little bit further into the matter and it seems that AppleScripts launches Applications “hidden” since OS X 10.5 [1]. I believe this “silent” launching is the behaviour that I encountered when describing the growing and shrinking of my Dock when `texmate` called (the uncompiled script) `refresh_viewer.scpt`.
I do not get this behaviour at all when `texmate` uses the compiled version of the script [2]. This could be because either the compiled version is much faster, or as pointed out by the Stack Overflow article mentioned by Jim [3], that compiled version of AppleScripts do not open Applications if they do not need to.
Angelo: You mentioned that your problems have been gone after you used the compiled version of the script. Is this still the case?
Jim: You said that the problem continues but you still could open `refresh_viewer.scpt` inside `Support/bin` after the changes. Could you please try to remove all LaTeX bundles and then clone the one from GitHub (again). After that, if the problem continues, please try to open `refresh_viewer.scpt` inside `Support/bin` with “Script Editor”. If that works, then it seems something overwrites the bundles content. If it does not, then I guess I have to come up with better solution to fix the command.
On 09 Jan 2015, at 19:40 , Matt Neuburg matt@tidbits.com wrote:
If an AppleScript script uses any terminology from an application, it must be resolved by looking in the application's dictionary. If I remember correctly (which may not be the case - it's been a long time), this is one of the thing the "using terms from" block was supposed to help with:
https://developer.apple.com/library/mac/documentation/AppleScript/Conceptual...
Thanks for the helpful resource. I guess this will be the next thing I will check out if the current compiled version of the script does not work.
On 09 Jan 2015, at 4:45 , Allan Odgaard mailinglist@textmate.org wrote:
No, this is just because it has recorded that the LaTeX bundle is installed in the local index and/or the bundle is present on disk (a newer version). TextMate isn’t able to tell if the one on disk is one that TextMate itself put there.
— especially since the preferences showed that the cloned bundle was updated 14 years [sic] ago.
The “14 years” would (sort of) verify that it’s the custom bundle, since TextMate lack the proper “last updated” meta-data.
Thanks for the clarification.
I’m jumping into the middle of this, so I might have missed some, but uncompiled AppleScripts are problematic because the system needs to compile them before it’s able to execute them, and for that, it need the scripting dictionaries of all programs referenced. If the user lack one of the programs, it will fail to compile.
Oh. It honestly did not know that. It seems that running scripts without installing all the referenced Application seems to work nowadays tough. If I remove “TeXShop”, open “Skim” and then run the `refresh_viewer.scpt Skim some.pdf`, where `refresh_viewer` is the uncompiled AppleScript I get no error.
If I run `refresh_viewer.scpt TeXShop some.pdf` the script returns with the expected error status and prints “./refresh_viewer.scpt:786:796: execution error: The variable refreshpdf is not defined. (-2753)”. The behaviour seems to be pretty much the one a programmer that has little to no knowledge of AppleScript — like myself — would expect.
I suggest dropping the external AppleScript and making two branches in the Python script instead, which each use: osascript -e 'tell app "…" to …'
This was actually the old behaviour. I did change it to fix the quoting of filenames with special characters [4]. Using an external script was an easy solution to get the proper filename trough to the AppleScript command.
Kind regards, René
textmate mailing list textmate@lists.macromates.com http://lists.macromates.com/listinfo/textmate
On 12 Jan 2015, at 22:41, René Schwaiger wrote:
I suggest dropping the external AppleScript and making two branches in the Python script instead, which each use: osascript -e 'tell app "…" to …'
This was actually the old behaviour. I did change it to fix the quoting of filenames with special characters [4]. Using an external script was an easy solution to get the proper filename trough to the AppleScript command.
I see — you might have the external script issues sorted out by now, but another alternative (where we do not have to consider AppleScript’s string quoting rules embedded into a shell string) would be to use an environment variable, for example:
import pipes import subprocess
path = "That's an "environment" variable!" cmd = "PDF={} osascript -e 'tell app "TextMate" to display alert (system attribute "PDF")'".format(pipes.quote(path)) subprocess.call(cmd, shell=True)
Hi Allan,
On 18 Jan 2015, at 13:52 , Allan Odgaard mailinglist@textmate.org wrote:
I see — you might have the external script issues sorted out by now, but another alternative (where we do not have to consider AppleScript’s string quoting rules embedded into a shell string) would be to use an environment variable, for example:
import pipes import subprocess
path = "That's an "environment" variable!" cmd = "PDF={} osascript -e 'tell app "TextMate" to display alert (system attribute "PDF")'".format(pipes.quote(path)) subprocess.call(cmd, shell=True)
thanks for the advice. With my current knowledge that is the solution I would have chosen to fix the quoting problem. The compiled version of the script seems to work too though. I will leave it like it is for now.
Kind regards, René