From mboxrd@z Thu Jan 1 00:00:00 1970 From: Pierre Neidhardt Subject: Re: Add helper for .desktop file creation? Date: Mon, 27 May 2019 18:45:49 +0200 Message-ID: <87blznlubm.fsf@ambrevar.xyz> 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> <878sur6fgl.fsf@nicolasgoaziou.fr> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([209.51.188.92]:42429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hVIl6-0007rO-ID for guix-devel@gnu.org; Mon, 27 May 2019 12:46:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hVIl4-00038R-Vo for guix-devel@gnu.org; Mon, 27 May 2019 12:46:00 -0400 Received: from relay11.mail.gandi.net ([217.70.178.231]:38415) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hVIl1-00032X-1B for guix-devel@gnu.org; Mon, 27 May 2019 12:45:58 -0400 In-Reply-To: <878sur6fgl.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: Guix-devel --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Nicolas Goaziou writes: > Not what you're asking for, but I had a few comments about the > implementation: Thanks for the feedback! >> --8<---------------cut here---------------start------------->8--- >> (define* (make-desktop-entry-file destination #:key >> (type "Application") ; One of "Applica= tion", "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. Nope, the current function only forces "Type" (the only mandatory field), everything else is omitted unless the key is explicitly set by the user. This is because I looped over ALL-ARGS (the #:rest argument) and I force-added #:type to it. >> (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 contai= n strings: ~a" args)))) >> (_ (error "Value must be a boolean, number, string or = list of strings")))) >> (format #t "~a=3D~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? True, but that's more work ;) I did not implement the full specs simply because I decided to draw an arbitrary line between short code, convenience and completeness. This is debatable of course and maybe a simple type-checking would not cost much. Supporting the full specs would require a significant amount of work howeve= r. >> (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. Hmm, OK but why? The procedure produces the expected behaviour with #:mime-type, is there anything else to clarify? > In any case, it looks nice and useful. Thanks! =2D-=20 Pierre Neidhardt https://ambrevar.xyz/ --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEUPM+LlsMPZAEJKvom9z0l6S7zH8FAlzsFD0ACgkQm9z0l6S7 zH8gRAf/Wz0h9gsiVyLuaiKxL2JPzGil8AbhxW/LML5qd/Xay0M+ieT+GYMbcwJe L2OCnrpuZvw7W9ll+p50PrYUhgXhLfjFnXERZHTqIx7q8Gq+juQp5SAew6K5Qp7P JKfbhP6vSKf3NXQ0Vshu3kDJ5e6bMdbh5vgn4e1LNZV1Qx1ZImpw6V/laD6ZVBhX mGLaqId9hNQsP2zpYvTA/x5naF1ElX0PVUxqc5FTSeVYgHKewMtJEfxKzAlWFcGq ccytBlskA2MnWqWwNg3BPkpMZ/cG9MNvEzNnwA68zZY2QvoKj7vQ1Lr6SVRSKt2f WJ6uBFNvkj5ZTjcohL5J7uIfzHBcsQ== =hP9x -----END PGP SIGNATURE----- --=-=-=--