Subject: Re: [PATCH v2] etc: Add tempel snippets.

From: Nicolas Graves <[email-masked]>
Date: Fri, 12 Aug 2022 08:20:53 +0200

On 2022-08-11 18:21, Liliana Marie Prikler wrote:

> I'm not too sure about the suffix here.  I'd personally prefer a
> suffix-less file with a mode-line.

OK, I thought it was necessary because of a previous failed attempt, but
it seems to work. The tempel path cannot be a directory though, it is
necessary to put a wildcard (at least using this version of TempEL).

>> +text-mode :when (git-commit-mode)

Here I have a bug when magit has never been opened before opening a
text-mode file, saying that git-commit-mode is not defined. Not sure
what the best way to resolve this is. Will investigate that.

> I'd suggest skipping the completing-read and just (p "gnu").  Most
> build systems should be easy enough to type without autocompletion.

But then you have to know the name and loose the listing if you're a
beginner and not sure. I'm fine with both options. I will follow your
suggestion if you confirm that you took this type of user into account
and still prefer just (p "gnu").

> Here, I think (p "url-fetch"), but (s "method") might also work.

I'm not sure I understand what you meant here. Can you write the final
method you would get this way?

> Will this cl-case be dynamically recomputed?  I wonder if we can get
> the result of the previous p/s here...

Yes it is recomputed. p/s stores the variable and for evaluations "Named
fields are lexically bound." It works when tested, we can get the result
of the previous p. As Daniel Mendler stressed here
(https://github.com/minad/tempel/issues/65), there is no possibility to
do a recursive template i.e. with a FORM evaluating to elements of a
snippet. So the best thing we might do with conditionals is to return a
string.

> Rather than that I think adding a template (git-file-name...) which
> expands to (file-name (git-file-name (p "name") (p "version")) and
> variants for the others is a better idea.

In most guix packages, it is left as simply name and version strings,
since they are defined for the package itself. I took the same approah
as the yasnippet template, since these field are almost always left
untouched. I don't see the benefit of this other approach.

Your other comments have been taken into account, I'm sending an updated
series as soon as I'm done with the git-commit-mode issue. Feel free to
send an idea for this issue if you have one! 

--
Best regards,
Nicolas Graves