From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andy Wingo Subject: Re: [PATCH] gnu-maintenance: update-package-source: Only update the desired package. Date: Tue, 05 Apr 2016 16:52:31 +0200 Message-ID: <87r3ekcdlc.fsf@igalia.com> References: <1459830946-2583-1-git-send-email-iyzsong@gmail.com> <87h9fgfomg.fsf@igalia.com> <87shz0v13q.fsf@gnu.org> <87inzwe4y2.fsf@igalia.com> <87wpocup4w.fsf@member.fsf.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38508) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1anSLP-0002f2-Qd for guix-devel@gnu.org; Tue, 05 Apr 2016 10:52:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1anSLM-0002In-Io for guix-devel@gnu.org; Tue, 05 Apr 2016 10:52:39 -0400 In-Reply-To: <87wpocup4w.fsf@member.fsf.org> (=?utf-8?B?IuWui+aWh+atpiIn?= =?utf-8?B?cw==?= message of "Tue, 05 Apr 2016 22:05:51 +0800") 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-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org Hi :) On Tue 05 Apr 2016 16:05, iyzsong@member.fsf.org (=E5=AE=8B=E6=96=87=E6=AD= =A6) writes: > Andy Wingo writes: > >> In that case I think the ideal is something like "edit-expression", >> which takes a source location that starts an expression, uses "read" to >> advance to the end of the expression, then edits the intervening string >> using whatever but verifies that the result can still be read as one >> expression. Having recorded the absolute byte positions of the start >> and end of the expression, you can then create the output by doing an >> efficient bytevector read of the prologue, then display the string for >> the edited expression, then the bytevector tail. >> >> Again, just a thought! Feel free to incorporate or not as you like, >> =E5=AE=8B=E6=96=87=E6=AD=A6 :) > Indeed this is better! To create the output from bytevector, it's > using `get-bytevector-n' to read and `utf8->string' to write, right? Hmm, good question. I think I would use put-bytevector, if I read using get-bytevector-n, assuming that the encoding of the input and the output ports were the same. Probably it is worth making sure that you set the encodings to be the same, but I don't know :) Hopefully everything is UTF-8 these days. > And I think `edit-expression' could be: > (define (edit-expression source-properties proc) > "Edit the object specified by SOURCE-PROPERTIS using PROC, which > should be a procedure that take the original object and returns > a new one." > ...) Yeah :) However probably the "proc" should take and return a string, so as to preserve formatting and comments. Good luck :) Andy