From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Pierre Neidhardt <mail@ambrevar.xyz>
Cc: Guix-devel <guix-devel@gnu.org>
Subject: Re: Add helper for .desktop file creation?
Date: Mon, 27 May 2019 18:15:54 +0200 [thread overview]
Message-ID: <878sur6fgl.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <877eacmksu.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Mon, 27 May 2019 09:13:53 +0200")
Hello,
Pierre Neidhardt <mail@ambrevar.xyz> writes:
> I came up with the following function, it seems to work well (need to
> test a little more though).
>
> Before I could submit a patch, I was wondering where I should place it:
> it seems that placing it in guix/utils.scm triggers a whole world
> rebuild.
>
> Is there a way around it or should I send this patch to core-updates?
Not what you're asking for, but I had a few comments about the
implementation:
> --8<---------------cut here---------------start------------->8---
> (define* (make-desktop-entry-file destination #:key
> (type "Application") ; One of "Application", "Link" or "Directory".
> (version "1.1")
> name
> (generic-name name)
> (no-display #f)
What about only providing default values only for mandatory keys, i.e.,
only "type" (name is also mandatory, but it has no default value).
I think the function currently adds entries that are not necessary.
> (define* (parse key value #:optional locale)
> (set! value (match value
> (#t "true")
> (#f "false")
> ((? number? n) n)
> ((? string? s) (escape-semicolon s))
> ((? list? value)
> (catch 'wrong-type-arg
> (lambda () (string-join (map escape-semicolon value) ";"))
> (lambda args (error "List arguments can only contain strings: ~a" args))))
> (_ (error "Value must be a boolean, number, string or list of strings"))))
> (format #t "~a=~a~%"
> (if locale
> (format #f "~a[~a]" key locale)
> key)
> value))
I wonder if it wouldn't be better to stick to the specification. For
example :comment expects a string, or an alist: shouldn't the function
return an error if its value is something else?
It requires us to hard-code the allow value types in the function, but
Not every packager knows these specifications, and it could help them
a bit. Also, we can limit keys to allowed ones, for increased typo
checking.
> (set! key
> (string-join (map string-titlecase
> (string-split (symbol->string
> (keyword->symbol key))
> #\-))
> ""))
The docstring may explain that, e.g., compound :mime-type key becomes
MimeType.
In any case, it looks nice and useful.
Regards,
--
Nicolas Goaziou
next prev parent reply other threads:[~2019-05-27 16:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-24 7:53 Add helper for .desktop file creation? Pierre Neidhardt
2019-05-25 12:06 ` Nicolas Goaziou
2019-05-25 12:21 ` Nicolas Goaziou
2019-05-25 12:51 ` Pierre Neidhardt
2019-05-25 13:33 ` Nicolas Goaziou
2019-05-25 13:45 ` Nicolas Goaziou
2019-05-25 14:20 ` Pierre Neidhardt
2019-05-25 18:37 ` Pierre Neidhardt
2019-05-27 7:13 ` Pierre Neidhardt
2019-05-27 16:15 ` Nicolas Goaziou [this message]
2019-05-27 16:45 ` Pierre Neidhardt
2019-05-27 17:39 ` Nicolas Goaziou
2019-05-27 17:58 ` Pierre Neidhardt
2019-05-27 19:19 ` Nicolas Goaziou
2019-05-30 8:24 ` Pierre Neidhardt
2019-05-27 19:54 ` Marius Bakke
2019-05-27 21:02 ` Pierre Neidhardt
2019-05-25 13:38 ` Amin Bandali
2019-05-25 14:30 ` Danny Milosavljevic
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878sur6fgl.fsf@nicolasgoaziou.fr \
--to=mail@nicolasgoaziou.fr \
--cc=guix-devel@gnu.org \
--cc=mail@ambrevar.xyz \
/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 external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.