It turns out to be quite fast, though a bit clumsy, to perform a triage of attributes based on whether or not they are members of the set of known system attributes.
Searching lists which are properties is, as you know, faster than searching through local variable lists, and an experiment with binary search turned out to add more code than significant speed
I think it might be sensible to ask Eastgate support to expose the groups of which attributes are members through the API, so that they can be easily grouped/selected for controls, but in the meanwhile, a basic partition of User vs System attributes in the active document might look something like:
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions
-- Rough sketch
-- Rob Trew 2019
property pAttrs : {"AIM", "Abstract", "AccentColor", "AccessDate", "Address", "AdornmentCount", "AdornmentFont", "AgentAction", "AgentCaseSensitive", "AgentPriority", "AgentQuery", "Aliases", "ArticleTitle", "Associates", "Author2", "Author3", "Author4", "Authors", "AutoFetch", "AutoFetchCommand", "Badge", "BadgeMonochrome", "BadgeSize", "Base", "BeforeVisit", "Bend", "BookTitle", "Border", "BorderBevel", "BorderColor", "BorderDash", "CallNumber", "Caption", "CaptionAlignment", "CaptionColor", "CaptionFont", "CaptionOpacity", "CaptionSize", "Checked", "ChildCount", "ChosenWord", "City", "CleanupAction", "ClusterTerms", "Color", "Color2", "Container", "Country", "Created", "Creator", "DEVONthinkGroup", "DEVONthinkLabel", "DOI", "Deck", "DescendantCount", "Direction", "DisplayExpression", "DisplayExpressionDisabled", "DisplayName", "District", "DueDate", "Edict", "EdictDisabled", "Edition", "Email", "EndDate", "EvernoteNotebook", "File", "Fill", "FillOpacity", "Flags", "FormattedAddress", "FullName", "GeocodedAddress", "GridColor", "GridColumns", "GridLabelFont", "GridLabelSize", "GridLabels", "GridOpacity", "GridRows", "HTMLBoldEnd", "HTMLBoldStart", "HTMLCloud1End", "HTMLCloud1Start", "HTMLCloud2End", "HTMLCloud2Start", "HTMLCloud3End", "HTMLCloud3Start", "HTMLCloud4End", "HTMLCloud4Start", "HTMLCloud5End", "HTMLCloud5Start", "HTMLDontExport", "HTMLEntities", "HTMLExportAfter", "HTMLExportBefore", "HTMLExportChildren", "HTMLExportCommand", "HTMLExportExtension", "HTMLExportFileName", "HTMLExportFileNameSpacer", "HTMLExportPath", "HTMLExportTemplate", "HTMLFileNameLowerCase", "HTMLFileNameMaxLength", "HTMLFirstParagraphEnd", "HTMLFirstParagraphStart", "HTMLFont", "HTMLFontSize", "HTMLImageEnd", "HTMLImageStart", "HTMLIndentedParagraphEnd", "HTMLIndentedParagraphStart", "HTMLItalicEnd", "HTMLItalicStart", "HTMLLinkExtension", "HTMLListEnd", "HTMLListItemEnd", "HTMLListItemStart", "HTMLListStart", "HTMLMarkDown", "HTMLMarkupText", "HTMLOrderedListEnd", "HTMLOrderedListItemStart", "HTMLOrderedListStart", "HTMLOrderedsListItemEnd", "HTMLOverwriteImages", "HTMLParagraphEnd", "HTMLParagraphStart", "HTMLPreviewCommand", "HTMLQuoteHTML", "HTMLStrikeEnd", "HTMLStrikeStart", "HTMLUnderlineEnd", "HTMLUnderlineStart", "Height", "HideKeyAttributes", "HoverExpression", "HoverFont", "HoverImage", "HoverOpacity", "ID", "ISBN", "ImageCount", "InboundLinkCount", "InteriorScale", "IrisAngle", "IrisRadius", "IsAdornment", "IsAlias", "IsComposite", "IsMultiple", "IsPrototype", "IsTemplate", "Issue", "Journal", "KeyAttributeDateFormat", "KeyAttributeFont", "KeyAttributeFontSize", "KeyAttributes", "LastFetched", "Latitude", "LeafBase", "LeafBend", "LeafDirection", "LeafTip", "LeftMargin", "LineSpacing", "Lock", "Longitude", "MapBackgroundAccentColor", "MapBackgroundColor", "MapBackgroundColor2", "MapBackgroundFill", "MapBackgroundFillOpacity", "MapBackgroundPattern", "MapBackgroundShadow", "MapBodyTextColor", "MapBodyTextSize", "MapScrollX", "MapScrollY", "MapTextSize", "Modified", "MyBoolean", "MyColor", "MyDate", "MyInterval", "MyList", "MyNumber", "MySet", "MyString", "NLNames", "NLOrganizations", "NLPlaces", "Name", "NameAlignment", "NameBold", "NameColor", "NameFont", "NameLeading", "NameStrike", "NeverComposite", "NoSpelling", "NoteURL", "NotesFolder", "NotesID", "NotesModified", "OnAdd", "OnJoin", "OnRemove", "OnVisit", "Opacity", "Organization", "OutboundLinkCount", "OutlineBackgroundColor", "OutlineColorSwatch", "OutlineDepth", "OutlineOrder", "OutlineTextSize", "Pages", "ParagraphSpacing", "Path", "Pattern", "PlainLinkCount", "PlotBackgroundColor", "PlotBackgroundOpacity", "PlotColor", "PlotColorList", "PostalCode", "Private", "Prototype", "PrototypeBequeathsChildren", "PrototypeHighlightColor", "PublicationCity", "PublicationYear", "Publisher", "RSSChannelTemplate", "RSSItemLimit", "RSSItemTemplate", "RawData", "ReadCount", "ReadOnly", "RefFormat", "RefKeywords", "RefType", "ReferenceRIS", "ReferenceTitle", "ReferenceURL", "Requirements", "ResetAction", "RightMargin", "Role", "Rule", "RuleDisabled", "ScrivenerID", "ScrivenerKeywords", "ScrivenerLabel", "ScrivenerLabelID", "ScrivenerNote", "ScrivenerStatus", "ScrivenerStatusID", "ScrivenerType", "Searchable", "SelectionCount", "Separator", "Shadow", "ShadowBlur", "ShadowColor", "ShadowDistance", "Shape", "ShowTitle", "SiblingOrder", "SimplenoteKey", "SimplenoteModified", "SimplenoteSync", "SimplenoteTags", "SimplenoteVersion", "SmartQuotes", "Sort", "SortAlso", "SortAlsoTransform", "SortBackward", "SortBackwardAlso", "SortTransform", "SourceCreated", "SourceModified", "SourceURL", "StartDate", "State", "Sticky", "Subtitle", "SubtitleColor", "SubtitleOpacity", "SubtitleSize", "TableExpression", "TableHeading", "Tabs", "Tags", "Telephone", "Text", "TextAlign", "TextBackgroundColor", "TextColor", "TextExportTemplate", "TextFont", "TextFontSize", "TextLength", "TextLinkCount", "TextPaneRatio", "TextPaneWidth", "TextSidebar", "TextWindowHeight", "TextWindowWidth", "TimelineAliases", "TimelineBand", "TimelineBandLabelColor", "TimelineBandLabelOpacity", "TimelineBandLabels", "TimelineColor", "TimelineDescendants", "TimelineEnd", "TimelineEndAttribute", "TimelineGridColor", "TimelineMarker", "TimelineScaleColor", "TimelineScaleColor2", "TimelineStart", "TimelineStartAttribute", "Tip", "TitleBackgroundColor", "TitleFont", "TitleForegroundColor", "TitleHeight", "TitleOpacity", "Twitter", "URL", "UUID", "User", "ViewInBrowser", "Visits", "Volume", "WatchFolder", "WebLinkCount", "WeblogPostID", "Width", "WordCount", "Xpos", "Ypos", "mt_allow_comments", "mt_allow_pings", "mt_convert_breaks", "mt_keywords"}
-- TEST ---------------------------------------------------
on run
-- List of user (vs system) attributes in front document:
tell application "Tinderbox 8"
set ks to (name of attributes of front document)
end tell
script isUserAttr
on |λ|(x)
pAttrs does not contain x
end |λ|
end script
-- set userAttribs to filter(isUserAttr, ks)
set ab to partition(isUserAttr, ks)
-- User attributes
item 1 of ab
-- Remaining (i.e. system) attributes
-- item 2 of ab
end run
-- GENERIC FUNCTIONS --------------------------------------
-- https://github.com/RobTrew/prelude-applescript
-- filter :: (a -> Bool) -> [a] -> [a]
on filter(f, xs)
tell mReturn(f)
set lst to {}
set lng to length of xs
repeat with i from 1 to lng
set v to item i of xs
if |λ|(v, i, xs) then set end of lst to v
end repeat
return lst
end tell
end filter
-- mReturn :: First-class m => (a -> b) -> m (a -> b)
on mReturn(f)
-- 2nd class handler function lifted into 1st class script wrapper.
if script is class of f then
f
else
script
property |λ| : f
end script
end if
end mReturn
-- partition :: predicate -> List -> (Matches, nonMatches)
-- partition :: (a -> Bool) -> [a] -> ([a], [a])
on partition(f, xs)
tell mReturn(f)
set ys to {}
set zs to {}
repeat with x in xs
set v to contents of x
if |λ|(v) then
set end of ys to v
else
set end of zs to v
end if
end repeat
end tell
{ys, zs}
end partition