[toolbox] TeXShop completions
Status: Planning
Brought to you by:
jlaurens
From: Will R. <ws...@gm...> - 2006-04-21 08:44:12
|
Hello everyone, I've finally gotten around to taking a more decent look at TeXShop's =20 completions, courtesy of some old file of Herb Schulz's I have lying =20 around. (Are you here, Herb?) I've been hacking away at it for a little while now when it occurred =20 to me that I should check if it's been improved since I got my hands =20 on it. (I don't even know if the file's publicly available any more.) Anyway, I think you'll like what I've been doing. I always forget =20 what the more complex optional arguments are supposed to be in things =20= like minipages. I've now got completions like the following: \framebox[#INS#=F0=DCwidth=DD][=F0=DCpos: c,l,r,s=DD]{=F0} \framebox[#INS#]{=F0} \makebox[#INS#=F0=DCwidth=DD][=F0=DCpos: c,l,r,s=DD]{=F0} \makebox[#INS#]{=F0} \raisebox{#INS#=F0=DCraise=DD}[=F0=DCheight=DD][=F0=DCdepth=DD]{=F0= } \raisebox{#INS#=F0=DCraise=DD}[=F0=DCheight=DD]{=F0} \raisebox{#INS#}{=F0} And I've modified the bullet searching TeXShop macros to select any =20 matching =DC...=DD text after a bullet as well (see appended, and feel =20= free to distribute -- I copied them from Herb). I'm keen on the idea of expanding the completion file to include as =20 much of base LaTeX as possible, following conventions something like =20 the above. There's no reason it should be TeXShop specific, either. I =20= don't know how much time I have or how long my motivation will last, =20 but anyone interested in helping out would be great. I guess this =20 file would need to be placed in a svn site somewhere if more than one =20= person were to work on it. Hypothetically, I would like this file to evolve beyond TeXShop's =20 current completion engine into a file that can be used for more =20 flexible purposes; e.g., code prompting as you type. New LaTeX =20 packages should be able to write their own command description file =20 (via the dtx mechanism) which would be preparsed somewhere such that =20 when a \usepackage is recognised, the extra macros can be added to =20 the current pool of "known" commands that the editor can prompt for. =20 Ideally, every single user command in LaTeX should be completely =20 documented in this way, which would then allow true syntax spell =20 checking of LaTeX code. I imagine an extension to \newcommand (or the LaTeX3 equivalent, more =20= likely) that takes such syntax information for purely metadata =20 reasons. E.g., \newcommand\mycommand[2] (1: first argument; 2:second argument) {#1: #2} (I just made that up on the spot. Perhaps it's not such a good idea.) =20= Alternatively, \newcommand\mycommand[2]{#1: #2} \describemacro\mycommand[1=3Dfirst arg, 2=3Dsecond arg]{This is a =20 macro for not doing much.} I know, I know. It's all easy to say these things, but I'm not the =20 first to think of them so I believe the idea has merit. (Frank =20 Mittelbach touches briefly on the subject in the documentation file, =20 if I recall correctly, ltxdoc.pdf .) Just some rambling thoughts for a procrastinating Friday evening. Any =20= thoughts? Will --AppleScript direct --Find Next "Tab" property bullet : "=F0" property openDelim : "=DC" property closeDelim : "=DD" try tell application "TeXShop" activate set searchOffset to (offset of selection of front = document) if (length of selection of front document) > 0 then set searchOffset to (searchOffset + 1) end if tell front document to set bulletMark to (search for = bullet =20 starting from searchOffset) if bulletMark > 0 then set offset of selection of front document to = (bulletMark - 1) if character (bulletMark + 1) of the text of the = front document is =20 openDelim then tell front document to set delimMark to = (search for closeDelim =20 starting from bulletMark) if delimMark > 0 then set length of selection of front = document to (delimMark - =20 bulletMark + 1) else set length of selection of front = document to 1 end if else set length of selection of front = document to 1 end if end if end tell end try --AppleScript direct --Find Previous "Tab" property bullet : "=F0" property openDelim : "=DC" property closeDelim : "=DD" try tell application "TeXShop" activate set searchOffset to (offset of selection of front = document) tell front document to set bulletMark to (search for = bullet =20 starting from searchOffset with searching backwards) if bulletMark > 0 then set offset of selection of front document to = (bulletMark - 1) if character (bulletMark + 1) of the text of the = front document is =20 openDelim then tell front document to set delimMark to = (search for closeDelim =20 starting from bulletMark) if delimMark > 0 then set length of selection of front = document to (delimMark - =20 bulletMark + 1) else set length of selection of front = document to 1 end if else set length of selection of front = document to 1 end if end if end tell end try |