Skip to content

Have the option to run emacs as --daemon in brew services #697

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

Closed
MuhmdRaouf opened this issue Jul 4, 2024 · 11 comments
Closed

Have the option to run emacs as --daemon in brew services #697

MuhmdRaouf opened this issue Jul 4, 2024 · 11 comments
Labels
feature request help needed This feature/issue is unlikely to be addressed by maintainers. So PR is needed.

Comments

@MuhmdRaouf
Copy link

Feature request description

Hello, I have installed Emacs and enabled brew services as well,
then realized that in /opt/homebrew/Cellar/emacs-plus@29/29.4/homebrew.mxcl.emacs-plus@29.plist it work as
--fg-daemon
can we add a flag while build to give us the ability to make it run as --daemon/--bg-daemon, as after I have change it and restart the service emacs loading became much faster (using doom emacs)

credit to the idea came from this comment in this gist
https://gist.github.com/redinger/1394910?permalink_comment_id=5001180#gistcomment-5001180

@d12frosted
Copy link
Owner

Hey @MuhmdRaouf,

I am not using Emacs as daemon/service. But I am completely open to the idea of making this work out of the box. But someone who cares needs to figure things out and prepare a PR 😸

A few random thoughts:

  1. Would be nice to avoid using any install flags. Installation should support two ways of starting Emacs without reinstalling it.
  2. Brew provides command/capabilities for running services, maybe it can be used.
  3. Would be nice to provide Emacs Client.app out of the box or make Emacs.app act as a client when service is running.

So please, if someone cares about daemon mode - chime in, figure things out and send a PR :)

@d12frosted d12frosted added feature request help needed This feature/issue is unlikely to be addressed by maintainers. So PR is needed. labels Aug 25, 2024
@d12frosted
Copy link
Owner

@MuhmdRaouf can you explain me why you need bg specifically? fg works and to my understanding, it is required if we want to stop the server whenever we stop the service.

In any case, I hope client users would find this useful - #783

@MuhmdRaouf
Copy link
Author

@d12frosted tbh I am new to Emacs and still learning, so what I wanted might work without the need for fg/bg

I wanted to run Emacs as a server (that's why I said bg) and connect to it via client, which will help me to avoid accidental close, or just close emacs client for now, but I wanna get back to the same point I left, and faster loading after the first time.

let me know if what make sense and what I asked for is reasonable

@d12frosted
Copy link
Owner

So it always worked :)

Just run brew services start emacs-plus@30 and then you can use emacsclient. Just make sure you are not using TCP (i.e. server-use-tcp is nil and EMACS_SERVER_FILE env var is not set).

@glucas
Copy link

glucas commented Feb 28, 2025

brew services start emacs-plus@30

This gives me the following:

Error: Formula emacs-plus@30 has not implemented #plist, #service or installed a locatable service file

@d12frosted
Copy link
Owner

@glucas

  1. did you tap emacs+ formula?
  2. what version of brew core are you using? i.e. share brew config
  3. what commit of emacs+ are you on? i.e. share cd $(brew --repository)/Library/Taps/d12frosted/homebrew-emacs-plus && git log -1

@glucas
Copy link

glucas commented Mar 1, 2025

I think everything is up to date. I had just done some cleanup and updates before installing v30.

> brew config
HOMEBREW_VERSION: 4.4.22
ORIGIN: https://github.com/Homebrew/brew
HEAD: 89d1d6b8f4adb0b8f6678912f648dca2475b7c7c
Last commit: 5 days ago
Branch: stable
Core tap JSON: 28 Feb 23:10 UTC
Core cask tap JSON: 28 Feb 23:10 UTC
...


> cd $(brew --repository)/Library/Taps/d12frosted/homebrew-emacs-plus && git log -1
commit 54556379f8909905f3338f30336b62bbd7812c1b (HEAD -> master, origin/master, origin/HEAD)
Author: Jimmy Rimmer <122916731+jrimmer-bendhealth@users.noreply.github.com>
Date:   Thu Feb 27 10:56:37 2025 -0800

    Update README for v30 (#798)

@glucas
Copy link

glucas commented Mar 1, 2025

Here's what I see:

~ $  brew doctor
Your system is ready to brew.

~ $  brew info emacs-plus
==> d12frosted/emacs-plus/emacs-plus@30: stable 30.1, HEAD
GNU Emacs text editor
https://www.gnu.org/software/emacs/
Installed
/usr/local/Cellar/emacs-plus@30/30.1 (7,467 files, 508.5MB) *
  Built from source on 2025-02-28 at 15:30:26
From: https://github.com/d12frosted/homebrew-emacs-plus/blob/HEAD/Formula/emacs-plus@30.rb
==> Dependencies
Build: make ✔, autoconf ✔, gnu-sed ✔, gnu-tar ✔, grep ✔, awk ✔, coreutils ✔, pkg-config ✔, texinfo ✔, xz ✔, m4 ✔, sqlite ✔, gmp ✔, libjpeg ✔, zlib ✔
Required: gnutls ✔, librsvg ✔, little-cms2 ✔, tree-sitter ✔, webp ✔, libgccjit ✔, gcc ✔
Optional: imagemagick ✘, dbus ✘, mailutils ✘
==> Options
...
==> Caveats
Emacs.app was installed to:
  /usr/local/opt/emacs-plus@30

To link the application to default Homebrew App location:
  osascript -e 'tell application "Finder" to make alias file to posix file "/usr/local/opt/emacs-plus@30/Emacs.app" at posix file "/Applications" with properties {name:"Emacs.app"}'

Your PATH value was injected into Emacs.app/Contents/Info.plist

Report any issues to https://github.com/d12frosted/homebrew-emacs-plus

To start d12frosted/emacs-plus/emacs-plus@30 now and restart at login:
  brew services start d12frosted/emacs-plus/emacs-plus@30
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/emacs-plus@30/bin/emacs --fg-daemon

~ $  brew services start d12frosted/emacs-plus/emacs-plus@30
Error: Formula `emacs-plus@30` has not implemented #plist, #service or installed a locatable service file

@d12frosted
Copy link
Owner

Can you try tapping emacs+ (as per first point in my previous message)?

Although the message is strange 🤷

@glucas
Copy link

glucas commented Mar 1, 2025

Can you try tapping emacs+ (as per first point in my previous message)?

Seems to be tapped, I've tried tapping again.

Thanks for the feedback though! I see it's working for others so I will dig a bit more. Right now I'm uninstalling 29 and 30 to try again clean.

@glucas
Copy link

glucas commented Mar 1, 2025

Right now I'm uninstalling 29 and 30 to try again clean.

Well.. no idea why, but it works fine after re-installing. Thanks again (for the feedback and the great project).

~ $  brew services start d12frosted/emacs-plus/emacs-plus@30
==> Successfully started `emacs-plus@30` (label: homebrew.mxcl.emacs-plus@30)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request help needed This feature/issue is unlikely to be addressed by maintainers. So PR is needed.
Projects
None yet
Development

No branches or pull requests

3 participants