Since the upgrade to macOS Catalina, I’ve had two serious annoyances with Emacs. Here’s a little insight into how I fixed them.
Issue 1: I Couldn’t Access Certain Folders
You can use a OSX GUI Emacs in the form of Aquamacs which is configured to be more OSX like it its key commands and menus and integrates with the OS. One appeal of emacs is because emacs is mainly written in the language (e-lisp) that users can use to extend it there are a lot of scripts that add all sorts of functionality to the editor making it nearly as powerful as an ide. Here are some tips and tricks on setting up Emacs.app on Mac OS X. These are based on my personal experience of using Emacs.app for the past 10 years or so; there may be better ways, but these work for me. Running Emacs.app from the command line. Call this script 'emacs' and put it somewhere in your PATH (/bin or /usr/local/bin): Using emacsclient. After upgrading to macOS Catalina, Emacs (v26.3 from GNU Emacs for Mac OS X) works very strange. Without Emacs already running, Finder can open a file with Emacs as usual. But once Emacs.app is run.
After the upgrade, Emacs was unable to access special folders, like the Documents folder. This is a ramification of the User Data Protection enhancements that were made in Catalina.
Here’s the gist of why this exists: In a previous version, macOS started displaying user prompts (similar to iOS) to grant application permission for accessing things like contacts, photos, location, etc. These prompts were displayed when using special APIs designated for those purposes.
Alas, there was an easy way to bypass these prompts. Rather than using APIs to, say, access your contacts, you could just read the contact database via the filesystem. Catalina now enforces these permissions at the filesystem APIs, as well. This means that, because it doesn’t even ask for permission, Emacs is simply forbidden from accessing certain files.
Top Hat’s lecture recording capabilities highlight your slides, class discussions and participation as they occurred in real time.
Apple did provide an escape hatch: Full Disk Access. You, the user, can provide this privilege to an application, and it is allowed to access all files that your user would otherwise be able to access. It’s pretty easy: Go to the Security section of System Preferences, find Full Disk Access in the list, and then add Emacs:
But…this solution didn’t work. After doing this, I still couldn’t access my documents folder. Solving this is directly related to the second issue that’s been nagging me since the upgrade to Catalina.
Issue 2: Spotlight Can’t Bring Emacs to the FrontEmacs On Mac Os X
I commonly switch between applications on macOS by pressing
cmd-space to bring up Spotlight, then the first few letters of the application name, and finally return. It’s often quicker than finding the icon via cmd-tab . Unfortunately, this method stopped working, too.
As it turns out, the binary embedded in Emacs.app is…actually not a binary. Instead, it’s a Ruby script. From the script:
Although this never caused problems on prior versions of macOS, here, it is responsible for both of these issues:
The Solution
On Catalina, the Ruby script will always choose to launch the bundled binary
Emacs-x86_64-10_14 . So, if you simply move it in place of the Emacs launcher script, everything starts working as normal. At the Terminal, just run these commands:
And, with that, Emacs should correctly receive its Full Disk Access permission, and Spotlight will correctly bring it to front (n.b., it’s still required to add Emacs to the Full Disk Access section of the security system preferences).
Note that, because we have been performing surgery on the Emacs app, its code signature is no longer valid. The last command above removes the code signature from the Emacs binary. On my machines, I had no issues. If you can’t launch Emacs after running these commands, try following the steps in this document from Apple.
Conclusion
One final caveat: This works for me using homebrew-cask-installed Emacs version 26.3. In future versions of Emacs, it’s possible that the correct binary might be something other than
Emacs-x86_64-10_14 .
If you’ve been plagued by these problems, I hope this post helped.
Here are some tips and tricks on setting up Emacs.app on Mac OS X. Theseare based on my personal experience of using Emacs.app for the past 10 yearsor so; there may be better ways, but these work for me.
Running Emacs.app from the command line
Call this script 'emacs' and put it somewhere in your PATH (~/bin or /usr/local/bin):
Using emacsclient
Using Emacs as the mergetool for git
Add add this snippet to your .gitconfig:
If you want to use emacsclient, add this snippet instead:
Mac app that converts pictures in audio. This version only has one female voice; the paid version has more voice choices and the option of saving the converted text as MP3, WAV, WMA and other audio file types. This software allows you to control the reading speed and lets you customize the voices.
Changing the Modifier KeysEasy
The easiest way is to use the Customize interface: 'M-x customize-group RET ns RET'.
Hard
If you don't like Customize and want to do it manually, the following variables control the modifier keys:
Each variable can be set to 'control, 'meta, 'alt, 'super, or 'hyper.
Emacs Mac Os X
In addition ns-alternative-modifier (and ns-option-modifier) can be setto 'none, which lets it get interpreted by the OS so it can be used toinput special characters.
The ns-right-* variables are set to 'left by default which makes them thesame as their left counterpart.
Macbook EmacsVerifying the Binary Integrity
This site serves the binaries via SSL and while the binaries are not GPG signed, the application is code signed. You can verify the signature like this:
Or, if you haven't installed emacs yet, but have mounted the disk image:
Mac Os Emacs
Look for the following in the output:
'Galvanix' is my consulting partnership and is what I registered my Apple developer account under. If you see that, the binary is intact.
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2020
Categories |