8

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 running, it cannot any longer. For example, double clicking the file on Finder window does nothing; no error message, either.

Opening a file from Emacs GUI causes no problem. Drag-ang-drop'ing a file onto Emacs also works fine.

  • I suggest you take a look (within Emacs) at C-h l after such "failed" operations to see if Emacs received some event at all. If not, the problem likely can't be solved on Emacs's side and you should post your question elsewhere. – Stefan Oct 20 '19 at 14:11
  • You're right. Looks like Emacs doesn't get any event call. But, is it not Emacs issue? I thought it's a matter of building Emacs. (By the way, I installed Emacs with Homebrew). Where would it suit better? Homebrew? – Masso Chailly Oct 21 '19 at 4:04
  • sorry, but my outlook on this is along the lines of "why don't you upgrade to GNU/Linux?", which probably won't help you very much. You can file a bug report with M-x report-emacs-bug. – Stefan Oct 21 '19 at 13:06
  • I see. Thanks for your remarks and suggestions anyhow. – Masso Chailly Oct 22 '19 at 6:22
  • I thought this answer would be responsive, but I tried the steps and it didn't work. – HaPsantran Nov 25 '19 at 16:07
1

This is the current solution that I came out with: use emacsclient and wrap it in an application.

First, put this line in ~/.emacs:

(server-start)

Create this bash script:

if ! pgrep Emacs; then
    open -a Emacs.app
    sleep 1
fi
for f in "$@"
do
    /usr/local/bin/emacsclient -c -n "$f"
done

Note: Make sure that your emacsclient path is correct.

Then create a wrapper application using this method: https://superuser.com/a/239235

But remember to change Shell to /bin/bash.

| improve this answer | |
  • Thanks for the temporary solution, which unfortunately is a bit limited in my workflow. I hope the ultimate solution comes soon with the next release of Eamcs. – Masso Chailly Oct 28 '19 at 0:04
  • @MassoChailly With the wrapper application, you can double click multiple files in Finder to Open all of them in Emacs, just like how it used to work. – Lawrence Oct 30 '19 at 2:45
  • Oh, right! Thanks! – Masso Chailly Oct 31 '19 at 6:56
  • Thanks, this looks helpful, and I've created both the shell script (exactly as above after confirming emacsclient path) and the automator script (exactly as the growl example but using the path of the aforementioned bash script instead), but it's unclear to me how running emacs myfile.py from the command line invokes the automator script. Can you please clarify? – HaPsantran Apr 22 at 11:30
  • @HaPsantran This method creates a graphical application, say XXX.app. From the command line, you could perform open -a XXX myfile.py – Lawrence Apr 24 at 8:51
6

If your Emacs is downloaded from https://emacsformacosx.com/, Emacs.app launches a binary Emacs.app/Contents/MacOS/Emacs-x86_64-10_14 via a ruby script Emacs.app/Contents/MacOS/Emacs. Modify Emacs.app to launch a binary directly with the following in terminal.

cd /Applications/Emacs.app/Contents/MacOS
mv Emacs Emacs-orig
ln -s Emacs-x86_64-10_9 Emacs
rm bin
ln -s bin-x86_64-10_9 bin
rm libexec
ln -s libexec-x86_64-10_9 libexec

Edit by Masso: Emacs-x86_64-10_14 breaks forward search (from Emacs to Skim) on macOS 10.15 (Catalina). So I have changed the version numbers above to 10_9 (instead of 10_14 that was originally suggested by Akira). Edit by acr: the rm'd directory should be libexec.

| improve this answer | |
  • * I wanted to add a comment for Akira Kitauchi, but I don't have enough (50) reputations to do it. Hence I put it here. Akira's solution is interesting and does work for me. However, the so-called "forward search" from Emacs (working with a LaTeX file) to Skim (v1.5.5) breaks down. Backward search from Skim to Emacs works fine. Any idea? Edit: Even more interesting! I switched symbolic links to x86_64_10_9 versions (rather than x86_64_10_14 versions as Akira originally suggested). Then both forward and backward search work well. Curiously, what are the differences between the different version – Masso Chailly Dec 18 '19 at 8:11
  • @MassoChailly The different versions are built for different versions of macOS, so if you're on macOS 10.14 (Mojave) or above then you want to use the _10_14 one. macOS 10.9 to 10.13 then _10_9, and so on. Although, to be honest, I wouldn't expect search to break. – Alan Third Jan 22 at 19:58
  • 1
    Hm...this "worked" for me, in the sense that everything behaves as expected using the Catalina "open" command (or the finder). However, now using emacs from inside a terminal window seems broken. – acr Feb 14 at 22:35
  • I also had to use a lower ending number, *_10 in my case, instead of a higher *_14 to get things to work, even when I was on Catalina – Paul Sep 2 at 1:10
1

There is an error when trying to open another file from Finder when Emacs.app is already running. This erorr is reported in Console:

LaunchedApplication: failed with error -13052 (null){ "ApplicationType"="Foreground", "BundleIdentifierLowerCase"="org.gnu.emacs", "CFBundleExecutablePath"="/Applications/Emacs.app/Contents/MacOS/Emacs", "CFBundleExecutablePathDeviceID"=16777220, "CFBundleExecutablePathINode"=8621172431, "CFBundleIdentifier"="org.gnu.Emacs", "CFBundleName"="Emacs", "CFBundlePackageType"="APPL", "CFBundleSignature"="EMAx", "LSASN"=ASN:0x0-0x49b49b:, "LSBundlePath"="/Applications/Emacs.app", "LSBundlePathDeviceID"=16777220, "LSBundlePathINode"=8621172365, "LSDisplayName"="Emacs", "LSExecutableFormat"="LSExecutable#!Format", "LSLaunchDLabel"="org.gnu.Emacs.5196", "LSLaunchedByLaunchServices"=true, "LSLaunchedWithLaunchD"=true, "LSLaunchEventRecordTime"=154695413870065, "LSLaunchTime"=now-ish 2019/10/24 09:37:28, "LSParentASN"=ASN:0x0-0x2d02d:, "LSWantsToComeForwardAtRegistrationTimeKey"=true, "pid"=50395 }

| improve this answer | |
  • Can something more be said about this error? Does this correspond to the case of OP's question (where it's said that there's no error message)? – Drew Oct 24 '19 at 2:00
  • Yes, this corresponds to OP's scenario. No error message; nothing happens. But there is an error log shown in Console. – Lawrence Oct 24 '19 at 9:35
  • I see the same thing in the Console. Is this a Catalina bug that we expect to be fixed or is it an incompatibility we expect Emacs to fix? – HaPsantran Nov 25 '19 at 23:03
0

This ultimately worked for me, as explained in this possibly redundant post I made.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.