From the “Learn AppleScript: The Comprehensive Guide to Scripting and Automation on Mac OS X” book by Hamish Sanderson, Hanaan Rosentha et al.:
An especially useful tip provided by AppleScript engineer Christopher Nebel is to change the style for application keywords so that they are underlined. This will also underline any spaces within keywords, making it easy to see where each keyword begins and ends; for example, path to startup disk
will appear as <u>path to</u> <u>startup disk</u>. To do this, go to the Formatting panel and use Shift-click to select all the application-related keyword styles (Application keywords, Command names, Parameter names, etc). Next, select Font > Show Fonts to bring up the Fonts palette. Click the pop-up menu in the top-left corner of the Fonts palette and select the Single underline style.
Could someone tell which other styles, that is, the styles apart of these three, are supposed to be underlined according to that recommendation?
1. New text (uncompiled)
2. Operators, etc. (+&,)
3. Language keywords
+ 4. Application keywords
5. Comments
6. Values (numbers, data)
7. Variables and subroutine names
8. Strings
+ 9. Command names
+ 10. Parameter names
11. Classes
12. Properties
13. Enumerated values
14. Addition command names
15. Addition parameter names
16. Addition classes
17. Addition properties
18. Addition enumerated values
That is handy for multiple-word terms, but for me it adds a bit of clutter for everything else. You can set the font, style, and color for any of those categories however you want, but the path to
items are from Scripting Additions, which would be the “Addition” categories.
1 Like
I agree, this can add clutter. But nevertheless, could you tell which styles are assumed to be changed?
I can describe how to detect which lexical element has underline. I don’t know about underline is good or bad. I never use underlined setting with Script Editor.
We can detect each element’s lexical style by reading ~/Library/Preferences/com.apple.applescript.plist file.
Each style data are parsed into NSAttributedString.
You can detect which lexical element has underline.
In this year, I wrote a book including the code how to parse each AppleScript lexical element from plist.
https://piyomarusoft.booth.pm/items/6521562
I don’t think that there was a particular set of categories in mind, the example just mentioned terms that have spaces. Like a lot of settings, this can vary, for example missing value
is in the “Classes” category, but that also includes stuff like integer
and list
. The “Properties” category would seem to be a decent choice, as there are several of those with spaces such as POSIX path
, but then other items like name
and contents
get included.
There isn’t anything in that setting specific to what the terms actually are (such as those with spaces), it just sets the font and attributes for everything that is in a particular category. I use a single font, group by color, and add bold/italic within a group, but this is another one of those things that is just a personal preference.
1 Like