[OS X TeX] Startup Items and Shutdown Items folders for TeXShop
Ramón Figueroa-Centeno
ramonf at hawaii.edu
Tue Apr 14 09:18:59 CEST 2009
Place the following script in the Startup Items folder to open the last "howmany" documents opened by TeXShop (if they exist)
property howmany : 5
property prefName : "TeXShop.plist"
set p2p to (path to preferences from user domain as text) & prefName
tell application "System Events"
try
set listRecents to value of property list item "NSRecentDocumentRecords" of property list file p2p
on error
return
end try
end tell
set i to 1
repeat with r in items of listRecents
set alis to |_NSAlias| of |_NSLocator| of r
try
alis as text
on error errmsg
set savedDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "****"
set errmsg to text item 2 of errmsg
set AppleScript's text item delimiters to "»"
set errmsg to text item 1 of errmsg
set AppleScript's text item delimiters to savedDelimiters
end try
set decode to do shell script "echo " & quoted form of errmsg & " | xxd -r -p"
set nullchar to ASCII character 0
set savedDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to nullchar
set maybe to {}
repeat with p in text items of decode
if ((count of p) > 1) and p contains ":" then copy p to end of maybe
end repeat
tell application "System Events"
set found to false
repeat with f in maybe
if exists file f then
set found to true
exit repeat
else
set f to text 2 thru -1 of f
if exists file f then
set found to true
exit repeat
end if
end if
end repeat
end tell
set AppleScript's text item delimiters to savedDelimiters
if found then
try
tell application "TeXShop" to open f
end try
end if
set i to i + 1
if i > howmany then
exit repeat
end if
end repeat
--
View this message in context: http://n2.nabble.com/Startup-Items-and-Shutdown-Items-folders-for-TeXShop-tp2618926p2631603.html
Sent from the MacOSX-TeX mailing list archive at Nabble.com.
More information about the macostex-archives
mailing list