Repository navigation
Conversation
On modern macOS `osacompile -r scpt:128 -t osas` produces empty or corrupt files, so osascript fails with "script error -1758" and app detection breaks. Bind default-directory around the existence guard so it stops recompiling on every call, drop the obsolete flags, and remove any stale output file before recompiling.
|
FYI, I was having the same problem. I applied this fix and it worked for me, but I had to remove the compiled script files after restarting Emacs with the patched version and restart again (just to have a clean slate. Could be my configuration, but it appears to be working fine again now. |
|
@mbarton98 I updated the PR to cover the case you reported: helper setup now checks whether existing scripts can actually be read, rather than only checking whether the files exist. With the updated code loaded, the next invocation automatically regenerates unreadable helpers, without manually deleting them. Compilation errors are now reported explicitly, and an existing helper is preserved if its replacement fails to compile. The regression tests cover existing corrupt files, legacy resource-fork scripts, and compiler failures. All seven tests pass on macOS 26.5.1 with Emacs 31.0.91. |
Problem
The macOS AppleScript helpers (
app-name,window-geometry,window-title) can remain unreadable, causingosascriptto report error-1758instead of returning application and window information.Closes #112.
The existing compilation used legacy resource-fork options, checked for files relative to the caller's directory, and could retain obsolete resource-fork data when overwriting an output. The original fix also skipped regeneration when all three files existed, even if they were corrupt. This explains why an existing installation could still require manual deletion of the helpers.
Change
osadecompile, so unreadable files are regenerated automatically.Valid helpers are reused unless forced regeneration is requested. Readability checks add three
osadecompilecalls when all cached helpers are valid.Validation
Seven ERT tests passed on macOS 26.5.1 with Emacs 31.0.91:
osacompilesyntax error: failure reported and the existing helper preserved.emacs --batch -Q -L . -l test/emacs-everywhere-test.el -f ert-run-tests-batch-and-exitByte compilation also completed; it reported warnings in existing code outside this change. Other macOS versions have not been tested in this update.