Hi,
I am working on a bundle (Stata) for which we'd like to implement several user-configurable preferences (e.g., like with the LaTeX or TODO bundles). These will certainly include both boolean values (i.e., checkboxes) and strings, but may also include other values as well (e.g., selections from a list or a reference to an installed application). I've looked at the way this is done in the LaTeX and TODO bundles (which are handled a bit differently), but before getting started I was wondering if there was a preferred approach to follow here. Any suggestions or pointers to examples (or documentation) would be most appreciated.
Thanks,
-- Phil
On Mar 26, 2013, at 4:47 PM, Phil Schumm wrote:
I am working on a bundle (Stata) for which we'd like to implement several user-configurable preferences (e.g., like with the LaTeX or TODO bundles). These will certainly include both boolean values (i.e., checkboxes) and strings, but may also include other values as well (e.g., selections from a list or a reference to an installed application). I've looked at the way this is done in the LaTeX and TODO bundles (which are handled a bit differently), but before getting started I was wondering if there was a preferred approach to follow here. Any suggestions or pointers to examples (or documentation) would be most appreciated.
Ok, I've done some more digging, and realized that I should have done so before posting (sorry for the naive question). I'll just say a few words here in case this may be of use to anyone else, hoping that those more knowledgable will correct any misstatements I may make. Looks like both the LaTeX and TODO bundles do in fact handle this the same way, which is to call $DIALOG with their own custom nib file. Help is available via ctrl-R when on a line containing
"$DIALOG" help
in a TextMate window. The result can then be written to
com.macromates.textmate.plist
and subsequently queried with tm_query. Seems fairly straightforward, actually.
-- Phil
On 27 Mar 2013, at 0:16, Phil Schumm wrote:
[…] The result can then be written to
com.macromates.textmate.plist
This would be for 1.x. The nib will bind to the program’s user defaults, which is `~/Library/Preferneces/«app-identifier».plist`. In 2.0 we have introduced the `TM_APP_IDENTIFIER` variable that should be used to access this file.
E.g. to read the LaTeX bundle’s ‘Viewer’ setting, from shell:
defaults read "$TM_APP_IDENTIFIER" latexViewer
And from ruby:
require "#{ENV['TM_SUPPORT_PATH']}/lib/osx/plist"
settings_path = "#{ENV['HOME']}/Library/Preferences/#{ENV['TM_APP_IDENTIFIER'] || 'com.macromates.textmate'}.plist" settings = open(settings_path) { |io| OSX::PropertyList.load(io) }
puts settings['latexViewer']
and subsequently queried with tm_query.
The `TM_QUERY` tool is for querying settings set in `.tm_properties` files.
On 27 Mar 2013, at 11:29, Allan Odgaard wrote:
E.g. to read the LaTeX bundle’s ‘Viewer’ setting, from shell:
defaults read "$TM_APP_IDENTIFIER" latexViewer
To offer the same 1.x backward compatibility that I did in the ruby example, it should have been:
defaults read "${TM_APP_IDENTIFIER:-com.macromates.textmate}" latexViewer
That said, for the bundles under https://github.com/textmate/ we dropped 1.x compatibility some time ago.
On Mar 27, 2013, at 5:29 AM, Allan Odgaard wrote:
This would be for 1.x. The nib will bind to the program’s user defaults, which is `~/Library/Preferneces/«app-identifier».plist`. In 2.0 we have introduced the `TM_APP_IDENTIFIER` variable that should be used to access this file.
E.g. to read the LaTeX bundle’s ‘Viewer’ setting, from shell:
defaults read "$TM_APP_IDENTIFIER" latexViewer
And from ruby:
require "#{ENV['TM_SUPPORT_PATH']}/lib/osx/plist"
settings_path = "#{ENV['HOME']}/Library/Preferences/#{ENV['TM_APP_IDENTIFIER'] || 'com.macromates.textmate'}.plist" settings = open(settings_path) { |io| OSX::PropertyList.load(io) }
puts settings['latexViewer']
Thanks!
-- Phil
On 27 Mar 2013, at 0:16, Phil Schumm wrote:
[…] The result can then be written to
com.macromates.textmate.plist
This would be for 1.x. The nib will bind to the program’s user defaults, which is `~/Library/Preferneces/«app-identifier».plist`. In 2.0 we have introduced the `TM_APP_IDENTIFIER` variable that should be used to access this file.
E.g. to read the LaTeX bundle’s ‘Viewer’ setting, from shell:
defaults read "$TM_APP_IDENTIFIER" latexViewer
And from ruby:
require "#{ENV['TM_SUPPORT_PATH']}/lib/osx/plist" settings_path =
"#{ENV['HOME']}/Library/Preferences/#{ENV['TM_APP_IDENTIFIER'] || 'com.macromates.textmate'}.plist" settings = open(settings_path) { |io| OSX::PropertyList.load(io) }
puts settings['latexViewer']
and subsequently queried with tm_query.
The `TM_QUERY` tool is for querying settings set in `.tm_properties` files.
Cool! Didn't know about that functionality.