[OS X TeX] Still trying...

Stefan Walsen stefan at walsen.net
Wed Apr 7 17:50:25 CEST 2004


Curtis Clifton wrote:
> On Apr 7, 2004, at 10:14 AM, Herb Schulz wrote:
>> I'm back to trying to write an Applescript that does a search for the 
>> next
>> occurrence of a particular character and then select that character 
>> within
>> TeXShop. I can get the search to work fine but that doesn't select the
>> character, it returns the character position in the file. Even though
>> selection is a defined object in the TeXShop Applescript library I get an
>> error when I try to set its position, length and contents to the required
>> value. Is it read only?
> I recall successfully setting the selection in TeXShop via Applescript 
> in the past, but I can't find the code that I used.

same here :)

I tried it from scratch ... This works for me:

--applescript
tell application "TeXShop"
  try
     set searchString to "#" -- or whatever you're looking for
     set searchOffset to (offset of selection of front document) +1
     search front document starting from searchOffset for searchString
     set offset of selection of front document to the result -1
     set length of selection of front document to 1
   end try
end tell
--end of script

Setting the offset of the search to the current cursor position +1 
prevents the script from finding the same character every time when 
called repeatedly.

Regards,
Stefan
-----------------------------------------------------
Please see <http://www.esm.psu.edu/mac-tex/> for list
guidelines, information, and LaTeX/TeX resources.





More information about the macostex-archives mailing list