Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 8B563431FB6 for ; Wed, 18 Jan 2012 08:29:12 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6K9EiNhf0MJe for ; Wed, 18 Jan 2012 08:29:12 -0800 (PST) Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id CE38D431FAE for ; Wed, 18 Jan 2012 08:29:11 -0800 (PST) Received: by bkty12 with SMTP id y12so1858077bkt.26 for ; Wed, 18 Jan 2012 08:29:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.205.127.132 with SMTP id ha4mr7592767bkc.35.1326904148673; Wed, 18 Jan 2012 08:29:08 -0800 (PST) Sender: awg@xvx.ca Received: by 10.205.33.73 with HTTP; Wed, 18 Jan 2012 08:29:08 -0800 (PST) X-Originating-IP: [208.77.198.202] In-Reply-To: References: <1326840818-6821-1-git-send-email-awg+notmuch@xvx.ca> Date: Wed, 18 Jan 2012 09:29:08 -0700 X-Google-Sender-Auth: x6foOs70-AK-jrIsMIUP91vaF_E Message-ID: Subject: Re: [PATCH v2 4/5] emacs: Use the new JSON reply format. From: Adam Wolfe Gordon To: David Edmondson Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: notmuch X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jan 2012 16:29:12 -0000 On Tue, Jan 17, 2012 at 23:54, David Edmondson wrote: > On Tue, 17 Jan 2012 15:53:37 -0700, Adam Wolfe Gordon wrote: >> +(defun notmuch-parts-filter-by-type (parts type) >> + =A0"Return a list of message parts with the given type" >> + =A0(let (result) >> + =A0 =A0(dolist (part (append parts nil) result) >> + =A0 =A0 =A0(if (string=3D (cdr (assq 'content-type part)) type) >> + =A0 =A0 =A0 (setq result (append result (list (cdr (assq 'content part= ))))))) >> + =A0 =A0result)) > > I still think that `loop' is easier to read :-) But no objection to this > code. I couldn't find the loop construct initially, but after the discussion of common lisp on IRC yesterday I found the cl package and figured out how your example worked. With loop and collect figured out, it is easier to read. >> +(defun notmuch-mua-insert-part-quoted (part) >> + =A0(let ((start (point)) >> + =A0 =A0 limit) >> + =A0 =A0(insert part) >> + =A0 =A0(setq limit (point)) >> + =A0 =A0(goto-char start) >> + =A0 =A0(while (re-search-forward "\\(^\\)[^$]" limit 0) >> + =A0 =A0 =A0(replace-match "> " nil nil nil 1) >> + =A0 =A0 =A0;; We have added two characters to the quotable region >> + =A0 =A0 =A0(setq limit (+ limit 2))) >> + =A0 =A0(set-buffer-modified-p nil))) > > You could use a marker for the limit, as it would then move along > automagically (sorry for not noticing this last time). Aha! Another trick I didn't know about. New patch forthcoming.