louabill / ado-mode

Major mode for editing Stata files in Emacs
GNU General Public License v3.0
17 stars 6 forks source link

sending code to Stata under Big Sur (macOS 11) #12

Open louabill opened 3 years ago

louabill commented 3 years ago

Please let me know if you start getting a dialog box popping up when you try to send code to Stata when using Big Sur.

TLDR: I started seeing this behavior after updating my Aquamacs Emacs to the 3.6 beta from Jun 7, 2021. After a bunch of fighting, I found that the 'ui elements enabled' applescript boolean seems to be set to false, even if it is possible for Emacs to send things to other apps. If I bypassed the check for 'ui elements enabled', there were no problems, but this clearly is not a real solution. I have not pushed this version, because that seems a bit dangerous, but if others need it, I'll push it with a caveat.

git-girl commented 2 years ago

hey, i just installed ado-mode and am new to Emacs, so I'm not sure if i have the same issue.

I'm on MacOS Catalina, and sending code to Stata opened System Preferences. The first time it asked me to allow emacs rights to access system events, which i did after which still system Preferences were opened.

After trying to understand a bit whats going on i enabled Emacs in the Accessibility Tab. Before osascript -e 'tell application "System Events" to get UI elements enabled' returned false, now it returns true. I'm a bit unsure if this is a good solution, and is what you are describing here.

louabill commented 2 years ago

I'll have to play with it some more, as the original problem was one of never being notified and the code-sending failing silently.

Thanks for the tip; I'll play around with it some next week.

marcklemp commented 1 year ago

Any more information on this? After upgrading to Emacs 30.0.50 on MacOS version 13.2 I have this problem, i.e., System Preferences opens when I try to send code to Stata. The pane selected in System Preferences is also irrelevant as it is the Appearance pane. The relevant permissions are given in the Privacy & Security -> Automation settings.

louabill commented 1 year ago

I've been a bit out of the loop (hospice care for a relative)... I'll try to look at this at some point.

louabill commented 1 week ago

Still shakin' the bush, boss... trying to figure out how to reproduce the problem

louabill commented 21 hours ago

Life seems to be confusing, at least under macOS 13 (Ventura), esp. with the new (imho awful) way that the System Preferences morphed into the incomprehensible System Settings.

The problem has to do with how the settings are working in the Accessibility and Automation parts of the Privacy & Security pane. So, say you install a new version of Emacs or a new version of Aquamacs Emacs. These will not be able to send code, though they will say that the code has been sent to Stata. Suppose that the first time you try to send code to Stata, you push the return key instead of clicking on the OK button. When you go to send to Stata again, Emacs will once again think you sent the code.

The solution, at least as far as I could find, is to reset the tcc (Transparency, Consent, and Control) database with regards to Emacs or Aquamacs Emacs. To do this by hand, open up a Terminal window. If you are using Emacs, put in the following command

tccutil reset All org.gnu.Emacs

If you are using Aquamacs Emacs, put in the following command

tccutil reset All org.gnu.Aquamacs

After you do this, when you try to send code to Stata, you should get the proper dialogs for you to get things to work.

If this still doesn't work, and instead the System Settings opens to the Accessibility tob of the Privacy & Security pane, click on the toggle next to System Events, even if it appears to be turned on. Then close the System Settings, and start the circus, again. (This is kind of similar to what @git-girl mentioned, above, except that you should click on it even if it looks to be enabled.)

If you have multiple versions of Emacs, it sometimes works to zip up all but one of them, get things working, and then unzip the others. Aquamacs Emacs and Emacs can peacefully coexist, because of the different code signatures above.

I'll try to do more about this programatically, but since I don't have any machines (virtual or actual) to test on any other versions of macOS than Ventura.