caldwell / build-emacs

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

Can't sem to open more than one file on macOS Catalina 10.15.7 with emacs: stable 27.1 (bottled) #101

Open pecastro opened 3 years ago

pecastro commented 3 years ago

Opening the first file via finder works fine, but as soon as I try opening a second file nothing happens. Console log reports

LaunchedApplication: failed with error -13052 (null){ "ApplicationType"="Foreground", "BundleIdentifierLowerCase"="org.gnu.emacs", "CFBundleExecutablePath"="/Applications/Emacs.app/Contents/MacOS/Emacs", "CFBundleExecutablePathDeviceID"=16777220, "CFBundleExecutablePathINode"=254038, "CFBundleIdentifier"="org.gnu.Emacs", "CFBundleName"="Emacs", "CFBundlePackageType"="APPL", "CFBundleSignature"="EMAx", "LSASN"=ASN:0x0-0x57c57c:, "LSBundlePath"="/Applications/Emacs.app", "LSBundlePathDeviceID"=16777220, "LSBundlePathINode"=253999, "LSDisplayName"="Emacs", "LSExecutableFormat"="LSExecutable#!Format", "LSLaunchDLabel"="org.gnu.Emacs.1308", "LSLaunchedByLaunchServices"=true, "LSLaunchedWithLaunchD"=true, "LSLaunchEventRecordTime"=510943459928231, "LSLaunchTime"=now-ish 2020/12/03 17:51:48, "LSParentASN"=ASN:0x0-0x12a12a:, "LSWantsToComeForwardAtRegistrationTimeKey"=true, "pid"=98401 }
Skeeve commented 2 years ago

Same happens for me.

How to reproduce: Open emacs however you want.

Then try this:

What does NOT work and fails with above mentioned Error is:

open -a Emacs path/to/a/file.txt

What DOES work, but opens a completely new emacs instance and not a new buffer:

/Applications/Emacs.app/Contents/MacOS/Emacs path/to/a/file.txt

What I'd like to see is, when emacs is already open:

Skeeve commented 2 years ago

A small workaround AppleScript droplet:

on open (a_document)
    tell application "Emacs"
        activate
        try
            open a_document
        end try
    end tell
end open

on run
    tell application "Emacs" to activate
end run

This will open a new window in a new or already the running instance of emacs containing the dropped document.

pecastro commented 2 years ago

A small workaround AppleScript droplet:

on open (a_document)
  tell application "Emacs"
      activate
      try
          open a_document
      end try
  end tell
end open

on run
  tell application "Emacs" to activate
end run

This will open a new window in a new or already the running instance of emacs containing the dropped document.

Couldn't seem to be able to make that work. Created an Automator app based on that script and associated the file type to it and still nothing.

Skeeve commented 2 years ago

I have no clue about automator. Never used it, or, t.b.h., tried once but found it rather complicated.

Maybe you simply open the Scripteditor, paste the source code in and save it as an App.

I tried it just now and it worked.

pecastro commented 2 years ago

Wicked. Made my day! :+1:

caldwell commented 2 years ago

The native emacs way of doing this is to M-x server-start and then use emacsclient (included in Emacs.app/Contents/MacOS/bin/emacsclient).

Skeeve commented 2 years ago

That doesn't help @caldwell and is in no way a fix to the issue.

caldwell commented 2 years ago

It's not really a build issue in the first place. If you feel it's an emacs bug, report it the Emacs maintainers with M-x report-emacs-bug. And yes, it does help, it's how I interact with emacs all day and it works fine…

pecastro commented 2 years ago

How do you double-click that second file which you configured to open with Emacs via your Finder ?!

That said my latest install of Emacs (GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95) of 2020-08-12 in a new Mac macOS Big Sur v11.6.4 doesn't seem to exhibit the same issue anymore.

caldwell commented 2 years ago

How do you double-click that second file which you configured to open with Emacs via your Finder ?!

Hmm—that just works for me… Maybe I'm misunderstanding the issue here—the apple script work arounds made me think this was an issue of opening from the terminal and not double clicking documents in Finder. Apologies.

Looking closer at your error, it might actually be the same as #84 (and #94). That actually has a fix in the latest nightly 2022-04-05. Would you mind trying that version and seeing if it fixes this issue, too?

Skeeve commented 2 years ago

I gave the open example in order to show how it's not working. The open, afaik is the same thing Finder does when double clicking.

Skeeve commented 2 years ago

Would you mind trying that version and seeing if it fixes this issue, too?

It doesn't run on my Mac 10.15.7.

image
caldwell commented 2 years ago

Sigh. I can reproduce that locally. I have no idea why it thinks it needs macOS 12.

caldwell commented 2 years ago

I figured it out and have built a new middle of the day nightly. Would it be possible for you to try it?

Skeeve commented 2 years ago

I tried it. It runs. But the effect is the same. The first file I open with a double click opens a new *GNU Emacs* window and an additional window with the clicked file. The second file opens nothing new.

When I open Emacs first and then double click a file, I get an additional *GNU Emacs* window and the additional window with the file. So I have three windows now. For the second file I double click, no window opens.

caldwell commented 2 years ago

I'm having trouble duplicating this—when I double click on files associated with Emacs it always opens a new window with a buffer visiting that file (same with open -a Emacs)

Are you still getting that error from the initial bug report in the console?

Does it make a difference what directory the file you are opening is stored in? ~/Documents vs ~/Downloads vs ~/Desktop vs ~/some-non-apple-create-dir?

Skeeve commented 2 years ago
fehler  07:11:58.915808+0200    Finder  LaunchedApplication: failed with error -13052 (null){ "ApplicationType"="Foreground", "BundleIdentifierLowerCase"="org.gnu.emacs", "CFBundleExecutablePath"="/Users/shk/Applications/Emacs.app/Contents/MacOS/Emacs", "CFBundleExecutablePathDeviceID"=16777221, "CFBundleExecutablePathINode"=85632700, "CFBundleIdentifier"="org.gnu.Emacs", "CFBundleName"="Emacs", "CFBundlePackageType"="APPL", "CFBundleSignature"="EMAx", "LSASN"=ASN:0x0-0x148f48e:, "LSBundlePath"="/Users/shk/Applications/Emacs.app", "LSBundlePathDeviceID"=16777221, "LSBundlePathINode"=85632672, "LSDisplayName"="Emacs", "LSExecutableFormat"="LSExecutableMachOFormat", "LSLaunchDLabel"="org.gnu.Emacs.40428", "LSLaunchedByLaunchServices"=true, "LSLaunchedWithLaunchD"=true, "LSLaunchEventRecordTime"=916954221476391, "LSLaunchTime"=now-ish 2022/04/06 07:11:58, "LSParentASN"=ASN:0x0-0x33033:, "LSWantsToComeForwardAtRegistrationTimeKey"=true, "pid"=77489 }

It makes no difference where the file is and it makes no difference where Emacs is. Note: I have it in ~/Applications, not in /Applications, but that doesn't change anything.

Skeeve commented 2 years ago

I'm wondering whether or not it could be an option to use AppleScript as the launcher instead of rust?

P.S. I'm willing to help in coding AppleScript. But I need to understand what exactly the launcher does. I don't know rust and so I only understand parts.