Support different CotEditor versions in AppleScript

This page lists notable changes to AppleScript support in previous versions of CotEditor.

Changes in CotEditor 6.2.3

Support of folder document

Folder documents can now be distinguished in scripts as folder document. In addition, any document API sent to a folder document is executed against the text document that is currently open in that folder document. You can also retrieve that text document from a folder document via the current document property.

Changes in CotEditor 6.0.0

Deprecation of change kana

The change kana command was deprecated.

Note: This change is not backward compatible with earlier versions.

Changes in CotEditor 5.1.0

Control of document editability

A new property editable was added to the document object.

Changes in CotEditor 5.0.7

Enhancements to the write to console command

The title and timestamp options were added to the write to console command, allowing the script name and timestamp to be omitted when writing to the console programmatically.

Changes in CotEditor 5.0.0

Change in character unit to grapheme cluster–based indexing

The character unit used in commands such as selection and jump was changed from UTF-16–based indexing to Unicode grapheme cluster–based indexing.

This change follows the specification introduced with AppleScript 2.0 in Mac OS X 10.5.

Changes in CotEditor 4.4.0

Deprecation of length

The length property of the document object was deprecated.

For backward compatibility, CotEditor 4.4.0 still allows the use of this property; however, it may be removed in a future version without notice.

Deletion of backward compatibility of path

The path property, which was deprecated in CotEditor 2.0.0 but quietly retained for backward compatibility, was completely deleted in this version.

Changes in CotEditor 4.1.0

Addition of the jump command

A new command jump was added to the document object.

Support for encodings with BOM

A new property has BOM was added to the document object and a new option BOM was added to the convert command.

Changes in CotEditor 4.0.7

IANA charset names support for convert / reinterpret

The convert and reinterpret commands now also accept encodings specified by IANA charset names.

Changes in CotEditor 3.9.7

Smart quotes

The following new commands were added to the selection object.

Changes in CotEditor 3.5.0

Editor’s opacity

view opacity property was deprecated in CotEditor 3.5.0.

Note: This change is not backward compatible with earlier versions.

Changes in CotEditor 3.1.2

Auto tab expansion

A new property expands tab was added to the document object.

Changes in CotEditor 2.6.0

Line spacing property

line spacing property was deprecated in CotEditor 2.6.0.

Note: This change is not backward compatible with earlier versions.

Changes in CotEditor 2.5.3

New Unicode normalization form

A new value Modified NFC was added to the normalize unicode command.

Changes in CotEditor 2.3.0

Editing selected lines

The following new commands were added to the selection object.

Changes in CotEditor 2.2.2

New Unicode normalization form

A new value Modified NFD was added to the normalize unicode command.

Changes in CotEditor 2.2.0

New Unicode normalization form

A new value NFCK Casefold was added to the normalize unicode command.

Changes in CotEditor 2.1.0

Tab width

A new property tab width was added to the document object.

Changes in CotEditor 2.0.1

Comment handling

New commands comment out and uncomment were added to the selection object.

Changes in CotEditor 2.0.0

Renaming of unicode normalization

The unicode normalization command in earlier versions was renamed to normalize unicode in CotEditor 2.0. The function and parameters are the same as before.

Note: This change is not backward compatible with earlier versions.

Discontinuation of path property

The path property of the document object has long been discontinued in the modern AppleScript Standard Suite. When CotEditor adopted the modern Standard Suite in version 2.0, this property was also deprecated. Use the file property instead. The file property returns a file object, whereas the path property returns a text object.

For backward compatibility, CotEditor 2.0 added a hidden path property to the document object; however, this property should not be used in new scripts, and existing scripts are strongly recommended to migrate to the file property.

Update of internal code for range property

The internal code for range property of the text selection object to identify itself has been changed in CotEditor 2.0. The key for the range property is still range, so no action is required when writing new scripts. However, compiled AppleScripts (.scpt) which were written previously may require updates due to this change.

How to fix: Open your .scpt files in AppleScript Editor (or Script Editor), the words that were range previously might be changed to «class prng» or something like that. Overwrite them with range again. And save them. This issue doesn’t occur with plain text AppleScript (.applescript).

Changes in CotEditor 1.5.0

Window transparency

Due to changes in the mechanism used to control window transparency in CotEditor 1.5, the related AppleScript terminology was also updated. The document object had the following properties up to version 1.4:

were deprecated, and the new window’s property:

was added instead.

Because the previous term “transparency” was incorrectly used until version 1.4, the property name was renamed from “transparency” to “opacity” but the value to set is not changed. In both cases, a value of 1.0 represents full opacity.

Note: This change is not backward compatible with earlier versions.

Selection object directly under the application

In version 0.6, the initial release of CotEditor, the frontmost window’s content was selected if you didn’t specify the selection object. However, it actually didn’t work correctly and was therefore deprecated. This method was yet kept valid to maintain backward compatibility.

In CotEditor 1.5, it was formally removed. When you get the selection object, specify the target like below:

tell application "CotEditor"
	contents of selection of front document
end tell
tell application "CotEditor"
	tell document 1
		contents of selection
	end tell
end tell

See also