From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: Add helper for .desktop file creation? Date: Mon, 27 May 2019 18:15:54 +0200 Message-ID: <878sur6fgl.fsf@nicolasgoaziou.fr> References: <878suwz3tg.fsf@ambrevar.xyz> <87d0k67n7n.fsf@nicolasgoaziou.fr> <878suu7mhk.fsf@nicolasgoaziou.fr> <87r28mofxd.fsf@ambrevar.xyz> <87r28m64m5.fsf@nicolasgoaziou.fr> <87o93qobso.fsf@ambrevar.xyz> <8736l2nzwm.fsf@ambrevar.xyz> <877eacmksu.fsf@ambrevar.xyz> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([209.51.188.92]:34713) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVIIF-00077N-8S for guix-devel@gnu.org; Mon, 27 May 2019 12:16:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVIIE-0006pk-9m for guix-devel@gnu.org; Mon, 27 May 2019 12:16:11 -0400 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:49843) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVIIE-0006iP-4W for guix-devel@gnu.org; Mon, 27 May 2019 12:16:10 -0400 In-Reply-To: <877eacmksu.fsf@ambrevar.xyz> (Pierre Neidhardt's message of "Mon, 27 May 2019 09:13:53 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Pierre Neidhardt Cc: Guix-devel Hello, Pierre Neidhardt 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