guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nicolas Graves] [PATCH v6 01/10] rde: emacs: Start emacs in --daemo


From: Ludovic Courtès
Subject: Re: [Nicolas Graves] [PATCH v6 01/10] rde: emacs: Start emacs in --daemon mode, with shepherd and pid-file
Date: Fri, 19 Apr 2024 16:25:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi,

Nicolas Graves <ngraves@ngraves.fr> skribis:

> (define (emacs-shepherd-service config name)
>   (shepherd-service
>    (documentation
>     (format #f "Emacs server.  Use ~a to connect to it."
>             (if (eq? 'server name)
>                 "@code{emacsclient}"
>                 (format #f "@code{emacsclient -s ~a}" name))))
>    (provision `(,(symbol-append 'emacs- name)))
>    (requirement '(emacs))
>    (modules '((shepherd support)))  ;for '%user-runtime-dir'
>    (start #~(make-systemd-constructor
>              (list #$(file-append
>                       (home-emacs-configuration-emacs config)
>                       "/bin/emacs") #$(format #f "--fg-daemon=~a" name))
>              (list (endpoint
>                     (make-socket-address
>                      AF_UNIX
>                      (string-append %user-runtime-dir
>                                     "/emacs/" #$(symbol->string name)))
>                     #:name '#$(format #f "emacs-~a" name)
>                     #:socket-directory-permissions #o700))
>              #:log-file (string-append
>                          (getenv "XDG_STATE_HOME") "/log"
>                          "/emacs-" #$(symbol->string name) ".log")))
>    (stop #~(make-systemd-destructor))))

Note that in this case the server is started lazily, the first time
someone connects to the socket.

You can pass #:lazy-start? #false if you instead want to start it
upfront.

> But I'm not sure it's better regarding user experience. On RDE we
> implemented a notifier that parses the result of
> herd eval root "(and=> (lookup-service 'emacs-server) service-status)"
> thus giving a nice "Emacs is currently starting" notification.

With socket activation, the service is immediately in “running” state:
starting it requires nothing more than accepting connections on the
socket.

(Maybe that’s one of the rare situations where sd-notify would help?)

> This evaluation doesn't seem to work using make-systemd-constructor,
> although it has its advantages (indeed launches a frame when available).
> It would be nice if service-status could "sync" with
> make-systemd-constructor in this case.
>
> I would be happy to send such a patch for Guix (is there already some
> patch series on which to graft this?), WDYT @Ludo?

Sure, feel free to send a patch for this; there are unfortunately
several attempts at an Emacs service in the issue tracker, but none of
them made it to the tree so far, in part because some were very
ambitious.

Thanks,
Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]