scripting/plugins?

Hi. Are there any plans to provide scripting / plugin abilities in Scrivener?

I’m particularly interested in adding compile and formatting abilities. I’m pretty sure I can read the xml and parse all of the rtf with an external program (thanks for using open standards!). But it would be nice to integrate it.

By the way, this might be of interest: johnmacfarlane.net/pandoc/

AppleScript is on the distant horizon somewhere…

And just to clarify the horizon is that thing way over there where the sky is supposed to meet the earth, but is invisible due to the smog. Right?

:stuck_out_tongue:

As this thread on Applescripting seems more alive (or recent) than the older ur-thread on “what do you want in Applescripting Scrivener?”, my tuppence worth is:

-expose more of the object model. At present it’s rather difficult to know via the Applescript mode what is active. So on Scrivener 2 (enclosed in a “tell application Scrivener/ end tell” block)

properties of front document
–> {file:file “Macintosh HD:Users:charles:Documents:Guardian:copy:lastbattle:lastbattle.scriv:”, name:“lastbattle.scriv”, class:document, modified:false}

which means this isn’t a “document”-based app. OK, so let’s get the properties of the front window:
properties of front window
–> {zoomed:false, miniaturized:false, name:“lastbattle - mygreatchapter”, document:document “lastbattle.scriv” of application “Scrivener”, miniaturizable:true, class:window, closeable:true, resizable:true, visible:true, zoomable:true, id:526, bounds:{200, 219, 1305, 963}, index:1}

which means that the document inside the window seem to be the things to target.

But
get properties of front document of front window
fails, and
get properties of active document of front window
fails.

This means that we can’t, with Applescript, start to dig at the place where we’re doing the work. For me, just being able to ask
get selected text of active document of front window
would be enormously helpful, because I could then use that to do Google searches (I’m writing a book where I’m looking stuff up): I could feed the selected text to Google.

This is where I’m saying that Scrivener needs to expose its object model more clearly to Applescript. That in itself will probably make it a lot easier for Applescripters to use it. It’s not a question of “adding features”; the features already exist. It’s a question of providing the ways to address them.

People like Daniel Jalkut (Red Sweater Software) and Brent Simmons (Ranchero) could probably give you some good hints - they have written apps that are very scriptable, simply because they create Applescript hooks in the software for the object. Rather than asking people here, it might make more sense to ask some developers who’ve done it before, who could show you what you need to do.

Oh, and - love Scrivener. Thank you so much for creating it.

Just to keep this thread alive - another request for an Applescript API. I have written a script to get notes taken in the Sente bibliography manager software exported for use in Scrivener, and have users wanting a more automated way to get the notes imported to Scrivener, as well as the setting of metadata, etc.

Looking forward to the horizon getting here! :slight_smile:

AppleScript is on the list for 2.1, but I haven’t even started that yet. The idea is that the 2.0x releases will be mainly minor refinements and stability fixes, and then later in the year once it’s as solid as possible, I’ll start working on AppleScript support for 2.1. I can’t guarantee it won’t get pushed back to 2.2 or 2.3, but it is definitely on the list for me to start working on this sometime this year.

Thanks,
Keith

Because you havent’t started yet :wink: it is still time to take a look at Lua, especially as you are travelling the multiplatform road. Lua has been deployed widely as an embedded scripting language. Plus, Lua is awesome and it is just fun to program in it. To me it seems a natural fit with Scrivener.

A few initial arguments are here: http://www.lua.org/about.html.
http://www.inf.puc-rio.br/~roberto/pil2/ and http://www.lua.org/gems/ are recommended reading.

M

FWIW, here’s a few things I’d like to see and do in AppleScript:

A simple way to add text TO any area of Scrivener.

  • For example, I could export my highlights from Skim into new note cards (into either the title or the body).
  • I could export quotes and notes from Sente into note cards, with the quote as either the title, the synopsis, or the body.
  • I could put the Sente reference code in one of the handy meta-data spots in Scrivener.
  • I could take snippets from the clipboard, process them, and send them to a document in Scrivener.

I’d like to be able to get data FROM Scrivener into other programs in a certain specific way.

  • When I export to OmniOutliner, I’d want something specific such as the synopsis in column 1, the status in column 2, etc.

Some ideas:

set synopsis of document "My great idea" of project "World Peace" to "promote justice" set body of document "My great idea" of project "World Peace" to "human rights" set status of document "My great idea" to "first draft" set keywords of document "My great idea" to myKeyList set notes of document "My great idea" to mySenteRefCode

Looking forward to AppleScript!

Hi cricketbird,

Thanks for the suggestions - most of that sounds doable and should be part of A/S support, apart from the OmniOutliner export, which is limited by the OPML format and how different programs read it (I’ll have to take a look at OO and how it handles OPML import for custom columns).

I’m hoping to make a start on A/S support sometime in summer, depending on how everything else goes. 2.0 has been out for a while now and the worst bugs have been fixed in 2.0.x releases (with the upcoming 2.0.5 fixing most of the remaining ones, I hope), so it will soon be time to start thinking about 2.1, of which AppleScript should be the main feature (that’s the plan anyway). That said, the release of Lion this summer could put things back a couple of months as I ensure everything is compatible.

Thanks and all the best,
Keith