From: Mathieu Lirzin <mathieu.lirzin@etu.u-bordeaux.fr>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: guix-devel@gnu.org, Alex Kost <alezost@gmail.com>
Subject: Re: Texinfo in descriptions?
Date: Fri, 04 Sep 2015 21:43:36 +0200 [thread overview]
Message-ID: <87si6uynpz.fsf@etu.u-bordeaux.fr> (raw)
In-Reply-To: <87bndjxicp.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Fri, 04 Sep 2015 00:12:38 +0200")
[-- Attachment #1: Type: text/plain, Size: 5350 bytes --]
ludo@gnu.org (Ludovic Courtès) writes:
> Mathieu Lirzin <mthl@openmailbox.org> skribis:
>
>> From e691c2080929dd1390184ab4669de8b2695a237f Mon Sep 17 00:00:00 2001
>> From: Mathieu Lirzin <mthl@openmailbox.org>
>> Date: Fri, 7 Aug 2015 00:10:43 +0200
>> Subject: [PATCH] ui: Add package-description-string.
>>
>> Provide support for Texinfo's markup in package description.
>>
>> * guix/ui.scm (%text-width, %initial-indent): New parameters.
>> (package-description-string): New variable.
>> (package->recutils): Use them.
>> * emacs/guix-main.scm (%package-param-alist): Use it.
>> * gnu/packages/databases.scm (perl-dbd-pg): Adapt to Texinfo's markup.
>> * gnu/packages/perl.scm (perl-devel-globaldestruction)
>> (perl-devel-lexalias, perl-exporter-lite): Likewise.
>> * gnu/packages/python.scm (python2-empy): Likewise.
>
> [...]
>
>> +++ b/gnu/packages/databases.scm
>> @@ -578,7 +578,7 @@ columns, primary keys, unique constraints and relationships.")
>> ("postgresql" ,postgresql)))
>> (home-page "http://search.cpan.org/dist/DBD-Pg")
>> (synopsis "DBI PostgreSQL interface")
>> - (description "")
>> + (description #f)
>
> Weird, and doesn’t really match the commit log. Maybe this hunk can be
> removed?
I get an error with "guix package -s perl-dbd-pg" without this change
--8<---------------cut here---------------start------------->8---
Backtrace:
In unknown file:
?: 19 [apply-smob/1 #<catch-closure 1cfa9a0>]
In ice-9/boot-9.scm:
63: 18 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
432: 17 [eval # #]
In ice-9/boot-9.scm:
2401: 16 [save-module-excursion #<procedure 1d18940 at ice-9/boot-9.scm:4045:3 ()>]
4050: 15 [#<procedure 1d18940 at ice-9/boot-9.scm:4045:3 ()>]
1724: 14 [%start-stack load-stack ...]
1729: 13 [#<procedure 1d2eea0 ()>]
In unknown file:
?: 12 [primitive-load "/home/mthl/src/gnu/guix/scripts/guix"]
In guix/ui.scm:
1058: 11 [run-guix-command package "-s" "perl-dbd-pg"]
In ice-9/boot-9.scm:
157: 10 [catch srfi-34 #<procedure 3b1a180 at guix/ui.scm:384:2 ()> ...]
157: 9 [catch system-error ...]
In guix/scripts/package.scm:
995: 8 [#<procedure 3b1e6f0 at guix/scripts/package.scm:994:4 ()>]
967: 7 [process-query (# # # # ...)]
In ice-9/boot-9.scm:
157: 6 [catch system-error ...]
In srfi/srfi-1.scm:
619: 5 [for-each #<procedure 3b1e630 at guix/scripts/package.scm:968:22 (t-139858)> ...]
In guix/ui.scm:
859: 4 [package->recutils # #<output: file /dev/pts/0> 80]
790: 3 [texi->plain-text "description: Project-Id-Version: guix-packages 0.8\nReport-Msgid-Bugs-To: ludo@gnu.org\nPOT-Creation-Date: 2015-07-21 21:35+0200\nPO-Revision-Date: 2014-12-20 22:00+0100\nLast-Translator: Rémy Chevalier <remychevalier@laposte.net>\nLanguage-Team: French <traduc@traduc.org>\nLanguage: fr\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n"]
In unknown file:
?: 2 [call-with-input-string "description: Project-Id-Version: guix-packages 0.8\nReport-Msgid-Bugs-To: ludo@gnu.org\nPOT-Creation-Date: 2015-07-21 21:35+0200\nPO-Revision-Date: 2014-12-20 22:00+0100\nLast-Translator: Rémy Chevalier <remychevalier@laposte.net>\nLanguage-Team: French <traduc@traduc.org>\nLanguage: fr\nMIME-Version: 1.0\nContent-Type: text/plain; charset=UTF-8\nContent-Transfer-Encoding: 8bit\n" ...]
In texinfo.scm:
1131: 1 [parse #<input: string 4517ea0>]
965: 0 [loop #<input: string 4517ea0> (*fragment*) ...]
texinfo.scm:965:23: In procedure loop:
texinfo.scm:965:23: Throw to key `parser-error' with args `(#f "Unknown command" gnu)'.
--8<---------------cut here---------------end--------------->8---
It's not directly related to texinfo description since
(package-description-string perl-dbd-pg) => ""
but caused by the fact there is this in "po/packages/fr.po"...
--8<---------------cut here---------------start------------->8---
msgid ""
msgstr ""
"Project-Id-Version: guix-packages 0.8\n"
"Report-Msgid-Bugs-To: ludo@gnu.org\n"
"POT-Creation-Date: 2014-11-10 15:37+0100\n"
"PO-Revision-Date: 2014-12-20 22:00+0100\n"
"Last-Translator: Rémy Chevalier <remychevalier@laposte.net>\n"
"Language-Team: French <traduc@traduc.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
--8<---------------cut here---------------end--------------->8---
which fails to be parsed by texinfo.
What is your recommandation about this?
>
>> +(set! (@@ (texinfo plain-text) wrap*)
>> + ;; Monkey patch this private procedure to let 'package->recutils'
> ^
> Please prepend “XXX” here to make the kludge more visible. (Eventually
> we should fix it in Guile.)
Done.
> I tried adding an @itemize list in a description and noticed that the
> initial indent is not working the way I thought:
> [...]
I should have test such case before proposing a patch sorry about that.
> I wonder if using ‘fill-paragraph’ instead of ‘fill-string’ would solve
> this.
I don't remember exactly the result I got with that but it wasn't
convincing.
> Could you look into it?
Here is "something" that seems to work. The idea is to append
"description: " to package description before 'stexi->plain-text' fills
the text.
[-- Attachment #2: 0001-ui-Add-package-description-string.patch --]
[-- Type: text/x-diff, Size: 8848 bytes --]
From 88f95bf594ded0e63b842e23bc06cbcd250d9660 Mon Sep 17 00:00:00 2001
From: Mathieu Lirzin <mthl@openmailbox.org>
Date: Fri, 7 Aug 2015 00:10:43 +0200
Subject: [PATCH] ui: Add package-description-string.
Provide support for Texinfo's markup in package description.
* guix/ui.scm (%text-width): New parameter.
(texi->plain-text): New variable.
(package->recutils): Use them.
(package-description-string): New variable.
* emacs/guix-main.scm (%package-param-alist): Use it.
* gnu/packages/databases.scm (perl-dbd-pg): Adapt to Texinfo's markup.
* gnu/packages/perl.scm (perl-devel-globaldestruction)
(perl-devel-lexalias, perl-exporter-lite): Likewise.
* gnu/packages/python.scm (python2-empy): Likewise.
---
emacs/guix-main.scm | 2 +-
gnu/packages/databases.scm | 2 +-
gnu/packages/perl.scm | 6 +++---
gnu/packages/python.scm | 2 +-
guix/ui.scm | 50 ++++++++++++++++++++++++++++++++++------------
5 files changed, 43 insertions(+), 19 deletions(-)
diff --git a/emacs/guix-main.scm b/emacs/guix-main.scm
index 8d3a881..712f519 100644
--- a/emacs/guix-main.scm
+++ b/emacs/guix-main.scm
@@ -282,7 +282,7 @@ Example:
(license . ,package-license-names)
(source . ,package-source-names)
(synopsis . ,package-synopsis)
- (description . ,package-description)
+ (description . ,package-description-string)
(home-url . ,package-home-page)
(outputs . ,package-outputs)
(non-unique . ,(negate package-unique?))
diff --git a/gnu/packages/databases.scm b/gnu/packages/databases.scm
index cbac16e..1710d0e 100644
--- a/gnu/packages/databases.scm
+++ b/gnu/packages/databases.scm
@@ -578,7 +578,7 @@ columns, primary keys, unique constraints and relationships.")
("postgresql" ,postgresql)))
(home-page "http://search.cpan.org/dist/DBD-Pg")
(synopsis "DBI PostgreSQL interface")
- (description "")
+ (description #f)
(license (package-license perl))))
(define-public perl-dbd-sqlite
diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index c528516..12fed2b 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -1705,7 +1705,7 @@ particular command is available.")
(home-page "http://search.cpan.org/dist/Devel-GlobalDestruction")
(synopsis "Provides equivalent of ${^GLOBAL_PHASE} eq 'DESTRUCT' for older perls")
(description "Devel::GlobalDestruction provides a function returning the
-equivalent of \"${^GLOBAL_PHASE} eq 'DESTRUCT'\" for older perls.")
+equivalent of \"$@{^GLOBAL_PHASE@} eq 'DESTRUCT'\" for older perls.")
(license (package-license perl))))
(define-public perl-devel-lexalias
@@ -1949,7 +1949,7 @@ constructors, which speeds code up at runtime by a significant amount. String
eval is not without its issues however - it's difficult to control the scope
it's used in (which determines which variables are in scope inside the eval),
and it's easy to miss compilation errors, since eval catches them and sticks
-them in $@ instead. This module attempts to solve these problems. It
+them in $@@ instead. This module attempts to solve these problems. It
provides an eval_closure function, which evals a string in a clean
environment, other than a fixed list of specified variables. Compilation
errors are rethrown automatically.")
@@ -1993,7 +1993,7 @@ in your modules in a \"Java-esque\" manner.")
(description
"Exporter::Lite is an alternative to Exporter, intended to provide a
lightweight subset of the most commonly-used functionality. It supports
-import(), @EXPORT and @EXPORT_OK and not a whole lot else.")
+import(), @@EXPORT and @@EXPORT_OK and not a whole lot else.")
(home-page (string-append "http://search.cpan.org/~neilb/"
"Exporter-Lite-" version))
(license (package-license perl))))
diff --git a/gnu/packages/python.scm b/gnu/packages/python.scm
index 313c625..5f3babf 100644
--- a/gnu/packages/python.scm
+++ b/gnu/packages/python.scm
@@ -1174,7 +1174,7 @@ other Python program.")
"EmPy is a system for embedding Python expressions and statements in
template text; it takes an EmPy source file, processes it, and produces
output. This is accomplished via expansions, which are special signals to the
-EmPy system and are set off by a special prefix (by default the at sign, @).
+EmPy system and are set off by a special prefix (by default the at sign, @@).
EmPy can expand arbitrary Python expressions and statements in this way, as
well as a variety of special forms. Textual data not explicitly delimited in
this way is sent unaffected to the output, allowing Python to be used in
diff --git a/guix/ui.scm b/guix/ui.scm
index 8de8e3c..876a63b 100644
--- a/guix/ui.scm
+++ b/guix/ui.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2014, 2015 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org>
;;; Copyright © 2014 Deck Pickard <deck.r.pickard@gmail.com>
;;;
;;; This file is part of GNU Guix.
@@ -45,6 +46,9 @@
#:use-module (ice-9 regex)
#:autoload (system repl repl) (start-repl)
#:autoload (system repl debug) (make-debug stack->vector)
+ #:use-module (texinfo)
+ #:use-module (texinfo plain-text)
+ #:use-module (texinfo string-utils)
#:export (_
N_
P_
@@ -69,6 +73,7 @@
switch-symlinks
config-directory
fill-paragraph
+ package-description-string
string->recutils
package->recutils
package-specification->name+version+output
@@ -767,6 +772,28 @@ converted to a space; sequences of more than one line break are preserved."
;;; Packages.
;;;
+(define %text-width
+ (make-parameter (or (and=> (getenv "WIDTH") string->number)
+ 80)))
+
+(set! (@@ (texinfo plain-text) wrap*)
+ ;; XXX: Monkey patch this private procedure to let 'package->recutils'
+ ;; parameterize the fill of description field correctly.
+ (lambda strings
+ (let ((indent (fluid-ref (@@ (texinfo plain-text) *indent*))))
+ (fill-string (string-concatenate strings)
+ #:line-width (%text-width) #:initial-indent indent
+ #:subsequent-indent indent))))
+
+(define (texi->plain-text str)
+ "Return a plain-text representation of texinfo fragment STR."
+ (stexi->plain-text (texi-fragment->stexi str)))
+
+(define (package-description-string package)
+ "Return a plain-text representation of PACKAGE description field."
+ (and=> (package-description package)
+ (compose texi->plain-text P_)))
+
(define (string->recutils str)
"Return a version of STR where newlines have been replaced by newlines
followed by \"+ \", which makes for a valid multi-line field value in the
@@ -779,18 +806,9 @@ followed by \"+ \", which makes for a valid multi-line field value in the
'()
str)))
-(define* (package->recutils p port
- #:optional (width (or (and=> (getenv "WIDTH")
- string->number)
- 80)))
+(define* (package->recutils p port #:optional (width (%text-width)))
"Write to PORT a `recutils' record of package P, arranging to fit within
WIDTH columns."
- (define (description->recutils str)
- (let ((str (P_ str)))
- (string->recutils
- (fill-paragraph str width
- (string-length "description: ")))))
-
(define (dependencies->recutils packages)
(let ((list (string-join (map package-full-name
(sort packages package<?)) " ")))
@@ -834,9 +852,15 @@ WIDTH columns."
(chr chr))
(or (and=> (package-synopsis p) P_)
"")))
- (format port "description: ~a~%"
- (and=> (package-description p) description->recutils))
- (newline port))
+ (format port "~a~2%"
+ (string->recutils
+ (string-trim-right
+ (parameterize ((%text-width width))
+ (texi->plain-text
+ (string-append "description: "
+ (or (and=> (package-description p) P_)
+ ""))))
+ #\newline))))
(define (string->generations str)
"Return the list of generations matching a pattern in STR. This function
--
2.5.1
[-- Attachment #3: Type: text/plain, Size: 39 bytes --]
What do you think?
--
Mathieu Lirzin
next prev parent reply other threads:[~2015-09-04 19:43 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-16 11:17 [PATCH] gnu packages: Clean up synopses and descriptions Alex Kost
2015-07-16 9:40 ` Eric Bavier
2015-07-16 15:55 ` Alex Kost
2015-07-16 19:08 ` Ludovic Courtès
2015-07-17 12:41 ` Alex Kost
2015-07-17 21:24 ` Ludovic Courtès
2015-07-18 10:07 ` Alex Kost
2015-07-16 11:52 ` Mathieu Lirzin
2015-07-16 15:50 ` Ludovic Courtès
2015-07-16 21:33 ` Mathieu Lirzin
2015-07-17 21:18 ` Texinfo in descriptions? Ludovic Courtès
2015-07-21 21:37 ` Mathieu Lirzin
2015-07-22 13:35 ` Ludovic Courtès
2015-07-22 21:24 ` Ludovic Courtès
2015-07-22 22:08 ` Andreas Enge
2015-07-23 9:49 ` Mathieu Lirzin
2015-07-23 13:57 ` Ludovic Courtès
2015-07-23 15:09 ` Daniel Pimentel
2015-07-23 18:00 ` Andreas Enge
2015-08-25 22:09 ` Mathieu Lirzin
2015-08-26 7:57 ` Andy Wingo
2015-08-27 19:48 ` Mathieu Lirzin
2015-07-23 13:54 ` Ludovic Courtès
2015-08-27 21:04 ` Mathieu Lirzin
2015-08-28 21:47 ` Mathieu Lirzin
2015-08-30 17:23 ` Ludovic Courtès
2015-08-30 19:06 ` Alex Kost
2015-08-30 20:42 ` Mathieu Lirzin
2015-08-31 21:21 ` Ludovic Courtès
2015-09-01 16:41 ` Mathieu Lirzin
2015-09-02 21:27 ` Mathieu Lirzin
2015-09-03 22:12 ` Ludovic Courtès
2015-09-04 19:43 ` Mathieu Lirzin [this message]
2015-09-06 13:51 ` Ludovic Courtès
2015-09-06 20:10 ` Alex Kost
2015-09-06 21:31 ` Ludovic Courtès
2015-09-07 15:50 ` Alex Kost
2015-09-07 15:59 ` Ludovic Courtès
2015-08-30 10:10 ` Alex Kost
2015-08-30 12:24 ` Mathieu Lirzin
2015-08-30 15:19 ` Alex Kost
2015-07-17 12:35 ` [PATCHES] gnu packages: Clean up synopses and descriptions Alex Kost
2015-07-17 21:07 ` Mathieu Lirzin
2015-07-17 21:30 ` Ludovic Courtès
2015-07-18 10:08 ` Alex Kost
2015-07-18 21:13 ` Andreas Enge
2015-07-19 9:58 ` Alex Kost
2015-07-16 16:03 ` [PATCH] " Alex Kost
2015-07-16 20:02 ` Mathieu Lirzin
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=87si6uynpz.fsf@etu.u-bordeaux.fr \
--to=mathieu.lirzin@etu.u-bordeaux.fr \
--cc=alezost@gmail.com \
--cc=guix-devel@gnu.org \
--cc=ludo@gnu.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 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.