[OS X TeX] Damn Applescript!

Herbert Schulz herbs at wideopenwest.com
Mon Sep 26 16:57:02 CEST 2005


Quite a while ago (using software time, not geological time here) I  
put together, with a bunch of help from this list, the following  
macro to ``Find Next "Tab"'' (where "Tab" is an embedded bullet  
character, `•', in a command completion):

--AppleScript direct
set searchString to "•"
	tell application "TeXShop"
		set searchOffset to (offset of selection of front document)
		if (length of selection of front document) > 0
			set searchOffset to (searchOffset + 1)
		end if
		tell front document
			set firstOccurrence to (search for searchString starting from  
		end tell
		if firstOccurrence > 0 then
			set offset of selection of front document to (firstOccurrence - 1)
			set length of selection of front document to (number of characters  
of contents of searchString)
		end if
	end tell
end try
-- end of script

The macro finds and selects the next "Tab" character if it exists.

Recently I was asked to also delete that "Tab" character with an  
example where that would be handy (saves pressing Del in certain  
nested environments with my completions). I tried using the line

delete the selection of the front document

after the

set length...

line but that didn't work. I'm amazed at the strange, seemingly  
random, syntax of Applescript but maybe that's my age showing since  
I'm used to procedural languages (I loved C). Any help here would be  
appreciated! Supposedly `delete' is a verb in TeXShop's  Applescript  
dictionary and I'd think that `selection of the front document' would  
be a decent noun so...

Good Luck,

Herb Schulz
(herbs at wideopenwest.com)

------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/

More information about the macostex-archives mailing list