unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Kierin Bell <fernseed@fernseed.me>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: cox.katherine.e+guix@gmail.com, "\(" <paren@disroot.org>,
	Andrew Tropin <andrew@trop.in>,
	64620@debbugs.gnu.org,
	Liliana Marie Prikler <liliana.prikler@gmail.com>
Subject: [bug#64620] [PATCH] gnu: home: Add home-emacs-service-type.
Date: Thu, 12 Oct 2023 18:15:15 -0400	[thread overview]
Message-ID: <8734yf4he4.fsf@fernseed.me> (raw)
In-Reply-To: <87a5spuoc5.fsf@gnu.org> ("Ludovic Courtès"'s message of "Wed, 11 Oct 2023 18:16:10 +0200")


Hello,

Ludovic Courtès <ludo@gnu.org> writes:

> Hello!
>
> If there’s consensus, I think we should go ahead with this patch series.
> Worst that could happen is that people will think of ways to change the
> service in one way or another, and that’s fine!
>
> Two general comments:
>
>   • As I wrote earlier, I think it’d be nice to have integration tests
>     for this, in addition to the unit tests the patch already adds.
>
>   • We may want to split the patch into sizable, self-contained bites.
>     For instance, the (guix read-print) changes should probably be
>     separated out.
>
> I’ll provide more specific comments about the code.
>
> To Emacs team members: please review the Emacs bits of the series!
>
> Thanks,
> Ludo’.
>
>

I have been working on getting v2 ready!

I'll address the comments specific to the reader, printer and
G-expression parts in a reply to the other message.

Specifically regarding the `home-emacs-service-type' interface, most of
it has not changed since July, but I have a few pertinent comments here.

First, I've made a few obvious improvements:

1. The package serializers no longer automatically try to add `-hook'
   suffixes to hook symbols specified in the `hooks' field of the
   `emacs-package' record type (à la `use-package').  This bites back
   when we want to use hooks whose names end in `-functions'.

2. In order to achieve (1), the `%emacs-use-package-serializer' needs to
   set the relevant options for `use-package' so that it does not add
   `-hook' suffixes.  Hence, I've added a new field to the
   `emacs-package-serializer' record type for any Elisp that must be
   evaluated in order for serialized package configuration to work
   properly.

3. Writing `(list (elisp .) (elisp .))' is cumbersome, so I implemented
   a new `elisp*' macro that splices multiple s-exps together.  We can
   achieve the same effect as above by writing `(elisp* . .)'.

4. I'm implementing two new functions,
   `make-simple-package-elisp-serializer' and
   `make-use-package-elisp-serializer', such that with no arguments they
   return the default package serializer procedures, but:
  
     (make-use-package-elisp-serializer EXTRA-KEYWORD-HANDLER)
 
   ...Returns a version that serializes the `extra-keywords' field of
   any `emacs-package' record according to the function
   EXTRA-KEYWORD-HANDLER.  I'm using this, for example, in my own config
   to define an `auto-faces' keyword that lets me specify faces on a
   per-theme basis.

5. I'm adding an `extra-init-files' field to the `emacs-package' record
   type that mirrors that of the `emacs-configuration' record type.  The
   rationale is that it is often convenient to have a complex
   configuration for a specific package in a self-contained Elisp file,
   which via this field can be loaded in the main Emacs user init file.

Second, I understand that the 1.3kloc implementation of the interface
for configuring Emacs packages in Scheme is rather opinionated.  Some
of the changes described above arguably add to this even more.

To simplify things, I've been playing around with splitting this
functionality into a `home-emacs-packages-service-type', which would
extend the `home-emacs-service-type'.  This could go in unofficial
channels, but ideally I'd like to see it included with this patch set.

The old configuration interface looks like this:
--8<---------------cut here---------------start------------->8---
(home-environment
 ;; ...
 (services
  (list
   ;; ...
   (service home-emacs-service-type
    (home-emacs-configuration
     (user-emacs-directory "~/.local/state/emacs/")
     (package-serializer %emacs-use-package-serializer)
     (configured-packages
      (list
      (emacs-package
       ;; ...
       )
       ;; ... Lots more stuff here ...
       )))))))
--8<---------------cut here---------------end--------------->8---

And the modularized configuration would look like this:
--8<---------------cut here---------------start------------->8---
(home-environment
 ;; ...
 (services
  (list
   ;; ...
   (service home-emacs-service-type
    (home-emacs-configuration
     (emacs %my-custom-emacs-version)
     (user-emacs-directory "~/.local/state/emacs/")
     (configured-packages
      (list
       (emacs-package
        ;; ...
        )
       ;; ... Lots more stuff here ...
       ))))
   (service home-emacs-packages-service-type
    (emacs %my-custom-emacs-version)
    (serializer %emacs-use-package-serializer)
    (packages
     (emacs-package
      ;; ...
      )
     ;; ... Lots of stuff here ...
     )))))
--8<---------------cut here---------------end--------------->8---

The benefits are maintainability and usability --- users who don't want
to use the package configuration interface don't have to deal with the
cognitive dissonance.

The downside is that Emacs package configuration becomes more cumbersome
for more advanced use cases.

One case, illustrated above, is that the
`home-emacs-packages-service-type' doesn't know the Emacs version used
by the `home-emacs-service-type' --- a non-default version of Emacs must
be specified again, separately, for the packages service (that is, if it
matters that the package serializer knows the Emacs version).

Another case is that in order to configure Emacs packages for specific
Emacs servers (created via the `servers' field of the
`home-emacs-configuration'), there would either need to be a `servers'
field in the `home-emacs-packages-configuration' record type
(complicated to implement) or users would need to do this manually (with
the help of a new function such as `emacs-server-with-packages').

I'd appreciate hearing preferences or arguments for or against either.
Also, suggestions for simplifying any part of the interface are welcome!

Thanks.
-- 
Kierin Bell
GPG Key: FCF2 5F08 EA4F 2E3D C7C3  0D41 D14A 8CD3 2D97 0B36




  reply	other threads:[~2023-10-12 22:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-14 15:12 [bug#64620] [PATCH] gnu: home: Add home-emacs-service-type fernseed
2023-07-22  2:45 ` 宋文武 via Guix-patches via
2023-08-23 10:01 ` Ludovic Courtès
2023-08-23 16:14   ` Kierin Bell
2023-08-24 12:26 ` Hilton Chain via Guix-patches via
2023-08-24 13:13   ` Kierin Bell
2023-08-24 20:00 ` ( via Guix-patches via
2023-08-26 14:06   ` Kierin Bell
2023-08-28  6:24     ` ( via Guix-patches via
2023-08-28 22:32       ` Kierin Bell
2023-08-29  6:03         ` ( via Guix-patches via
2023-10-11 16:16           ` Ludovic Courtès
2023-10-12 22:15             ` Kierin Bell [this message]
2023-10-13  4:30               ` Liliana Marie Prikler
2023-10-13 13:59                 ` Kierin Bell
2023-08-26 20:01 ` Liliana Marie Prikler
2023-08-28 22:27   ` Kierin Bell
2023-08-29  4:24     ` Liliana Marie Prikler
2023-10-11 16:48 ` Ludovic Courtès
2023-10-12 22:26   ` Kierin Bell
2024-04-01  8:28 ` [bug#64620] Bumping - " Steve George

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8734yf4he4.fsf@fernseed.me \
    --to=fernseed@fernseed.me \
    --cc=64620@debbugs.gnu.org \
    --cc=andrew@trop.in \
    --cc=cox.katherine.e+guix@gmail.com \
    --cc=liliana.prikler@gmail.com \
    --cc=ludo@gnu.org \
    --cc=paren@disroot.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).