From: ludo@gnu.org (Ludovic Courtès)
To: 宋文武 <iyzsong@gmail.com>
Cc: guix-devel@gnu.org
Subject: Re: [PATCH] gnu-maintenance: update-package-source: Only update the desired package.
Date: Tue, 05 Apr 2016 11:45:56 +0200 [thread overview]
Message-ID: <87y48sv163.fsf@gnu.org> (raw)
In-Reply-To: <1459830946-2583-1-git-send-email-iyzsong@gmail.com> ("宋文武"'s message of "Tue, 5 Apr 2016 12:35:46 +0800")
宋文武 <iyzsong@gmail.com> skribis:
> Fixes <http://bugs.gnu.org/22693>.
> Suggested by Andy Wingo.
>
> * guix/upstream.scm (update-package-source): Use a customized 'substitute'
> to work within lines of the package's source.
[...]
> + (define (substitute+ file start end pattern+procs)
> + ;; Same as substitute, but within lines from START to END.
Please make it a top-level procedure, for clarity.
> + (define (package-location-line-start package)
> + (location-line (package-location package)))
> +
> + (define (package-location-line-end package)
> + (define (goto port line column)
> + (unless (and (= (port-column port)) (- column 1)
> + (= (port-line port) (- line 1)))
> + (unless (eof-object? (read-char port))
> + (goto port line column))))
> +
> + (match (package-location package)
> + (($ <location> file line column)
> + (call-with-input-file (search-path %load-path file)
> + (lambda (port)
> + (goto port line column)
> + (match (read port)
> + (('package _ ...)
> + (1+ (port-line port)))))))))
I think you should add a ‘match’ case here, for when (read port) returns
something that is not a ‘package’ form (that could happen.)
The docstring should specify that this can return #f, and callers should
fall back to a wild guess, like:
(or (package-location-end-line p)
(+ (package-location-start-line p) 30))
But overall the approach looks good to me!
Could you:
1. Call these two procedure ‘package-location-start-line’ and
‘package-location-end-line’ (I think it sounds better from a
grammatical standpoint ;-))?
2. Move them to (guix packages), next to ‘package-field-location’?
3. Add tests in tests/packages.scm?
The (guix upstream) changes would come in a separate patch.
WDYT?
Thank you!
Ludo’.
prev parent reply other threads:[~2016-04-05 9:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-05 4:35 [PATCH] gnu-maintenance: update-package-source: Only update the desired package 宋文武
2016-04-05 8:25 ` Andy Wingo
2016-04-05 9:47 ` Ludovic Courtès
2016-04-05 10:16 ` Andy Wingo
2016-04-05 14:05 ` 宋文武
2016-04-05 14:52 ` Andy Wingo
2016-04-05 20:20 ` Ludovic Courtès
2016-04-05 9:45 ` Ludovic Courtès [this message]
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y48sv163.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guix-devel@gnu.org \
--cc=iyzsong@gmail.com \
/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 public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).