caldwell / build-emacs

Build scripts for www.emacsformacosx.com
http://www.emacsformacosx.com/about
GNU General Public License v3.0
368 stars 62 forks source link

Spotlight bring-to-foreground feature broken in macOS Catalina #91

Closed srcreigh closed 2 years ago

srcreigh commented 4 years ago

THANK YOU for your efforts to bring emacs to macOS.

This issue is one of the first issues I ran into when upgrading to Catalina since I rely on emacs so heavily.

Someone named Chris Farber documented this problem + a workaround back in Dec 2019, so I won't rehash everything here. https://spin.atomicobject.com/2019/12/12/fixing-emacs-macos-catalina/

EDIT: I can confirm that following those steps fixed the issue for me. To reproduce:

  1. Install emacs via Homebrew brew cask install emacs this installs Emacs 26.3
  2. Upgrade to macOS Catalina. I am on version 10.15.3
  3. Open emacs via spotlight (Cmd+Space "ema" enter)
  4. Switch to a different window
  5. Fail to switch to emacs via spotlight: Cmd+Space "ema" enter but the focus does not change to Emacs window.
  6. Follow the steps in that post - give Emacs disk access, swap in the right binary, and remove the code signature
  7. Switch to emacs via spotlight: Cmd+Space "ema" enter this time the focus changes to emacs window
dougharris commented 3 years ago

This solution on the emacs StackExchange has a similar workaround https://emacs.stackexchange.com/a/54383/11315

truthdoug commented 2 years ago

I was reminded of this again today after installing the latest emacs 28 prerelease. The same steps fixed it.

As of today, I'm running MacOS 10.15.7 and installed GNU Emacs 28.0.92 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2022-03-13

caldwell commented 2 years ago

I believe this is the same issue as #84

dougharris commented 2 years ago

This continues for me with the latest (28.1-1).

With the newly installed version, I start emacs. It loads fine. If I open a file using emacsclient that works fine.

But, if I use spotlight to switch to emacs (as described in the original post on this issue), a new instance of emacs launches.

I tried shuffling the symlinks as descrbied in the emacs.stackexhange.com link above and it doesn't work with this latest version. This works worse than the stock download now. I see the app in my dock but it shows as non-responding and I have to kill it.

dougharris commented 2 years ago

And it's still here in 28.1-4. If it helps, here's what I see in /Applications/Emacs.app/Contents/MacOS after first launch:

$ ls -l
total 147656
-rwxr-xr-x@ 1 dharris  admin   4085936 May 11 15:52 Emacs*
-rwxr-xr-x@ 1 dharris  admin   7271920 May 11 15:52 Emacs-arm64-11*
-rw-r--r--@ 1 dharris  admin  15866112 May 11 15:52 Emacs-arm64-11.pdmp
-rwxr-xr-x@ 1 dharris  admin   9191280 May 11 15:52 Emacs-x86_64-10_11*
-rw-r--r--@ 1 dharris  admin  15865720 May 11 15:52 Emacs-x86_64-10_11.pdmp
-rwxr-xr-x@ 1 dharris  admin   7427120 May 11 15:52 Emacs-x86_64-10_14*
-rw-r--r--@ 1 dharris  admin  15865960 May 11 15:52 Emacs-x86_64-10_14.pdmp
lrwxr-xr-x  1 dharris  admin        16 May 11 15:52 bin@ -> bin-x86_64-10_11
drwxr-xr-x@ 6 dharris  admin       192 May 11 15:52 bin-arm64-11/
drwxr-xr-x@ 6 dharris  admin       192 May 11 15:52 bin-x86_64-10_11/
drwxr-xr-x@ 6 dharris  admin       192 May 11 15:52 bin-x86_64-10_14/
-rwxr-xr-x@ 1 dharris  admin     11272 May 11 15:52 launch.rs*
drwxr-xr-x@ 8 dharris  admin       256 May 11 15:52 lib-arm64-11/
drwxr-xr-x@ 9 dharris  admin       288 May 11 15:52 lib-x86_64-10_11/
drwxr-xr-x@ 8 dharris  admin       256 May 11 15:52 lib-x86_64-10_14/
lrwxr-xr-x  1 dharris  admin        20 May 11 15:52 libexec@ -> libexec-x86_64-10_11
drwxr-xr-x@ 5 dharris  admin       160 May 11 15:52 libexec-arm64-11/
drwxr-xr-x@ 5 dharris  admin       160 May 11 15:52 libexec-x86_64-10_11/
drwxr-xr-x@ 5 dharris  admin       160 May 11 15:52 libexec-x86_64-10_14/

Note that the symlinks are pointing to the 10_11 and not to 10_14. The aforementioned stackexchange answer still fixes this for me.

The resulting directory listing has these lines changed:

lrwxr-xr-x  1 dharris  admin        18 May 12 09:55 Emacs@ -> Emacs-x86_64-10_14
lrwxr-xr-x  1 dharris  admin        16 May 12 09:55 bin@ -> bin-x86_64-10_14
lrwxr-xr-x  1 dharris  admin        20 May 12 09:55 libexec@ -> libexec-x86_64-10_14