homebrew-emacs-plus icon indicating copy to clipboard operation
homebrew-emacs-plus copied to clipboard

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

Open MuhmdRaouf opened this issue 1 year ago • 1 comments

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/[email protected] 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

MuhmdRaouf avatar Jul 04 '24 18:07 MuhmdRaouf

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 avatar Jul 15 '24 08:07 d12frosted

@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 - https://github.com/d12frosted/homebrew-emacs-plus/pull/783

d12frosted avatar Feb 24 '25 19:02 d12frosted

@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

MuhmdRaouf avatar Feb 25 '25 13:02 MuhmdRaouf

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).

d12frosted avatar Feb 25 '25 14:02 d12frosted

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

glucas avatar Feb 28 '25 22:02 glucas

@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

d12frosted avatar Mar 01 '25 06:03 d12frosted

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 <[email protected]>
Date:   Thu Feb 27 10:56:37 2025 -0800

    Update README for v30 (#798)

glucas avatar Mar 01 '25 15:03 glucas

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/[email protected]
==> 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

glucas avatar Mar 01 '25 15:03 glucas

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

Although the message is strange 🤷

d12frosted avatar Mar 01 '25 15:03 d12frosted

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 avatar Mar 01 '25 15:03 glucas

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)

glucas avatar Mar 01 '25 16:03 glucas