Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOS App should detect running emacs brew service and connect as a GUI emacsclient. #398

Closed
cwlbraa opened this issue Sep 27, 2021 · 17 comments
Assignees

Comments

@cwlbraa
Copy link

cwlbraa commented Sep 27, 2021

I love that this formula includes a brew service, and for the longest time I was running that service alongside the Emacs.App. I only recently realized that these 2 paths to invoking Emacs are unaware of each other, and the App will not attempt to connect to the daemon started by the brew service.

If this worked, it'd be amazing for startup times and keeping a single persistent Emacs daemon.

@d12frosted
Copy link
Owner

Hey @cwlbraa

I think this kind of relates to #158. That issue stagnated though.

What do you think about the following solution?

In addition to Emacs.app, emacs-plus provides extra application Emacs Client.app that is a wrapper around emacsclient. This way we don't need to come up with fancy heuristics, but instead rely on emacsclient itself that knows how to work.

The only possible issue I see - there will be no way to configure socket and server, you'll have to use defaults.

@cwlbraa
Copy link
Author

cwlbraa commented Sep 29, 2021

I'd use the simple solution if it existed, so yeah I think it's good. I'd probably hide the full Emacs.app from Alfred and end up with basically the same behavior as the fancy thing I previously described. I'd also be perfectly happy with defaults.

@shaunsingh
Copy link

Currently I use an "application" created via automator that runs emacsclient -c, its been working great for me so far

The solution you propose seems about the same, having it included with emacs-plus would be very nice

@C1oud555
Copy link

It would be great to have the Emacs Client.app.

@diocletiann
Copy link

I'm having trouble finding Emacs Client.app, do you have to install with a specific flag? Thanks.

@d12frosted
Copy link
Owner

@restfuladi you can't find it because it doesn't exist :) But there is emacsclient binary installed that you can use for your needs.

@diocletiann
Copy link

@restfuladi you can't find it because it doesn't exist :) But there is emacsclient binary installed that you can use for your needs.

Makes sense, thanks. Any ideas on how to integrate that with Spotlight/Alfred?

@gf3
Copy link

gf3 commented May 12, 2022

@restfuladi Spotlight/Alfred have issues with symlinks, however Raycast works really well!

@mjgiffin
Copy link

@restfuladi you can't find it because it doesn't exist :) But there is emacsclient binary installed that you can use for your needs.

Makes sense, thanks. Any ideas on how to integrate that with Spotlight/Alfred?

If you create an Automator application for emacs client and put it in /Applications, that should work with Spotlight. I recommend full path:
/opt/homebrew/bin/emacsclient -c -a emacs "$@" >/dev/null 2>&1

@rross101
Copy link

Piggy-backing on this issue, happy to make another one - when I launch emacsclient from terminal or Alfred, it doesn't switch to the app - the window opens behind other windows, and then I have to manually switch to it. Has anyone a fix for that?

@ChauhanT
Copy link

ChauhanT commented Dec 2, 2022

Hi, I think Emacsclient.app is a fantastic idea. Is this something that will become available in the homebrew installation? I am new to macos (coming from linux), and I have very little experience doing mac-y things. I also observed what @rross101 said. It's a minor inconvenience, but of course, if it can be addressed it's even better.

Software architecture of the mac is so, so inefficient. It's like homebrew is creating an OS within an OS, and obviously there are no standards like XDG or how permissions are managed etc. I can't even get my brew-installed hunspell to integrate with emacs-plus. Sorry for the rant, but macos is just such a user unfriendly environment to work in if you are trying to something even remotely technical.

@d12frosted
Copy link
Owner

Hi, I think Emacsclient.app is a fantastic idea. Is this something that will become available in the homebrew installation?

The idea is to provide this as part of Emacs+ installation. But it's not high on my priority list. So if someone really wants it, contributions are welcome.

Software architecture of the mac is so, so inefficient. It's like homebrew is creating an OS within an OS, and obviously there are no standards like XDG or how permissions are managed etc.

Indeed, macOS is slightly (quite?) different in many regards and might be confusing if you come from newer Linux-es. macOS is based on older FreeBSD.

I can't even get my brew-installed hunspell to integrate with emacs-plus. Sorry for the rant, but macos is just such a user unfriendly environment to work in if you are trying to something even remotely technical.

Look, if you need some help, don't hesitate to open a discussion. The problem you describe is not really related to Emacs+, but it's somewhere on the border, so maybe it's fine :)

@citizen428
Copy link

citizen428 commented Dec 28, 2022

@ChauhanT This is what I did:

  1. Start the emacs-plus service and register it to launch on login/boot:
    brew services start emacs-plus@29
  2. Create an "application" with Automator:
    Screenshot 2022-12-28 at 16 14 28
  3. If you want, change the app icon (Right click -> "Get info" or Cmd-i). I used the same I compile emacs-plus with, nobu417-big-sur-icon:
    Screenshot 2022-12-28 at 16 17 49

@rross101 You could use Apple Script for that: osascript -e 'tell application "Emacs" to activate' You can wrap that up in aliases or shell functions, e.g.

function ec() {
  emacsclient $@ && osascript -e 'tell application "Emacs" to activate'
}

@johnhamelink
Copy link

johnhamelink commented Apr 10, 2023

I found I had to tweak @citizen428's answer a little bit to get the applescript to work reliably:

Screenshot 2023-04-10 at 20 33 57

@rross101
Copy link

I found I had to tweak @citizen428's answer a little bit to get the applescript to work reliably:

Screenshot 2023-04-10 at 20 33 57

This works for me. Thank you!

@GauravTalreja
Copy link

I changed it to following to set Emacs Client as the default text editor:

image

@michaelssingh
Copy link

I just checked quickly and noticed that these Automator scripts do not launch emacs when the server is not running. Has anyone else encountered this?

Repository owner locked and limited conversation to collaborators Aug 25, 2024
@d12frosted d12frosted converted this issue into discussion #716 Aug 25, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests