Hi Rainer,
This script looks for the existence of an optional
.rainer.conf file in the parent directories.
If the file exists it reads it, parses it and acts in consequence.
Same logic could be applied based on project window names, document file types, document file languages, etc.
HTH
Jean Jourdain
--
on readRainerConf(aFile)
set vRainerConf to ".rainer.conf"
tell application "Finder"
set vContainer to container of file aFile
repeat while true
try
if exists file vRainerConf of vContainer then
set vConfFile to (file vRainerConf of vContainer) as alias
set vConfig to read vConfFile
return vConfig
end if
set vContainer to container of vContainer
on error
exit repeat
end try
end repeat
return missing value
end tell
end readRainerConf
tell application "BBEdit"
set vDocument to first document of first window
if not vDocument's on disk then
return
end if
-- Check for a configuration file.
set vConfig to my readRainerConf(vDocument's file)
-- Parse the the config and act appropriately.
if vConfig contains "optionA" then
set vCommand to "do A command"
else if vConfig contains "optionB" then
set vCommand to "do B command"
else
set vCommand to "do default command"
end if
display dialog vCommand
end tell